Zezo Ai ๐Ÿš€ Prompt Engine ุงุญุชุฑุงููŠ โ€” ู…ูˆู„ู‘ุฏ ู‚ูˆุงู„ุจ ูˆุซูŠู…ุงุช ูˆุฅุถุงูุงุช WordPress ุจู„ุบุฉ PHP

Prompt Engine ุงุญุชุฑุงููŠ โ€” ู…ูˆู„ู‘ุฏ ู‚ูˆุงู„ุจ ูˆุซูŠู…ุงุช ูˆุฅุถุงูุงุช WordPress ุจู„ุบุฉ PHP


๐Ÿ“‹ ุงู„ุฌุฒุก ุงู„ุฃูˆู„: ุจู†ูŠุฉ ู…ุญุฑูƒ ุงู„ู…ุทุงู„ุจุงุช (Prompt Engine Architecture)

๐Ÿ—๏ธ ุงู„ู…ูƒูˆู‘ู†ุงุช ุงู„ุฃุณุงุณูŠุฉ ู„ู„ู…ุญุฑูƒ

text

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    PROMPT ENGINE LAYERS                      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Layer 1: System Prompt (ุงู„ู‚ูˆุงุนุฏ ุงู„ุฅู„ุฒุงู…ูŠุฉ)                 โ”‚
โ”‚  Layer 2: Global Variables (ุงู„ู…ุชุบูŠุฑุงุช ุงู„ุฃุณุงุณูŠุฉ)              โ”‚
โ”‚  Layer 3: Prompt Templates (ู‚ูˆุงู„ุจ ุงู„ู…ุทุงู„ุจุงุช)                 โ”‚
โ”‚  Layer 4: Output Schema (ู‡ูŠูƒู„ ุงู„ู…ุฎุฑุฌุงุช)                     โ”‚
โ”‚  Layer 5: Validation Rules (ู‚ูˆุงุนุฏ ุงู„ุชุญู‚ู‚)                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐ŸŽฏ ุงู„ู…ุจุงุฏุฆ ุงู„ุฎู…ุณุฉ ู„ู„ู…ุญุฑูƒ

ุงู„ู…ุจุฏุฃุงู„ูˆุตูุงู„ุชุทุจูŠู‚
Determinismู…ุฎุฑุฌุงุช ู…ุชูˆู‚ุนุฉ ุจุฏูˆู† ู‡ู„ูˆุณุฉSystem Prompt ุตุงุฑู… + Schemas ู…ุญุฏุฏุฉ
WPCS Complianceุงู„ุชุฒุงู… ุฏู‚ูŠู‚ ุจู…ุนุงูŠูŠุฑ WordPressุฐูƒุฑ WPCS ููŠ ูƒู„ ู‚ุงู„ุจ
Security-Firstูƒู„ ู‚ุงู„ุจ ูŠุญุชูˆูŠ ุนู„ู‰ ู‚ูŠูˆุฏ ุฃู…ู†ูŠุฉNonces, Sanitization, Escaping, Capabilities
Extensibilityุณู‡ูˆู„ุฉ ุฅุถุงูุฉ ู‚ูˆุงู„ุจ ุฌุฏูŠุฏุฉุจู†ูŠุฉ ู…ุนูŠุงุฑูŠุฉ + ู…ุชุบูŠุฑุงุช ู…ูˆุญุฏุฉ
Modularityูƒู„ ู‚ุงู„ุจ ู…ุณุชู‚ู„ ูˆู‚ุงุจู„ ู„ู„ุชุฑูƒูŠุจTemplates ู…ู†ูุตู„ุฉ ู‚ุงุจู„ุฉ ู„ู„ุชุฌู…ูŠุน

๐Ÿ”ท System Prompt (ุงู„ู†ูˆุงุฉ ุงู„ุฅู„ุฒุงู…ูŠุฉ โ€” ุชูุถุงู ู„ูƒู„ ู…ุทุงู„ุจุฉ)

markdown

ุฃู†ุช ู…ู‡ู†ุฏุณ WordPress ุฎุจูŠุฑ ู…ุนุชู…ุฏ (Senior WordPress Engineer) ุจุฎุจุฑุฉ 10+ ุณู†ูˆุงุช
ููŠ ุชุทูˆูŠุฑ ุงู„ุซูŠู…ุงุช ูˆุงู„ุฅุถุงูุงุช ูˆูู‚ ู…ุนุงูŠูŠุฑ WordPress ุงู„ุฑุณู…ูŠุฉ.

## ุงู„ู‚ูˆุงุนุฏ ุงู„ุฅู„ุฒุงู…ูŠุฉ (Non-Negotiable Rules):

1. **WPCS Compliance**: ุงุชุจุน WordPress Coding Standards ุญุฑููŠุงู‹:
   - Snakes_case for functions/variables
   - PascalCase for classes
   - UPPER_CASE for constants
   - Tabs for indentation (not spaces)
   - DocBlocks ู„ูƒู„ function/class/method

2. **Security Constraints (ุฅู„ุฒุงู…ูŠุฉ ููŠ ูƒู„ ู…ู„ู)**:
   - โœ… ุงุณุชุฎุฏู… `wp_nonce_field()` ูˆ `check_admin_referer()` ู„ูƒู„ form
   - โœ… ุงุณุชุฎุฏู… `sanitize_text_field()`, `sanitize_email()`, `absint()` ู„ูƒู„ input
   - โœ… ุงุณุชุฎุฏู… `esc_html()`, `esc_attr()`, `esc_url()`, `wp_kses_post()` ู„ูƒู„ output
   - โœ… ุงุณุชุฎุฏู… `current_user_can()` ู‚ุจู„ ุฃูŠ ุนู…ู„ูŠุฉ ุญุณุงุณุฉ
   - โœ… ุงุณุชุฎุฏู… `$wpdb->prepare()` ู„ูƒู„ ุงุณุชุนู„ุงู… SQL
   - โœ… ุงุณุชุฎุฏู… `wp_enqueue_script/style()` ูˆู„ูŠุณ `<script>/<link>` ู…ุจุงุดุฑุฉ
   - โœ… ุชุญู‚ู‚ ู…ู† `ABSPATH` ููŠ ุจุฏุงูŠุฉ ูƒู„ ู…ู„ู PHP

3. **WordPress APIs Only**:
   - ุงุณุชุฎุฏู… `WP_Query` ุจุฏู„ุงู‹ ู…ู† `mysql_query`
   - ุงุณุชุฎุฏู… `wp_remote_get/post()` ุจุฏู„ุงู‹ ู…ู† `curl`
   - ุงุณุชุฎุฏู… `wp_mail()` ุจุฏู„ุงู‹ ู…ู† `mail()`
   - ุงุณุชุฎุฏู… `wp_upload_dir()` ู„ู„ุชุนุงู…ู„ ู…ุน ุงู„ู…ู„ูุงุช

4. **Internationalization (i18n)**:
   - ุงุณุชุฎุฏู… `__()`, `_e()`, `esc_html__()`, `esc_attr__()`
   - Text Domain = ุงุณู… ุงู„ู…ุดุฑูˆุน (ู…ุทุงุจู‚ ู„ู„ู€ slug)
   - ูƒู„ ุงู„ู†ุตูˆุต ู‚ุงุจู„ุฉ ู„ู„ุชุฑุฌู…ุฉ

5. **Anti-Hallucination**:
   - ู„ุง ุชุฎุชุฑุน ุฏูˆุงู„ุงู‹ ุบูŠุฑ ู…ูˆุฌูˆุฏุฉ ููŠ WordPress
   - ู„ุง ุชูุชุฑุถ ุฅุตุฏุงุฑุงุช ุบูŠุฑ ู…ุญุฏุฏุฉ
   - ุงุฐูƒุฑ ุงู„ู‚ูŠูˆุฏ ูˆุงู„ู…ุชุทู„ุจุงุช ุจูˆุถูˆุญ
   - ุฅู† ูƒุงู† ู‡ู†ุงูƒ ุบู…ูˆุถุŒ ุงุทุฑุญ ุงูุชุฑุงุถุงู‹ ูˆุงุถุญุงู‹ ูˆู…ูˆุซู‚ุงู‹

6. **Output Format**:
   - ูƒู„ ู…ู„ู ููŠ code block ู…ู†ูุตู„ ุจุงุณู…ู‡ ุงู„ูƒุงู…ู„
   - ุจู†ูŠุฉ ู…ุฌู„ุฏุงุช ูˆุงุถุญุฉ ููŠ ุงู„ุจุฏุงูŠุฉ
   - ู…ู„ู README.md ู…ุน ุชุนู„ูŠู…ุงุช ุงู„ุชุซุจูŠุช

๐Ÿ”ท ุงู„ุฌุฒุก ุงู„ุซุงู†ูŠ: ุชุญูˆูŠู„ ุจูŠุงู†ุงุชูƒ ุฅู„ู‰ ู…ุทุงู„ุจุงุช ุงุญุชุฑุงููŠุฉ

๐ŸŽฏ ุงู„ู…ุชุบูŠุฑุงุช ุงู„ุฃุณุงุณูŠุฉ (Global Variables)

text

{{PROJECT_NAME}}       โ†’ ุงุณู… ุงู„ู…ุดุฑูˆุน (PascalCase ู„ู„ูƒู„ุงุณุงุชุŒ snake_case ู„ู„ุฏูˆุงู„)
{{PROJECT_SLUG}}       โ†’ slug ุงู„ู…ุดุฑูˆุน (lowercase-hyphen)
{{TEXT_DOMAIN}}        โ†’ ุงู„ู†ุทุงู‚ ุงู„ู†ุตูŠ (ู…ุทุงุจู‚ ู„ู„ู€ slug)
{{VERSION}}            โ†’ ุฅุตุฏุงุฑ ุงู„ู…ุดุฑูˆุน (ู…ุซู„: 1.0.0)
{{AUTHOR}}             โ†’ ุงุณู… ุงู„ู…ุคู„ู
{{AUTHOR_URI}}         โ†’ ุฑุงุจุท ุงู„ู…ุคู„ู
{{PHP_VERSION}}        โ†’ ุงู„ุญุฏ ุงู„ุฃุฏู†ู‰ ู„ุฅุตุฏุงุฑ PHP (ุงูุชุฑุงุถูŠ: 7.4)
{{WP_VERSION}}         โ†’ ุงู„ุญุฏ ุงู„ุฃุฏู†ู‰ ู„ุฅุตุฏุงุฑ WordPress (ุงูุชุฑุงุถูŠ: 6.0)
{{NAMESPACE}}          โ†’ Namespace ู„ู„ูƒู„ุงุณุงุช (ู…ุซู„: Vendor\ProjectName)
{{PREFIX}}             โ†’ ุจุงุฏุฆุฉ ุงู„ุฏูˆุงู„ (ู…ุซู„: myplugin_)
{{FEATURES}}           โ†’ ู‚ุงุฆู…ุฉ ุงู„ู…ูŠุฒุงุช ุงู„ู…ุทู„ูˆุจุฉ
{{TARGET_AUDIENCE}}    โ†’ ุงู„ูุฆุฉ ุงู„ู…ุณุชู‡ุฏูุฉ
{{INTEGRATIONS}}       โ†’ ุชูƒุงู…ู„ุงุช ู…ุน ุฅุถุงูุงุช ุฃุฎุฑู‰ (WooCommerce, ACF, ...)

๐Ÿ”ท ุงู„ุฌุฒุก ุงู„ุซุงู„ุซ: ู‚ูˆุงู„ุจ ุงู„ู…ุทุงู„ุจุงุช ุงู„ุงุญุชุฑุงููŠุฉ (Prompt Templates)


๐Ÿ”ถ T1 โ€” ู…ูˆู„ู‘ุฏ ุงู„ุซูŠู…ุงุช (Theme Generator)

markdown

# [T1] PROMPT: WordPress Theme Generator

## ROLE
ุฃู†ุช ู…ุทูˆู‘ุฑ ุซูŠู…ุงุช WordPress ุฎุจูŠุฑ (Senior WordPress Theme Developer).

## CONTEXT
- Project Name: {{PROJECT_NAME}}
- Slug: {{PROJECT_SLUG}}
- Text Domain: {{TEXT_DOMAIN}}
- Version: {{VERSION}}
- Author: {{AUTHOR}}
- Min PHP: {{PHP_VERSION}}
- Min WP: {{WP_VERSION}}
- Namespace: {{NAMESPACE}}
- Target Audience: {{TARGET_AUDIENCE}}
- Features: {{FEATURES}}

## TASK
ุฃู†ุดุฆ ุซูŠู… WordPress ูƒุงู…ู„ (Classic Theme) ุจู…ูŠุฒุงุช:
{{FEATURES}}

## MANDATORY STRUCTURE

{{PROJECT_SLUG}}/
โ”œโ”€โ”€ style.css (ุจุชุฑูˆูŠุณุฉ WordPress ุงู„ูƒุงู…ู„ุฉ)
โ”œโ”€โ”€ functions.php (bootstrap ูู‚ุทุŒ ู„ุง ู…ู†ุทู‚ ู…ุจุงุดุฑ)
โ”œโ”€โ”€ index.php
โ”œโ”€โ”€ header.php
โ”œโ”€โ”€ footer.php
โ”œโ”€โ”€ sidebar.php
โ”œโ”€โ”€ single.php
โ”œโ”€โ”€ page.php
โ”œโ”€โ”€ archive.php
โ”œโ”€โ”€ search.php
โ”œโ”€โ”€ 404.php
โ”œโ”€โ”€ screenshot.png (ูˆุตู 1200×900)
โ”œโ”€โ”€ readme.txt
โ”œโ”€โ”€ inc/
โ”‚ โ”œโ”€โ”€ class-{{PROJECT_SLUG}}-setup.php
โ”‚ โ”œโ”€โ”€ class-{{PROJECT_SLUG}}-assets.php
โ”‚ โ”œโ”€โ”€ class-{{PROJECT_SLUG}}-walker-nav.php
โ”‚ โ”œโ”€โ”€ template-tags.php
โ”‚ โ””โ”€โ”€ customizer.php
โ”œโ”€โ”€ template-parts/
โ”‚ โ”œโ”€โ”€ content.php
โ”‚ โ”œโ”€โ”€ content-single.php
โ”‚ โ”œโ”€โ”€ content-page.php
โ”‚ โ””โ”€โ”€ content-none.php
โ”œโ”€โ”€ assets/
โ”‚ โ”œโ”€โ”€ css/
โ”‚ โ”‚ โ”œโ”€โ”€ main.css
โ”‚ โ”‚ โ””โ”€โ”€ editor.css
โ”‚ โ”œโ”€โ”€ js/
โ”‚ โ”‚ โ”œโ”€โ”€ navigation.js
โ”‚ โ”‚ โ””โ”€โ”€ main.js
โ”‚ โ””โ”€โ”€ images/
โ””โ”€โ”€ languages/
โ””โ”€โ”€ {{TEXT_DOMAIN}}.pot

text

## TECHNICAL REQUIREMENTS

### style.css Header (ุฅู„ุฒุงู…ูŠ)
```css
/*
Theme Name: {{PROJECT_NAME}}
Theme URI: {{AUTHOR_URI}}
Author: {{AUTHOR}}
Author URI: {{AUTHOR_URI}}
Description: {{PROJECT_DESCRIPTION}}
Version: {{VERSION}}
Requires at least: {{WP_VERSION}}
Tested up to: 6.5
Requires PHP: {{PHP_VERSION}}
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: {{TEXT_DOMAIN}}
Tags: {{THEME_TAGS}}
*/

functions.php (Bootstrap ูู‚ุท)

php

<?php
/**
 * {{PROJECT_NAME}} functions and definitions.
 *
 * @package {{NAMESPACE}}
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

define( '{{PREFIX}}_VERSION', '{{VERSION}}' );
define( '{{PREFIX}}_DIR', get_template_directory() );
define( '{{PREFIX}}_URI', get_template_directory_uri() );

require_once {{PREFIX}}_DIR . '/inc/class-{{PROJECT_SLUG}}-setup.php';
require_once {{PREFIX}}_DIR . '/inc/class-{{PROJECT_SLUG}}-assets.php';
require_once {{PREFIX}}_DIR . '/inc/template-tags.php';
require_once {{PREFIX}}_DIR . '/inc/customizer.php';

new {{NAMESPACE}}\Setup();
new {{NAMESPACE}}\Assets();

Security Checklist (ูŠุฌุจ ุชุทุจูŠู‚ู‡)

  • โ–กย if ( ! defined( 'ABSPATH' ) ) exit;ย ููŠ ูƒู„ ู…ู„ู PHP
  • โ–กย wp_head()ย ูˆย wp_body_open()ย ูˆย wp_footer()ย ููŠ ุงู„ุฃู…ุงูƒู† ุงู„ุตุญูŠุญุฉ
  • โ–กย wp_enqueue_style/scriptย ููŠย wp_enqueue_scriptsย hook
  • โ–กย add_theme_support( 'title-tag' )ย ูˆย 'post-thumbnails'
  • โ–กย esc_url( home_url() )ย ู„ูƒู„ ุงู„ุฑูˆุงุจุท
  • โ–กย esc_html()ย ู„ูƒู„ ุงู„ู†ุตูˆุต
  • โ–กย wp_nav_menu()ย ู…ุนย theme_locationย ุตุญูŠุญ
  • โ–กย register_nav_menus()ย ููŠ Setup class
  • โ–กย add_theme_support( 'html5', [...] )
  • โ–กย wp_kses_post()ย ู„ูƒู„ ู…ุญุชูˆู‰ ุบูŠุฑ ู…ูˆุซูˆู‚

OUTPUT FORMAT

  1. ุดุฌุฑุฉ ุงู„ู…ุดุฑูˆุน
  2. ูƒู„ ู…ู„ู ููŠ code block ู…ู†ูุตู„ ู…ุน ุงุณู…ู‡
  3. README.md ู…ุน ุฎุทูˆุงุช ุงู„ุชุซุจูŠุช ูˆุงู„ุชูุนูŠู„
  4. ู…ู„ุงุญุธุงุช ุฃู…ู†ูŠุฉ ููŠ ู†ู‡ุงูŠุฉ ุงู„ุฑุฏ

CONSTRAINTS

  • ู„ุง ุชุณุชุฎุฏู… ุฏูˆุงู„ุงู‹ ู…ู‡ุฌูˆุฑุฉ (deprecated)
  • ู„ุง ุชุณุชุฎุฏู… CSS/JS inline
  • ู„ุง ุชุฎุชุฑุน hooks ุบูŠุฑ ู…ูˆุฌูˆุฏุฉ
  • ุงุชุจุน WPCS ุญุฑููŠุงู‹

text

---

### ๐Ÿ”ถ T2 โ€” ู…ูˆู„ู‘ุฏ ุงู„ุฅุถุงูุงุช (Plugin Generator)

```markdown
# [T2] PROMPT: WordPress Plugin Generator

## ROLE
ุฃู†ุช ู…ุทูˆู‘ุฑ ุฅุถุงูุงุช WordPress ุฎุจูŠุฑ ู…ุนุชู…ุฏ (Senior WordPress Plugin Developer).

## CONTEXT
- Plugin Name: {{PROJECT_NAME}}
- Slug: {{PROJECT_SLUG}}
- Namespace: {{NAMESPACE}}
- Text Domain: {{TEXT_DOMAIN}}
- Version: {{VERSION}}
- Author: {{AUTHOR}}
- Min PHP: {{PHP_VERSION}}
- Min WP: {{WP_VERSION}}
- Features: {{FEATURES}}
- Integrations: {{INTEGRATIONS}}
- Target Audience: {{TARGET_AUDIENCE}}

## TASK
ุฃู†ุดุฆ ุฅุถุงูุฉ WordPress ูƒุงู…ู„ุฉ (OOP + Namespaces + PSR-4 Autoload) ุจู…ูŠุฒุงุช:
{{FEATURES}}

## MANDATORY STRUCTURE

