@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,270 @@
|
|
|
1
|
+
# WordPress Directory Structure Patterns
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document defines the standard directory structures for WordPress projects: full installations, themes, plugins, and blocks.
|
|
6
|
+
|
|
7
|
+
## Standard WordPress Installation
|
|
8
|
+
|
|
9
|
+
### Complete Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
wordpress/
|
|
13
|
+
├── wp-admin/ # WordPress admin area
|
|
14
|
+
│ ├── css/
|
|
15
|
+
│ ├── images/
|
|
16
|
+
│ ├── includes/
|
|
17
|
+
│ ├── js/
|
|
18
|
+
│ ├── maint/
|
|
19
|
+
│ ├── network/
|
|
20
|
+
│ ├── user/
|
|
21
|
+
│ └── *.php # Admin pages
|
|
22
|
+
├── wp-content/ # User content (themes, plugins, uploads)
|
|
23
|
+
│ ├── themes/ # Themes directory
|
|
24
|
+
│ │ ├── twentytwentyfour/ # Default theme
|
|
25
|
+
│ │ └── [custom-theme]/ # Custom themes
|
|
26
|
+
│ ├── plugins/ # Plugins directory
|
|
27
|
+
│ │ ├── akismet/
|
|
28
|
+
│ │ ├── hello.php
|
|
29
|
+
│ │ └── [custom-plugin]/ # Custom plugins
|
|
30
|
+
│ ├── mu-plugins/ # Must-use plugins (auto-loaded)
|
|
31
|
+
│ ├── uploads/ # Media uploads
|
|
32
|
+
│ │ └── [year]/
|
|
33
|
+
│ │ └── [month]/
|
|
34
|
+
│ ├── languages/ # Translation files
|
|
35
|
+
│ └── upgrade/ # Temporary upgrade files
|
|
36
|
+
├── wp-includes/ # WordPress core files
|
|
37
|
+
│ ├── blocks/
|
|
38
|
+
│ ├── certificates/
|
|
39
|
+
│ ├── css/
|
|
40
|
+
│ ├── customize/
|
|
41
|
+
│ ├── fonts/
|
|
42
|
+
│ ├── images/
|
|
43
|
+
│ ├── js/
|
|
44
|
+
│ ├── pomo/
|
|
45
|
+
│ ├── rest-api/
|
|
46
|
+
│ ├── theme-compat/
|
|
47
|
+
│ ├── widgets/
|
|
48
|
+
│ └── *.php # Core PHP files
|
|
49
|
+
├── .htaccess # Apache configuration
|
|
50
|
+
├── index.php # Main entry point
|
|
51
|
+
├── license.txt # GPL license
|
|
52
|
+
├── readme.html # WordPress readme
|
|
53
|
+
├── wp-activate.php # Multisite activation
|
|
54
|
+
├── wp-blog-header.php # Blog header loader
|
|
55
|
+
├── wp-comments-post.php # Comment handler
|
|
56
|
+
├── wp-config.php # WordPress configuration (CRITICAL)
|
|
57
|
+
├── wp-config-sample.php # Sample configuration
|
|
58
|
+
├── wp-cron.php # Cron handler
|
|
59
|
+
├── wp-links-opml.php # OPML export
|
|
60
|
+
├── wp-load.php # Bootstrap loader
|
|
61
|
+
├── wp-login.php # Login page
|
|
62
|
+
├── wp-mail.php # Email handler
|
|
63
|
+
├── wp-settings.php # Settings loader
|
|
64
|
+
├── wp-signup.php # Multisite signup
|
|
65
|
+
├── wp-trackback.php # Trackback handler
|
|
66
|
+
└── xmlrpc.php # XML-RPC handler
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Key Directories
|
|
70
|
+
|
|
71
|
+
**wp-admin/**
|
|
72
|
+
- WordPress administration interface
|
|
73
|
+
- DO NOT modify core files
|
|
74
|
+
- Use hooks and filters instead
|
|
75
|
+
|
|
76
|
+
**wp-content/**
|
|
77
|
+
- User-generated content
|
|
78
|
+
- Safe to modify
|
|
79
|
+
- Version control this directory
|
|
80
|
+
|
|
81
|
+
**wp-includes/**
|
|
82
|
+
- WordPress core library
|
|
83
|
+
- DO NOT modify
|
|
84
|
+
- Use plugins/themes for customization
|
|
85
|
+
|
|
86
|
+
## Theme Structure
|
|
87
|
+
|
|
88
|
+
### Classic Theme
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
theme-name/
|
|
92
|
+
├── style.css # Required: Theme stylesheet with header
|
|
93
|
+
├── functions.php # Required: Theme functions
|
|
94
|
+
├── index.php # Required: Main template
|
|
95
|
+
├── header.php # Header template
|
|
96
|
+
├── footer.php # Footer template
|
|
97
|
+
├── sidebar.php # Sidebar template
|
|
98
|
+
├── single.php # Single post template
|
|
99
|
+
├── page.php # Page template
|
|
100
|
+
├── archive.php # Archive template
|
|
101
|
+
├── category.php # Category archive
|
|
102
|
+
├── tag.php # Tag archive
|
|
103
|
+
├── author.php # Author archive
|
|
104
|
+
├── date.php # Date archive
|
|
105
|
+
├── search.php # Search results
|
|
106
|
+
├── 404.php # 404 error page
|
|
107
|
+
├── comments.php # Comments template
|
|
108
|
+
├── front-page.php # Front page template
|
|
109
|
+
├── home.php # Blog home template
|
|
110
|
+
├── attachment.php # Attachment template
|
|
111
|
+
├── image.php # Image attachment
|
|
112
|
+
├── template-parts/ # Reusable template parts
|
|
113
|
+
│ ├── content.php
|
|
114
|
+
│ ├── content-single.php
|
|
115
|
+
│ └── content-page.php
|
|
116
|
+
├── inc/ # Include files
|
|
117
|
+
│ ├── customizer.php
|
|
118
|
+
│ ├── template-tags.php
|
|
119
|
+
│ └── template-functions.php
|
|
120
|
+
├── assets/ # Theme assets
|
|
121
|
+
│ ├── css/
|
|
122
|
+
│ │ ├── main.css
|
|
123
|
+
│ │ └── editor-style.css
|
|
124
|
+
│ ├── js/
|
|
125
|
+
│ │ ├── main.js
|
|
126
|
+
│ │ └── customizer.js
|
|
127
|
+
│ └── images/
|
|
128
|
+
│ └── *.png, *.jpg, *.svg
|
|
129
|
+
├── languages/ # Translation files
|
|
130
|
+
│ └── theme-slug.pot
|
|
131
|
+
├── screenshot.png # Theme screenshot (880x660px)
|
|
132
|
+
└── readme.txt # Theme documentation
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Block Theme (FSE)
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
theme-name/
|
|
139
|
+
├── style.css # Required: Theme stylesheet with header
|
|
140
|
+
├── functions.php # Theme functions (minimal)
|
|
141
|
+
├── theme.json # Required: Theme configuration
|
|
142
|
+
├── templates/ # Required: Block templates
|
|
143
|
+
│ ├── index.html # Required: Main template
|
|
144
|
+
│ ├── single.html # Single post
|
|
145
|
+
│ ├── page.html # Page
|
|
146
|
+
│ ├── archive.html # Archive
|
|
147
|
+
│ ├── search.html # Search results
|
|
148
|
+
│ ├── 404.html # 404 error
|
|
149
|
+
│ ├── front-page.html # Front page
|
|
150
|
+
│ └── home.html # Blog home
|
|
151
|
+
├── parts/ # Template parts
|
|
152
|
+
│ ├── header.html
|
|
153
|
+
│ ├── footer.html
|
|
154
|
+
│ ├── sidebar.html
|
|
155
|
+
│ └── comments.html
|
|
156
|
+
├── patterns/ # Block patterns
|
|
157
|
+
│ ├── hero.php
|
|
158
|
+
│ ├── call-to-action.php
|
|
159
|
+
│ └── testimonials.php
|
|
160
|
+
├── assets/ # Theme assets
|
|
161
|
+
│ ├── css/
|
|
162
|
+
│ ├── js/
|
|
163
|
+
│ └── images/
|
|
164
|
+
├── inc/ # Include files
|
|
165
|
+
│ └── block-patterns.php
|
|
166
|
+
├── languages/ # Translation files
|
|
167
|
+
├── screenshot.png # Theme screenshot
|
|
168
|
+
└── readme.txt # Theme documentation
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Plugin Structure
|
|
172
|
+
|
|
173
|
+
### Standard Plugin
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
plugin-name/
|
|
177
|
+
├── plugin-name.php # Required: Main plugin file with header
|
|
178
|
+
├── uninstall.php # Cleanup on uninstall
|
|
179
|
+
├── readme.txt # WordPress.org readme
|
|
180
|
+
├── LICENSE # License file
|
|
181
|
+
├── includes/ # Core functionality
|
|
182
|
+
│ ├── class-plugin-name.php
|
|
183
|
+
│ ├── class-loader.php
|
|
184
|
+
│ ├── class-i18n.php
|
|
185
|
+
│ └── functions.php
|
|
186
|
+
├── admin/ # Admin-specific functionality
|
|
187
|
+
│ ├── class-admin.php
|
|
188
|
+
│ ├── partials/
|
|
189
|
+
│ │ └── admin-display.php
|
|
190
|
+
│ ├── css/
|
|
191
|
+
│ │ └── admin.css
|
|
192
|
+
│ └── js/
|
|
193
|
+
│ └── admin.js
|
|
194
|
+
├── public/ # Public-facing functionality
|
|
195
|
+
│ ├── class-public.php
|
|
196
|
+
│ ├── partials/
|
|
197
|
+
│ │ └── public-display.php
|
|
198
|
+
│ ├── css/
|
|
199
|
+
│ │ └── public.css
|
|
200
|
+
│ └── js/
|
|
201
|
+
│ └── public.js
|
|
202
|
+
├── assets/ # Shared assets
|
|
203
|
+
│ ├── images/
|
|
204
|
+
│ └── fonts/
|
|
205
|
+
├── languages/ # Translation files
|
|
206
|
+
│ └── plugin-slug.pot
|
|
207
|
+
└── tests/ # PHPUnit tests
|
|
208
|
+
├── bootstrap.php
|
|
209
|
+
└── test-*.php
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Block Plugin
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
block-plugin/
|
|
216
|
+
├── plugin-name.php # Main plugin file
|
|
217
|
+
├── block.json # Block metadata
|
|
218
|
+
├── package.json # Build dependencies
|
|
219
|
+
├── src/ # Source files
|
|
220
|
+
│ ├── index.js # Block registration
|
|
221
|
+
│ ├── edit.js # Editor component
|
|
222
|
+
│ ├── save.js # Save function
|
|
223
|
+
│ ├── style.scss # Frontend styles
|
|
224
|
+
│ └── editor.scss # Editor styles
|
|
225
|
+
├── build/ # Compiled files (gitignored)
|
|
226
|
+
│ ├── index.js
|
|
227
|
+
│ ├── index.asset.php
|
|
228
|
+
│ ├── style-index.css
|
|
229
|
+
│ └── index.css
|
|
230
|
+
└── languages/
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Gutenberg Block Development
|
|
234
|
+
|
|
235
|
+
### Standalone Block
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
block-name/
|
|
239
|
+
├── block.json # Block metadata
|
|
240
|
+
├── package.json # Dependencies
|
|
241
|
+
├── src/ # Source files
|
|
242
|
+
│ ├── index.js
|
|
243
|
+
│ ├── edit.js
|
|
244
|
+
│ ├── save.js
|
|
245
|
+
│ ├── style.scss
|
|
246
|
+
│ └── editor.scss
|
|
247
|
+
├── build/ # Build output
|
|
248
|
+
└── readme.md
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Best Practices
|
|
252
|
+
|
|
253
|
+
### DO
|
|
254
|
+
|
|
255
|
+
✅ Keep themes in `wp-content/themes/`
|
|
256
|
+
✅ Keep plugins in `wp-content/plugins/`
|
|
257
|
+
✅ Use `mu-plugins/` for critical plugins
|
|
258
|
+
✅ Organize assets in dedicated directories
|
|
259
|
+
✅ Use `inc/` or `includes/` for PHP includes
|
|
260
|
+
✅ Separate admin and public code
|
|
261
|
+
✅ Use `languages/` for translations
|
|
262
|
+
|
|
263
|
+
### DON'T
|
|
264
|
+
|
|
265
|
+
❌ Modify `wp-admin/` or `wp-includes/`
|
|
266
|
+
❌ Store uploads outside `wp-content/uploads/`
|
|
267
|
+
❌ Mix theme and plugin code
|
|
268
|
+
❌ Put sensitive data in public directories
|
|
269
|
+
❌ Hardcode paths (use WordPress functions)
|
|
270
|
+
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# WordPress File Patterns
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document defines key WordPress file patterns, their purposes, and usage guidelines.
|
|
6
|
+
|
|
7
|
+
## Theme Files
|
|
8
|
+
|
|
9
|
+
### Required Files
|
|
10
|
+
|
|
11
|
+
#### style.css
|
|
12
|
+
**Purpose**: Theme stylesheet and metadata
|
|
13
|
+
**Location**: Theme root
|
|
14
|
+
**Required**: Yes
|
|
15
|
+
|
|
16
|
+
**Structure**:
|
|
17
|
+
```css
|
|
18
|
+
/*
|
|
19
|
+
Theme Name: Twenty Twenty-Four
|
|
20
|
+
Theme URI: https://wordpress.org/themes/twentytwentyfour/
|
|
21
|
+
Author: the WordPress team
|
|
22
|
+
Author URI: https://wordpress.org
|
|
23
|
+
Description: A modern block theme
|
|
24
|
+
Requires at least: 6.4
|
|
25
|
+
Tested up to: 6.4
|
|
26
|
+
Requires PHP: 7.0
|
|
27
|
+
Version: 1.0
|
|
28
|
+
License: GNU General Public License v2 or later
|
|
29
|
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
30
|
+
Text Domain: twentytwentyfour
|
|
31
|
+
Tags: blog, one-column, custom-colors, custom-menu, editor-style
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/* Theme styles go here */
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Key Points**:
|
|
38
|
+
- Must be in theme root
|
|
39
|
+
- Header comment is required
|
|
40
|
+
- Contains theme metadata
|
|
41
|
+
- Can contain CSS or be empty (if using separate CSS files)
|
|
42
|
+
|
|
43
|
+
#### functions.php
|
|
44
|
+
**Purpose**: Theme functions and hooks
|
|
45
|
+
**Location**: Theme root
|
|
46
|
+
**Required**: Yes (recommended)
|
|
47
|
+
|
|
48
|
+
**Common Uses**:
|
|
49
|
+
```php
|
|
50
|
+
<?php
|
|
51
|
+
// Theme setup
|
|
52
|
+
function mytheme_setup() {
|
|
53
|
+
// Add theme support
|
|
54
|
+
add_theme_support( 'title-tag' );
|
|
55
|
+
add_theme_support( 'post-thumbnails' );
|
|
56
|
+
add_theme_support( 'html5', array( 'search-form', 'comment-form' ) );
|
|
57
|
+
|
|
58
|
+
// Register menus
|
|
59
|
+
register_nav_menus( array(
|
|
60
|
+
'primary' => __( 'Primary Menu', 'mytheme' ),
|
|
61
|
+
'footer' => __( 'Footer Menu', 'mytheme' ),
|
|
62
|
+
) );
|
|
63
|
+
}
|
|
64
|
+
add_action( 'after_setup_theme', 'mytheme_setup' );
|
|
65
|
+
|
|
66
|
+
// Enqueue scripts and styles
|
|
67
|
+
function mytheme_scripts() {
|
|
68
|
+
wp_enqueue_style( 'mytheme-style', get_stylesheet_uri() );
|
|
69
|
+
wp_enqueue_script( 'mytheme-script', get_template_directory_uri() . '/js/main.js', array(), '1.0', true );
|
|
70
|
+
}
|
|
71
|
+
add_action( 'wp_enqueue_scripts', 'mytheme_scripts' );
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### index.php
|
|
75
|
+
**Purpose**: Main template fallback
|
|
76
|
+
**Location**: Theme root
|
|
77
|
+
**Required**: Yes (classic themes)
|
|
78
|
+
|
|
79
|
+
**Template Hierarchy**: Lowest priority fallback for all template types
|
|
80
|
+
|
|
81
|
+
### Block Theme Files
|
|
82
|
+
|
|
83
|
+
#### theme.json
|
|
84
|
+
**Purpose**: Theme configuration for block themes
|
|
85
|
+
**Location**: Theme root
|
|
86
|
+
**Required**: Yes (block themes)
|
|
87
|
+
|
|
88
|
+
**Structure**:
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"$schema": "https://schemas.wp.org/trunk/theme.json",
|
|
92
|
+
"version": 2,
|
|
93
|
+
"settings": {
|
|
94
|
+
"color": {
|
|
95
|
+
"palette": [
|
|
96
|
+
{
|
|
97
|
+
"slug": "primary",
|
|
98
|
+
"color": "#0073aa",
|
|
99
|
+
"name": "Primary"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"typography": {
|
|
104
|
+
"fontSizes": [
|
|
105
|
+
{
|
|
106
|
+
"slug": "small",
|
|
107
|
+
"size": "14px",
|
|
108
|
+
"name": "Small"
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"styles": {
|
|
114
|
+
"color": {
|
|
115
|
+
"background": "#ffffff",
|
|
116
|
+
"text": "#000000"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### templates/*.html
|
|
123
|
+
**Purpose**: Block templates
|
|
124
|
+
**Location**: `templates/` directory
|
|
125
|
+
**Required**: `index.html` is required
|
|
126
|
+
|
|
127
|
+
**Common Templates**:
|
|
128
|
+
- `index.html` - Main template (required)
|
|
129
|
+
- `single.html` - Single post
|
|
130
|
+
- `page.html` - Page
|
|
131
|
+
- `archive.html` - Archive
|
|
132
|
+
- `404.html` - 404 error
|
|
133
|
+
- `front-page.html` - Front page
|
|
134
|
+
- `home.html` - Blog home
|
|
135
|
+
|
|
136
|
+
#### parts/*.html
|
|
137
|
+
**Purpose**: Reusable template parts
|
|
138
|
+
**Location**: `parts/` directory
|
|
139
|
+
**Required**: No
|
|
140
|
+
|
|
141
|
+
**Common Parts**:
|
|
142
|
+
- `header.html` - Site header
|
|
143
|
+
- `footer.html` - Site footer
|
|
144
|
+
- `sidebar.html` - Sidebar
|
|
145
|
+
- `comments.html` - Comments section
|
|
146
|
+
|
|
147
|
+
### Classic Theme Templates
|
|
148
|
+
|
|
149
|
+
#### Template Hierarchy Files
|
|
150
|
+
|
|
151
|
+
**Single Post**:
|
|
152
|
+
- `single-{post-type}-{slug}.php`
|
|
153
|
+
- `single-{post-type}.php`
|
|
154
|
+
- `single.php`
|
|
155
|
+
- `singular.php`
|
|
156
|
+
- `index.php`
|
|
157
|
+
|
|
158
|
+
**Page**:
|
|
159
|
+
- `page-{slug}.php`
|
|
160
|
+
- `page-{id}.php`
|
|
161
|
+
- `page.php`
|
|
162
|
+
- `singular.php`
|
|
163
|
+
- `index.php`
|
|
164
|
+
|
|
165
|
+
**Archive**:
|
|
166
|
+
- `archive-{post-type}.php`
|
|
167
|
+
- `archive.php`
|
|
168
|
+
- `index.php`
|
|
169
|
+
|
|
170
|
+
**Category**:
|
|
171
|
+
- `category-{slug}.php`
|
|
172
|
+
- `category-{id}.php`
|
|
173
|
+
- `category.php`
|
|
174
|
+
- `archive.php`
|
|
175
|
+
- `index.php`
|
|
176
|
+
|
|
177
|
+
**Tag**:
|
|
178
|
+
- `tag-{slug}.php`
|
|
179
|
+
- `tag-{id}.php`
|
|
180
|
+
- `tag.php`
|
|
181
|
+
- `archive.php`
|
|
182
|
+
- `index.php`
|
|
183
|
+
|
|
184
|
+
**Author**:
|
|
185
|
+
- `author-{nicename}.php`
|
|
186
|
+
- `author-{id}.php`
|
|
187
|
+
- `author.php`
|
|
188
|
+
- `archive.php`
|
|
189
|
+
- `index.php`
|
|
190
|
+
|
|
191
|
+
**Date**:
|
|
192
|
+
- `date.php`
|
|
193
|
+
- `archive.php`
|
|
194
|
+
- `index.php`
|
|
195
|
+
|
|
196
|
+
**Search**:
|
|
197
|
+
- `search.php`
|
|
198
|
+
- `index.php`
|
|
199
|
+
|
|
200
|
+
**404**:
|
|
201
|
+
- `404.php`
|
|
202
|
+
- `index.php`
|
|
203
|
+
|
|
204
|
+
**Front Page**:
|
|
205
|
+
- `front-page.php`
|
|
206
|
+
- `home.php`
|
|
207
|
+
- `index.php`
|
|
208
|
+
|
|
209
|
+
## Plugin Files
|
|
210
|
+
|
|
211
|
+
### Main Plugin File
|
|
212
|
+
|
|
213
|
+
**Purpose**: Plugin entry point with header
|
|
214
|
+
**Location**: Plugin root
|
|
215
|
+
**Naming**: `plugin-name.php` or `plugin-slug.php`
|
|
216
|
+
|
|
217
|
+
**Structure**:
|
|
218
|
+
```php
|
|
219
|
+
<?php
|
|
220
|
+
/**
|
|
221
|
+
* Plugin Name: My Plugin
|
|
222
|
+
* Plugin URI: https://example.com/my-plugin
|
|
223
|
+
* Description: Plugin description
|
|
224
|
+
* Version: 1.0.0
|
|
225
|
+
* Requires at least: 6.0
|
|
226
|
+
* Requires PHP: 7.4
|
|
227
|
+
* Author: Author Name
|
|
228
|
+
* Author URI: https://example.com
|
|
229
|
+
* License: GPL v2 or later
|
|
230
|
+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
231
|
+
* Text Domain: my-plugin
|
|
232
|
+
* Domain Path: /languages
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
// Prevent direct access
|
|
236
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
237
|
+
exit;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Plugin code here
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### uninstall.php
|
|
244
|
+
|
|
245
|
+
**Purpose**: Cleanup on plugin deletion
|
|
246
|
+
**Location**: Plugin root
|
|
247
|
+
**Required**: No (recommended)
|
|
248
|
+
|
|
249
|
+
**Structure**:
|
|
250
|
+
```php
|
|
251
|
+
<?php
|
|
252
|
+
// If uninstall not called from WordPress, exit
|
|
253
|
+
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|
254
|
+
exit;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Delete options
|
|
258
|
+
delete_option( 'my_plugin_option' );
|
|
259
|
+
|
|
260
|
+
// Delete custom tables
|
|
261
|
+
global $wpdb;
|
|
262
|
+
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}my_plugin_table" );
|
|
263
|
+
|
|
264
|
+
// Clear scheduled hooks
|
|
265
|
+
wp_clear_scheduled_hook( 'my_plugin_cron' );
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Block Files
|
|
269
|
+
|
|
270
|
+
### block.json
|
|
271
|
+
|
|
272
|
+
**Purpose**: Block metadata
|
|
273
|
+
**Location**: Block root
|
|
274
|
+
**Required**: Yes (blocks)
|
|
275
|
+
|
|
276
|
+
**Structure**:
|
|
277
|
+
```json
|
|
278
|
+
{
|
|
279
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
280
|
+
"apiVersion": 2,
|
|
281
|
+
"name": "namespace/block-name",
|
|
282
|
+
"title": "Block Title",
|
|
283
|
+
"category": "widgets",
|
|
284
|
+
"icon": "smiley",
|
|
285
|
+
"description": "Block description",
|
|
286
|
+
"keywords": ["keyword1", "keyword2"],
|
|
287
|
+
"version": "1.0.0",
|
|
288
|
+
"textdomain": "block-slug",
|
|
289
|
+
"attributes": {
|
|
290
|
+
"content": {
|
|
291
|
+
"type": "string",
|
|
292
|
+
"source": "html",
|
|
293
|
+
"selector": "p"
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
"supports": {
|
|
297
|
+
"html": false,
|
|
298
|
+
"align": true
|
|
299
|
+
},
|
|
300
|
+
"example": {
|
|
301
|
+
"attributes": {
|
|
302
|
+
"content": "Example content"
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
"editorScript": "file:./index.js",
|
|
306
|
+
"editorStyle": "file:./index.css",
|
|
307
|
+
"style": "file:./style-index.css"
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Configuration Files
|
|
312
|
+
|
|
313
|
+
### wp-config.php
|
|
314
|
+
|
|
315
|
+
**Purpose**: WordPress configuration
|
|
316
|
+
**Location**: WordPress root
|
|
317
|
+
**Required**: Yes
|
|
318
|
+
|
|
319
|
+
**CRITICAL SAFETY RULES**:
|
|
320
|
+
- ❌ NEVER modify database credentials
|
|
321
|
+
- ❌ NEVER commit to version control
|
|
322
|
+
- ✅ READ ONLY for AI operations
|
|
323
|
+
- ✅ Only modify debug settings or add constants
|
|
324
|
+
|
|
325
|
+
**Common Constants**:
|
|
326
|
+
```php
|
|
327
|
+
// Database (READ ONLY)
|
|
328
|
+
define( 'DB_NAME', 'database_name' );
|
|
329
|
+
define( 'DB_USER', 'database_user' );
|
|
330
|
+
define( 'DB_PASSWORD', 'database_password' );
|
|
331
|
+
define( 'DB_HOST', 'localhost' );
|
|
332
|
+
|
|
333
|
+
// Debug (SAFE TO MODIFY)
|
|
334
|
+
define( 'WP_DEBUG', true );
|
|
335
|
+
define( 'WP_DEBUG_LOG', true );
|
|
336
|
+
define( 'WP_DEBUG_DISPLAY', false );
|
|
337
|
+
|
|
338
|
+
// Custom constants (SAFE TO ADD)
|
|
339
|
+
define( 'CUSTOM_CONSTANT', 'value' );
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### .htaccess
|
|
343
|
+
|
|
344
|
+
**Purpose**: Apache configuration
|
|
345
|
+
**Location**: WordPress root
|
|
346
|
+
**Required**: No (Apache only)
|
|
347
|
+
|
|
348
|
+
**Common Rules**:
|
|
349
|
+
```apache
|
|
350
|
+
# BEGIN WordPress
|
|
351
|
+
<IfModule mod_rewrite.c>
|
|
352
|
+
RewriteEngine On
|
|
353
|
+
RewriteBase /
|
|
354
|
+
RewriteRule ^index\.php$ - [L]
|
|
355
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
|
356
|
+
RewriteCond %{REQUEST_FILENAME} !-d
|
|
357
|
+
RewriteRule . /index.php [L]
|
|
358
|
+
</IfModule>
|
|
359
|
+
# END WordPress
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### composer.json
|
|
363
|
+
|
|
364
|
+
**Purpose**: PHP dependency management
|
|
365
|
+
**Location**: Theme/plugin root
|
|
366
|
+
**Required**: No (if using Composer)
|
|
367
|
+
|
|
368
|
+
### package.json
|
|
369
|
+
|
|
370
|
+
**Purpose**: JavaScript dependency management
|
|
371
|
+
**Location**: Theme/plugin/block root
|
|
372
|
+
**Required**: No (if using npm/yarn)
|
|
373
|
+
|
|
374
|
+
**Block Development**:
|
|
375
|
+
```json
|
|
376
|
+
{
|
|
377
|
+
"name": "block-name",
|
|
378
|
+
"version": "1.0.0",
|
|
379
|
+
"scripts": {
|
|
380
|
+
"build": "wp-scripts build",
|
|
381
|
+
"start": "wp-scripts start"
|
|
382
|
+
},
|
|
383
|
+
"devDependencies": {
|
|
384
|
+
"@wordpress/scripts": "^26.0.0"
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
## Translation Files
|
|
390
|
+
|
|
391
|
+
### .pot (Template)
|
|
392
|
+
**Purpose**: Translation template
|
|
393
|
+
**Location**: `languages/` directory
|
|
394
|
+
**Generated**: Yes (using WP-CLI or tools)
|
|
395
|
+
|
|
396
|
+
### .po (Translation)
|
|
397
|
+
**Purpose**: Human-readable translations
|
|
398
|
+
**Location**: `languages/` directory
|
|
399
|
+
|
|
400
|
+
### .mo (Compiled)
|
|
401
|
+
**Purpose**: Machine-readable translations
|
|
402
|
+
**Location**: `languages/` directory
|
|
403
|
+
**Generated**: Yes (from .po files)
|
|
404
|
+
|
|
405
|
+
## Best Practices
|
|
406
|
+
|
|
407
|
+
### File Naming
|
|
408
|
+
|
|
409
|
+
✅ Use lowercase with hyphens: `my-plugin.php`
|
|
410
|
+
✅ Match text domain: `my-plugin` → `my-plugin.php`
|
|
411
|
+
✅ Be descriptive: `class-admin-settings.php`
|
|
412
|
+
❌ Avoid spaces: `My Plugin.php`
|
|
413
|
+
❌ Avoid underscores in slugs: `my_plugin.php`
|
|
414
|
+
|
|
415
|
+
### File Organization
|
|
416
|
+
|
|
417
|
+
✅ Group related files in directories
|
|
418
|
+
✅ Separate admin and public code
|
|
419
|
+
✅ Use `inc/` or `includes/` for PHP includes
|
|
420
|
+
✅ Keep assets in `assets/` or dedicated directories
|
|
421
|
+
❌ Don't mix concerns in single files
|
|
422
|
+
❌ Don't create deeply nested structures
|
|
423
|
+
|