Prompts / WordPress Plugin Development Prompt

WordPress Plugin Development Prompt

by hasan6

1
Develop Fully functional Prompts With AI
coding
Version imports

Prompt Template

# WordPress Plugin Development with AI

## 1. Environment & OS

- A local WordPress site running.
- We are now in the actual plugin folder created inside `wp-content/plugins/`.
- A Git repository initialized inside this plugin folder and connected to GitHub
- **Operating System:** [OS]
- **Local Web Server Stack:** [WEB_SERVER]

**Please:**
- Adapt any file paths, CLI commands, and line endings to my OS.
- If you show any shell commands (like `cd`, `ls`, `mkdir`, `git`), make them valid for my OS.

## 2. Your Role & Response Style

Act as a **senior WordPress plugin developer**.

When you respond:
- Work **step-by-step** instead of dumping all code at once.
- For each step, include:
  - A short explanation of what this piece does and why we need it.
- Follow WordPress coding standards and best practices:
  - **Security:** nonces, `wp_verify_nonce`, capabilities, sanitization, escaping.
  - **Performance and maintainability** (no overengineering).
- Use clear headings like:
  - `### Step 1 – Plugin Structure`, `### Step 2 – PLAN.md`, etc.

## 3. Tech Stack & Architecture

We are building a custom WordPress plugin with:

- A **main plugin file** with:
  - Proper header (name, description, version, author, etc.).
  - Activation/deactivation hooks.
- Prefer an **OOP-ish and Modular structure**
- Use relevant **WordPress APIs**, depending on my Plugin Idea:
  - Hooks: `add_action`, `add_filter`.
  - Shortcodes.
  - Admin menus & pages.
  - Settings API.
  - Custom Post Types / Taxonomies or custom DB tables.
  - AJAX (`wp_ajax_...`) or REST API if needed.
  - `wp_mail()` if sending emails.
- The plugin should be **self-contained:**
  - No Composer or big external frameworks.
  - Only enqueue scripts/styles when necessary.

## 4. Development Workflow

You will:
1. Start by folder structure.
2. Then generate the base skeleton of the plugin.
3. Then proceed in small, testable steps implementing the features from my Plugin Idea.

## 5. Data & Storage Layer

Based on my Plugin Idea, help me decide whether to use:
- Custom Post Type with meta.
- A custom DB table.
- Simple options/meta only.

## 6. Frontend (Public)

Implement all frontend features described in my Plugin Idea, like:
- Shortcodes `[my_plugin]`.
- Forms for user input.
- Lists, tables, or widgets displaying stored data.
- AJAX-based interactivity if needed.

## 7. Admin / Dashboard

Implement admin functionality, such as:
- Top-level or submenu under Settings/Tools.
- Admin pages for:
  - Viewing, filtering, editing plugin data.
  - Managing settings.
- Use capability checks (`manage_options` or custom capability).

## 8. Settings & Configuration

If my plugin requires settings (API keys, email templates, toggles, etc.):
- Use the Settings API.
- Create a settings page with sections & fields.
- Implement sanitization callbacks.
- Read & use settings in the plugin logic.

## 9. Security, Validation & UX

Make sure:
- All forms/actions use nonces and `wp_verify_nonce`.
- All input is sanitized (`sanitize_text_field`, `sanitize_email`, `esc_url_raw`, etc.).
- All output is escaped (`esc_html`, `esc_attr`, `esc_url`, etc.).
- Only allowed users can access admin features (capability checks).

Improve UX:
- Clear messages on success/error.
- Basic styling where necessary (no heavy frameworks).

## 10. My Plugin Idea

### Simple Testimonials Collector

**Goal / Purpose:**
A plugin that allows users to submit testimonials via a frontend form. Admins can review and approve testimonials in the dashboard. Approved testimonials can be displayed anywhere using a shortcode.

**Frontend Features:**
- Public form for submitting:
  - Name
  - Email
  - Testimonial text
  - (Optional) Rating 1–5
- Validation + nonces
- Success message on submit
- Shortcode `[testimonials]` to display approved testimonials

**Admin Features:**
- Admin menu: "Testimonials"
- List of submitted testimonials (Pending / Approved)
- Ability to approve or reject
- Ability to edit testimonials
- Optional settings page (toggle rating on/off)

**Data Storage:**
- Use a Custom Post Type: `testimonial`
- Store rating as post meta
- Store email only for admin view (not public)

---

**Important:** Ask me questions to understand exactly what I want.