{{PROJECT_SLUG}}/
โ”œโ”€โ”€ {{PROJECT_SLUG}}.php (ู…ู„ู Bootstrap ูู‚ุท)
โ”œโ”€โ”€ uninstall.php (ุชู†ุธูŠู ูƒุงู…ู„ ุนู†ุฏ ุงู„ุญุฐู)
โ”œโ”€โ”€ readme.txt (WordPress.org format)
โ”œโ”€โ”€ composer.json (PSR-4 autoload)
โ”œโ”€โ”€ includes/
โ”‚ โ”œโ”€โ”€ class-plugin.php (Main class – Singleton)
โ”‚ โ”œโ”€โ”€ class-activator.php (Activation logic)
โ”‚ โ”œโ”€โ”€ class-deactivator.php (Deactivation logic)
โ”‚ โ”œโ”€โ”€ class-loader.php (Hooks loader)
โ”‚ โ”œโ”€โ”€ class-i18n.php (Internationalization)
โ”‚ โ””โ”€โ”€ traits/
โ”‚ โ””โ”€โ”€ trait-singleton.php
โ”œโ”€โ”€ admin/
โ”‚ โ”œโ”€โ”€ class-admin.php
โ”‚ โ”œโ”€โ”€ class-settings.php
โ”‚ โ”œโ”€โ”€ class-metabox.php
โ”‚ โ”œโ”€โ”€ views/
โ”‚ โ”‚ โ”œโ”€โ”€ settings-page.php
โ”‚ โ”‚ โ”œโ”€โ”€ metabox-form.php
โ”‚ โ”‚ โ””โ”€โ”€ list-table.php
โ”‚ โ”œโ”€โ”€ css/admin.css
โ”‚ โ””โ”€โ”€ js/admin.js
โ”œโ”€โ”€ public/
โ”‚ โ”œโ”€โ”€ class-public.php
โ”‚ โ”œโ”€โ”€ class-shortcodes.php
โ”‚ โ”œโ”€โ”€ class-ajax-handlers.php
โ”‚ โ”œโ”€โ”€ class-rest-controller.php
โ”‚ โ”œโ”€โ”€ css/public.css
โ”‚ โ””โ”€โ”€ js/public.js
โ”œโ”€โ”€ includes/
โ”‚ โ”œโ”€โ”€ class-cpt.php (Custom Post Types)
โ”‚ โ”œโ”€โ”€ class-taxonomy.php (Custom Taxonomies)
โ”‚ โ”œโ”€โ”€ class-db.php (Database layer)
โ”‚ โ””โ”€โ”€ helpers.php
โ”œโ”€โ”€ languages/
โ”‚ โ””โ”€โ”€ {{TEXT_DOMAIN}}.pot
โ””โ”€โ”€ assets/
โ”œโ”€โ”€ css/
โ””โ”€โ”€ js/

text

## CORE PATTERNS

### 1. Main Plugin Class (Singleton Pattern)
```php
<?php
namespace {{NAMESPACE}};

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

final class Plugin {
    use Traits\Singleton;
    
    public const VERSION     = '{{VERSION}}';
    public const PLUGIN_FILE = __FILE__;
    public const SLUG        = '{{PROJECT_SLUG}}';
    public const TEXT_DOMAIN = '{{TEXT_DOMAIN}}';
    public const CAPABILITY  = 'manage_options';
    public const NONCE_ACTION = '{{PREFIX}}_action';
    public const NONCE_NAME   = '{{PREFIX}}_nonce';
    
    protected function __construct() {
        $this->load_dependencies();
        $this->register_hooks();
    }
    
    private function load_dependencies(): void {
        require_once __DIR__ . '/class-loader.php';
        require_once __DIR__ . '/class-i18n.php';
        // Admin
        require_once {{PREFIX}}_DIR . 'admin/class-admin.php';
        // Public
        require_once {{PREFIX}}_DIR . 'public/class-public.php';
    }
    
    private function register_hooks(): void {
        $loader = new Loader();
        $loader->add_action( 'plugins_loaded', new I18n(), 'load_textdomain' );
        ( new Admin() )->register( $loader );
        ( new Public_Hooks() )->register( $loader );
        $loader->run();
    }
}

2. Activator Class

php

<?php
namespace {{NAMESPACE}};

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

final class Activator {
    public static function activate(): void {
        if ( version_compare( PHP_VERSION, '{{PHP_VERSION}}', '<' ) ) {
            deactivate_plugins( plugin_basename( {{PREFIX}}_FILE ) );
            wp_die( esc_html__( 'This plugin requires PHP {{PHP_VERSION}} or higher.', '{{TEXT_DOMAIN}}' ) );
        }
        
        if ( version_compare( get_bloginfo( 'version' ), '{{WP_VERSION}}', '<' ) ) {
            deactivate_plugins( plugin_basename( {{PREFIX}}_FILE ) );
            wp_die( esc_html__( 'This plugin requires WordPress {{WP_VERSION}} or higher.', '{{TEXT_DOMAIN}}' ) );
        }
        
        if ( ! current_user_can( 'activate_plugins' ) ) {
            return;
        }
        
        self::create_tables();
        self::set_default_options();
        flush_rewrite_rules();
    }
    
    private static function create_tables(): void {
        global $wpdb;
        $charset = $wpdb->get_charset_collate();
        $table   = $wpdb->prefix . '{{PREFIX}}_data';
        $sql     = "CREATE TABLE {$table} (
            id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
            user_id BIGINT UNSIGNED NOT NULL,
            created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
            data LONGTEXT NULL,
            PRIMARY KEY  (id),
            KEY user_id (user_id)
        ) {$charset};";
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        dbDelta( $sql );
    }
    
    private static function set_default_options(): void {
        add_option( '{{PREFIX}}_settings', array( 'enabled' => 1 ) );
    }
}

3. Settings Page (Admin)

php

<?php
namespace {{NAMESPACE}}\Admin;

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

final class Settings {
    
    public function register_page(): void {
        add_options_page(
            __( '{{PROJECT_NAME}} Settings', '{{TEXT_DOMAIN}}' ),
            __( '{{PROJECT_NAME}}', '{{TEXT_DOMAIN}}' ),
            \{{NAMESPACE}}\Plugin::CAPABILITY,
            '{{PROJECT_SLUG}}-settings',
            array( $this, 'render_page' )
        );
    }
    
    public function handle_form(): void {
        if ( ! current_user_can( \{{NAMESPACE}}\Plugin::CAPABILITY ) ) {
            wp_die( esc_html__( 'Unauthorized.', '{{TEXT_DOMAIN}}' ) );
        }
        check_admin_referer( \{{NAMESPACE}}\Plugin::NONCE_ACTION, \{{NAMESPACE}}\Plugin::NONCE_NAME );
        
        $enabled = isset( $_POST['enabled'] ) ? absint( $_POST['enabled'] ) : 0;
        $title   = isset( $_POST['title'] ) ? sanitize_text_field( wp_unslash( $_POST['title'] ) ) : '';
        
        update_option( '{{PREFIX}}_settings', array(
            'enabled' => $enabled,
            'title'   => $title,
        ) );
        
        add_settings_error( '{{PREFIX}}_settings', 'saved', __( 'Settings saved.', '{{TEXT_DOMAIN}}' ), 'updated' );
    }
    
    public function render_page(): void {
        if ( ! current_user_can( \{{NAMESPACE}}\Plugin::CAPABILITY ) ) {
            return;
        }
        $options = get_option( '{{PREFIX}}_settings', array() );
        require __DIR__ . '/views/settings-page.php';
    }
}

4. Settings View (with Security)

php

<?php
if ( ! defined( 'ABSPATH' ) ) exit;
?>
<div class="wrap">
    <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
    <?php settings_errors( '{{PREFIX}}_settings' ); ?>
    <form method="post" action="<?php echo esc_url( admin_url( 'options-general.php?page={{PROJECT_SLUG}}-settings' ) ); ?>">
        <?php wp_nonce_field( \{{NAMESPACE}}\Plugin::NONCE_ACTION, \{{NAMESPACE}}\Plugin::NONCE_NAME ); ?>
        <table class="form-table">
            <tr>
                <th scope="row"><label for="enabled"><?php esc_html_e( 'Enable', '{{TEXT_DOMAIN}}' ); ?></label></th>
                <td><input type="checkbox" id="enabled" name="enabled" value="1" <?php checked( ! empty( $options['enabled'] ) ); ?> /></td>
            </tr>
            <tr>
                <th scope="row"><label for="title"><?php esc_html_e( 'Title', '{{TEXT_DOMAIN}}' ); ?></label></th>
                <td><input type="text" id="title" name="title" class="regular-text" value="<?php echo esc_attr( $options['title'] ?? '' ); ?>" /></td>
            </tr>
        </table>
        <?php submit_button( __( 'Save Changes', '{{TEXT_DOMAIN}}' ) ); ?>
    </form>
</div>

5. AJAX Handler (Secure)

php

<?php
namespace {{NAMESPACE}}\Public_Hooks;

if ( ! defined( 'ABSPATH' ) ) exit;

final class Ajax_Handlers {
    
    public function register(): void {
        add_action( 'wp_ajax_{{PREFIX}}_action', array( $this, 'handle' ) );
        add_action( 'wp_ajax_nopriv_{{PREFIX}}_action', array( $this, 'handle' ) );
        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ) );
    }
    
    public function enqueue(): void {
        wp_enqueue_script(
            '{{PREFIX}}-public',
            {{PREFIX}}_URL . 'public/js/public.js',
            array( 'jquery' ),
            \{{NAMESPACE}}\Plugin::VERSION,
            true
        );
        wp_localize_script( '{{PREFIX}}-public', '{{PREFIX}}Obj', array(
            'ajaxUrl' => admin_url( 'admin-ajax.php' ),
            'nonce'   => wp_create_nonce( \{{NAMESPACE}}\Plugin::NONCE_ACTION ),
            'i18n'    => array( 'error' => __( 'An error occurred.', '{{TEXT_DOMAIN}}' ) ),
        ) );
    }
    
    public function handle(): void {
        check_ajax_referer( \{{NAMESPACE}}\Plugin::NONCE_ACTION, 'nonce' );
        
        $input = isset( $_POST['data'] ) ? sanitize_text_field( wp_unslash( $_POST['data'] ) ) : '';
        
        if ( empty( $input ) ) {
            wp_send_json_error( array( 'message' => __( 'Invalid input.', '{{TEXT_DOMAIN}}' ) ), 400 );
        }
        
        wp_send_json_success( array( 'message' => __( 'OK', '{{TEXT_DOMAIN}}' ), 'received' => $input ) );
    }
}

6. REST API Controller

php

<?php
namespace {{NAMESPACE}}\Public_Hooks;

if ( ! defined( 'ABSPATH' ) ) exit;

final class REST_Controller {
    
    public const NAMESPACE = '{{PROJECT_SLUG}}/v1';
    
    public function register_routes(): void {
        register_rest_route( self::NAMESPACE, '/items', array(
            array(
                'methods'             => \WP_REST_Server::READABLE,
                'callback'            => array( $this, 'get_items' ),
                'permission_callback' => array( $this, 'read_permission' ),
                'args'                => array(
                    'page' => array( 'type' => 'integer', 'default' => 1, 'sanitize_callback' => 'absint' ),
                ),
            ),
            array(
                'methods'             => \WP_REST_Server::CREATABLE,
                'callback'            => array( $this, 'create_item' ),
                'permission_callback' => array( $this, 'write_permission' ),
                'args'                => array(
                    'title' => array( 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field' ),
                ),
            ),
        ) );
    }
    
    public function read_permission(): bool {
        return true;
    }
    
    public function write_permission(): bool {
        return current_user_can( 'edit_posts' );
    }
    
    public function get_items( \WP_REST_Request $request ): \WP_REST_Response {
        return new \WP_REST_Response( array( 'items' => array() ), 200 );
    }
    
    public function create_item( \WP_REST_Request $request ): \WP_REST_Response {
        return new \WP_REST_Response( array( 'id' => 1 ), 201 );
    }
}

7. uninstall.php (Cleanup)

php

<?php
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    exit;
}

global $wpdb;

delete_option( '{{PREFIX}}_settings' );
delete_option( '{{PREFIX}}_version' );

$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}{{PREFIX}}_data" );

wp_cache_flush();

SECURITY CHECKLIST

  • โ–กย check_admin_referer()ย /ย check_ajax_referer()ย /ย wp_verify_nonce()ย ููŠ ูƒู„ ู†ู…ูˆุฐุฌ/ุทู„ุจ
  • โ–กย current_user_can()ย ู‚ุจู„ ูƒู„ ุนู…ู„ูŠุฉ ุญุณุงุณุฉ
  • โ–กย sanitize_*ย ู„ูƒู„ input
  • โ–กย esc_*ย ู„ูƒู„ output
  • โ–กย $wpdb->prepare()ย ู„ูƒู„ SQL
  • โ–กย wp_kses_post()ย ู„ูƒู„ HTML ุบูŠุฑ ู…ูˆุซูˆู‚
  • โ–กย ABSPATHย check ููŠ ูƒู„ ู…ู„ู
  • โ–กย uninstall.phpย ูŠู†ุธู ูƒู„ ุดูŠุก
  • โ–กย ู„ุง ุชุณุฑูŠุจ ู„ุจูŠุงู†ุงุช ุญุณุงุณุฉ ููŠ REST responses
  • โ–กย ุงุณุชุฎุฏุงู…ย wp_safe_redirect()ย ู„ู„ุชุญูˆูŠู„ุงุช

OUTPUT FORMAT

  1. ุดุฌุฑุฉ ุงู„ู…ุดุฑูˆุน ุงู„ูƒุงู…ู„ุฉ
  2. composer.json ู…ุน PSR-4
  3. ูƒู„ ู…ู„ู ููŠ code block ู…ู†ูุตู„
  4. readme.txt ุจุตูŠุบุฉย WordPress.org
  5. ู…ู„ุงุญุธุงุช ุฃู…ู†ูŠุฉ ุฎุชุงู…ูŠุฉ

CONSTRAINTS

  • ุงุณุชุฎุฏู… Namespaces + PSR-4 ุญุตุฑุงู‹
  • ู„ุง ุชุณุชุฎุฏู…ย globalย ุฅู„ุง ุนู†ุฏ ุงู„ุถุฑูˆุฑุฉ ุงู„ู‚ุตูˆู‰
  • ู„ุง ุชุฎุชุฑุน ุฏูˆุงู„ุงู‹ ุบูŠุฑ ู…ูˆุฌูˆุฏุฉ
  • ุงู„ุชุฒู… ุจู€ WPCS (tabs, snake_case, Yoda conditions)

text

---

### ๐Ÿ”ถ T3 โ€” ู…ูˆู„ู‘ุฏ Boilerplate (Plugin Boilerplate Generator)

```markdown
# [T3] PROMPT: WordPress Plugin Boilerplate Generator

## ROLE
ุฃู†ุช ู…ูˆู„ู‘ุฏ Boilerplate ุงุญุชุฑุงููŠ ู„ุฅุถุงูุงุช WordPress.

## CONTEXT
- Plugin Name:    {{PROJECT_NAME}}
- Slug:           {{PROJECT_SLUG}}
- Namespace:      {{NAMESPACE}}
- Prefix:         {{PREFIX}}
- Text Domain:    {{TEXT_DOMAIN}}
- Version:        {{VERSION}}
- Author:         {{AUTHOR}}
- Author URI:     {{AUTHOR_URI}}
- Min PHP:        {{PHP_VERSION}}
- Min WP:         {{WP_VERSION}}
- Features:       {{FEATURES}}
- Includes REST?: {{INCLUDE_REST}}
- Includes CPT?:  {{INCLUDE_CPT}}
- Includes Settings?: {{INCLUDE_SETTINGS}}

## TASK
ูˆู„ู‘ุฏ Boilerplate ูƒุงู…ู„ ู‚ุงุจู„ ู„ู„ุชุดุบูŠู„ ุงู„ููˆุฑูŠ (Ready-to-Activate) ูŠุญุชูˆูŠ ูู‚ุท
ุนู„ู‰ ุงู„ู‡ูŠูƒู„ ูˆุงู„ู€ stubsุŒ ุจุฏูˆู† ู…ู†ุทู‚ ุฃุนู…ุงู„ (Business Logic) โ€” ูƒุจุฏุงูŠุฉ ู†ุธูŠูุฉ.

## GENERATION ALGORITHM

### Step 1: Generate Directory Tree

{{PROJECT_SLUG}}/
โ”œโ”€โ”€ {{PROJECT_SLUG}}.php
โ”œโ”€โ”€ uninstall.php
โ”œโ”€โ”€ readme.txt
โ”œโ”€โ”€ composer.json
โ”œโ”€โ”€ includes/
โ”‚ โ”œโ”€โ”€ class-{{PROJECT_SLUG}}.php
โ”‚ โ”œโ”€โ”€ class-activator.php
โ”‚ โ”œโ”€โ”€ class-deactivator.php
โ”‚ โ”œโ”€โ”€ class-loader.php
โ”‚ โ”œโ”€โ”€ class-i18n.php
โ”‚ โ””โ”€โ”€ traits/trait-singleton.php
โ”œโ”€โ”€ admin/class-admin.php
โ”œโ”€โ”€ public/class-public.php
โ”œโ”€โ”€ languages/{{TEXT_DOMAIN}}.pot
โ””โ”€โ”€ assets/{css,js}/

text

### Step 2: Generate Each File (with placeholders resolved)

