@mytechtoday/augment-extensions 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/augment-extensions/domain-rules/wordpress/README.md +163 -0
- package/augment-extensions/domain-rules/wordpress/module.json +32 -0
- package/augment-extensions/domain-rules/wordpress/rules/coding-standards.md +617 -0
- package/augment-extensions/domain-rules/wordpress/rules/directory-structure.md +270 -0
- package/augment-extensions/domain-rules/wordpress/rules/file-patterns.md +423 -0
- package/augment-extensions/domain-rules/wordpress/rules/gutenberg-blocks.md +493 -0
- package/augment-extensions/domain-rules/wordpress/rules/performance.md +568 -0
- package/augment-extensions/domain-rules/wordpress/rules/plugin-development.md +510 -0
- package/augment-extensions/domain-rules/wordpress/rules/project-detection.md +251 -0
- package/augment-extensions/domain-rules/wordpress/rules/rest-api.md +501 -0
- package/augment-extensions/domain-rules/wordpress/rules/security.md +564 -0
- package/augment-extensions/domain-rules/wordpress/rules/theme-development.md +388 -0
- package/augment-extensions/domain-rules/wordpress/rules/woocommerce.md +441 -0
- package/augment-extensions/domain-rules/wordpress-plugin/README.md +139 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/ajax-plugin.md +1599 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/custom-post-type-plugin.md +1727 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/gutenberg-block-plugin.md +428 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/gutenberg-block.md +422 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/mvc-plugin.md +1623 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/object-oriented-plugin.md +1343 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/rest-endpoint.md +734 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/settings-page-plugin.md +1350 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/simple-procedural-plugin.md +503 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/singleton-plugin.md +971 -0
- package/augment-extensions/domain-rules/wordpress-plugin/module.json +53 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/activation-hooks.md +770 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/admin-interface.md +874 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/ajax-handlers.md +629 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/asset-management.md +559 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/context-providers.md +709 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/cron-jobs.md +736 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/database-management.md +1057 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/documentation-standards.md +463 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/frontend-functionality.md +478 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/gutenberg-blocks.md +818 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/internationalization.md +416 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/migration.md +667 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/performance-optimization.md +878 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/plugin-architecture.md +693 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/plugin-structure.md +352 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/rest-api.md +818 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/scaffolding-workflow.md +624 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/security-best-practices.md +866 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/testing-patterns.md +1165 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/testing.md +414 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/vscode-integration.md +751 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/woocommerce-integration.md +949 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/wordpress-org-submission.md +458 -0
- package/augment-extensions/examples/gutenberg-block-plugin/README.md +101 -0
- package/augment-extensions/examples/gutenberg-block-plugin/examples/testimonial-block.md +428 -0
- package/augment-extensions/examples/gutenberg-block-plugin/module.json +40 -0
- package/augment-extensions/examples/rest-api-plugin/README.md +98 -0
- package/augment-extensions/examples/rest-api-plugin/examples/task-manager-api.md +1299 -0
- package/augment-extensions/examples/rest-api-plugin/module.json +40 -0
- package/augment-extensions/examples/woocommerce-extension/README.md +98 -0
- package/augment-extensions/examples/woocommerce-extension/examples/product-customizer.md +763 -0
- package/augment-extensions/examples/woocommerce-extension/module.json +40 -0
- package/augment-extensions/workflows/wordpress-plugin/README.md +232 -0
- package/augment-extensions/workflows/wordpress-plugin/ai-prompts.md +839 -0
- package/augment-extensions/workflows/wordpress-plugin/bead-decomposition-patterns.md +854 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/complete-plugin-example.md +540 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/custom-post-type-example.md +1083 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/feature-addition-workflow.md +669 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/plugin-creation-workflow.md +597 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/secure-form-handler-example.md +925 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/security-audit-workflow.md +752 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/wordpress-org-submission-workflow.md +773 -0
- package/augment-extensions/workflows/wordpress-plugin/module.json +49 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/best-practices.md +942 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/development-workflow.md +702 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/submission-workflow.md +728 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/testing-workflow.md +775 -0
- package/cli/dist/cli.js +5 -1
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/show.d.ts.map +1 -1
- package/cli/dist/commands/show.js +41 -0
- package/cli/dist/commands/show.js.map +1 -1
- package/modules.md +52 -0
- package/package.json +1 -1
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
# Context Providers for WordPress Plugin Development
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This guide documents WordPress-specific file context providers that help AI assistants understand the purpose and constraints of different WordPress files. Each file type has specific patterns, best practices, and safety rules.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. functions.php (Theme Functions File)
|
|
10
|
+
|
|
11
|
+
### Purpose
|
|
12
|
+
|
|
13
|
+
Theme setup, customization, and functionality extension.
|
|
14
|
+
|
|
15
|
+
### Context Rules
|
|
16
|
+
|
|
17
|
+
**When editing functions.php:**
|
|
18
|
+
|
|
19
|
+
- ✅ **DO**: Add theme support features
|
|
20
|
+
- ✅ **DO**: Register navigation menus
|
|
21
|
+
- ✅ **DO**: Enqueue theme styles and scripts
|
|
22
|
+
- ✅ **DO**: Register widget areas
|
|
23
|
+
- ✅ **DO**: Add custom image sizes
|
|
24
|
+
- ✅ **DO**: Customize excerpt length
|
|
25
|
+
- ✅ **DO**: Add theme-specific filters and actions
|
|
26
|
+
|
|
27
|
+
- ❌ **DON'T**: Modify core WordPress files
|
|
28
|
+
- ❌ **DON'T**: Add plugin-level functionality (use plugins instead)
|
|
29
|
+
- ❌ **DON'T**: Include large amounts of business logic
|
|
30
|
+
- ❌ **DON'T**: Hardcode URLs or paths
|
|
31
|
+
|
|
32
|
+
### Common Patterns
|
|
33
|
+
|
|
34
|
+
```php
|
|
35
|
+
<?php
|
|
36
|
+
/**
|
|
37
|
+
* Theme functions and definitions
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
// Exit if accessed directly
|
|
41
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
42
|
+
exit;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Theme setup
|
|
47
|
+
*/
|
|
48
|
+
function mytheme_setup() {
|
|
49
|
+
// Add theme support
|
|
50
|
+
add_theme_support( 'title-tag' );
|
|
51
|
+
add_theme_support( 'post-thumbnails' );
|
|
52
|
+
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
|
|
53
|
+
add_theme_support( 'custom-logo' );
|
|
54
|
+
|
|
55
|
+
// Register navigation menus
|
|
56
|
+
register_nav_menus( array(
|
|
57
|
+
'primary' => __( 'Primary Menu', 'mytheme' ),
|
|
58
|
+
'footer' => __( 'Footer Menu', 'mytheme' ),
|
|
59
|
+
) );
|
|
60
|
+
|
|
61
|
+
// Add custom image sizes
|
|
62
|
+
add_image_size( 'mytheme-featured', 800, 600, true );
|
|
63
|
+
}
|
|
64
|
+
add_action( 'after_setup_theme', 'mytheme_setup' );
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Enqueue scripts and styles
|
|
68
|
+
*/
|
|
69
|
+
function mytheme_enqueue_scripts() {
|
|
70
|
+
// Enqueue styles
|
|
71
|
+
wp_enqueue_style( 'mytheme-style', get_stylesheet_uri(), array(), '1.0.0' );
|
|
72
|
+
|
|
73
|
+
// Enqueue scripts
|
|
74
|
+
wp_enqueue_script( 'mytheme-script', get_template_directory_uri() . '/js/script.js', array( 'jquery' ), '1.0.0', true );
|
|
75
|
+
}
|
|
76
|
+
add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_scripts' );
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Register widget areas
|
|
80
|
+
*/
|
|
81
|
+
function mytheme_widgets_init() {
|
|
82
|
+
register_sidebar( array(
|
|
83
|
+
'name' => __( 'Sidebar', 'mytheme' ),
|
|
84
|
+
'id' => 'sidebar-1',
|
|
85
|
+
'description' => __( 'Add widgets here.', 'mytheme' ),
|
|
86
|
+
'before_widget' => '<section id="%1$s" class="widget %2$s">',
|
|
87
|
+
'after_widget' => '</section>',
|
|
88
|
+
'before_title' => '<h2 class="widget-title">',
|
|
89
|
+
'after_title' => '</h2>',
|
|
90
|
+
) );
|
|
91
|
+
}
|
|
92
|
+
add_action( 'widgets_init', 'mytheme_widgets_init' );
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Safety Rules
|
|
96
|
+
|
|
97
|
+
- **NEVER** remove the opening `<?php` tag
|
|
98
|
+
- **ALWAYS** use proper WordPress hooks
|
|
99
|
+
- **ALWAYS** prefix function names with theme slug
|
|
100
|
+
- **ALWAYS** use translation functions for user-facing strings
|
|
101
|
+
- **ALWAYS** check if functions exist before defining them
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 2. wp-config.php (WordPress Configuration File)
|
|
106
|
+
|
|
107
|
+
### Purpose
|
|
108
|
+
|
|
109
|
+
WordPress core configuration including database credentials, security keys, and environment settings.
|
|
110
|
+
|
|
111
|
+
### Context Rules
|
|
112
|
+
|
|
113
|
+
**When viewing wp-config.php:**
|
|
114
|
+
|
|
115
|
+
- ✅ **DO**: Read configuration values
|
|
116
|
+
- ✅ **DO**: Suggest environment-specific constants
|
|
117
|
+
- ✅ **DO**: Recommend security improvements
|
|
118
|
+
- ✅ **DO**: Suggest debugging settings for development
|
|
119
|
+
|
|
120
|
+
- ❌ **DON'T**: Modify database credentials without explicit permission
|
|
121
|
+
- ❌ **DON'T**: Change security keys without warning
|
|
122
|
+
- ❌ **DON'T**: Enable debugging in production
|
|
123
|
+
- ❌ **DON'T**: Expose sensitive information
|
|
124
|
+
|
|
125
|
+
### Read-Only Context
|
|
126
|
+
|
|
127
|
+
**wp-config.php is READ-ONLY by default. Only suggest changes, never make them automatically.**
|
|
128
|
+
|
|
129
|
+
### Common Safe Additions
|
|
130
|
+
|
|
131
|
+
```php
|
|
132
|
+
// Development environment settings (ONLY for local development)
|
|
133
|
+
define( 'WP_DEBUG', true );
|
|
134
|
+
define( 'WP_DEBUG_LOG', true );
|
|
135
|
+
define( 'WP_DEBUG_DISPLAY', false );
|
|
136
|
+
define( 'SCRIPT_DEBUG', true );
|
|
137
|
+
|
|
138
|
+
// Memory limits
|
|
139
|
+
define( 'WP_MEMORY_LIMIT', '256M' );
|
|
140
|
+
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
|
|
141
|
+
|
|
142
|
+
// Auto-save interval (in seconds)
|
|
143
|
+
define( 'AUTOSAVE_INTERVAL', 160 );
|
|
144
|
+
|
|
145
|
+
// Post revisions
|
|
146
|
+
define( 'WP_POST_REVISIONS', 5 );
|
|
147
|
+
|
|
148
|
+
// Trash auto-empty (in days)
|
|
149
|
+
define( 'EMPTY_TRASH_DAYS', 30 );
|
|
150
|
+
|
|
151
|
+
// Disable file editing in admin
|
|
152
|
+
define( 'DISALLOW_FILE_EDIT', true );
|
|
153
|
+
|
|
154
|
+
// Force SSL for admin
|
|
155
|
+
define( 'FORCE_SSL_ADMIN', true );
|
|
156
|
+
|
|
157
|
+
// Custom content directory
|
|
158
|
+
define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/wp-content' );
|
|
159
|
+
define( 'WP_CONTENT_URL', 'https://example.com/wp-content' );
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Safety Rules
|
|
163
|
+
|
|
164
|
+
- **NEVER** modify without explicit user permission
|
|
165
|
+
- **ALWAYS** warn before suggesting changes
|
|
166
|
+
- **ALWAYS** recommend backups before changes
|
|
167
|
+
- **ALWAYS** distinguish between development and production settings
|
|
168
|
+
- **NEVER** log or expose database credentials
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 3. block.json (Block Metadata File)
|
|
173
|
+
|
|
174
|
+
### Purpose
|
|
175
|
+
|
|
176
|
+
Gutenberg block metadata including attributes, supports, and registration details.
|
|
177
|
+
|
|
178
|
+
### Context Rules
|
|
179
|
+
|
|
180
|
+
**When editing block.json:**
|
|
181
|
+
|
|
182
|
+
- ✅ **DO**: Define block attributes
|
|
183
|
+
- ✅ **DO**: Specify block supports
|
|
184
|
+
- ✅ **DO**: Set block category
|
|
185
|
+
- ✅ **DO**: Define block keywords
|
|
186
|
+
- ✅ **DO**: Specify editor and view scripts
|
|
187
|
+
- ✅ **DO**: Define block styles
|
|
188
|
+
|
|
189
|
+
- ❌ **DON'T**: Use invalid JSON syntax
|
|
190
|
+
- ❌ **DON'T**: Omit required fields
|
|
191
|
+
- ❌ **DON'T**: Use reserved block names
|
|
192
|
+
|
|
193
|
+
### Standard block.json Structure
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
198
|
+
"apiVersion": 3,
|
|
199
|
+
"name": "myplugin/custom-block",
|
|
200
|
+
"version": "1.0.0",
|
|
201
|
+
"title": "Custom Block",
|
|
202
|
+
"category": "widgets",
|
|
203
|
+
"icon": "smiley",
|
|
204
|
+
"description": "A custom Gutenberg block",
|
|
205
|
+
"keywords": ["custom", "block"],
|
|
206
|
+
"textdomain": "myplugin",
|
|
207
|
+
"supports": {
|
|
208
|
+
"html": false,
|
|
209
|
+
"align": true,
|
|
210
|
+
"color": {
|
|
211
|
+
"background": true,
|
|
212
|
+
"text": true
|
|
213
|
+
},
|
|
214
|
+
"spacing": {
|
|
215
|
+
"margin": true,
|
|
216
|
+
"padding": true
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"attributes": {
|
|
220
|
+
"content": {
|
|
221
|
+
"type": "string",
|
|
222
|
+
"default": ""
|
|
223
|
+
},
|
|
224
|
+
"alignment": {
|
|
225
|
+
"type": "string",
|
|
226
|
+
"default": "left"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"editorScript": "file:./index.js",
|
|
230
|
+
"editorStyle": "file:./editor.css",
|
|
231
|
+
"style": "file:./style.css"
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Common Attributes
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"attributes": {
|
|
240
|
+
"title": {
|
|
241
|
+
"type": "string",
|
|
242
|
+
"default": ""
|
|
243
|
+
},
|
|
244
|
+
"content": {
|
|
245
|
+
"type": "string",
|
|
246
|
+
"source": "html",
|
|
247
|
+
"selector": "p"
|
|
248
|
+
},
|
|
249
|
+
"imageUrl": {
|
|
250
|
+
"type": "string",
|
|
251
|
+
"default": ""
|
|
252
|
+
},
|
|
253
|
+
"imageId": {
|
|
254
|
+
"type": "number"
|
|
255
|
+
},
|
|
256
|
+
"isEnabled": {
|
|
257
|
+
"type": "boolean",
|
|
258
|
+
"default": true
|
|
259
|
+
},
|
|
260
|
+
"items": {
|
|
261
|
+
"type": "array",
|
|
262
|
+
"default": []
|
|
263
|
+
},
|
|
264
|
+
"settings": {
|
|
265
|
+
"type": "object",
|
|
266
|
+
"default": {}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Safety Rules
|
|
273
|
+
|
|
274
|
+
- **ALWAYS** validate JSON syntax
|
|
275
|
+
- **ALWAYS** include required fields (name, title, category)
|
|
276
|
+
- **ALWAYS** use proper attribute types
|
|
277
|
+
- **ALWAYS** prefix block names with plugin/theme namespace
|
|
278
|
+
- **NEVER** use core WordPress block names
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 4. theme.json (Global Styles and Settings)
|
|
283
|
+
|
|
284
|
+
### Purpose
|
|
285
|
+
|
|
286
|
+
Define global styles, color palettes, typography, and layout settings for block themes.
|
|
287
|
+
|
|
288
|
+
### Context Rules
|
|
289
|
+
|
|
290
|
+
**When editing theme.json:**
|
|
291
|
+
|
|
292
|
+
- ✅ **DO**: Define color palettes
|
|
293
|
+
- ✅ **DO**: Set typography scales
|
|
294
|
+
- ✅ **DO**: Configure layout settings
|
|
295
|
+
- ✅ **DO**: Define custom CSS properties
|
|
296
|
+
- ✅ **DO**: Set block-specific styles
|
|
297
|
+
|
|
298
|
+
- ❌ **DON'T**: Use invalid JSON syntax
|
|
299
|
+
- ❌ **DON'T**: Override user preferences without reason
|
|
300
|
+
- ❌ **DON'T**: Define inaccessible color combinations
|
|
301
|
+
|
|
302
|
+
### Standard theme.json Structure
|
|
303
|
+
|
|
304
|
+
```json
|
|
305
|
+
{
|
|
306
|
+
"$schema": "https://schemas.wp.org/trunk/theme.json",
|
|
307
|
+
"version": 2,
|
|
308
|
+
"settings": {
|
|
309
|
+
"color": {
|
|
310
|
+
"palette": [
|
|
311
|
+
{
|
|
312
|
+
"slug": "primary",
|
|
313
|
+
"color": "#0073aa",
|
|
314
|
+
"name": "Primary"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"slug": "secondary",
|
|
318
|
+
"color": "#23282d",
|
|
319
|
+
"name": "Secondary"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"slug": "white",
|
|
323
|
+
"color": "#ffffff",
|
|
324
|
+
"name": "White"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"slug": "black",
|
|
328
|
+
"color": "#000000",
|
|
329
|
+
"name": "Black"
|
|
330
|
+
}
|
|
331
|
+
],
|
|
332
|
+
"gradients": [
|
|
333
|
+
{
|
|
334
|
+
"slug": "primary-to-secondary",
|
|
335
|
+
"gradient": "linear-gradient(135deg, #0073aa 0%, #23282d 100%)",
|
|
336
|
+
"name": "Primary to Secondary"
|
|
337
|
+
}
|
|
338
|
+
],
|
|
339
|
+
"duotone": [],
|
|
340
|
+
"custom": true,
|
|
341
|
+
"customGradient": true,
|
|
342
|
+
"link": true
|
|
343
|
+
},
|
|
344
|
+
"typography": {
|
|
345
|
+
"fontSizes": [
|
|
346
|
+
{
|
|
347
|
+
"slug": "small",
|
|
348
|
+
"size": "14px",
|
|
349
|
+
"name": "Small"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"slug": "medium",
|
|
353
|
+
"size": "18px",
|
|
354
|
+
"name": "Medium"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"slug": "large",
|
|
358
|
+
"size": "24px",
|
|
359
|
+
"name": "Large"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"slug": "x-large",
|
|
363
|
+
"size": "32px",
|
|
364
|
+
"name": "Extra Large"
|
|
365
|
+
}
|
|
366
|
+
],
|
|
367
|
+
"fontFamilies": [
|
|
368
|
+
{
|
|
369
|
+
"slug": "system",
|
|
370
|
+
"fontFamily": "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif",
|
|
371
|
+
"name": "System Font"
|
|
372
|
+
}
|
|
373
|
+
],
|
|
374
|
+
"customFontSize": true,
|
|
375
|
+
"lineHeight": true
|
|
376
|
+
},
|
|
377
|
+
"spacing": {
|
|
378
|
+
"units": ["px", "em", "rem", "vh", "vw", "%"],
|
|
379
|
+
"padding": true,
|
|
380
|
+
"margin": true
|
|
381
|
+
},
|
|
382
|
+
"layout": {
|
|
383
|
+
"contentSize": "800px",
|
|
384
|
+
"wideSize": "1200px"
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
"styles": {
|
|
388
|
+
"color": {
|
|
389
|
+
"background": "#ffffff",
|
|
390
|
+
"text": "#000000"
|
|
391
|
+
},
|
|
392
|
+
"typography": {
|
|
393
|
+
"fontSize": "18px",
|
|
394
|
+
"lineHeight": "1.6",
|
|
395
|
+
"fontFamily": "var(--wp--preset--font-family--system)"
|
|
396
|
+
},
|
|
397
|
+
"spacing": {
|
|
398
|
+
"padding": {
|
|
399
|
+
"top": "0",
|
|
400
|
+
"right": "0",
|
|
401
|
+
"bottom": "0",
|
|
402
|
+
"left": "0"
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
"elements": {
|
|
406
|
+
"link": {
|
|
407
|
+
"color": {
|
|
408
|
+
"text": "var(--wp--preset--color--primary)"
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
"h1": {
|
|
412
|
+
"typography": {
|
|
413
|
+
"fontSize": "var(--wp--preset--font-size--x-large)"
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
"blocks": {
|
|
418
|
+
"core/paragraph": {
|
|
419
|
+
"spacing": {
|
|
420
|
+
"margin": {
|
|
421
|
+
"bottom": "1em"
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### Safety Rules
|
|
431
|
+
|
|
432
|
+
- **ALWAYS** validate JSON syntax
|
|
433
|
+
- **ALWAYS** use version 2 schema
|
|
434
|
+
- **ALWAYS** ensure color contrast meets WCAG standards
|
|
435
|
+
- **ALWAYS** provide fallback values
|
|
436
|
+
- **NEVER** remove default color palette without replacement
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## 5. style.css (Theme Metadata File)
|
|
441
|
+
|
|
442
|
+
### Purpose
|
|
443
|
+
|
|
444
|
+
Theme metadata and optional theme styles.
|
|
445
|
+
|
|
446
|
+
### Context Rules
|
|
447
|
+
|
|
448
|
+
**When editing style.css:**
|
|
449
|
+
|
|
450
|
+
- ✅ **DO**: Update theme metadata in header
|
|
451
|
+
- ✅ **DO**: Add theme-specific styles
|
|
452
|
+
- ✅ **DO**: Use proper CSS syntax
|
|
453
|
+
- ✅ **DO**: Include version number
|
|
454
|
+
|
|
455
|
+
- ❌ **DON'T**: Remove required header fields
|
|
456
|
+
- ❌ **DON'T**: Use invalid CSS syntax
|
|
457
|
+
- ❌ **DON'T**: Hardcode colors without CSS variables
|
|
458
|
+
|
|
459
|
+
### Required Header Format
|
|
460
|
+
|
|
461
|
+
```css
|
|
462
|
+
/*
|
|
463
|
+
Theme Name: My Theme
|
|
464
|
+
Theme URI: https://example.com/my-theme
|
|
465
|
+
Author: Author Name
|
|
466
|
+
Author URI: https://example.com
|
|
467
|
+
Description: A custom WordPress theme
|
|
468
|
+
Version: 1.0.0
|
|
469
|
+
Requires at least: 5.8
|
|
470
|
+
Tested up to: 6.4
|
|
471
|
+
Requires PHP: 7.4
|
|
472
|
+
License: GNU General Public License v2 or later
|
|
473
|
+
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
474
|
+
Text Domain: mytheme
|
|
475
|
+
Domain Path: /languages
|
|
476
|
+
Tags: blog, custom-background, custom-logo, custom-menu, featured-images
|
|
477
|
+
*/
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
### Required Fields
|
|
481
|
+
|
|
482
|
+
- **Theme Name**: Display name of the theme
|
|
483
|
+
- **Author**: Theme author name
|
|
484
|
+
- **Description**: Brief theme description
|
|
485
|
+
- **Version**: Theme version number
|
|
486
|
+
- **License**: Theme license
|
|
487
|
+
- **Text Domain**: Translation text domain
|
|
488
|
+
|
|
489
|
+
### Optional Fields
|
|
490
|
+
|
|
491
|
+
- **Theme URI**: Theme homepage URL
|
|
492
|
+
- **Author URI**: Author homepage URL
|
|
493
|
+
- **Requires at least**: Minimum WordPress version
|
|
494
|
+
- **Tested up to**: Maximum tested WordPress version
|
|
495
|
+
- **Requires PHP**: Minimum PHP version
|
|
496
|
+
- **Domain Path**: Translation files directory
|
|
497
|
+
- **Tags**: Theme tags for WordPress.org
|
|
498
|
+
|
|
499
|
+
### Safety Rules
|
|
500
|
+
|
|
501
|
+
- **NEVER** remove the theme header comment
|
|
502
|
+
- **ALWAYS** update version number when making changes
|
|
503
|
+
- **ALWAYS** use valid CSS syntax
|
|
504
|
+
- **ALWAYS** match Text Domain with theme slug
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
## 6. Plugin Main File (my-plugin.php)
|
|
509
|
+
|
|
510
|
+
### Purpose
|
|
511
|
+
|
|
512
|
+
Plugin entry point with metadata and initialization.
|
|
513
|
+
|
|
514
|
+
### Context Rules
|
|
515
|
+
|
|
516
|
+
**When editing plugin main file:**
|
|
517
|
+
|
|
518
|
+
- ✅ **DO**: Update plugin metadata in header
|
|
519
|
+
- ✅ **DO**: Define plugin constants
|
|
520
|
+
- ✅ **DO**: Include required files
|
|
521
|
+
- ✅ **DO**: Initialize plugin functionality
|
|
522
|
+
- ✅ **DO**: Add activation/deactivation hooks
|
|
523
|
+
|
|
524
|
+
- ❌ **DON'T**: Remove required header fields
|
|
525
|
+
- ❌ **DON'T**: Execute code before security checks
|
|
526
|
+
- ❌ **DON'T**: Include large amounts of code directly
|
|
527
|
+
|
|
528
|
+
### Required Header Format
|
|
529
|
+
|
|
530
|
+
```php
|
|
531
|
+
<?php
|
|
532
|
+
/**
|
|
533
|
+
* Plugin Name: My Plugin
|
|
534
|
+
* Plugin URI: https://example.com/my-plugin
|
|
535
|
+
* Description: A custom WordPress plugin
|
|
536
|
+
* Version: 1.0.0
|
|
537
|
+
* Requires at least: 5.8
|
|
538
|
+
* Requires PHP: 7.4
|
|
539
|
+
* Author: Author Name
|
|
540
|
+
* Author URI: https://example.com
|
|
541
|
+
* License: GPL v2 or later
|
|
542
|
+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
543
|
+
* Text Domain: myplugin
|
|
544
|
+
* Domain Path: /languages
|
|
545
|
+
*/
|
|
546
|
+
|
|
547
|
+
// Exit if accessed directly
|
|
548
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
549
|
+
exit;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// Define plugin constants
|
|
553
|
+
define( 'MYPLUGIN_VERSION', '1.0.0' );
|
|
554
|
+
define( 'MYPLUGIN_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
|
555
|
+
define( 'MYPLUGIN_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
|
556
|
+
define( 'MYPLUGIN_PLUGIN_FILE', __FILE__ );
|
|
557
|
+
|
|
558
|
+
// Include required files
|
|
559
|
+
require_once MYPLUGIN_PLUGIN_DIR . 'includes/class-myplugin.php';
|
|
560
|
+
|
|
561
|
+
// Initialize plugin
|
|
562
|
+
function myplugin_init() {
|
|
563
|
+
$plugin = new MyPlugin();
|
|
564
|
+
$plugin->run();
|
|
565
|
+
}
|
|
566
|
+
add_action( 'plugins_loaded', 'myplugin_init' );
|
|
567
|
+
|
|
568
|
+
// Activation hook
|
|
569
|
+
register_activation_hook( __FILE__, 'myplugin_activate' );
|
|
570
|
+
function myplugin_activate() {
|
|
571
|
+
// Activation code
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// Deactivation hook
|
|
575
|
+
register_deactivation_hook( __FILE__, 'myplugin_deactivate' );
|
|
576
|
+
function myplugin_deactivate() {
|
|
577
|
+
// Deactivation code
|
|
578
|
+
}
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### Required Fields
|
|
582
|
+
|
|
583
|
+
- **Plugin Name**: Display name of the plugin
|
|
584
|
+
- **Description**: Brief plugin description
|
|
585
|
+
- **Version**: Plugin version number
|
|
586
|
+
- **Author**: Plugin author name
|
|
587
|
+
- **License**: Plugin license
|
|
588
|
+
- **Text Domain**: Translation text domain
|
|
589
|
+
|
|
590
|
+
### Safety Rules
|
|
591
|
+
|
|
592
|
+
- **NEVER** remove the plugin header comment
|
|
593
|
+
- **ALWAYS** include ABSPATH security check
|
|
594
|
+
- **ALWAYS** define plugin constants
|
|
595
|
+
- **ALWAYS** use proper activation/deactivation hooks
|
|
596
|
+
- **ALWAYS** update version number when making changes
|
|
597
|
+
|
|
598
|
+
---
|
|
599
|
+
|
|
600
|
+
## 7. readme.txt (WordPress.org Plugin Readme)
|
|
601
|
+
|
|
602
|
+
### Purpose
|
|
603
|
+
|
|
604
|
+
Plugin documentation for WordPress.org plugin directory.
|
|
605
|
+
|
|
606
|
+
### Context Rules
|
|
607
|
+
|
|
608
|
+
**When editing readme.txt:**
|
|
609
|
+
|
|
610
|
+
- ✅ **DO**: Update version numbers
|
|
611
|
+
- ✅ **DO**: Add changelog entries
|
|
612
|
+
- ✅ **DO**: Update compatibility information
|
|
613
|
+
- ✅ **DO**: Improve installation instructions
|
|
614
|
+
- ✅ **DO**: Add FAQ entries
|
|
615
|
+
|
|
616
|
+
- ❌ **DON'T**: Remove required sections
|
|
617
|
+
- ❌ **DON'T**: Use invalid markdown syntax
|
|
618
|
+
- ❌ **DON'T**: Include promotional content
|
|
619
|
+
|
|
620
|
+
### Standard readme.txt Structure
|
|
621
|
+
|
|
622
|
+
```
|
|
623
|
+
=== My Plugin ===
|
|
624
|
+
Contributors: username
|
|
625
|
+
Donate link: https://example.com/donate
|
|
626
|
+
Tags: tag1, tag2, tag3
|
|
627
|
+
Requires at least: 5.8
|
|
628
|
+
Tested up to: 6.4
|
|
629
|
+
Requires PHP: 7.4
|
|
630
|
+
Stable tag: 1.0.0
|
|
631
|
+
License: GPLv2 or later
|
|
632
|
+
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
633
|
+
|
|
634
|
+
Short description of the plugin.
|
|
635
|
+
|
|
636
|
+
== Description ==
|
|
637
|
+
|
|
638
|
+
Detailed description of the plugin.
|
|
639
|
+
|
|
640
|
+
Features:
|
|
641
|
+
* Feature 1
|
|
642
|
+
* Feature 2
|
|
643
|
+
* Feature 3
|
|
644
|
+
|
|
645
|
+
== Installation ==
|
|
646
|
+
|
|
647
|
+
1. Upload the plugin files to `/wp-content/plugins/my-plugin`
|
|
648
|
+
2. Activate the plugin through the 'Plugins' screen in WordPress
|
|
649
|
+
3. Use the Settings->My Plugin screen to configure the plugin
|
|
650
|
+
|
|
651
|
+
== Frequently Asked Questions ==
|
|
652
|
+
|
|
653
|
+
= Question 1 =
|
|
654
|
+
|
|
655
|
+
Answer 1
|
|
656
|
+
|
|
657
|
+
= Question 2 =
|
|
658
|
+
|
|
659
|
+
Answer 2
|
|
660
|
+
|
|
661
|
+
== Screenshots ==
|
|
662
|
+
|
|
663
|
+
1. Screenshot 1 description
|
|
664
|
+
2. Screenshot 2 description
|
|
665
|
+
|
|
666
|
+
== Changelog ==
|
|
667
|
+
|
|
668
|
+
= 1.0.0 =
|
|
669
|
+
* Initial release
|
|
670
|
+
|
|
671
|
+
== Upgrade Notice ==
|
|
672
|
+
|
|
673
|
+
= 1.0.0 =
|
|
674
|
+
Initial release
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
### Safety Rules
|
|
678
|
+
|
|
679
|
+
- **ALWAYS** update version numbers consistently
|
|
680
|
+
- **ALWAYS** add changelog entries for new versions
|
|
681
|
+
- **ALWAYS** update "Tested up to" version
|
|
682
|
+
- **ALWAYS** use proper markdown syntax
|
|
683
|
+
- **NEVER** include promotional links in description
|
|
684
|
+
|
|
685
|
+
---
|
|
686
|
+
|
|
687
|
+
## Summary
|
|
688
|
+
|
|
689
|
+
**Key context providers for WordPress development:**
|
|
690
|
+
|
|
691
|
+
1. **functions.php** - Theme setup and customization
|
|
692
|
+
2. **wp-config.php** - Configuration (READ-ONLY)
|
|
693
|
+
3. **block.json** - Gutenberg block metadata
|
|
694
|
+
4. **theme.json** - Global styles and settings
|
|
695
|
+
5. **style.css** - Theme metadata
|
|
696
|
+
6. **Plugin main file** - Plugin entry point
|
|
697
|
+
7. **readme.txt** - WordPress.org documentation
|
|
698
|
+
|
|
699
|
+
**Safety rules:**
|
|
700
|
+
|
|
701
|
+
- ✅ Always validate syntax before saving
|
|
702
|
+
- ✅ Always backup before making changes
|
|
703
|
+
- ✅ Always use WordPress coding standards
|
|
704
|
+
- ✅ Always check for required fields
|
|
705
|
+
- ❌ Never modify wp-config.php without permission
|
|
706
|
+
- ❌ Never remove required metadata
|
|
707
|
+
- ❌ Never use invalid syntax
|
|
708
|
+
|
|
709
|
+
|