#### File: `{{PROJECT_SLUG}}.php`
```php
<?php
/**
 * Plugin Name:       {{PROJECT_NAME}}
 * Plugin URI:        {{AUTHOR_URI}}
 * Description:       {{PROJECT_DESCRIPTION}}
 * Version:           {{VERSION}}
 * Requires at least: {{WP_VERSION}}
 * Requires PHP:      {{PHP_VERSION}}
 * Author:            {{AUTHOR}}
 * Author URI:        {{AUTHOR_URI}}
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       {{TEXT_DOMAIN}}
 * Domain Path:       /languages
 *
 * @package {{NAMESPACE}}
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

define( '{{PREFIX}}_VERSION', '{{VERSION}}' );
define( '{{PREFIX}}_FILE', __FILE__ );
define( '{{PREFIX}}_DIR', plugin_dir_path( __FILE__ ) );
define( '{{PREFIX}}_URL', plugin_dir_url( __FILE__ ) );
define( '{{PREFIX}}_BASENAME', plugin_basename( __FILE__ ) );

require_once {{PREFIX}}_DIR . 'vendor/autoload.php';

register_activation_hook( __FILE__, array( '{{NAMESPACE}}\\Activator', 'activate' ) );
register_deactivation_hook( __FILE__, array( '{{NAMESPACE}}\\Deactivator', 'deactivate' ) );

add_action( 'plugins_loaded', static function () {
    \{{NAMESPACE}}\Plugin::instance();
} );

File: composer.json

json

{
    "name": "{{AUTHOR_SLUG}}/{{PROJECT_SLUG}}",
    "description": "{{PROJECT_DESCRIPTION}}",
    "type": "wordpress-plugin",
    "license": "GPL-2.0-or-later",
    "require": {
        "php": ">={{PHP_VERSION}}"
    },
    "autoload": {
        "psr-4": {
            "{{NAMESPACE}}\\": "includes/"
        }
    },
    "config": {
        "optimize-autoloader": true,
        "sort-packages": true
    }
}

File: includes/traits/trait-singleton.php

php

<?php
namespace {{NAMESPACE}}\Traits;

if ( ! defined( 'ABSPATH' ) ) exit;

trait Singleton {
    private static ?self $instance = null;
    
    public static function instance(): self {
        return self::$instance ??= new self();
    }
    
    private function __clone() {}
    public function __wakeup() {
        throw new \LogicException( 'Cannot unserialize singleton.' );
    }
}

File: includes/class-loader.php

php

<?php
namespace {{NAMESPACE}};

if ( ! defined( 'ABSPATH' ) ) exit;

final class Loader {
    private array $actions = array();
    private array $filters = array();
    
    public function add_action( string $hook, $component, string $callback, int $priority = 10, int $args = 1 ): void {
        $this->actions[] = compact( 'hook', 'component', 'callback', 'priority', 'args' );
    }
    
    public function add_filter( string $hook, $component, string $callback, int $priority = 10, int $args = 1 ): void {
        $this->filters[] = compact( 'hook', 'component', 'callback', 'priority', 'args' );
    }
    
    public function run(): void {
        foreach ( $this->filters as $f ) {
            add_filter( $f['hook'], array( $f['component'], $f['callback'] ), $f['priority'], $f['args'] );
        }
        foreach ( $this->actions as $a ) {
            add_action( $a['hook'], array( $a['component'], $a['callback'] ), $a['priority'], $a['args'] );
        }
    }
}

File: includes/class-i18n.php

php

<?php
namespace {{NAMESPACE}};

if ( ! defined( 'ABSPATH' ) ) exit;

final class I18n {
    public function load_textdomain(): void {
        load_plugin_textdomain(
            '{{TEXT_DOMAIN}}',
            false,
            dirname( {{PREFIX}}_BASENAME ) . '/languages'
        );
    }
}

Step 3: Activation/Deactivation

  • class-activator.phpย โ†’ ูŠุชุญู‚ู‚ ู…ู† PHP/WP + ูŠู†ุดุฆ options + flush_rewrite_rules
  • class-deactivator.phpย โ†’ flush_rewrite_rules + ู…ุณุญ transients

Step 4: Generate Translation Template (.pot)

pot

# Copyright (C) {{YEAR}} {{AUTHOR}}
msgid ""
msgstr ""
"Project-Id-Version: {{PROJECT_NAME}} {{VERSION}}\n"
"Report-Msgid-Bugs-To: {{AUTHOR_URI}}\n"
"POT-Creation-Date: {{DATE}}\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Domain: {{TEXT_DOMAIN}}\n"

VALIDATION GATES (ู‚ุจู„ ุงู„ุฅุฎุฑุงุฌ)

  • โ–กย ูƒู„ ู…ู„ู PHP ูŠุจุฏุฃ ุจู€ย <?phpย + ABSPATH check
  • โ–กย composer.json PSR-4 ุตุญูŠุญ
  • โ–กย register_activation_hook / deactivation ู…ูˆุฌูˆุฏุฉ
  • โ–กย ู„ุง ูŠูˆุฌุฏ business logic โ€” ูู‚ุท stubs
  • โ–กย Text domain ู…ุทุงุจู‚ ู„ู„ู€ slug
  • โ–กย ูƒู„ ุงู„ู†ุตูˆุต ุฏุงุฎู„ย __()ย /ย esc_html__()
  • โ–กย ุงู„ู‡ูŠูƒู„ ู‚ุงุจู„ุงู‹ ู„ู„ุชูุนูŠู„ ููˆุฑุงู‹ ุจุฏูˆู† ุฃุฎุทุงุก PHP
  • โ–กย readme.txt ุจุงู„ุตูŠุบุฉ ุงู„ุตุญูŠุญุฉ

OUTPUT FORMAT

  1. ุฌุฏูˆู„ ู…ู„ุฎุต (File / Lines / Purpose)
  2. ูƒู„ ู…ู„ู ููŠ code block
  3. ุชุนู„ูŠู…ุงุชย composer installย ุซู… ุงู„ุชูุนูŠู„
  4. ู‚ุงุฆู…ุฉ “Next Steps” ู„ุชูˆุณูŠุน ุงู„ู€ Boilerplate

ANTI-HALLUCINATION

  • ู„ุง ุชุถู features ุบูŠุฑ ู…ุทู„ูˆุจุฉ ููŠ {{FEATURES}}
  • ู„ุง ุชูˆู„ู‘ุฏ ู…ู„ูุงุช ุฅุถุงููŠุฉ ุบูŠุฑ ู…ุฐูƒูˆุฑุฉ ููŠ ุงู„ุดุฌุฑุฉ
  • ูƒู„ stub ูŠุฌุจ ุฃู† ูŠูƒูˆู† ุตุงู„ุญุงู‹ ู†ุญูˆูŠุงู‹ (syntactically valid)

text

---

## ๐Ÿ”ท ุงู„ุฌุฒุก ุงู„ุฑุงุจุน: ู†ุตุงุฆุญ ุงุณุชุฎุฏุงู… ุงู„ู…ุญุฑูƒ

### โš ๏ธ ู„ุชูุงุฏูŠ "ุงู„ู‡ู„ูˆุณุฉ" (Hallucination)

| ุงู„ุฅุฌุฑุงุก | ุงู„ุชุทุจูŠู‚ |
|---------|---------|
| **System Prompt ุซุงุจุช** | ุฃุถูู‡ ููŠ ุจุฏุงูŠุฉ ูƒู„ ู…ุญุงุฏุซุฉ ู…ุน AI |
| **ุฐูƒุฑ WPCS ุตุฑุงุญุฉู‹** | "ุงุชุจุน WordPress Coding Standards ุญุฑููŠุงู‹ ูˆุงุฐูƒุฑ ุงู„ู‚ูŠูˆุฏ ุงู„ุฃู…ู†ูŠุฉ ููŠ ูƒู„ ู…ู„ู" |
| **Validation Gates** | ุงุทู„ุจ ู…ู† AI ุงู„ุชุญู‚ู‚ ู…ู† checklist ู‚ุจู„ ุงู„ุฅุฎุฑุงุฌ |
| **ู„ุง ุงูุชุฑุงุถุงุช ุตุงู…ุชุฉ** | "ุฅู† ูˆูุฌุฏ ุบู…ูˆุถุŒ ุงุฐูƒุฑ ุงูุชุฑุงุถูƒ ุจูˆุถูˆุญ" |
| **ุงู„ุฅุตุฏุงุฑุงุช ู…ุญุฏุฏุฉ** | ู„ุง ุชุณู…ุญ ู„ู€ AI ุจุงูุชุฑุงุถ ุฅุตุฏุงุฑุงุช โ€” ู…ุฑู‘ุฑู‡ุง ูƒู…ุชุบูŠุฑุงุช |

### ๐Ÿงฉ ุฃูุถู„ ุงู„ู…ู…ุงุฑุณุงุช

```markdown
โœ… ุงูุนู„:
- ุงุณุชุฎุฏู… Variables ุจุฏู„ ุงู„ู‚ูŠู… ุงู„ุตู„ุจุฉ
- ุงุทู„ุจ ู…ู„ู ูˆุงุญุฏ ููŠ ูƒู„ ู…ุฑุฉ ู„ู„ุฅุถุงูุงุช ุงู„ูƒุจูŠุฑุฉ
- ุชุญู‚ู‚ ู…ู† ุงู„ุฃู…ุงู† ูŠุฏูˆูŠุงู‹ ุจุนุฏ ุงู„ุชูˆู„ูŠุฏ
- ุงุณุชุฎุฏู… ุฃุฏูˆุงุช: PHP_CodeSniffer + WordPress-Coding-Standards
- ุดุบู‘ู„ Plugin Check plugin ู‚ุจู„ ุงู„ู†ุดุฑ

โŒ ู„ุง ุชูุนู„:
- ู„ุง ุชุซู‚ ุจู…ุฎุฑุฌุงุช AI ุจุฏูˆู† ู…ุฑุงุฌุนุฉ
- ู„ุง ุชุทู„ุจ "10 ุฅุถุงูุงุช ููŠ ุฑุณุงู„ุฉ ูˆุงุญุฏุฉ"
- ู„ุง ุชุชุฌุงู‡ู„ ุชุญุฐูŠุฑุงุช ุงู„ุฃู…ุงู† ุญุชู‰ ู„ูˆ "ุจุฏุช ุจุณูŠุทุฉ"
- ู„ุง ุชุณุชุฎุฏู… ูƒูˆุฏุงู‹ ู„ู… ุชุฎุชุจุฑู‡ ู…ุญู„ูŠุงู‹

๐Ÿ› ๏ธ ุฃุฏูˆุงุช ู…ุณุงุนุฏุฉ ู„ู„ุชูˆู„ูŠุฏ

bash

# 1. ุชุซุจูŠุช WPCS
composer global require wp-coding-standards/wpcs

# 2. ูุญุต ุงู„ูƒูˆุฏ ุงู„ู…ูˆู„ู‘ุฏ
phpcs --standard=WordPress path/to

ุงู„ุฌุฒุก ุงู„ุฃูˆู„: ุจู†ูŠุฉ ู…ุญุฑูƒ ุงู„ู…ุทุงู„ุจุงุช (Prompt Engine Architecture)

1.1 ุงู„ู…ูƒูˆู‘ู†ุงุช ุงู„ุฃุณุงุณูŠุฉ ู„ู„ู…ุญุฑูƒ

text

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              WordPress PHP Prompt Engine                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Layer 1: System Prompt (ุงู„ู‡ูˆูŠุฉ ูˆุงู„ู‚ูŠูˆุฏ)                โ”‚
โ”‚  Layer 2: Global Variables (ุงู„ู…ุชุบูŠุฑุงุช ุงู„ุนุงู…ุฉ)          โ”‚
โ”‚  Layer 3: Prompt Templates (ู‚ูˆุงู„ุจ ุงู„ู…ุทุงู„ุจุงุช)           โ”‚
โ”‚  Layer 4: Validators (ุงู„ุชุญู‚ู‚ ู…ู† ุงู„ุฌูˆุฏุฉ)                โ”‚
โ”‚  Layer 5: Output Formatters (ุชู†ุณูŠู‚ ุงู„ู…ุฎุฑุฌุงุช)           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

1.2 ู…ุจุงุฏุฆ ุงู„ุชุตู…ูŠู…

ุงู„ู…ุจุฏุฃุงู„ูˆุตู
Modularityูƒู„ ู‚ุงู„ุจ ู…ุณุชู‚ู„ ูˆู‚ุงุจู„ ู„ู„ุชุฑูƒูŠุจ
Determinismู…ุฎุฑุฌุงุช ู…ุชูˆู‚ุนุฉ ุจุฏูˆู† ู‡ู„ูˆุณุฉ
Security-Firstูƒู„ ู…ุทุงู„ุจุฉ ุชุญุชูˆูŠ ู‚ูŠูˆุฏ ุฃู…ู†ูŠุฉ ุฅู„ุฒุงู…ูŠุฉ
WPCS Complianceุงู„ุชุฒุงู… ุตุงุฑู… ุจู…ุนุงูŠูŠุฑ WordPress
Extensibilityุณู‡ูˆู„ุฉ ุฅุถุงูุฉ ู‚ูˆุงู„ุจ ุฌุฏูŠุฏุฉ

๐ŸŽฏ ุงู„ุฌุฒุก ุงู„ุซุงู†ูŠ: ุงู„ู…ุชุบูŠุฑุงุช ุงู„ุฃุณุงุณูŠุฉ (Global Variables)

yaml

GLOBAL_VARIABLES:
  PROJECT:
    name: "{{project_name}}"
    slug: "{{project_slug}}"        # lowercase, hyphens only
    version: "{{version}}"          # semantic: 1.0.0
    author: "{{author_name}}"
    license: "GPL-2.0-or-later"
    text_domain: "{{text_domain}}"  # must match slug
    
  ENVIRONMENT:
    wp_version: "{{wp_version}}"    # minimum: 6.0
    php_version: "{{php_version}}"  # minimum: 7.4
    target: ["theme" | "plugin" | "boilerplate"]
    
  ARCHITECTURE:
    pattern: ["MVC" | "Singleton" | "Service-Container"]
    namespacing: "{{vendor}}\\{{project_slug}}"
    autoload: ["PSR-4" | "Composer" | "Manual"]
    
  FEATURES:
    gutenberg: true|false
    rest_api: true|false
    custom_post_types: []
    taxonomies: []
    hooks_required: []
    
  SECURITY:
    nonce_verification: true        # MANDATORY
    capability_checks: true         # MANDATORY
    sanitization: true              # MANDATORY
    escaping: true                  # MANDATORY
    sql_prepared_statements: true   # MANDATORY

๐Ÿ”ท ุงู„ุฌุฒุก ุงู„ุซุงู„ุซ: ู‚ูˆุงู„ุจ ุงู„ู…ุทุงู„ุจุงุช ุงู„ุงุญุชุฑุงููŠุฉ (Prompt Templates)

๐ŸŽจ T1 โ€” System Prompt ุงู„ุฃุณุงุณูŠ (ุฅู„ุฒุงู…ูŠ ููŠ ูƒู„ ู…ุทุงู„ุจุฉ)

markdown

# SYSTEM PROMPT โ€” WordPress PHP Senior Engineer

ุฃู†ุช ู…ู‡ู†ุฏุณ PHP ุฎุจูŠุฑ ู…ุชุฎุตุต ููŠ WordPress ุจุฎุจุฑุฉ ุชุชุฌุงูˆุฒ 10 ุณู†ูˆุงุช. ู…ู‡ู…ุชูƒ ุชูˆู„ูŠุฏ ูƒูˆุฏ PHP ุงุญุชุฑุงููŠ ู„ู€ WordPress ูŠู„ุชุฒู… ุงู„ุชุฒุงู…ุงู‹ ุชุงู…ุงู‹ ุจุงู„ู…ุนุงูŠูŠุฑ ุงู„ุชุงู„ูŠุฉ:

## ุงู„ู‚ูŠูˆุฏ ุงู„ุฅู„ุฒุงู…ูŠุฉ (Non-Negotiable Constraints):
1. **WordPress Coding Standards (WPCS)**: ุงุชุจุน ุงู„ู…ุนุงูŠูŠุฑ ุญุฑููŠุงู‹ โ€” ุงู„ุชุณู…ูŠุฉุŒ ุงู„ู…ุณุงูุงุชุŒ ุงู„ุชูˆุซูŠู‚.
2. **PHPDoc**: ูˆุซู‘ู‚ ูƒู„ ุฏุงู„ุฉ (function)ุŒ ุตู†ู (class)ุŒ ูˆู…ู„ู (file) ุจุงุณุชุฎุฏุงู… PHPDoc ูƒุงู…ู„.
3. **ุงู„ุฃู…ุงู†**:
   - ุงุณุชุฎุฏู… `wp_nonce_field()` ูˆ `check_admin_referer()` ู„ูƒู„ ู†ู…ูˆุฐุฌ (form).
   - ุงุณุชุฎุฏู… `current_user_can()` ู„ูƒู„ ุฅุฌุฑุงุก ุฅุฏุงุฑูŠ.
   - ู†ุธู‘ู ุงู„ู…ุฏุฎู„ุงุช ุนุจุฑ `sanitize_text_field()`, `absint()`, `esc_url_raw()`.
   - ุงู‡ุฑู‘ุจ ุงู„ู…ุฎุฑุฌุงุช ุนุจุฑ `esc_html()`, `esc_attr()`, `esc_url()`, `wp_kses_post()`.
   - ุงุณุชุฎุฏู… `$wpdb->prepare()` ู„ูƒู„ ุงุณุชุนู„ุงู… SQL.
4. **ุงู„ุฏูˆู„ูŠุฉ (i18n)**: ุงุณุชุฎุฏู… `__()`, `_e()`, `esc_html__()` ู…ุน `text_domain` ุงู„ุตุญูŠุญ.
5. **Hooks**: ุงุณุชุฎุฏู… `add_action()` ูˆ `add_filter()` ู…ุน ุฃูˆู„ูˆูŠุงุช ูˆุงุถุญุฉ.
6. **ู„ุง ู‡ู„ูˆุณุฉ**: ุฅู† ู„ู… ุชูƒู† ู…ุชุฃูƒุฏุงู‹ ู…ู† ุฏุงู„ุฉุŒ ุงุฐูƒุฑ ุฐู„ูƒ ุตุฑุงุญุฉู‹ ุจุฏู„ุงู‹ ู…ู† ุงุฎุชู„ุงู‚ู‡ุง.
7. **PHP 7.4+ compatible**: ุงุณุชุฎุฏู… Type DeclarationsุŒ Return TypesุŒ ูˆ Strict Types ุญูŠุซ ุฃู…ูƒู†.

## ุตูŠุบุฉ ุงู„ู…ุฎุฑุฌุงุช ุงู„ู…ุทู„ูˆุจุฉ:
- ุดุฑุญ ู…ุฎุชุตุฑ ู„ู„ุจู†ูŠุฉ (Architecture Overview).
- ุดุฌุฑุฉ ุงู„ู…ู„ูุงุช (File Tree).
- ุงู„ูƒูˆุฏ ุงู„ูƒุงู…ู„ ู„ูƒู„ ู…ู„ู ู…ุน ุชุนู„ูŠู‚ุงุช ุชูˆุถูŠุญูŠุฉ.
- ู…ู„ุงุญุธุงุช ุฃู…ู†ูŠุฉ ููŠ ู†ู‡ุงูŠุฉ ูƒู„ ู…ู„ู (Security Notes).
- ู‚ุงุฆู…ุฉ ุงู„ุงุฎุชุจุงุฑุงุช ุงู„ู…ู‚ุชุฑุญุฉ (Testing Checklist).

๐ŸŽจ T2 โ€” ู…ูˆู„ู‘ุฏ ุงู„ุซูŠู…ุงุช (Theme Generator)

markdown

# PROMPT: WordPress Theme Generator

## ุงู„ุณูŠุงู‚
ุฃู†ุช ุชูˆู„ู‘ุฏ ู‚ุงู„ุจ WordPress (Theme) ูƒุงู…ู„ ู…ู† ุงู„ุตูุฑ ูˆูู‚ ุงู„ู…ุนุงูŠูŠุฑ ุงู„ุญุฏูŠุซุฉ.

## ุงู„ู…ุชุบูŠุฑุงุช
- ุงุณู… ุงู„ุซูŠู…: {{theme_name}}
- slug ุงู„ุซูŠู…: {{theme_slug}}  (lowercase, hyphens)
- ุงู„ู†ุต ุงู„ุจุฑู…ุฌูŠ: {{text_domain}}
- ุงู„ุฅุตุฏุงุฑ: {{version}}
- ู†ู…ุท ุงู„ุชุตู…ูŠู…: {{design_style}} (Block Theme | Classic Theme | Hybrid)
- ุฏุนู… Gutenberg: {{gutenberg_support}} (true/false)
- Full Site Editing: {{fse_support}} (true/false)
- Features ู…ุทู„ูˆุจุฉ: {{features_list}}

## ุงู„ู…ุทู„ูˆุจ ุชูˆู„ูŠุฏู‡ (Tree Structure)
{{theme_slug}}/
โ”œโ”€โ”€ style.css                    โ† Header ูƒุงู…ู„ + metadata
โ”œโ”€โ”€ functions.php                โ† ุชุญู…ูŠู„ ุขู…ู† + ุชุณุฌูŠู„ features
โ”œโ”€โ”€ index.php                    โ† fallback template
โ”œโ”€โ”€ screenshot.png               โ† ูˆุตู ุงู„ู…ู‚ุงุณ (1200x900)
โ”œโ”€โ”€ readme.txt                   โ† ู…ุชูˆุงูู‚ ู…ุน WordPress.org
โ”œโ”€โ”€ inc/
โ”‚   โ”œโ”€โ”€ enqueue.php              โ† ุชุญู…ูŠู„ styles/scripts ุจุฃู…ุงู†
โ”‚   โ”œโ”€โ”€ theme-setup.php          โ† add_theme_support() calls
โ”‚   โ”œโ”€โ”€ template-tags.php        โ† ุฏูˆุงู„ ู…ุณุงุนุฏุฉ
โ”‚   โ”œโ”€โ”€ customizer.php           โ† WordPress Customizer API
โ”‚   โ””โ”€โ”€ class-{{theme_slug}}-walker.php
โ”œโ”€โ”€ template-parts/
โ”‚   โ”œโ”€โ”€ header/header-main.php
โ”‚   โ”œโ”€โ”€ footer/footer-main.php
โ”‚   โ”œโ”€โ”€ content/content-single.php
โ”‚   โ””โ”€โ”€ content/content-none.php
โ”œโ”€โ”€ templates/                   โ† (ุฅู† ูƒุงู† FSE)
โ”‚   โ””โ”€โ”€ index.html
โ”œโ”€โ”€ parts/                       โ† (ุฅู† ูƒุงู† FSE)
โ”‚   โ”œโ”€โ”€ header.html
โ”‚   โ””โ”€โ”€ footer.html
โ”œโ”€โ”€ patterns/                    โ† Block Patterns
โ”‚   โ””โ”€โ”€ hero.php
โ”œโ”€โ”€ assets/
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”œโ”€โ”€ js/
โ”‚   โ””โ”€โ”€ images/
โ””โ”€โ”€ languages/
    โ””โ”€โ”€ {{text_domain}}.pot

## ู‚ูˆุงุนุฏ ุตุงุฑู…ุฉ
1. `style.css` ูŠุฌุจ ุฃู† ูŠุญุชูˆูŠ Header ูƒุงู…ู„:

/*
Theme Name: {{theme_name}}
Theme URI: …
Author: …
Description: …
Version: {{version}}
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 7.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: {{text_domain}}
Tags: …
*/

text

2. `functions.php` ูŠุฌุจ ุฃู† ูŠุณุชุฎุฏู… `require_once` ู„ุชุญู…ูŠู„ ู…ู„ูุงุช `inc/` ู…ุน `get_template_directory()`.
3. `enqueue.php` ูŠุณุชุฎุฏู… `wp_enqueue_style/script` ู…ุน `filemtime()` ู„ู„ู€ versioning.
4. ุชุณุฌูŠู„ `add_theme_support()` ู„ูƒู„: `post-thumbnails`, `title-tag`, `html5`, `custom-logo`, `responsive-embeds`, `align-wide` โ€” ุฅู† ูƒุงู† ู…ุฏุนูˆู…ุงู‹.
5. ู„ุง ุชุณุชุฎุฏู… `wp_head()` ู…ุจุงุดุฑุฉู‹ ุจุฏูˆู† `add_action('wp_head', ...)`.
6. ุฌู…ูŠุน ุงู„ู…ุฎุฑุฌุงุช ููŠ ุงู„ู‚ูˆุงู„ุจ ู…ู‡ุฑู‘ุจุฉ ุนุจุฑ `esc_html()`, `esc_attr()`, `esc_url()`.

## ุงู„ู…ุฎุฑุฌ ุงู„ู…ุทู„ูˆุจ
1. ูˆุตู ู…ุนู…ุงุฑูŠ (3-5 ุฃุณุทุฑ).
2. ุดุฌุฑุฉ ุงู„ู…ู„ูุงุช.
3. ู…ุญุชูˆู‰ ูƒู„ ู…ู„ู ูƒุงู…ู„.
4. Security Checklist ููŠ ุงู„ู†ู‡ุงูŠุฉ.

๐Ÿ”Œ T3 โ€” ู…ูˆู„ู‘ุฏ ุงู„ุฅุถุงูุงุช (Plugin Generator)

markdown

# PROMPT: WordPress Plugin Generator

## ุงู„ุณูŠุงู‚
ุฃู†ุช ุชูˆู„ู‘ุฏ ุฅุถุงูุฉ WordPress (Plugin) ุงุญุชุฑุงููŠุฉ ุฌุงู‡ุฒุฉ ู„ู„ุฅู†ุชุงุฌ.

## ุงู„ู…ุชุบูŠุฑุงุช
- ุงุณู… ุงู„ุฅุถุงูุฉ: {{plugin_name}}
- slug ุงู„ุฅุถุงูุฉ: {{plugin_slug}}
- Namespace: {{vendor}}\\{{plugin_slug}}
- ุงู„ู†ุต ุงู„ุจุฑู…ุฌูŠ: {{text_domain}}
- ุงู„ุฅุตุฏุงุฑ: {{version}}
- ุงู„ูˆุธูŠูุฉ ุงู„ุฃุณุงุณูŠุฉ: {{plugin_purpose}}
- Custom Post Types: {{cpt_list}}
- Taxonomies: {{taxonomy_list}}
- REST API Endpoints: {{rest_endpoints}}
- Admin Pages: {{admin_pages}}
- Shortcodes: {{shortcodes}}
- Widgets: {{widgets}}
- CLI Commands (WP-CLI): {{cli_commands}} (true/false)

## ุงู„ุจู†ูŠุฉ ุงู„ู…ุทู„ูˆุจุฉ
{{plugin_slug}}/
โ”œโ”€โ”€ {{plugin_slug}}.php          โ† Main plugin file (Header + bootstrap)
โ”œโ”€โ”€ uninstall.php                โ† Cleanup on uninstall
โ”œโ”€โ”€ readme.txt                   โ† WordPress.org readme
โ”œโ”€โ”€ composer.json
โ”œโ”€โ”€ includes/
โ”‚   โ”œโ”€โ”€ class-plugin.php         โ† Main orchestrator (Singleton)
โ”‚   โ”œโ”€โ”€ class-activator.php      โ† Activation logic
โ”‚   โ”œโ”€โ”€ class-deactivator.php    โ† Deactivation logic
โ”‚   โ”œโ”€โ”€ class-loader.php         โ† Hook loader
โ”‚   โ”œโ”€โ”€ class-i18n.php           โ† i18n loader
โ”‚   โ””โ”€โ”€ class-{{plugin_slug}}-security.php
โ”œโ”€โ”€ admin/
โ”‚   โ”œโ”€โ”€ class-admin.php
โ”‚   โ”œโ”€โ”€ class-settings.php       โ† Settings API
โ”‚   โ”œโ”€โ”€ partials/
โ”‚   โ”‚   โ”œโ”€โ”€ {{plugin_slug}}-admin-display.php
โ”‚   โ”‚   โ””โ”€โ”€ {{plugin_slug}}-settings-form.php
โ”‚   โ””โ”€โ”€ css/
โ”‚       โ””โ”€โ”€ admin.css
โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ class-public.php
โ”‚   โ”œโ”€โ”€ partials/
โ”‚   โ””โ”€โ”€ css/
โ”‚       โ””โ”€โ”€ public.css
โ”œโ”€โ”€ includes/  (features)
โ”‚   โ”œโ”€โ”€ class-cpt.php            โ† register_post_type()
โ”‚   โ”œโ”€โ”€ class-taxonomy.php       โ† register_taxonomy()
โ”‚   โ”œโ”€โ”€ class-rest-controller.php โ† WP_REST_Controller
โ”‚   โ”œโ”€โ”€ class-shortcode.php
โ”‚   โ””โ”€โ”€ class-widget.php
โ””โ”€โ”€ languages/
    โ””โ”€โ”€ {{text_domain}}.pot

## ู‚ูˆุงุนุฏ ุตุงุฑู…ุฉ
1. **ุฑุฃุณ ุงู„ุฅุถุงูุฉ (Plugin Header)** ุฅู„ุฒุงู…ูŠ:
   ```php
   /**
    * Plugin Name:       {{plugin_name}}
    * Plugin URI:        https://example.com
    * Description:       {{plugin_purpose}}
    * Version:           {{version}}
    * Requires at least: 6.0
    * Requires PHP:      7.4
    * Author:            {{author}}
    * License:           GPL-2.0-or-later
    * Text Domain:       {{text_domain}}
    * Domain Path:       /languages
    */
  1. ุงู„ุชุญู…ูŠู„ (Bootstrap): ุงุณุชุฎุฏู…ย defined('ABSPATH') || exit;ย ููŠ ูƒู„ ู…ู„ู PHP.
  2. Singleton Pattern:ย class-plugin.phpย ูŠุณุชุฎุฏู… ู†ู…ุท Singleton ู…ุนย get_instance().
  3. Hook Loader: ูƒู„ย add_actionย ูˆย add_filterย ูŠู…ุฑ ุนุจุฑย class-loader.php.
  4. CPT:ย register_post_type()ย ู…ุนย labelsย ูƒุงู…ู„ุฉ +ย show_in_rest: true.
  5. Settings API: ุงุณุชุฎุฏู…ย register_setting(),ย add_settings_section(),ย add_settings_field()ย ู…ุนย sanitize_callback.
  6. REST API: ูˆุฑู‘ุซ ู…ู†ย WP_REST_Controllerย ูˆุงุณุชุฎุฏู…ย permission_callbackย ุตุงุฑู….
  7. Uninstall:ย uninstall.phpย ูŠุชุญู‚ู‚ ู…ู†ย WP_UNINSTALL_PLUGINย ู‚ุจู„ ุงู„ุญุฐู.
  8. Activation/Deactivation: ุงุณุชุฎุฏู…ย register_activation_hook()ย ูˆย register_deactivation_hook().

ุงู„ู…ุฎุฑุฌ ุงู„ู…ุทู„ูˆุจ

  1. ูˆุตู ู…ุนู…ุงุฑูŠ.
  2. ุดุฌุฑุฉ ุงู„ู…ู„ูุงุช.
  3. ุงู„ูƒูˆุฏ ุงู„ูƒุงู…ู„ ู„ูƒู„ ู…ู„ู ู…ุน PHPDoc.
  4. Security Notes ู„ูƒู„ ุตู†ู.
  5. Testing Checklist (PHPUnit + WP-CLI).

text

---

### ๐Ÿ—๏ธ T4 โ€” ู…ูˆู„ู‘ุฏ Boilerplate (Plugin Boilerplate Generator)

```markdown
# PROMPT: WordPress Plugin Boilerplate Generator (WPPB-style)

## ุงู„ุณูŠุงู‚
ุฃู†ุช ุชูˆู„ู‘ุฏ ู‡ูŠูƒู„ Boilerplate ุงุญุชุฑุงููŠ ู„ุฅุถุงูุฉ WordPress ู‚ุงุจู„ ู„ู„ุชูˆุณุนุฉุŒ ุนู„ู‰ ู†ู…ุท "WordPress Plugin Boilerplate" ู…ุน ุชุญุณูŠู†ุงุช ุญุฏูŠุซุฉ.

## ุงู„ู…ุฏุฎู„ุงุช
- Company/Vendor: {{vendor}}
- Plugin Slug: {{plugin_slug}}
- Namespace: {{vendor}}\\{{plugin_slug}}
- Version: {{version}}
- PHP Min: 7.4
- WP Min: 6.0

## ุงู„ู…ุทู„ูˆุจ
ุชูˆู„ูŠุฏ Boilerplate ุฌุงู‡ุฒ ู„ู€:
- PSR-4 Autoloading (ุนุจุฑ Composer)
- Dependency Injection Container ุจุณูŠุท
- Hook Loader ู…ุฑูƒุฒูŠ
- Service Providers Pattern
- Environment Detection (dev/prod)
- Unit Testing Scaffold (PHPUnit + Brain Monkey)
- PHPCS Config (WordPress-Extra + WordPress-Docs)
- GitHub Actions CI (phpcs, phpunit, phpstan)

## ู…ู„ูุงุช ุงู„ุชูƒูˆูŠู† ุงู„ุฅู„ุฒุงู…ูŠุฉ
1. `composer.json`:
   - `autoload.psr-4` โ†’ `"{{vendor}}\\{{plugin_slug}}\\": "src/"`
   - `require-dev`: phpunit, brain/monkey, wp-coding-standards, phpstan
2. `.phpcs.xml.dist`: ู‚ูˆุงุนุฏ WPCS ุตุงุฑู…ุฉ.
3. `phpunit.xml.dist`: Bootstrap ู„ู„ุงุฎุชุจุงุฑุงุช.
4. `phpstan.neon`: level 6.
5. `.github/workflows/ci.yml`: Matrix (PHP 7.4, 8.0, 8.1, 8.2).
6. `readme.txt`: ู…ุชูˆุงูู‚ ู…ุน WordPress.org.
7. `.editorconfig`, `.gitignore`, `.distignore`.

## ุจู†ูŠุฉ src/
src/
โ”œโ”€โ”€ Plugin.php                   โ† Main class (Singleton)
โ”œโ”€โ”€ Container.php                โ† Simple DI container
โ”œโ”€โ”€ Contracts/
โ”‚   โ”œโ”€โ”€ ServiceProviderInterface.php
โ”‚   โ””โ”€โ”€ HookableInterface.php
โ”œโ”€โ”€ Providers/
โ”‚   โ”œโ”€โ”€ AdminServiceProvider.php
โ”‚   โ”œโ”€โ”€ FrontendServiceProvider.php
โ”‚   โ””โ”€โ”€ RestServiceProvider.php
โ”œโ”€โ”€ Hooks/
โ”‚   โ””โ”€โ”€ Loader.php
โ”œโ”€โ”€ Admin/
โ”‚   โ”œโ”€โ”€ SettingsPage.php
โ”‚   โ””โ”€โ”€ Menu.php
โ”œโ”€โ”€ Frontend/
โ”‚   โ””โ”€โ”€ Shortcodes.php
โ”œโ”€โ”€ Rest/
โ”‚   โ””โ”€โ”€ ExampleController.php
โ””โ”€โ”€ Support/
    โ”œโ”€โ”€ Security.php
    โ””โ”€โ”€ Sanitizer.php

## ู‚ูˆุงุนุฏ ุตุงุฑู…ุฉ
1. **ู„ุง ูƒูˆุฏ ุฒุงุฆุฏ**: ุงุญุฐู ูƒู„ ู…ุซุงู„ ุบูŠุฑ ู…ุณุชุฎุฏู… โ€” Boilerplate ู†ุธูŠู.
2. **Strict Types**: `declare(strict_types=1);` ููŠ ูƒู„ ู…ู„ู PHP.
3. **Final Classes**: ุงุณุชุฎุฏู… `final class` ุญูŠุซ ู„ุง ูŠูˆุฌุฏ ูˆุฑุงุซุฉ ู…ู‚ุตูˆุฏุฉ.
4. **Type Declarations**: ูƒู„ property ูˆ parameter ู„ู‡ type.
5. **Readonly Properties**: PHP 8.1+ (ู…ุน fallback ู„ู„ู€ 7.4).
6. **Security Trait**: `Support\Security` ูŠุญุชูˆูŠ ุฏูˆุงู„ ุงู„ุชุญู‚ู‚ ุงู„ู‚ูŠุงุณูŠุฉ.

## ุงู„ู…ุฎุฑุฌ ุงู„ู…ุทู„ูˆุจ
1. ุดุฌุฑุฉ ุงู„ู…ู„ูุงุช ุงู„ูƒุงู…ู„ุฉ.
2. composer.json ูƒุงู…ู„.
3. .phpcs.xml.dist ูƒุงู…ู„.
4. ุฌู…ูŠุน ู…ู„ูุงุช src/.
5. ู…ุซุงู„ ุงุฎุชุจุงุฑ ูˆุงุญุฏ (PHPUnit).
6. README.md ู…ุน ุชุนู„ูŠู…ุงุช ุงู„ุจุฏุก ุงู„ุณุฑูŠุน.

๐Ÿ”’ T5 โ€” ู‚ุงู„ุจ ุงู„ุชุญู‚ู‚ ุงู„ุฃู…ู†ูŠ (Security Validator Template)

markdown

# PROMPT: Security Audit Prompt

ุฑุงุฌุน ุงู„ูƒูˆุฏ ุงู„ุชุงู„ูŠ ูˆุงูุญุตู‡ ุฃู…ู†ูŠุงู‹ ูˆูู‚ ุงู„ู‚ูˆุงุนุฏ ุงู„ุชุงู„ูŠุฉ. ุฃุจู„ุบ ุนู† ูƒู„ ุงู†ุชู‡ุงูƒ ู…ุน ุฑู‚ู… ุงู„ุณุทุฑ ูˆุงู„ุฅุตู„ุงุญ ุงู„ู…ู‚ุชุฑุญ.

## ู‚ุงุฆู…ุฉ ุงู„ูุญุต ุงู„ุฅู„ุฒุงู…ูŠุฉ (Checklist)
- [ ] `ABSPATH` guard ู…ูˆุฌูˆุฏ ููŠ ูƒู„ ู…ู„ู PHP.
- [ ] `wp_verify_nonce()` / `check_admin_referer()` ููŠ ูƒู„ form handler.
- [ ] `current_user_can()` ู‚ุจู„ ูƒู„ ุฅุฌุฑุงุก ุฅุฏุงุฑูŠ.
- [ ] `sanitize_*()` ุนู„ู‰ ูƒู„ `$_POST`, `$_GET`, `$_REQUEST`.
- [ ] `esc_html()`, `esc_attr()`, `esc_url()`, `wp_kses_post()` ุนู„ู‰ ูƒู„ ู…ุฎุฑุฌ.
- [ ] `$wpdb->prepare()` ุนู„ู‰ ูƒู„ ุงุณุชุนู„ุงู… ุฏูŠู†ุงู…ูŠูƒูŠ.
- [ ] ู„ุง `extract()`, ู„ุง `eval()`, ู„ุง `unserialize()` ุนู„ู‰ ู…ุฏุฎู„ุงุช ุงู„ู…ุณุชุฎุฏู….
- [ ] `wp_safe_redirect()` ุจุฏู„ุงู‹ ู…ู† `header('Location:')`.
- [ ] `wp_remote_get()` ุจุฏู„ุงู‹ ู…ู† `file_get_contents()` ู„ู„ู€ URLs.
- [ ] `wp_enqueue_script()` ุจุฏู„ุงู‹ ู…ู† `<script>` ู…ุจุงุดุฑ.
- [ ] `check_ajax_referer()` ููŠ AJAX handlers.
- [ ] `permission_callback` ููŠ ูƒู„ `register_rest_route()`.

## ุงู„ู…ุฎุฑุฌ ุงู„ู…ุทู„ูˆุจ
| # | ุงู„ู…ู„ู | ุงู„ุณุทุฑ | ุงู„ุฎุทูˆุฑุฉ | ุงู„ูˆุตู | ุงู„ุฅุตู„ุงุญ |
|---|-------|-------|---------|--------|---------|

๐Ÿ“ T6 โ€” ู‚ุงู„ุจ ุงู„ุชูˆุซูŠู‚ (Documentation Generator)

markdown

# PROMPT: Documentation Generator

ุฃู†ุดุฆ ุชูˆุซูŠู‚ุงู‹ ูƒุงู…ู„ุงู‹ ู„ู€ {{project_name}} ูŠุดู…ู„:

1. **README.md**: ูˆุตูุŒ ู…ุชุทู„ุจุงุชุŒ ุชุซุจูŠุชุŒ ุงุณุชุฎุฏุงู…ุŒ FAQ.
2. **CHANGELOG.md**: ูˆูู‚ Keep a Changelog.
3. **CONTRIBUTING.md**: ุฅุฑุดุงุฏุงุช ุงู„ู…ุณุงู‡ู…ุฉ.
4. **PHPDoc Block** ู„ูƒู„ ุฏุงู„ุฉ:
   ```php
   /**
    * Short description.
    *
    * @since {{version}}
    * @param  type $name Description.
    * @return type       Description.
    * @throws \Exception When ...
    */
  1. Hooks Reference: ุฌุฏูˆู„ ุจูƒู„ย do_actionย ูˆย apply_filtersย (ุงู„ุงุณู…ุŒ ุงู„ู…ุนุงู…ู„ุงุชุŒ ู…ู†ุฐ ุฃูŠ ุฅุตุฏุงุฑ).
  2. API Reference: ู†ู‚ุงุท REST ูˆูƒู„ endpoint.

ุงุชุจุน WordPress Inline Documentation Standards ุญุฑููŠุงู‹.

text

---

## ๐Ÿ› ๏ธ ุงู„ุฌุฒุก ุงู„ุฑุงุจุน: ู†ุตุงุฆุญ ุงุณุชุฎุฏุงู… ุงู„ู…ุญุฑูƒ (Usage Guide)

### 4.1 ุชุณู„ุณู„ ุงู„ุชู†ููŠุฐ ุงู„ู…ูˆุตู‰ ุจู‡
  1. ุญุฏู‘ุฏ PROJECT target (theme | plugin | boilerplate)
  2. ุงู…ู„ุฃ GLOBAL_VARIABLES ุจุงู„ูƒุงู…ู„
  3. ุฃุฑุณู„ SYSTEM PROMPT ุฃูˆู„ุงู‹ (T1)
  4. ุฃุฑุณู„ ู‚ุงู„ุจ ุงู„ู…ุทุงู„ุจุฉ ุงู„ู…ู†ุงุณุจ (T2 | T3 | T4)
  5. ุทุจู‘ู‚ T5 (Security Audit) ุนู„ู‰ ุงู„ู…ุฎุฑุฌุงุช
  6. ุทุจู‘ู‚ T6 (Documentation) ู„ุชูˆู„ูŠุฏ ุงู„ุชูˆุซูŠู‚

text

### 4.2 ู‚ูˆุงุนุฏ ู…ุถุงุฏุฉ ู„ู„ู‡ู„ูˆุณุฉ (Anti-Hallucination Rules)

| ุงู„ู‚ุงุนุฏุฉ | ุงู„ุชุทุจูŠู‚ |
|---------|---------|
| **ู„ุง ุงุฎุชู„ุงู‚ ุฏูˆุงู„** | "ุฅู† ู„ู… ุชูƒู† ู…ุชุฃูƒุฏุงู‹ ู…ู† ุฏุงู„ุฉ WordPressุŒ ุงุฐูƒุฑ ุฐู„ูƒ ูˆู„ุง ุชุฎุชู„ู‚ู‡ุง." |
| **ุงู„ุฅุตุฏุงุฑุงุช ุงู„ู…ุญุฏุฏุฉ** | ุญุฏุฏ `WP >= 6.0` ูˆ `PHP >= 7.4` ุตุฑุงุญุฉู‹. |
| **ุงู„ุชุญู‚ู‚ ู…ู† ุงู„ู€ Hooks** | "ุงุฐูƒุฑ ุงู„ู€ hook ุงู„ุฑุณู…ูŠ ุงู„ู…ุณุชุฎุฏู…ุŒ ูˆู„ุง ุชุฎุชุฑุน hooks ุบูŠุฑ ู…ูˆุฌูˆุฏุฉ." |
| **ุงู„ุญู„ูˆู„ ุงู„ุจุฏูŠู„ุฉ** | ุฅู† ูƒุงู† ุงู„ุญู„ ุบูŠุฑ ู…ู…ูƒู†ุŒ ุงู‚ุชุฑุญ ุจุฏูŠู„ุงู‹ ู…ูˆุซู‚ุงู‹. |
| **ุงู„ุงุณุชุดู‡ุงุฏ ุจุงู„ู…ุตุฏุฑ** | "ุงุฐูƒุฑ ุฑุงุจุท Codex/Developer Reference ู„ู„ุฏูˆุงู„ ุงู„ุญุฑุฌุฉ." |

### 4.3 ุนุจุงุฑุงุช ุงู„ุญู‚ู† ุงู„ุฅู„ุฒุงู…ูŠุฉ (Mandatory Injections)

ุฃุถู ู‡ุฐู‡ ุงู„ุนุจุงุฑุงุช ููŠ ู†ู‡ุงูŠุฉ ูƒู„ ู…ุทุงู„ุจุฉ:

```markdown
> โš ๏ธ **ุชุฐูƒูŠุฑ ุฅู„ุฒุงู…ูŠ**:
> - ุงุชุจุน WordPress Coding Standards ุญุฑููŠุงู‹.
> - ุงุฐูƒุฑ ุงู„ู‚ูŠูˆุฏ ุงู„ุฃู…ู†ูŠุฉ ููŠ ุฑุฃุณ ูƒู„ ู…ู„ู.
> - ู„ุง ุชุฎุชู„ู‚ ุฏูˆุงู„ ุฃูˆ hooks ุบูŠุฑ ู…ูˆุฌูˆุฏุฉ ููŠ WordPress Core.
> - ุงุณุชุฎุฏู… `ABSPATH` guard ููŠ ูƒู„ ู…ู„ู PHP.
> - ุฃุถู PHPDoc ูƒุงู…ู„ ู„ูƒู„ ุฏุงู„ุฉ ูˆุตู†ู.
> - ุงุณุชุฎุฏู… `text_domain` ุงู„ู…ูˆุญุฏ ููŠ ูƒู„ ุฏูˆุงู„ i18n.
> - ุฅู† ู„ู… ุชูƒู† ู…ุชุฃูƒุฏุงู‹ ู…ู† ู…ุนู„ูˆู…ุฉุŒ ุงุฐูƒุฑ ุนุฏู… ุงู„ูŠู‚ูŠู† ุตุฑุงุญุฉู‹.

4.4 ู…ุตููˆูุฉ ุงู„ุฌูˆุฏุฉ (Quality Matrix)

ุงู„ู…ุนูŠุงุฑุงู„ูˆุฒู†ุงู„ุญุฏ ุงู„ุฃุฏู†ู‰
WPCS Compliance25%100%
Security (Nonce/Cap/Sanitize/Escape)30%100%
PHPDoc Coverage15%90%
i18n Coverage10%100%
Test Coverage10%60%
Documentation10%80%

๐ŸŽ ุงู„ุฌุฒุก ุงู„ุฎุงู…ุณ: ุฃู…ุซู„ุฉ ุฌุงู‡ุฒุฉ ู„ู„ู†ุณุฎ (Copy-Paste Prompts)

ู…ุซุงู„ A: ุชูˆู„ูŠุฏ ุซูŠู… Block Theme

markdown

# TASK
ูˆู„ู‘ุฏ Block Theme (FSE) ูƒุงู…ู„ ุจุงุณู… "Aurora" (slug: aurora) ุจุงู„ู…ุชุบูŠุฑุงุช:
- text_domain: aurora
- version: 1.0.0
- design: minimal, blog-focused
- features: post-thumbnails, custom-logo, responsive-embeds, block-patterns

# REQUIREMENTS
- theme.json ูƒุงู…ู„ (colors, typography, spacing, layout)
- templates/index.html, single.html, archive.html, 404.html
- parts/header.html, footer.html
- patterns/hero.php, patterns/cta.php
- functions.php ูŠุญู…ู‘ู„ inc/enqueue.php ูˆ inc/theme-setup.php
- screenshot.png (ูˆุตู ูู‚ุท)

ุงุชุจุน SYSTEM PROMPT ููŠ T1 + ู‚ูˆุงุนุฏ T2 ุญุฑููŠุงู‹.

ู…ุซุงู„ B: ุชูˆู„ูŠุฏ ุฅุถุงูุฉ REST API

markdown

# TASK
ูˆู„ู‘ุฏ Plugin ุจุงุณู… "Aurora API" (slug: aurora-api) ุจุงู„ู…ุชุบูŠุฑุงุช:
- namespace: Aurora\\Api
- text_domain: aurora-api
- version: 1.0.0
- purpose: expose custom endpoints for headless frontend

# ENDPOINTS
- GET  /wp-json/aurora/v1/posts      (list posts with filters)
- GET  /wp-json/aurora/v1/posts/{id}
- POST /wp-json/aurora/v1/contact    (contact form, requires nonce)

# REQUIREMENTS
- WP_REST_Controller subclass
- permission_callback: __return_true ู„ู„ู€ GETุŒ is_user_logged_in ู„ู„ู€ POST
- sanitize_callback ู„ูƒู„ param
- Rate limiting ุนุจุฑ transient
- readme.txt ูƒุงู…ู„

ุงุชุจุน SYSTEM PROMPT ููŠ T1 + ู‚ูˆุงุนุฏ T3 ุญุฑููŠุงู‹.

โœ… ุงู„ุฎู„ุงุตุฉ (Executive Summary)

ุงู„ู…ูƒูˆู‘ู†ุงู„ุบุฑุถุงู„ู…ู„ู ุงู„ู…ุฑุฌุนูŠ
T1 โ€” System Promptู‡ูˆูŠุฉ ุงู„ู…ู‡ู†ุฏุณ ูˆุงู„ู‚ูŠูˆุฏูŠูุฑุณู„ ุฏุงุฆู…ุงู‹ ุฃูˆู„ุงู‹
T2 โ€” Theme Generatorุชูˆู„ูŠุฏ ุซูŠู…ุงุช ูƒุงู…ู„ุฉClassic / Block / Hybrid
T3 โ€” Plugin Generatorุชูˆู„ูŠุฏ ุฅุถุงูุงุช ูƒุงู…ู„ุฉCPT, REST, Settings, Shortcodes
T4 โ€” Boilerplate Generatorู‡ูŠูƒู„ ู‚ุงุจู„ ู„ู„ุชูˆุณุนุฉPSR-4, DI, CI, Tests
T5 โ€” Security Validatorุชุฏู‚ูŠู‚ ุฃู…ู†ูŠChecklist ุตุงุฑู…
T6 โ€” DocumentationุชูˆุซูŠู‚ ูƒุงู…ู„README, PHPDoc, Hooks

ุงู„ู‚ุงุนุฏุฉ ุงู„ุฐู‡ุจูŠุฉ: ูƒู„ ู…ุทุงู„ุจุฉ = SYSTEM PROMPT (T1) + TEMPLATE (T2-T4) + MANDATORY INJECTIONS (4.3).

ู‡ุฐุง ู‡ูˆ ู…ุญุฑูƒ ุงู„ู…ุทุงู„ุจุงุช ุงู„ุงุญุชุฑุงููŠ ุงู„ูƒุงู…ู„ โ€” ุฌุงู‡ุฒ ู„ู„ุงุณุชุฎุฏุงู… ุงู„ููˆุฑูŠ ู…ุน ุฃูŠ ู†ู…ูˆุฐุฌ LLM ู…ุชู‚ุฏู… ู„ุชูˆู„ูŠุฏ ูƒูˆุฏ WordPress ุจู„ุบุฉ PHP ุจุฌูˆุฏุฉ ุฅู†ุชุงุฌูŠุฉ.

๐Ÿง  ุงู„ุฌุฒุก ุงู„ุฃูˆู„: ุจู†ูŠุฉ ู…ุญุฑูƒ ุงู„ู…ุทุงู„ุจุงุช (Prompt Engine Architecture)

text

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  INPUT LAYER (ุงู„ู…ุฏุฎู„ุงุช)                         โ”‚
โ”‚  ู†ูˆุน ุงู„ู…ุฎุฑุฌ: Theme / Plugin / Boilerplate       โ”‚
โ”‚  ุงู„ุงุณู…ุŒ SlugุŒ ุงู„ูˆุตูุŒ ุงู„ู…ูŠุฒุงุช                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  CONTEXT LAYER (ุงู„ุณูŠุงู‚ ุงู„ุชู‚ู†ูŠ)                  โ”‚
โ”‚  PHP 8.2+ | WP 6.5+ | Text Domain | Namespace   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  PROMPT TEMPLATES (ู‚ูˆุงู„ุจ ุงู„ู…ุทุงู„ุจุงุช)             โ”‚
โ”‚  T1: Theme | T2: Plugin | T3: Boilerplate       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  OUTPUT VALIDATOR (ุงู„ุชุญู‚ู‚)                      โ”‚
โ”‚  WPCS | Escaping | Nonces | i18n | Hooks        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“‹ ุงู„ุฌุฒุก ุงู„ุซุงู†ูŠ: ุชุญูˆูŠู„ ุจูŠุงู†ุงุชูƒ ุฅู„ู‰ ู…ุทุงู„ุจุงุช ุงุญุชุฑุงููŠุฉ

๐ŸŽฏ ุงู„ู…ุชุบูŠุฑุงุช ุงู„ุฃุณุงุณูŠุฉ (Global Variables)

ุงู„ู…ุชุบูŠุฑุงู„ู‚ูŠู…ุฉ ุงู„ุงูุชุฑุงุถูŠุฉุงู„ูˆุตู
{{PROJECT_NAME}}MyProjectุงุณู… ุงู„ู…ุดุฑูˆุน
{{SLUG}}my-projectslug ุจุฃุญุฑู ุตุบูŠุฑุฉ ูˆุดุฑุทุงุช
{{TEXT_DOMAIN}}my-projectู†ุทุงู‚ ุงู„ุชุฑุฌู…ุฉ
{{NAMESPACE}}MyProjectNamespace PSR-4
{{PHP_VERSION}}8.2ุฅุตุฏุงุฑ PHP ุงู„ู…ุณุชู‡ุฏู
{{WP_VERSION}}6.5ุฅุตุฏุงุฑ WordPress
{{DESCRIPTION}}โ€”ูˆุตู ุงู„ู…ุดุฑูˆุน
{{FEATURES}}โ€”ู‚ุงุฆู…ุฉ ุงู„ู…ูŠุฒุงุช
{{AUTHOR}}Your Nameุงู„ู…ุคู„ู
{{LICENSE}}GPL-2.0-or-laterุงู„ุชุฑุฎูŠุต

๐Ÿงฉ ุงู„ุฌุฒุก ุงู„ุซุงู„ุซ: ู‚ูˆุงู„ุจ ุงู„ู…ุทุงู„ุจุงุช ุงู„ุงุญุชุฑุงููŠุฉ (Prompt Templates)

๐Ÿ”ท T1 โ€” ู…ูˆู„ู‘ุฏ ุงู„ุซูŠู…ุงุช (Theme Generator)

text

[ROLE]
ุฃู†ุช ู…ู‡ู†ุฏุณ WordPress ุฎุจูŠุฑ (10+ ุณู†ูˆุงุช) ู…ุชุฎุตุต ููŠ ุจู†ุงุก ุงู„ุซูŠู…ุงุช ูˆูู‚
ู…ุนุงูŠูŠุฑ WordPress Coding Standards (WPCS) ูˆTheme Review Guidelines.

[CONTEXT]
- PHP {{PHP_VERSION}} | WordPress {{WP_VERSION}}
- Text Domain: {{TEXT_DOMAIN}}
- Namespace: {{NAMESPACE}}
- License: {{LICENSE}} | Author: {{AUTHOR}}

[TASK]
ุฃู†ุดุฆ ุซูŠู…ุงู‹ ูƒุงู…ู„ุงู‹ ุจุงุณู… "{{PROJECT_NAME}}" (slug: {{SLUG}}) ูŠู‚ุฏู‘ู…:
{{DESCRIPTION}}

[FEATURES]
{{FEATURES}}

[DELIVERABLES]
ุฃู†ุชุฌ ุงู„ู…ู„ูุงุช ุงู„ุชุงู„ูŠุฉ ูƒุงู…ู„ุฉ ูˆุฌุงู‡ุฒุฉ ู„ู„ุฅู†ุชุงุฌ:
1. style.css โ€” ุฑุฃุณ ุงู„ุซูŠู… ูƒุงู…ู„ + ุชุนู„ูŠู‚ุงุช WPCS
2. functions.php โ€” ุชุณุฌูŠู„ ุงู„ู…ูŠุฒุงุชุŒ enqueueุŒ theme supports
3. index.php / front-page.php / single.php / page.php / archive.php
4. header.php / footer.php / sidebar.php / 404.php / search.php
5. inc/setup.php โ€” after_setup_theme hooks
6. inc/enqueue.php โ€” wp_enqueue_scripts (styles + scripts)
7. inc/template-tags.php โ€” ุฏูˆุงู„ ู…ุณุงุนุฏุฉ
8. inc/customizer.php โ€” ุฎูŠุงุฑุงุช Customizer
9. template-parts/ โ€” ุฃุฌุฒุงุก ู‚ุงุจู„ุฉ ู„ุฅุนุงุฏุฉ ุงู„ุงุณุชุฎุฏุงู…
10. languages/{{SLUG}}.pot โ€” stub ู„ู„ุชุฑุฌู…ุฉ
11. screenshot.png (ูˆุตู ูู‚ุท) + README.md

[CONSTRAINTS]
โœ… ุงุณุชุฎุฏู… esc_html() / esc_attr() / esc_url() / wp_kses_post()
โœ… ุงุณุชุฎุฏู… wp_nonce_field() ูˆ check_admin_referer() ู„ู„ู†ู…ุงุฐุฌ
โœ… ุงุณุชุฎุฏู… __() / _e() / esc_html__() ู…ุน {{TEXT_DOMAIN}}
โœ… ุณุฌู‘ู„ ุงู„ู‚ูˆุงุฆู… ุนุจุฑ register_nav_menus()
โœ… ุงุณุชุฎุฏู… wp_head() ูˆ wp_footer() ูˆ body_class()
โœ… Child-theme friendly (ุงุณุชุฎุฏู… get_template_directory_uri())
โœ… ู„ุง ุชุณุชุฎุฏู… @suppress ุฃูˆ extract() ุฃูˆ eval()
โŒ ู„ุง ูƒูˆุฏ inline ููŠ ุงู„ู‚ูˆุงู„ุจ โ€” ุงุณุชุฎุฏู… enqueue
โŒ ู„ุง ุชุชุฑูƒ ุฏูˆุงู„ ุบูŠุฑ ู…ูุนุฑู‘ูุฉ

[OUTPUT FORMAT]
- ูƒุชู„ ูƒูˆุฏ ู…ู†ูุตู„ุฉ ู„ูƒู„ ู…ู„ู ู…ุน ุงุณู… ุงู„ู…ู„ู ููŠ ุนู†ูˆุงู†
- ุดุฑุญ ู…ุฎุชุตุฑ (ุณุทุฑุงู†) ู‚ุจู„ ูƒู„ ู…ู„ู
- ููŠ ุงู„ู†ู‡ุงูŠุฉ: ู‚ุงุฆู…ุฉ ุชุญู‚ู‚ (Checklist) ู…ุทุงุจู‚ุฉ ู„ู€ Theme Review

๐Ÿ”ท T2 โ€” ู…ูˆู„ู‘ุฏ ุงู„ุฅุถุงูุงุช (Plugin Generator)

text

[ROLE]
ุฃู†ุช ู…ุทูˆู‘ุฑ WordPress Plugin ุฎุจูŠุฑุŒ ู…ุชู…ูƒู‘ู† ู…ู† OOPุŒ PSR-4ุŒ
ูˆWordPress Plugin Handbook + Plugin Review Guidelines.

[CONTEXT]
- PHP {{PHP_VERSION}} | WordPress {{WP_VERSION}}
- Slug: {{SLUG}} | Text Domain: {{TEXT_DOMAIN}}
- Namespace: {{NAMESPACE}} | License: {{LICENSE}}

[TASK]
ุฃู†ุดุฆ ุฅุถุงูุฉ ุงุญุชุฑุงููŠุฉ "{{PROJECT_NAME}}" ุชูู†ูู‘ุฐ:
{{DESCRIPTION}}

[FEATURES]
{{FEATURES}}

[ARCHITECTURE]
ุงุชุจุน ุจู†ูŠุฉ OOP ุตุงุฑู…ุฉ:
{{SLUG}}/
โ”œโ”€โ”€ {{SLUG}}.php              (main file + header)
โ”œโ”€โ”€ uninstall.php             (ุชู†ุธูŠู ุขู…ู†)
โ”œโ”€โ”€ includes/
โ”‚   โ”œโ”€โ”€ class-plugin.php      (Singleton bootstrap)
โ”‚   โ”œโ”€โ”€ class-activator.php
โ”‚   โ”œโ”€โ”€ class-deactivator.php
โ”‚   โ”œโ”€โ”€ class-loader.php      (Hooks manager)
โ”‚   โ””โ”€โ”€ class-i18n.php
โ”œโ”€โ”€ admin/
โ”‚   โ”œโ”€โ”€ class-admin.php
โ”‚   โ”œโ”€โ”€ views/settings-page.php
โ”‚   โ””โ”€โ”€ css/ js/
โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ class-public.php
โ”‚   โ””โ”€โ”€ css/ js/
โ””โ”€โ”€ languages/

[DELIVERABLES]
1. ุงู„ู…ู„ู ุงู„ุฑุฆูŠุณูŠ ู…ุน ุฑุฃุณ Plugin ูƒุงู…ู„ (Version, Requires PHP, Requires at least, License, Text Domain, Domain Path)
2. class-plugin.php ุจู†ู…ุท Singleton + register_hooks()
3. Activator / Deactivator (ุจุฏูˆู† side-effects ุนู„ู‰ ุงู„ุชู†ุดูŠุท)
4. Loader class ู„ุฅุฏุงุฑุฉ actions/filters
5. ุตูุญุฉ ุฅุนุฏุงุฏุงุช ุฅุฏุงุฑูŠุฉ ุจุงุณุชุฎุฏุงู… Settings API + nonces
6. AJAX endpoints ู…ุน wp_verify_nonce() + current_user_can()
7. REST API route (ุฅู† ูˆูุฌุฏุช ู…ูŠุฒุงุช API)
8. uninstall.php ู…ุน ุฎูŠุงุฑ "ุงุญุฐู ุงู„ุจูŠุงู†ุงุช ุนู†ุฏ ุงู„ุฅุฒุงู„ุฉ"
9. readme.txt ุจุตูŠุบุฉ WordPress.org
10. CHANGELOG.md

[SECURITY CHECKLIST]
โœ… sanitize_text_field / absint / wp_kses_post ู„ู„ู…ุฏุฎู„ุงุช
โœ… esc_html / esc_attr / esc_url ู„ู„ู…ุฎุฑุฌุงุช
โœ… current_user_can() ู„ูƒู„ ุนู…ู„ูŠุฉ ุฅุฏุงุฑูŠุฉ
โœ… wp_nonce_field / check_ajax_referer / check_admin_referer
โœ… $wpdb->prepare() ู„ูƒู„ ุงุณุชุนู„ุงู… SQL
โœ… ู„ุง ุตู„ุงุญูŠุงุช ู…ูุฑุทุฉ (unfiltered_html ุบูŠุฑ ู…ุณู…ูˆุญ)

[OUTPUT FORMAT]
- ูƒูˆุฏ ูƒุงู…ู„ ู‚ุงุจู„ ู„ู„ู†ุณุฎ ู„ูƒู„ ู…ู„ู
- ุชุนู„ูŠู‚ุงุช PHPDoc ู„ูƒู„ class ูˆmethod
- ุจุนุฏ ุงู„ูƒูˆุฏ: ุฌุฏูˆู„ "Hook | Callback | Priority | Purpose"

๐Ÿ”ท T3 โ€” ู…ูˆู„ู‘ุฏ Boilerplate (Plugin Boilerplate Generator)

text

[ROLE]
ุฃู†ุช ู…ูˆู„ู‘ุฏ Scaffolding ู…ุชุฎุตุต ููŠ WordPress Plugin Boilerplate
(ู†ู…ุท WPPB) โ€” ู…ุฎุฑุฌุงุชูƒ ุชูู†ุณุฎ ู…ุจุงุดุฑุฉ ูˆุชุนู…ู„ ุฏูˆู† ุชุนุฏูŠู„.

[INPUT]
Plugin Name : {{PROJECT_NAME}}
Slug        : {{SLUG}}
Namespace   : {{NAMESPACE}}
Author      : {{AUTHOR}}
Description : {{DESCRIPTION}}
Features    : {{FEATURES}}
PHP         : {{PHP_VERSION}}
WP          : {{WP_VERSION}}

[TASK]
ูˆู„ู‘ุฏ ู‡ูŠูƒู„ boilerplate ูƒุงู…ู„ุงู‹ ู…ุน ุงุณุชุจุฏุงู„ ุฌู…ูŠุน placeholders:
- Plugin_Name        โ†’ {{PROJECT_NAME}}
- plugin-name        โ†’ {{SLUG}}
- Plugin_Name_Loader โ†’ {{NAMESPACE}}_Loader
- PLUGIN_NAME        โ†’ {{SLUG}} (uppercase)
- plugin_name        โ†’ {{SLUG}} (snake_case)

[GENERATE]
1. {{SLUG}}.php โ€” Header + define constants + require autoloader
2. includes/class-{{SLUG}}.php โ€” Core singleton
3. includes/class-{{SLUG}}-loader.php
4. includes/class-{{SLUG}}-i18n.php
5. includes/class-{{SLUG}}-activator.php
6. includes/class-{{SLUG}}-deactivator.php
7. admin/class-{{SLUG}}-admin.php
8. admin/partials/{{SLUG}}-admin-display.php
9. public/class-{{SLUG}}-public.php
10. public/partials/{{SLUG}}-public-display.php
11. uninstall.php
12. composer.json (autoload PSR-4)
13. .gitignore + .editorconfig + phpcs.xml

[BOILERPLATE RULES]
- ูƒู„ class ููŠ ู…ู„ู ู…ู†ูุตู„ ุจุงุณู… class-{{SLUG}}-*.php
- Autoload ุนุจุฑ spl_autoload_register ุฃูˆ Composer
- ูƒู„ hook ู…ูุณุฌู‘ู„ ุนุจุฑ $this->loader->add_action(...)
- ู„ุง ู…ู†ุทู‚ ุฃุนู…ุงู„ ููŠ ุงู„ู…ู„ู ุงู„ุฑุฆูŠุณูŠ โ€” ูู‚ุท bootstrap

[OUTPUT]
- ุดุฌุฑุฉ ู…ู„ูุงุช ุฃูˆู„ุงู‹
- ุซู… ูƒู„ ู…ู„ู ุจูƒูˆุฏ ูƒุงู…ู„
- ุซู… ุฃูˆุงู…ุฑ CLI: composer install / phpcs --standard=WordPress

๐Ÿ› ๏ธ ุงู„ุฌุฒุก ุงู„ุฑุงุจุน: ูƒูˆุฏ PHP ูˆุงู‚ุนูŠ (ู†ู…ูˆุฐุฌ ู…ุตุบู‘ุฑ ู„ู„ู…ุญุฑูƒ)

ู‡ุฐุง ู…ุซุงู„ ุญู‚ูŠู‚ูŠ ู„ู…ุญุฑูƒ ู…ุทุงู„ุจุงุช ู…ุจุณู‘ุท ุจู„ุบุฉ PHP ูŠู…ูƒู†ูƒ ุชุดุบูŠู„ู‡ ู…ุญู„ูŠุงู‹ ู„ุชูˆู„ูŠุฏ ุงู„ู…ุทุงู„ุจุงุช.

php

<?php
/**
 * Prompt Engine for WordPress Theme/Plugin Generation
 * Usage: php prompt-engine.php --type=plugin --name=MySEO --slug=my-seo
 */

declare(strict_types=1);

final class WP_Prompt_Engine {

    private array $vars;

    public function __construct(array $vars) {
        $defaults = [
            'PROJECT_NAME' => 'MyProject',
            'SLUG'         => 'my-project',
            'TEXT_DOMAIN'  => 'my-project',
            'NAMESPACE'    => 'MyProject',
            'PHP_VERSION'  => '8.2',
            'WP_VERSION'   => '6.5',
            'AUTHOR'       => 'Your Name',
            'LICENSE'      => 'GPL-2.0-or-later',
            'DESCRIPTION'  => '',
            'FEATURES'     => '- Default feature',
        ];
        $this->vars = array_merge($defaults, $vars);
    }

    public function render(string $template): string {
        return preg_replace_callback(
            '/\{\{([A-Z_]+)\}\}/',
            fn($m) => $this->vars[$m[1]] ?? $m[0],
            $template
        );
    }

    public function theme(): string {
        return $this->render(<<<'PROMPT'
[ROLE] ุฃู†ุช ู…ู‡ู†ุฏุณ WordPress ุฎุจูŠุฑ ู…ุชุฎุตุต ููŠ ุงู„ุซูŠู…ุงุช ูˆูู‚ WPCS.
[TASK] ุฃู†ุดุฆ ุซูŠู…ุงู‹ ุจุงุณู… "{{PROJECT_NAME}}" (slug: {{SLUG}}).
[CONTEXT] PHP {{PHP_VERSION}} | WP {{WP_VERSION}} | Text Domain: {{TEXT_DOMAIN}}
[DESCRIPTION] {{DESCRIPTION}}
[FEATURES]
{{FEATURES}}
[DELIVERABLES] style.css, functions.php, index.php, header.php, footer.php,
single.php, page.php, archive.php, 404.php, search.php, inc/setup.php,
inc/enqueue.php, inc/customizer.php, template-parts/, languages/{{SLUG}}.pot
[CONSTRAINTS] esc_* ู„ูƒู„ ุงู„ู…ุฎุฑุฌุงุช | nonces ู„ู„ู†ู…ุงุฐุฌ | i18n ุจู€ {{TEXT_DOMAIN}} | Child-theme friendly
PROMPT);
    }

    public function plugin(): string {
        return $this->render(<<<'PROMPT'
[ROLE] ู…ุทูˆู‘ุฑ WordPress Plugin ุฎุจูŠุฑ (OOP + PSR-4 + Plugin Handbook).
[TASK] ุฃู†ุดุฆ ุฅุถุงูุฉ "{{PROJECT_NAME}}" (slug: {{SLUG}}).
[CONTEXT] PHP {{PHP_VERSION}} | WP {{WP_VERSION}} | Namespace: {{NAMESPACE}}
[DESCRIPTION] {{DESCRIPTION}}
[FEATURES]
{{FEATURES}}
[ARCHITECTURE] Singleton + Loader + Activator/Deactivator + Admin/Public split
[DELIVERABLES] {{SLUG}}.php, includes/class-{{SLUG}}.php, class-{{SLUG}}-loader.php,
class-{{SLUG}}-i18n.php, class-{{SLUG}}-activator.php, class-{{SLUG}}-deactivator.php,
admin/class-{{SLUG}}-admin.php, public/class-{{SLUG}}-public.php, uninstall.php, readme.txt
[SECURITY] sanitize_* | esc_* | current_user_can | $wpdb->prepare | nonces
PROMPT);
    }

    public function boilerplate(): string {
        return $this->render(<<<'PROMPT'
[ROLE] ู…ูˆู„ู‘ุฏ Scaffolding ู„ู†ู…ุท WordPress Plugin Boilerplate (WPPB).
[TASK] ูˆู„ู‘ุฏ boilerplate ูƒุงู…ู„ุงู‹ ู„ู€ "{{PROJECT_NAME}}" (slug: {{SLUG}}).
[REPLACE] Plugin_Nameโ†’{{PROJECT_NAME}} | plugin-nameโ†’{{SLUG}} | plugin_nameโ†’{{SLUG}}
[GENERATE] {{SLUG}}.php, includes/class-{{SLUG}}.php, class-{{SLUG}}-loader.php,
class-{{SLUG}}-i18n.php, class-{{SLUG}}-activator.php, class-{{SLUG}}-deactivator.php,
admin/, public/, uninstall.php, composer.json (PSR-4), phpcs.xml
[OUTPUT] ุดุฌุฑุฉ ู…ู„ูุงุช + ูƒู„ ู…ู„ู ูƒุงู…ู„ + ุฃูˆุงู…ุฑ CLI
PROMPT);
    }
}

// ---- CLI Runner ----
$opts = getopt('', ['type:', 'name::', 'slug::', 'desc::']);
$engine = new WP_Prompt_Engine([
    'PROJECT_NAME' => $opts['name'] ?? 'MyProject',
    'SLUG'         => $opts['slug'] ?? 'my-project',
    'DESCRIPTION'  => $opts['desc'] ?? '',
]);

echo match ($opts['type'] ?? 'plugin') {
    'theme'       => $engine->theme(),
    'boilerplate' => $engine->boilerplate(),
    default       => $engine->plugin(),
};

ุงู„ุชุดุบูŠู„:

bash

php prompt-engine.php --type=plugin --name="SEO Booster" --slug="seo-booster"

โœ… ุงู„ุฌุฒุก ุงู„ุฎุงู…ุณ: ู‚ุงุฆู…ุฉ ุงู„ุชุญู‚ู‚ (Prompt Validator Checklist)

ุงู„ุจู†ุฏThemePluginBoilerplate
Header ูƒุงู…ู„ (Version, Requires, License)โœ…โœ…โœ…
esc_html / esc_attr / esc_urlโœ…โœ…โœ…
Nonces ุนู„ู‰ ูƒู„ ู†ู…ูˆุฐุฌโœ…โœ…โœ…
$wpdb->prepare ู„ู„ุงุณุชุนู„ุงู…ุงุชโ€”โœ…โœ…
current_user_can()โ€”โœ…โœ…
Text Domain + .potโœ…โœ…โœ…
uninstall.phpโ€”โœ…โœ…
readme.txt (WP.org)โœ…โœ…โœ…
PSR-4 AutoloadุงุฎุชูŠุงุฑูŠโœ…โœ…
phpcs.xml + WPCSโœ…โœ…โœ…

๐Ÿ’ก ุงู„ุฌุฒุก ุงู„ุณุงุฏุณ: ู†ุตุงุฆุญ ุงุณุชุฎุฏุงู… ุงู„ู…ุญุฑูƒ

  1. ุงู…ู„ุฃ ุงู„ู…ุชุบูŠุฑุงุช ุฃูˆู„ุงู‹ย ู‚ุจู„ ู„ุตู‚ ุงู„ู‚ุงู„ุจ ููŠ LLM.
  2. ู‚ุณู‘ู… ุงู„ุทู„ุจย โ€” ุงุทู„ุจ ู…ู„ูุงู‹ ุฃูˆ ุงุซู†ูŠู† ููŠ ูƒู„ ู…ุฑุฉ ู„ุชูุงุฏูŠ “ุงู„ู‡ู„ูˆุณุฉ”.
  3. ุฃุถู ุฏุงุฆู…ุงู‹: “ุงุชุจุน WordPress Coding Standards ุญุฑููŠุงู‹”.
  4. ุงุทู„ุจ ุงุฎุชุจุงุฑุงู‹: “ุฃุถู ุฃู…ุซู„ุฉ PHPUnit ู„ู„ู€ core class”.
  5. ุชุญู‚ู‚ ู†ู‡ุงุฆูŠุงู‹ย ุจุฃุฏูˆุงุช:ย phpcs --standard=WordPressย ูˆPlugin Check.

ู‡ู„ ุชุฑูŠุฏ ุฃู† ุฃููˆู„ู‘ุฏ ู„ูƒ ุงู„ุขู† ู…ุฎุฑุฌุงู‹ ูุนู„ูŠุงู‹ ุจุงุณุชุฎุฏุงู… ุฃุญุฏ ุงู„ู‚ูˆุงู„ุจ (ู…ุซู„ุงู‹ ุฅุถุงูุฉ SEO Booster ุฃูˆ ุซูŠู… ู…ุฏูˆู†ุฉ ูƒุงู…ู„)ุŸ ูู‚ุท ุฃุฎุจุฑู†ูŠ ุจู€ {{PROJECT_NAME}} ูˆ{{FEATURES}}.

ุฃูƒุชุจ prompt engine ู„ู„ุบุฉ ูˆุจุฑู…ุฌุฉ ุฅุทุงุฑ php WordPress Ai ูˆุชุญูˆูŠู„ ุฌู…ูŠุน ุงู„ุจูŠุงู†ุงุช ุงู„ุชุงู„ูŠุฉ ุงู„ู‰ ู…ุทุงู„ุจุงุช ุงุญุชุฑุงููŠู‡ ู…ูˆู„ุฏ ู‚ูˆุงู„ุจ ูˆุซูŠู…ุงุช ูˆุฅุถุงูุงุช ุจู„ุบุฉ php WordPress ู…ูˆู„ุฏ ู‚ูˆุงู„ุจ ูˆุซูŠู…ุงุช ูˆุฅุถุงูุงุช WordPress ุจู„ุบุฉ PHP ุณุฃู‚ุฏู… ู„ูƒ ุฏู„ูŠู„ุงู‹ ุดุงู…ู„ุงู‹ ู…ุน ุฃู…ุซู„ุฉ ุนู…ู„ูŠุฉ ู„ุจู†ุงุก ู‚ูˆุงู„ุจ (Themes) ูˆุฅุถุงูุงุช (Plugins) ููŠ WordPress WordPress plugin boilerplate generator Prompt Engine ุงุญุชุฑุงููŠ โ€” ู…ูˆู„ู‘ุฏ ู‚ูˆุงู„ุจ ูˆุซูŠู…ุงุช ูˆุฅุถุงูุงุช WordPress ุจู„ุบุฉ PHP ุงู„ุฌุฒุก ุงู„ุฃูˆู„: ุจู†ูŠุฉ ู…ุญุฑูƒ ุงู„ู…ุทุงู„ุจุงุช (Prompt Engine Architecture) ๐Ÿ“‹ ุงู„ุฌุฒุก ุงู„ุซุงู†ูŠ: ุชุญูˆูŠู„ ุจูŠุงู†ุงุชูƒ ุฅู„ู‰ ู…ุทุงู„ุจุงุช ุงุญุชุฑุงููŠุฉ ู…ุทุงู„ุจุงุช ุงุญุชุฑุงููŠุฉ ๐ŸŽฏ ุงู„ู…ุชุบูŠุฑุงุช ุงู„ุฃุณุงุณูŠุฉ (Global Variables) ุงู„ุฌุฒุก ุงู„ุซุงู„ุซ: ู‚ูˆุงู„ุจ ุงู„ู…ุทุงู„ุจุงุช ุงู„ุงุญุชุฑุงููŠุฉ (Prompt Templates) Templates) ๐Ÿ”ท T1 โ€” ู…ูˆู„ู‘ุฏ ุงู„ุซูŠู…ุงุช (Theme Generator) ู…ูˆู„ู‘ุฏ ุงู„ุฅุถุงูุงุช (Plugin Generator) ู…ูˆู„ู‘ุฏ Boilerplate (Plugin Boilerplate Generator) ุงู„ุฌุฒุก ุงู„ุณุงุฏุณ: ู†ุตุงุฆุญ ุงุณุชุฎุฏุงู… ุงู„ู…ุญุฑูƒ

๐Ÿš€ Prompt Engine ุงุญุชุฑุงููŠ ูƒุงู…ู„ โ€” ู…ูˆู„ู‘ุฏ ู‚ูˆุงู„ุจ ูˆุซูŠู…ุงุช ูˆุฅุถุงูุงุช WordPress ุจู„ุบุฉ PHP

ู…ู„ุงุญุธุฉ ุชูˆุถูŠุญูŠุฉ: ุงู„ู€ “Prompt Engine” ู‡ู†ุง ู‡ูˆ ู…ุญุฑูƒ ู…ุทุงู„ุจุงุช (Prompts) ู…ูˆุฌู‘ู‡ ู„ู†ู…ุงุฐุฌ ุงู„ุฐูƒุงุก ุงู„ุงุตุทู†ุงุนูŠ (ChatGPT / Claude / Gemini / Copilot) ู„ูŠูƒุชุจ ุจุฏูˆุฑู‡ ูƒูˆุฏ WordPress ุงุญุชุฑุงููŠ. ู„ุง ูŠูˆุฌุฏ ู…ุญุฑูƒ PHP ูŠุนู…ู„ ุฐุงุชูŠุงู‹ ุจุฏูˆู† ู†ู…ูˆุฐุฌ ู„ุบูˆูŠุŒ ู„ูƒู†ู†ูŠ ุณุฃู‚ุฏู‘ู… ู„ูƒ:

  1. ุจู†ูŠุฉ ุงู„ู…ุญุฑูƒย (Architecture)
  2. ู…ุชุบูŠุฑุงุช ุนุงู„ู…ูŠุฉ ู‚ุงุจู„ุฉ ู„ู„ุญู‚ู†
  3. ู‚ูˆุงู„ุจ ู…ุทุงู„ุจุงุช ุงุญุชุฑุงููŠุฉ (Templates)
  4. ูƒูˆุฏ PHP ูˆุงู‚ุนูŠย ู„ู…ุญุฑูƒ ูŠุจู†ูŠ ุงู„ู…ุทุงู„ุจุงุช ูˆูŠุทุจุนู‡ุง
  5. ู†ุตุงุฆุญ ุงู„ุงุณุชุฎุฏุงู… + Validator

๐Ÿ—๏ธ ุงู„ุฌุฒุก ุงู„ุฃูˆู„: ุจู†ูŠุฉ ู…ุญุฑูƒ ุงู„ู…ุทุงู„ุจุงุช (Prompt Engine Architecture)

text

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  โ‘  INPUT LAYER โ€” ุทุจู‚ุฉ ุงู„ู…ุฏุฎู„ุงุช                             โ”‚
โ”‚     โ€ข ู†ูˆุน ุงู„ู…ุฎุฑุฌ: theme | plugin | boilerplate            โ”‚
โ”‚     โ€ข ุงู„ุงุณู… / Slug / Text Domain / Namespace              โ”‚
โ”‚     โ€ข ุงู„ูˆุตู / ุงู„ู…ูŠุฒุงุช / ุงู„ู…ูƒุฏุณ ุงู„ุชู‚ู†ูŠ                     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ‘ก CONTEXT LAYER โ€” ุทุจู‚ุฉ ุงู„ุณูŠุงู‚ ุงู„ุชู‚ู†ูŠ                      โ”‚
โ”‚     โ€ข PHP 8.2+ | WP 6.5+ | WPCS | PSR-4 | GPL-2.0         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ‘ข TEMPLATE LAYER โ€” ู‚ูˆุงู„ุจ ุงู„ู…ุทุงู„ุจุงุช                        โ”‚
โ”‚     โ€ข T1: Theme Generator                                 โ”‚
โ”‚     โ€ข T2: Plugin Generator                                โ”‚
โ”‚     โ€ข T3: Plugin Boilerplate Generator                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ‘ฃ RENDER LAYER โ€” ุญู‚ู† ุงู„ู…ุชุบูŠุฑุงุช {{VAR}} ููŠ ุงู„ู‚ูˆุงู„ุจ         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ‘ค VALIDATION LAYER โ€” ู‚ุงุฆู…ุฉ ุชุญู‚ู‚ ุฃู…ู†ูŠุฉ ูˆWPCS              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“‹ ุงู„ุฌุฒุก ุงู„ุซุงู†ูŠ: ุชุญูˆูŠู„ ุจูŠุงู†ุงุชูƒ ุฅู„ู‰ ู…ุทุงู„ุจุงุช ุงุญุชุฑุงููŠุฉ

๐ŸŽฏ ุงู„ู…ุชุบูŠุฑุงุช ุงู„ุฃุณุงุณูŠุฉ (Global Variables)

ุงู„ู…ุชุบูŠุฑุงู„ุงูุชุฑุงุถูŠุงู„ูˆุตู
{{PROJECT_NAME}}MyProjectุงุณู… ุงู„ู…ุดุฑูˆุน (PascalCase)
{{SLUG}}my-projectslug (lowercase-hyphen)
{{TEXT_DOMAIN}}my-projectู†ุทุงู‚ ุงู„ุชุฑุฌู…ุฉ (ูŠูุณุงูˆูŠ slug ุนุงุฏุฉู‹)
{{NAMESPACE}}MyProjectNamespace PHP (PSR-4)
{{PHP_VERSION}}8.2ุฅุตุฏุงุฑ PHP ุงู„ู…ุณุชู‡ุฏู
{{WP_VERSION}}6.5ุฅุตุฏุงุฑ WordPress ุงู„ู…ุณุชู‡ุฏู
{{AUTHOR}}Your Nameุงุณู… ุงู„ู…ุคู„ู
{{LICENSE}}GPL-2.0-or-laterุงู„ุชุฑุฎูŠุต
{{DESCRIPTION}}โ€”ูˆุตู ุงู„ู…ุดุฑูˆุน
{{FEATURES}}โ€”ู‚ุงุฆู…ุฉ ุงู„ู…ูŠุฒุงุช (bullet points)

๐Ÿงพ ุจูŠุงู†ุงุชูƒ ุงู„ุฃุตู„ูŠุฉ โ†’ ู…ุทุงู„ุจุฉ ุงุญุชุฑุงููŠุฉ (ู…ุซุงู„ ุชุญูˆูŠู„)

ุจูŠุงู†ุงุชูƒ ุงู„ุฎุงู…ุงู„ู…ุทุงู„ุจุฉ ุงู„ู…ูุนุงุฏ ุตูŠุงุบุชู‡ุง
“ู…ูˆู„ุฏ ู‚ูˆุงู„ุจ ูˆุซูŠู…ุงุช ูˆุฅุถุงูุงุช WordPress ุจู„ุบุฉ PHP”“ุฃู†ุช ู…ู‡ู†ุฏุณ WordPress ุฎุจูŠุฑ (10+ ุณู†ูˆุงุช) ู…ุชุฎุตุต ููŠ ุจู†ุงุก ุงู„ุซูŠู…ุงุช ูˆุงู„ุฅุถุงูุงุช ูˆูู‚ WPCS ูˆTheme/Plugin Review Guidelines. ู…ู‡ู…ุชูƒ ุฅู†ุดุงุก [Theme/Plugin/Boilerplate] ุจุงุณู… {{PROJECT_NAME}} (slug: {{SLUG}}) ุจู„ุบุฉ PHP {{PHP_VERSION}} ูˆWP {{WP_VERSION}} โ€ฆ”
“ุฏู„ูŠู„ ุดุงู…ู„ ู…ุน ุฃู…ุซู„ุฉ ุนู…ู„ูŠุฉ ู„ุจู†ุงุก ู‚ูˆุงู„ุจ ูˆุฅุถุงูุงุช”“ุฃุฎุฑุฌ ูƒูˆุฏุงู‹ ูƒุงู…ู„ุงู‹ ู‚ุงุจู„ุงู‹ ู„ู„ู†ุณุฎ ู„ูƒู„ ู…ู„ูุŒ ู…ุน ุชุนู„ูŠู‚ุงุช PHPDoc ูˆุดุฑุญ ู…ุฎุชุตุฑ ู‚ุจู„ ูƒู„ ู…ู„ูุŒ ุซู… ุฌุฏูˆู„ Hooks.”
“WordPress plugin boilerplate generator”“ูˆู„ู‘ุฏ ู‡ูŠูƒู„ WPPB ูƒุงู…ู„ุงู‹ ุจุงุณุชุจุฏุงู„ placeholders (Plugin_Name, plugin-name, plugin_name) ูˆุจู†ูŠุฉ includes/, admin/, public/, uninstall.php, composer.json (PSR-4).”

๐Ÿงฉ ุงู„ุฌุฒุก ุงู„ุซุงู„ุซ: ู‚ูˆุงู„ุจ ุงู„ู…ุทุงู„ุจุงุช ุงู„ุงุญุชุฑุงููŠุฉ (Prompt Templates)

๐Ÿ”ท T1 โ€” ู…ูˆู„ู‘ุฏ ุงู„ุซูŠู…ุงุช (Theme Generator)

text

[ROLE]
ุฃู†ุช ู…ู‡ู†ุฏุณ WordPress ุฎุจูŠุฑ (10+ ุณู†ูˆุงุช) ู…ุชุฎุตุต ููŠ ุงู„ุซูŠู…ุงุช ูˆูู‚
WordPress Coding Standards (WPCS) ูˆTheme Review Guidelines.

[CONTEXT]
- PHP {{PHP_VERSION}} | WordPress {{WP_VERSION}}
- Text Domain: {{TEXT_DOMAIN}} | Namespace: {{NAMESPACE}}
- License: {{LICENSE}} | Author: {{AUTHOR}}

[TASK]
ุฃู†ุดุฆ ุซูŠู…ุงู‹ ูƒุงู…ู„ุงู‹ ุจุงุณู… "{{PROJECT_NAME}}" (slug: {{SLUG}}) ูŠู‚ุฏู‘ู…:
{{DESCRIPTION}}

[FEATURES]
{{FEATURES}}

[DELIVERABLES]
style.css (ุฑุฃุณ ูƒุงู…ู„) โ€” functions.php โ€” index.php โ€” front-page.php โ€” single.php
page.php โ€” archive.php โ€” header.php โ€” footer.php โ€” sidebar.php โ€” 404.php
search.php โ€” inc/setup.php โ€” inc/enqueue.php โ€” inc/template-tags.php
inc/customizer.php โ€” template-parts/ โ€” languages/{{SLUG}}.pot โ€” README.md

[CONSTRAINTS]
โœ… esc_html / esc_attr / esc_url / wp_kses_post
โœ… wp_nonce_field / check_admin_referer
โœ… __() / _e() / esc_html__() ู…ุน {{TEXT_DOMAIN}}
โœ… register_nav_menus / add_theme_support / body_class / wp_head / wp_footer
โœ… Child-theme friendly (get_template_directory_uri / get_stylesheet_uri)
โŒ ู„ุง extract() ูˆู„ุง eval() ูˆู„ุง ูƒูˆุฏ inline โ€” ุงุณุชุฎุฏู… enqueue

[OUTPUT FORMAT]
ูƒูˆุฏ ูƒุงู…ู„ ู„ูƒู„ ู…ู„ู + ุนู†ูˆุงู† ุงู„ู…ู„ู + ุดุฑุญ ุณุทุฑูŠู† ู‚ุจู„ ูƒู„ ู…ู„ู
+ Checklist ู…ุทุงุจู‚ุฉ Theme Review ููŠ ุงู„ู†ู‡ุงูŠุฉ.

๐Ÿ”ท T2 โ€” ู…ูˆู„ู‘ุฏ ุงู„ุฅุถุงูุงุช (Plugin Generator)

text

[ROLE]
ุฃู†ุช ู…ุทูˆู‘ุฑ WordPress Plugin ุฎุจูŠุฑ (OOP + PSR-4 + Plugin Handbook
+ Plugin Review Guidelines).

[CONTEXT]
PHP {{PHP_VERSION}} | WP {{WP_VERSION}} | Slug: {{SLUG}}
Namespace: {{NAMESPACE}} | Text Domain: {{TEXT_DOMAIN}} | License: {{LICENSE}}

[TASK]
ุฃู†ุดุฆ ุฅุถุงูุฉ ุงุญุชุฑุงููŠุฉ "{{PROJECT_NAME}}" ุชูู†ูู‘ุฐ:
{{DESCRIPTION}}

[FEATURES]
{{FEATURES}}

[ARCHITECTURE]
{{SLUG}}/
โ”œโ”€โ”€ {{SLUG}}.php                (main + header)
โ”œโ”€โ”€ uninstall.php
โ”œโ”€โ”€ includes/class-plugin.php   (Singleton)
โ”œโ”€โ”€ includes/class-activator.php
โ”œโ”€โ”€ includes/class-deactivator.php
โ”œโ”€โ”€ includes/class-loader.php
โ”œโ”€โ”€ includes/class-i18n.php
โ”œโ”€โ”€ admin/class-admin.php + views/settings-page.php + css/js
โ”œโ”€โ”€ public/class-public.php + css/js
โ””โ”€โ”€ languages/

[DELIVERABLES]
1) ุฑุฃุณ Plugin ูƒุงู…ู„ (Version, Requires PHP, Requires at least, License, Text Domain, Domain Path)
2) class-plugin.php (Singleton + register_hooks)
3) Activator / Deactivator ุจุฏูˆู† side-effects
4) Loader ู„ุฅุฏุงุฑุฉ actions/filters
5) Settings API + nonces + sanitize
6) AJAX + REST endpoints ู…ุญู…ูŠุฉ
7) uninstall.php (ุงุญุชุฑุงู… ุฎูŠุงุฑ "ุญุฐู ุงู„ุจูŠุงู†ุงุช")
8) readme.txt (WordPress.org) + CHANGELOG.md

[SECURITY]
sanitize_text_field / absint / wp_kses_post โ€” esc_* โ€” current_user_can
wp_nonce_field / check_ajax_referer โ€” $wpdb->prepare โ€” ู„ุง unfiltered_html

[OUTPUT]
ูƒูˆุฏ ูƒุงู…ู„ + PHPDoc + ุฌุฏูˆู„: Hook | Callback | Priority | Purpose

๐Ÿ”ท T3 โ€” ู…ูˆู„ู‘ุฏ Boilerplate (Plugin Boilerplate Generator)

text

[ROLE]
ู…ูˆู„ู‘ุฏ Scaffolding ู…ุชุฎุตุต ููŠ WordPress Plugin Boilerplate (WPPB)
โ€” ู…ุฎุฑุฌุงุชูƒ ุชูู†ุณุฎ ูˆุชุนู…ู„ ุฏูˆู† ุชุนุฏูŠู„.

[INPUT]
Plugin Name : {{PROJECT_NAME}}
Slug        : {{SLUG}}
Namespace   : {{NAMESPACE}}
Author      : {{AUTHOR}}
Description : {{DESCRIPTION}}
Features    : {{FEATURES}}
PHP / WP    : {{PHP_VERSION}} / {{WP_VERSION}}

[TASK]
ูˆู„ู‘ุฏ boilerplate ูƒุงู…ู„ุงู‹ ู…ุน ุงุณุชุจุฏุงู„:
Plugin_Name โ†’ {{PROJECT_NAME}}
plugin-name โ†’ {{SLUG}}
Plugin_Name_Loader โ†’ {{NAMESPACE}}_Loader
PLUGIN_NAME โ†’ {{SLUG}} (UPPER)
plugin_name โ†’ {{SLUG}} (snake)

[GENERATE]
{{SLUG}}.php โ€” includes/class-{{SLUG}}.php โ€” class-{{SLUG}}-loader.php
class-{{SLUG}}-i18n.php โ€” class-{{SLUG}}-activator.php โ€” class-{{SLUG}}-deactivator.php
admin/class-{{SLUG}}-admin.php โ€” admin/partials/{{SLUG}}-admin-display.php
public/class-{{SLUG}}-public.php โ€” public/partials/{{SLUG}}-public-display.php
uninstall.php โ€” composer.json (PSR-4) โ€” .gitignore โ€” .editorconfig โ€” phpcs.xml

[RULES]
ูƒู„ class ููŠ ู…ู„ู ู…ู†ูุตู„ ุจุงุณู… class-{{SLUG}}-*.php
Autoload ุนุจุฑ spl_autoload_register ุฃูˆ Composer
ูƒู„ hook ุนุจุฑ $this->loader->add_action(...)
ู„ุง ู…ู†ุทู‚ ุฃุนู…ุงู„ ููŠ ุงู„ู…ู„ู ุงู„ุฑุฆูŠุณูŠ โ€” bootstrap ูู‚ุท

[OUTPUT]
ุดุฌุฑุฉ ู…ู„ูุงุช โ†’ ูƒู„ ู…ู„ู ูƒุงู…ู„ โ†’ ุฃูˆุงู…ุฑ:
composer install && vendor/bin/phpcs --standard=WordPress

๐Ÿ› ๏ธ ุงู„ุฌุฒุก ุงู„ุฑุงุจุน: ูƒูˆุฏ PHP ูˆุงู‚ุนูŠ ู„ู„ู…ุญุฑูƒ (Renderer)

php

<?php
/**
 * WP Prompt Engine โ€” ูŠูˆู„ู‘ุฏ ู…ุทุงู„ุจุงุช ุงุญุชุฑุงููŠุฉ ู„ุชูˆู„ูŠุฏ ูƒูˆุฏ WordPress.
 * Usage:
 *   php prompt-engine.php --type=plugin --name="SEO Booster" --slug="seo-booster"
 */

declare(strict_types=1);

final class WP_Prompt_Engine {

    /** @var array<string,string> */
    private array $vars;

    public function __construct(array $vars = []) {
        $this->vars = array_merge([
            'PROJECT_NAME' => 'MyProject',
            'SLUG'         => 'my-project',
            'TEXT_DOMAIN'  => 'my-project',
            'NAMESPACE'    => 'MyProject',
            'PHP_VERSION'  => '8.2',
            'WP_VERSION'   => '6.5',
            'AUTHOR'       => 'Your Name',
            'LICENSE'      => 'GPL-2.0-or-later',
            'DESCRIPTION'  => 'Project description here.',
            'FEATURES'     => "- Feature one\n- Feature two",
        ], $vars);
    }

    public function render(string $tpl): string {
        return (string) preg_replace_callback(
            '/\{\{([A-Z_]+)\}\}/',
            fn(array $m): string => $this->vars[$m[1]] ?? $m[0],
            $tpl
        );
    }

    public function theme(): string {
        return $this->render(<<<'PROMPT'
[ROLE] ุฃู†ุช ู…ู‡ู†ุฏุณ WordPress ุฎุจูŠุฑ (10+ ุณู†ูˆุงุช) ููŠ ุงู„ุซูŠู…ุงุช ูˆูู‚ WPCS ูˆTheme Review.
[CONTEXT] PHP {{PHP_VERSION}} | WP {{WP_VERSION}} | Text Domain: {{TEXT_DOMAIN}} | NS: {{NAMESPACE}} | License: {{LICENSE}} | Author: {{AUTHOR}}
[TASK] ุฃู†ุดุฆ ุซูŠู…ุงู‹ ูƒุงู…ู„ุงู‹ "{{PROJECT_NAME}}" (slug: {{SLUG}}) ูŠู‚ุฏู‘ู…: {{DESCRIPTION}}
[FEATURES]
{{FEATURES}}
[DELIVERABLES] style.css, functions.php, index.php, front-page.php, single.php, page.php,
archive.php, header.php, footer.php, sidebar.php, 404.php, search.php,
inc/setup.php, inc/enqueue.php, inc/template-tags.php, inc/customizer.php,
template-parts/, languages/{{SLUG}}.pot, README.md
[CONSTRAINTS] esc_* ู„ูƒู„ ู…ุฎุฑุฌ | nonces ู„ู„ู†ู…ุงุฐุฌ | i18n ุจู€ {{TEXT_DOMAIN}} | Child-theme friendly
[OUTPUT] ูƒูˆุฏ ูƒุงู…ู„ ู„ูƒู„ ู…ู„ู + Checklist Theme Review.
PROMPT);
    }

    public function plugin(): string {
        return $this->render(<<<'PROMPT'
[ROLE] ู…ุทูˆู‘ุฑ WordPress Plugin ุฎุจูŠุฑ (OOP + PSR-4 + Plugin Handbook).
[CONTEXT] PHP {{PHP_VERSION}} | WP {{WP_VERSION}} | Slug: {{SLUG}} | NS: {{NAMESPACE}} | TD: {{TEXT_DOMAIN}} | License: {{LICENSE}}
[TASK] ุฃู†ุดุฆ ุฅุถุงูุฉ "{{PROJECT_NAME}}" ุชูู†ูู‘ุฐ: {{DESCRIPTION}}
[FEATURES]
{{FEATURES}}
[ARCHITECTURE] Singleton + Loader + Activator/Deactivator + Admin/Public split
[DELIVERABLES] {{SLUG}}.php, includes/class-{{SLUG}}.php, class-{{SLUG}}-loader.php,
class-{{SLUG}}-i18n.php, class-{{SLUG}}-activator.php, class-{{SLUG}}-deactivator.php,
admin/class-{{SLUG}}-admin.php, admin/views/settings-page.php,
public/class-{{SLUG}}-public.php, uninstall.php, readme.txt, CHANGELOG.md
[SECURITY] sanitize_* | esc_* | current_user_can | nonces | $wpdb->prepare
[OUTPUT] ูƒูˆุฏ ูƒุงู…ู„ + PHPDoc + ุฌุฏูˆู„: Hook | Callback | Priority | Purpose.
PROMPT);
    }

    public function boilerplate(): string {
        return $this->render(<<<'PROMPT'
[ROLE] ู…ูˆู„ู‘ุฏ Scaffolding ู„ู†ู…ุท WordPress Plugin Boilerplate (WPPB).
[TASK] ูˆู„ู‘ุฏ boilerplate ูƒุงู…ู„ุงู‹ ู„ู€ "{{PROJECT_NAME}}" (slug: {{SLUG}}).
[REPLACE] Plugin_Nameโ†’{{PROJECT_NAME}} | plugin-nameโ†’{{SLUG}} | plugin_nameโ†’{{SLUG}} | Plugin_Name_Loaderโ†’{{NAMESPACE}}_Loader
[GENERATE] {{SLUG}}.php, includes/class-{{SLUG}}.php, class-{{SLUG}}-loader.php,
class-{{SLUG}}-i18n.php, class-{{SLUG}}-activator.php, class-{{SLUG}}-deactivator.php,
admin/, public/, uninstall.php, composer.json (PSR-4), .gitignore, phpcs.xml
[RULES] ูƒู„ class ููŠ ู…ู„ู ู…ู†ูุตู„ | Autoload PSR-4 | ู„ุง ู…ู†ุทู‚ ููŠ ุงู„ู…ู„ู ุงู„ุฑุฆูŠุณูŠ
[OUTPUT] ุดุฌุฑุฉ ู…ู„ูุงุช + ูƒู„ ู…ู„ู ูƒุงู…ู„ + ุฃูˆุงู…ุฑ CLI.
PROMPT);
    }
}

// ---- CLI Runner ----
$opts = getopt('', ['type:', 'name::', 'slug::', 'desc::', 'features::']);

if (PHP_SAPI !== 'cli') {
    http_response_code(403);
    exit('CLI only');
}

$engine = new WP_Prompt_Engine([
    'PROJECT_NAME' => $opts['name']     ?? 'MyProject',
    'SLUG'         => $opts['slug']     ?? 'my-project',
    'TEXT_DOMAIN'  => $opts['slug']     ?? 'my-project',
    'NAMESPACE'    => $opts['name']     ? preg_replace('/\W/', '', $opts['name']) : 'MyProject',
    'DESCRIPTION'  => $opts['desc']     ?? 'Project description here.',
    'FEATURES'     => $opts['features'] ?? "- Feature one\n- Feature two",
]);

echo match ($opts['type'] ?? 'plugin') {
    'theme'       => $engine->theme(),
    'boilerplate' => $engine->boilerplate(),
    default       => $engine->plugin(),
};
echo PHP_EOL;

ุฃูˆุงู…ุฑ ุงู„ุชุดุบูŠู„:

bash

# ู…ุทุงู„ุจุฉ ุฅุถุงูุฉ
php prompt-engine.php --type=plugin --name="SEO Booster" --slug="seo-booster" \
  --desc="ุฅุถุงูุฉ ุชุญุณูŠู† SEO ุฎููŠูุฉ" --features="- Meta tags\n- Sitemap\n- Schema JSON-LD"

# ู…ุทุงู„ุจุฉ ุซูŠู…
php prompt-engine.php --type=theme --name="Aurora" --slug="aurora"

# ู…ุทุงู„ุจุฉ boilerplate
php prompt-engine.php --type=boilerplate --name="Booking Core" --slug="booking-core"

๐Ÿ“Œ ุงู†ุณุฎ ุงู„ุฎุฑุฌ ูˆุงู„ุตู‚ู‡ ููŠ ChatGPT/Claude/Gemini ู„ุชุญุตู„ ุนู„ู‰ ูƒูˆุฏ WordPress ูƒุงู…ู„.


โœ… ุงู„ุฌุฒุก ุงู„ุฎุงู…ุณ: Validator โ€” ู‚ุงุฆู…ุฉ ุงู„ุชุญู‚ู‚ ุงู„ู†ู‡ุงุฆูŠุฉ

ุงู„ุจู†ุฏThemePluginBoilerplate
Header ูƒุงู…ู„ (Version, Requires, License)โœ…โœ…โœ…
esc_html / esc_attr / esc_url / wp_kses_postโœ…โœ…โœ…
Nonces ุนู„ู‰ ูƒู„ ู†ู…ูˆุฐุฌโœ…โœ…โœ…
current_user_can()โ€”โœ…โœ…
$wpdb->prepare() ู„ู„ุงุณุชุนู„ุงู…ุงุชโ€”โœ…โœ…
Text Domain + .potโœ…โœ…โœ…
uninstall.php ุขู…ู†โ€”โœ…โœ…
readme.txt (WP.org)โœ…โœ…โœ…
PSR-4 AutoloadุงุฎุชูŠุงุฑูŠโœ…โœ…
phpcs.xml + WPCSโœ…โœ…โœ…
AJAX/REST ู…ุญู…ูŠุฉโ€”โœ…โœ…
Child-theme friendlyโœ…โ€”โ€”

๐Ÿ’ก ุงู„ุฌุฒุก ุงู„ุณุงุฏุณ: ู†ุตุงุฆุญ ุงุณุชุฎุฏุงู… ุงู„ู…ุญุฑูƒ

  1. ุงู…ู„ุฃ ุงู„ู…ุชุบูŠุฑุงุช ุฃูˆู„ุงู‹ย (--name,ย --slug,ย --features) ู‚ุจู„ ุฃูŠ ุดูŠุก.
  2. ู‚ุณู‘ู… ุงู„ุทู„ุจ ุนู„ู‰ ู…ุฑุงุญู„ย โ€” ุงุทู„ุจ ู…ู„ูุงู‹ ุฃูˆ ุงุซู†ูŠู† ู„ูƒู„ ุฑุณุงู„ุฉ ู„ุชูุงุฏูŠ “ุงู„ู‡ู„ูˆุณุฉ” (Hallucination).
  3. ุฃุถู ุฏุงุฆู…ุงู‹: “ุงุชุจุน WordPress Coding Standards ุญุฑููŠุงู‹ ูˆุงุฐูƒุฑ ุงู„ู‚ูŠูˆุฏ ุงู„ุฃู…ู†ูŠุฉ ููŠ ูƒู„ ู…ู„ู”.
  4. ุงุทู„ุจ ุงู„ุงุฎุชุจุงุฑ: “ุฃุถู ุฃู…ุซู„ุฉ PHPUnit ู„ู„ู€ core class ูˆrest controller”.
  5. ุชุญู‚ู‘ู‚ ู†ู‡ุงุฆูŠุงู‹ย ุจุฃุฏูˆุงุช:
    • vendor/bin/phpcs --standard=WordPress
    • wp plugin check <slug>ย (Plugin Check)
    • wp theme check <slug>ย (Theme Check)
  6. ุงุญูุธ ุงู„ู…ุฎุฑุฌุงุช ููŠ Gitย ู…ุนย CHANGELOG.mdย ู„ุชู†ุธูŠู… ุงู„ุฅุตุฏุงุฑุงุช.
  7. ู„ุง ุชู†ุณูŽ ุงู„ุชุฑุฌู…ุฉ: ุจุนุฏ ุงู„ุชูˆู„ูŠุฏ ุดุบู‘ู„ย wp i18n make-pot . languages/<slug>.pot.

๐ŸŽ ู…ุฎุฑุฌ ุฌุงู‡ุฒ ู„ู„ู†ุณุฎ (Prompt ู…ุถุบูˆุท ูƒุงู…ู„)

ุฅุฐุง ุฃุฑุฏุช ู„ุตู‚ ู…ุทุงู„ุจุฉ ูˆุงุญุฏุฉ ุณุฑูŠุนุฉ ููŠ ุฃูŠ LLM:

text

ุฃู†ุช ู…ู‡ู†ุฏุณ WordPress ุฎุจูŠุฑ (10+ ุณู†ูˆุงุช) ููŠ WPCS ูˆTheme/Plugin Review.
PHP 8.2 | WP 6.5 | Text Domain: my-project | Namespace: MyProject | GPL-2.0.

ุงู„ู…ู‡ู…ุฉ: ุฃู†ุดุฆ [ุฅุถุงูุฉ/ุซูŠู…/boilerplate] ุจุงุณู… "MyProject" (slug: my-project) ูŠู‚ุฏู‘ู…:
- [ุงู„ู…ูŠุฒุฉ 1]
- [ุงู„ู…ูŠุฒุฉ 2]

ุงู„ุฃุตูˆู„: ูƒูˆุฏ ูƒุงู…ู„ ู„ูƒู„ ู…ู„ู + PHPDoc + ุฌุฏูˆู„ Hooks.
ุงู„ุฃู…ุงู†: esc_* / sanitize_* / nonces / current_user_can / $wpdb->prepare.
ุงู„ุจู†ูŠุฉ: Singleton + Loader + Activator/Deactivator (ุฅู† ุฅุถุงูุฉ).
ุงู„ู…ุฎุฑุฌุงุช: ุดุฌุฑุฉ ู…ู„ูุงุช + ูƒูˆุฏ ูƒู„ ู…ู„ู + Checklist ู†ู‡ุงุฆูŠ.

ู‡ู„ ุชุฑูŠุฏ ุฃู† ุฃูุดุบู‘ู„ ุงู„ู…ุญุฑูƒ ุงู„ุขู† ุนู„ู‰ ู…ุดุฑูˆุน ู…ุญุฏุฏุŸ ุฃุนุทู†ูŠ:

  • ุงู„ู†ูˆุน:ย themeย /ย pluginย /ย boilerplate
  • ุงู„ุงุณู… + Slug
  • ุงู„ู…ูŠุฒุงุช (3โ€“6 ู†ู‚ุงุท)

ูˆุณุฃูˆู„ู‘ุฏ ู„ูƒ ุงู„ู…ุทุงู„ุจุฉ ุงู„ู†ู‡ุงุฆูŠุฉ + ุงู„ูƒูˆุฏ ุงู„ูƒุงู…ู„ ุจุงู„ุนุฑุจูŠุฉ ูˆุงู„ุฅู†ุฌู„ูŠุฒูŠุฉ ุฌุงู‡ุฒุงู‹ ู„ู„ู†ุณุฎ. ๐Ÿš€

ู…ูˆู„ุฏ ู‚ูˆุงู„ุจ ูˆุซูŠู…ุงุช ูˆุฅุถุงูุงุช WordPress ุจู„ุบุฉ PHP

ุณุฃู‚ุฏู… ู„ูƒ ุฏู„ูŠู„ุงู‹ ุดุงู…ู„ุงู‹ ู…ุน ุฃู…ุซู„ุฉ ุนู…ู„ูŠุฉ ู„ุจู†ุงุก ู‚ูˆุงู„ุจ (Themes) ูˆุฅุถุงูุงุช (Plugins) ููŠ WordPress.


1. ู‡ูŠูƒู„ ู‚ุงู„ุจ WordPress ุฃุณุงุณูŠ

text

my-theme/
โ”œโ”€โ”€ style.css          (ู…ุทู„ูˆุจ - ู…ุนู„ูˆู…ุงุช ุงู„ู‚ุงู„ุจ)
โ”œโ”€โ”€ index.php          (ู…ุทู„ูˆุจ - ุงู„ู…ู„ู ุงู„ุฃุณุงุณูŠ)
โ”œโ”€โ”€ functions.php      (ูˆุธุงุฆู ุงู„ู‚ุงู„ุจ)
โ”œโ”€โ”€ header.php
โ”œโ”€โ”€ footer.php
โ”œโ”€โ”€ sidebar.php
โ”œโ”€โ”€ single.php
โ”œโ”€โ”€ page.php
โ”œโ”€โ”€ archive.php
โ”œโ”€โ”€ 404.php
โ””โ”€โ”€ assets/
    โ”œโ”€โ”€ css/
    โ”œโ”€โ”€ js/
    โ””โ”€โ”€ images/

style.css (ุฑุฃุณ ุงู„ู‚ุงู„ุจ)

css

/*
Theme Name: My Custom Theme
Theme URI: https://example.com
Author: Your Name
Author URI: https://example.com
Description: ู‚ุงู„ุจ ู…ุฎุตุต ุงุญุชุฑุงููŠ
Version: 1.0.0
License: GPL v2 or later
Text Domain: my-theme
*/

functions.php

php

<?php
// ุชุณุฌูŠู„ ุงู„ู‚ูˆุงุฆู…
function mytheme_setup() {
    add_theme_support('title-tag');
    add_theme_support('post-thumbnails');
    add_theme_support('custom-logo');
    add_theme_support('html5', ['search-form', 'comment-form']);

    register_nav_menus([
        'primary' => __('ุงู„ู‚ุงุฆู…ุฉ ุงู„ุฑุฆูŠุณูŠุฉ', 'my-theme'),
        'footer'  => __('ู‚ุงุฆู…ุฉ ุงู„ุชุฐูŠูŠู„', 'my-theme'),
    ]);
}
add_action('after_setup_theme', 'mytheme_setup');

// ุชุญู…ูŠู„ ุงู„ู…ู„ูุงุช
function mytheme_assets() {
    wp_enqueue_style('mytheme-style', get_stylesheet_uri(), [], '1.0.0');
    wp_enqueue_style('mytheme-main', get_template_directory_uri() . '/assets/css/main.css', [], '1.0.0');
    wp_enqueue_script('mytheme-main', get_template_directory_uri() . '/assets/js/main.js', ['jquery'], '1.0.0', true);
}
add_action('wp_enqueue_scripts', 'mytheme_assets');

// ุชุณุฌูŠู„ ู…ู†ุทู‚ุฉ ุงู„ูˆุฏุฌุงุช
function mytheme_widgets() {
    register_sidebar([
        'name'          => __('ุงู„ุดุฑูŠุท ุงู„ุฌุงู†ุจูŠ', 'my-theme'),
        'id'            => 'sidebar-1',
        'before_widget' => '<div class="widget">',
        'after_widget'  => '</div>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ]);
}
add_action('widgets_init', 'mytheme_widgets');

index.php

php

<?php get_header(); ?>

<main class="site-main">
    <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
            <article <?php post_class(); ?>>
                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                <div class="entry-meta">
                    <?php echo get_the_date(); ?> | <?php the_author(); ?>
                </div>
                <div class="entry-content">
                    <?php the_excerpt(); ?>
                </div>
            </article>
        <?php endwhile; ?>
        <?php the_posts_pagination(); ?>
    <?php else : ?>
        <p><?php _e('ู„ุง ุชูˆุฌุฏ ู…ู‚ุงู„ุงุช.', 'my-theme'); ?></p>
    <?php endif; ?>
</main>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

2. ู‡ูŠูƒู„ ุฅุถุงูุฉ WordPress ุฃุณุงุณูŠุฉ

text

my-plugin/
โ”œโ”€โ”€ my-plugin.php      (ุงู„ู…ู„ู ุงู„ุฑุฆูŠุณูŠ)
โ”œโ”€โ”€ includes/
โ”‚   โ”œโ”€โ”€ class-my-plugin.php
โ”‚   โ””โ”€โ”€ helpers.php
โ”œโ”€โ”€ admin/
โ”‚   โ””โ”€โ”€ settings.php
โ”œโ”€โ”€ assets/
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ””โ”€โ”€ js/
โ””โ”€โ”€ readme.txt

my-plugin.php (ุงู„ู…ู„ู ุงู„ุฑุฆูŠุณูŠ)

php

<?php
/**
 * Plugin Name: My Custom Plugin
 * Plugin URI:  https://example.com
 * Description: ุฅุถุงูุฉ ู…ุฎุตุตุฉ ุงุญุชุฑุงููŠุฉ
 * Version:     1.0.0
 * Author:      Your Name
 * License:     GPL-2.0+
 * Text Domain: my-plugin
 */

if (!defined('ABSPATH')) exit;

define('MY_PLUGIN_VERSION', '1.0.0');
define('MY_PLUGIN_PATH', plugin_dir_path(__FILE__));
define('MY_PLUGIN_URL', plugin_dir_url(__FILE__));

// ุงู„ุชู†ุดูŠุท
register_activation_hook(__FILE__, 'my_plugin_activate');
function my_plugin_activate() {
    // ุฅู†ุดุงุก ุฌุฏูˆู„ ุฃูˆ ุฎูŠุงุฑุงุช ุนู†ุฏ ุงู„ุชู†ุดูŠุท
    add_option('my_plugin_settings', []);
}

// ุฅู„ุบุงุก ุงู„ุชู†ุดูŠุท
register_deactivation_hook(__FILE__, 'my_plugin_deactivate');
function my_plugin_deactivate() {
    // ุชู†ุธูŠู
}

// ุชุญู…ูŠู„ ุงู„ูƒู„ุงุณุงุช
require_once MY_PLUGIN_PATH . 'includes/class-my-plugin.php';
require_once MY_PLUGIN_PATH . 'admin/settings.php';

// ุชู‡ูŠุฆุฉ ุงู„ุฅุถุงูุฉ
add_action('plugins_loaded', function() {
    new My_Plugin();
});

includes/class-my-plugin.php

php

<?php
if (!defined('ABSPATH')) exit;

class My_Plugin {
    public function __construct() {
        add_action('init', [$this, 'register_shortcode']);
        add_action('wp_enqueue_scripts', [$this, 'enqueue_assets']);
    }

    public function register_shortcode() {
        add_shortcode('my_greeting', [$this, 'render_greeting']);
    }

    public function render_greeting($atts) {
        $atts = shortcode_atts(['name' => 'ุนุงู„ู…'], $atts, 'my_greeting');
        return '<div class="my-greeting">ู…ุฑุญุจุงู‹ ูŠุง ' . esc_html($atts['name']) . '!</div>';
    }

    public function enqueue_assets() {
        wp_enqueue_style('my-plugin-style', MY_PLUGIN_URL . 'assets/css/style.css', [], MY_PLUGIN_VERSION);
        wp_enqueue_script('my-plugin-script', MY_PLUGIN_URL . 'assets/js/script.js', ['jquery'], MY_PLUGIN_VERSION, true);
    }
}

admin/settings.php

php

<?php
if (!defined('ABSPATH')) exit;

// ุฅุถุงูุฉ ุตูุญุฉ ุฅุนุฏุงุฏุงุช
add_action('admin_menu', function() {
    add_options_page(
        __('ุฅุนุฏุงุฏุงุช ุฅุถุงูุชูŠ', 'my-plugin'),
        'My Plugin',
        'manage_options',
        'my-plugin',
        'my_plugin_settings_page'
    );
});

function my_plugin_settings_page() {
    if (isset($_POST['my_plugin_nonce']) && wp_verify_nonce($_POST['my_plugin_nonce'], 'my_plugin_save')) {
        update_option('my_plugin_text', sanitize_text_field($_POST['my_plugin_text']));
        echo '<div class="notice notice-success"><p>ุชู… ุงู„ุญูุธ!</p></div>';
    }
    $value = get_option('my_plugin_text', '');
    ?>
    <div class="wrap">
        <h1>ุฅุนุฏุงุฏุงุช ุงู„ุฅุถุงูุฉ</h1>
        <form method="post">
            <?php wp_nonce_field('my_plugin_save', 'my_plugin_nonce'); ?>
            <table class="form-table">
                <tr>
                    <th><label for="my_plugin_text">ุงู„ู†ุต</label></th>
                    <td><input type="text" id="my_plugin_text" name="my_plugin_text"
                        value="<?php echo esc_attr($value); ?>" class="regular-text"></td>
                </tr>
            </table>
            <?php submit_button(); ?>
        </form>
    </div>
    <?php
}

3. ุฃู†ูˆุงุน ุงู„ู…ุญุชูˆู‰ ุงู„ู…ุฎุตุต (CPT) ูˆุงู„ุชุงูƒุณูˆู†ูˆู…ูŠ

php

add_action('init', function() {
    // Custom Post Type: Portfolio
    register_post_type('portfolio', [
        'labels' => [
            'name'          => 'ุงู„ุฃุนู…ุงู„',
            'singular_name' => 'ุนู…ู„',
            'add_new_item'  => 'ุฅุถุงูุฉ ุนู…ู„ ุฌุฏูŠุฏ',
        ],
        'public'      => true,
        'has_archive' => true,
        'menu_icon'   => 'dashicons-portfolio',
        'supports'    => ['title', 'editor', 'thumbnail', 'excerpt'],
        'rewrite'     => ['slug' => 'portfolio'],
        'show_in_rest' => true,
    ]);

    // Taxonomy: Project Type
    register_taxonomy('project_type', 'portfolio', [
        'labels' => [
            'name'          => 'ุฃู†ูˆุงุน ุงู„ู…ุดุงุฑูŠุน',
            'singular_name' => 'ู†ูˆุน ุงู„ู…ุดุฑูˆุน',
        ],
        'hierarchical'      => true,
        'show_admin_column' => true,
        'rewrite'           => ['slug' => 'project-type'],
        'show_in_rest'      => true,
    ]);
});

4. ุฃู†ูˆุงุน ุงู„ุญู‚ูˆู„ ุงู„ู…ุฎุตุตุฉ (Meta Boxes)

php

add_action('add_meta_boxes', function() {
    add_meta_box('portfolio_details', 'ุชูุงุตูŠู„ ุงู„ุนู…ู„', 'render_portfolio_meta', 'portfolio', 'normal', 'high');
});

function render_portfolio_meta($post) {
    wp_nonce_field('portfolio_meta_save', 'portfolio_meta_nonce');
    $client = get_post_meta($post->ID, '_client_name', true);
    $url    = get_post_meta($post->ID, '_project_url', true);
    ?>
    <p>
        <label>ุงุณู… ุงู„ุนู…ูŠู„:</label>
        <input type="text" name="client_name" value="<?php echo esc_attr($client); ?>" class="widefat">
    </p>
    <p>
        <label>ุฑุงุจุท ุงู„ู…ุดุฑูˆุน:</label>
        <input type="url" name="project_url" value="<?php echo esc_attr($url); ?>" class="widefat">
    </p>
    <?php
}

add_action('save_post_portfolio', function($post_id) {
    if (!isset($_POST['portfolio_meta_nonce']) ||
        !wp_verify_nonce($_POST['portfolio_meta_nonce'], 'portfolio_meta_save')) return;
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
    if (!current_user_can('edit_post', $post_id)) return;

    if (isset($_POST['client_name'])) {
        update_post_meta($post_id, '_client_name', sanitize_text_field($_POST['client_name']));
    }
    if (isset($_POST['project_url'])) {
        update_post_meta($post_id, '_project_url', esc_url_raw($_POST['project_url']));
    }
});

5. ุตูุญุฉ ุฅุนุฏุงุฏุงุช ุงู„ู‚ุงู„ุจ (Customizer)

php

add_action('customize_register', function($wp_customize) {
    $wp_customize->add_section('mytheme_colors', [
        'title'    => __('ุฃู„ูˆุงู† ุงู„ู‚ุงู„ุจ', 'my-theme'),
        'priority' => 30,
    ]);

    $wp_customize->add_setting('primary_color', [
        'default'           => '#0073aa',
        'sanitize_callback' => 'sanitize_hex_color',
    ]);

    $wp_customize->add_control(new WP_Customize_Color_Control(
        $wp_customize, 'primary_color', [
            'label'   => __('ุงู„ู„ูˆู† ุงู„ุฃุณุงุณูŠ', 'my-theme'),
            'section' => 'mytheme_colors',
        ]
    ));
});

// ุชุทุจูŠู‚ ุงู„ู„ูˆู†
add_action('wp_head', function() {
    $color = get_theme_mod('primary_color', '#0073aa');
    echo "<style>:root{--primary:{$color};}</style>";
});

6. ุฅุถุงูุฉ ูˆุฏุฌุช ู…ุฎุตุต

php

class My_Custom_Widget extends WP_Widget {
    public function __construct() {
        parent::__construct('my_custom_widget', 'ูˆุฏุฌุช ู…ุฎุตุต', ['description' => 'ูˆุฏุฌุช ุชุฌุฑูŠุจูŠ']);
    }

    public function widget($args, $instance) {
        echo $args['before_widget'];
        echo $args['before_title'] . esc_html($instance['title']) . $args['after_title'];
        echo '<p>' . esc_html($instance['content']) . '</p>';
        echo $args['after_widget'];
    }

    public function form($instance) {
        $title   = $instance['title'] ?? '';
        $content = $instance['content'] ?? '';
        ?>
        <p>
            <label>ุงู„ุนู†ูˆุงู†:</label>
            <input class="widefat" name="<?php echo $this->get_field_name('title'); ?>"
                value="<?php echo esc_attr($title); ?>">
        </p>
        <p>
            <label>ุงู„ู…ุญุชูˆู‰:</label>
            <textarea class="widefat" name="<?php echo $this->get_field_name('content'); ?>">
                <?php echo esc_textarea($content); ?>
            </textarea>
        </p>
        <?php
    }

    public function update($new, $old) {
        return [
            'title'   => sanitize_text_field($new['title']),
            'content' => sanitize_textarea_field($new['content']),
        ];
    }
}

add_action('widgets_init', function() {
    register_widget('My_Custom_Widget');
});

7. AJAX ููŠ WordPress

php

// ููŠ functions.php
add_action('wp_enqueue_scripts', function() {
    wp_localize_script('mytheme-main', 'MyAjax', [
        'ajaxurl' => admin_url('admin-ajax.php'),
        'nonce'   => wp_create_nonce('my_ajax_nonce'),
    ]);
});

add_action('wp_ajax_get_posts_by_cat', 'handle_get_posts');
add_action('wp_ajax_nopriv_get_posts_by_cat', 'handle_get_posts');

function handle_get_posts() {
    check_ajax_referer('my_ajax_nonce', 'nonce');
    $cat = absint($_POST['cat_id'] ?? 0);

    $query = new WP_Query([
        'cat'            => $cat,
        'posts_per_page' => 5,
    ]);

    $result = [];
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $result[] = ['title' => get_the_title(), 'url' => get_permalink()];
        }
        wp_reset_postdata();
    }

    wp_send_json_success($result);
}

javascript

// JS
fetch(MyAjax.ajaxurl, {
    method: 'POST',
    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    body: new URLSearchParams({
        action: 'get_posts_by_cat',
        nonce: MyAjax.nonce,
        cat_id: 5
    })
}).then(r => r.json()).then(res => console.log(res.data));

8. ุฃูุถู„ ุงู„ู…ู…ุงุฑุณุงุช ุงู„ุฃู…ู†ูŠุฉ

ุงู„ู…ู…ุงุฑุณุฉุงู„ุงุณุชุฎุฏุงู…
esc_html()ุชุฃู…ูŠู† ุงู„ู†ุตูˆุต ููŠ ุงู„ุนุฑุถ
esc_attr()ุชุฃู…ูŠู† ุงู„ุฎุตุงุฆุต
esc_url()ุชุฃู…ูŠู† ุงู„ุฑูˆุงุจุท
sanitize_text_field()ุชู†ุธูŠู ุงู„ู…ุฏุฎู„ุงุช
wp_verify_nonce()ุงู„ุชุญู‚ู‚ ู…ู† ุงู„ู†ู…ุงุฐุฌ
check_ajax_referer()ุญู…ุงูŠุฉ AJAX
current_user_can()ุงู„ุชุญู‚ู‚ ู…ู† ุงู„ุตู„ุงุญูŠุงุช
$wpdb->prepare()ุงุณุชุนู„ุงู…ุงุช ู‚ุงุนุฏุฉ ุจูŠุงู†ุงุช ุขู…ู†ุฉ

9. ุฃุฏูˆุงุช ู…ุณุงุนุฏุฉ ู„ู„ู…ุทูˆุฑูŠู†

  • WP-CLI:ย wp scaffold theme mythemeย /ย wp scaffold plugin myplugin
  • Plugin Boilerplate:ย wppb.me
  • Theme Boilerplate:ย underscores.meย (_s)
  • Debug:ย define('WP_DEBUG', true);ย ููŠย wp-config.php

ู‡ู„ ุชุฑูŠุฏ ุฃู† ุฃุชุนู…ู‚ ููŠ ุฌุฒุก ู…ุนูŠู† (ู…ุซู„ ุจู†ุงุก ู‚ุงู„ุจ ูƒุงู…ู„ ู…ู† ุงู„ุตูุฑุŒ ุฃูˆ ุฅุถุงูุฉ ุจู†ุธุงู… ุฅุนุฏุงุฏุงุช ู…ุชู‚ุฏู…ุŒ ุฃูˆ ุฏู…ุฌ REST APIุŒ ุฃูˆ ุฅู†ุดุงุก ู…ูˆู„ู‘ุฏ ู‚ูˆุงู„ุจ ุขู„ูŠ ูŠุญูˆู‘ู„ ู…ุฏุฎู„ุงุช ุงู„ู…ุณุชุฎุฏู… ุฅู„ู‰ ู…ู„ูุงุช PHP)ุŸ

Scroll to Top