@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,751 @@
|
|
|
1
|
+
# VS Code Integration for WordPress Plugin Development
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This guide provides VS Code configuration for WordPress plugin development including file associations, task suggestions, context menu integrations, snippets, and recommended extensions.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. File Associations
|
|
10
|
+
|
|
11
|
+
### .vscode/settings.json
|
|
12
|
+
|
|
13
|
+
Configure file associations for WordPress-specific files:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"files.associations": {
|
|
18
|
+
"*.php": "php",
|
|
19
|
+
"*.inc": "php",
|
|
20
|
+
"*.module": "php",
|
|
21
|
+
"*.install": "php",
|
|
22
|
+
"*.theme": "php",
|
|
23
|
+
"*.profile": "php",
|
|
24
|
+
"*.test": "php",
|
|
25
|
+
"*.tpl.php": "php",
|
|
26
|
+
"*.twig": "twig",
|
|
27
|
+
"*.scss": "scss",
|
|
28
|
+
"*.sass": "sass",
|
|
29
|
+
"*.less": "less",
|
|
30
|
+
"*.json": "jsonc",
|
|
31
|
+
"composer.lock": "json",
|
|
32
|
+
"*.lock": "json",
|
|
33
|
+
".phpcs.xml": "xml",
|
|
34
|
+
"phpcs.xml": "xml",
|
|
35
|
+
"phpunit.xml": "xml",
|
|
36
|
+
".editorconfig": "editorconfig"
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
"files.exclude": {
|
|
40
|
+
"**/.git": true,
|
|
41
|
+
"**/.svn": true,
|
|
42
|
+
"**/.hg": true,
|
|
43
|
+
"**/CVS": true,
|
|
44
|
+
"**/.DS_Store": true,
|
|
45
|
+
"**/node_modules": true,
|
|
46
|
+
"**/vendor": true,
|
|
47
|
+
"**/.sass-cache": true,
|
|
48
|
+
"**/dist": true,
|
|
49
|
+
"**/build": true
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
"search.exclude": {
|
|
53
|
+
"**/node_modules": true,
|
|
54
|
+
"**/vendor": true,
|
|
55
|
+
"**/dist": true,
|
|
56
|
+
"**/build": true,
|
|
57
|
+
"**/.git": true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 2. Task Suggestions
|
|
65
|
+
|
|
66
|
+
### .vscode/tasks.json
|
|
67
|
+
|
|
68
|
+
Define common WordPress plugin development tasks:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"version": "2.0.0",
|
|
73
|
+
"tasks": [
|
|
74
|
+
{
|
|
75
|
+
"label": "WordPress: Install Dependencies",
|
|
76
|
+
"type": "shell",
|
|
77
|
+
"command": "composer install && npm install",
|
|
78
|
+
"group": "build",
|
|
79
|
+
"presentation": {
|
|
80
|
+
"reveal": "always",
|
|
81
|
+
"panel": "new"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"label": "WordPress: Run PHPUnit Tests",
|
|
86
|
+
"type": "shell",
|
|
87
|
+
"command": "vendor/bin/phpunit",
|
|
88
|
+
"group": "test",
|
|
89
|
+
"presentation": {
|
|
90
|
+
"reveal": "always",
|
|
91
|
+
"panel": "new"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"label": "WordPress: Run PHP CodeSniffer",
|
|
96
|
+
"type": "shell",
|
|
97
|
+
"command": "vendor/bin/phpcs --standard=WordPress .",
|
|
98
|
+
"group": "test",
|
|
99
|
+
"presentation": {
|
|
100
|
+
"reveal": "always",
|
|
101
|
+
"panel": "new"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"label": "WordPress: Fix PHP CodeSniffer Issues",
|
|
106
|
+
"type": "shell",
|
|
107
|
+
"command": "vendor/bin/phpcbf --standard=WordPress .",
|
|
108
|
+
"group": "build",
|
|
109
|
+
"presentation": {
|
|
110
|
+
"reveal": "always",
|
|
111
|
+
"panel": "new"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"label": "WordPress: Build Assets",
|
|
116
|
+
"type": "shell",
|
|
117
|
+
"command": "npm run build",
|
|
118
|
+
"group": "build",
|
|
119
|
+
"presentation": {
|
|
120
|
+
"reveal": "always",
|
|
121
|
+
"panel": "new"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"label": "WordPress: Watch Assets",
|
|
126
|
+
"type": "shell",
|
|
127
|
+
"command": "npm run watch",
|
|
128
|
+
"group": "build",
|
|
129
|
+
"isBackground": true,
|
|
130
|
+
"presentation": {
|
|
131
|
+
"reveal": "always",
|
|
132
|
+
"panel": "new"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"label": "WordPress: Generate POT File",
|
|
137
|
+
"type": "shell",
|
|
138
|
+
"command": "wp i18n make-pot . languages/my-plugin.pot",
|
|
139
|
+
"group": "build",
|
|
140
|
+
"presentation": {
|
|
141
|
+
"reveal": "always",
|
|
142
|
+
"panel": "new"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"label": "WordPress: Activate Plugin",
|
|
147
|
+
"type": "shell",
|
|
148
|
+
"command": "wp plugin activate my-plugin",
|
|
149
|
+
"group": "none",
|
|
150
|
+
"presentation": {
|
|
151
|
+
"reveal": "always",
|
|
152
|
+
"panel": "new"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"label": "WordPress: Deactivate Plugin",
|
|
157
|
+
"type": "shell",
|
|
158
|
+
"command": "wp plugin deactivate my-plugin",
|
|
159
|
+
"group": "none",
|
|
160
|
+
"presentation": {
|
|
161
|
+
"reveal": "always",
|
|
162
|
+
"panel": "new"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"label": "WordPress: Flush Rewrite Rules",
|
|
167
|
+
"type": "shell",
|
|
168
|
+
"command": "wp rewrite flush",
|
|
169
|
+
"group": "none",
|
|
170
|
+
"presentation": {
|
|
171
|
+
"reveal": "always",
|
|
172
|
+
"panel": "new"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 3. Launch Configurations
|
|
182
|
+
|
|
183
|
+
### .vscode/launch.json
|
|
184
|
+
|
|
185
|
+
Configure debugging for WordPress plugins:
|
|
186
|
+
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"version": "0.2.0",
|
|
190
|
+
"configurations": [
|
|
191
|
+
{
|
|
192
|
+
"name": "Listen for Xdebug",
|
|
193
|
+
"type": "php",
|
|
194
|
+
"request": "launch",
|
|
195
|
+
"port": 9003,
|
|
196
|
+
"pathMappings": {
|
|
197
|
+
"/var/www/html/wp-content/plugins/my-plugin": "${workspaceFolder}"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"name": "Launch currently open script",
|
|
202
|
+
"type": "php",
|
|
203
|
+
"request": "launch",
|
|
204
|
+
"program": "${file}",
|
|
205
|
+
"cwd": "${fileDirname}",
|
|
206
|
+
"port": 9003
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 4. Code Snippets
|
|
215
|
+
|
|
216
|
+
### .vscode/wordpress.code-snippets
|
|
217
|
+
|
|
218
|
+
Create WordPress-specific code snippets:
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"WordPress Plugin Header": {
|
|
223
|
+
"prefix": "wp-plugin-header",
|
|
224
|
+
"body": [
|
|
225
|
+
"<?php",
|
|
226
|
+
"/**",
|
|
227
|
+
" * Plugin Name: ${1:Plugin Name}",
|
|
228
|
+
" * Plugin URI: ${2:https://example.com/plugin}",
|
|
229
|
+
" * Description: ${3:Plugin description}",
|
|
230
|
+
" * Version: ${4:1.0.0}",
|
|
231
|
+
" * Requires at least: ${5:5.8}",
|
|
232
|
+
" * Requires PHP: ${6:7.4}",
|
|
233
|
+
" * Author: ${7:Author Name}",
|
|
234
|
+
" * Author URI: ${8:https://example.com}",
|
|
235
|
+
" * License: ${9:GPL v2 or later}",
|
|
236
|
+
" * License URI: ${10:https://www.gnu.org/licenses/gpl-2.0.html}",
|
|
237
|
+
" * Text Domain: ${11:plugin-slug}",
|
|
238
|
+
" * Domain Path: ${12:/languages}",
|
|
239
|
+
" */",
|
|
240
|
+
"",
|
|
241
|
+
"// Exit if accessed directly",
|
|
242
|
+
"if ( ! defined( 'ABSPATH' ) ) {",
|
|
243
|
+
"\texit;",
|
|
244
|
+
"}",
|
|
245
|
+
"",
|
|
246
|
+
"$0"
|
|
247
|
+
],
|
|
248
|
+
"description": "WordPress plugin header"
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
"WordPress Action Hook": {
|
|
252
|
+
"prefix": "wp-action",
|
|
253
|
+
"body": [
|
|
254
|
+
"add_action( '${1:hook_name}', '${2:callback_function}', ${3:10}, ${4:1} );",
|
|
255
|
+
"",
|
|
256
|
+
"function ${2:callback_function}( $${5:arg} ) {",
|
|
257
|
+
"\t$0",
|
|
258
|
+
"}"
|
|
259
|
+
],
|
|
260
|
+
"description": "WordPress action hook"
|
|
261
|
+
},
|
|
262
|
+
|
|
263
|
+
"WordPress Filter Hook": {
|
|
264
|
+
"prefix": "wp-filter",
|
|
265
|
+
"body": [
|
|
266
|
+
"add_filter( '${1:hook_name}', '${2:callback_function}', ${3:10}, ${4:1} );",
|
|
267
|
+
"",
|
|
268
|
+
"function ${2:callback_function}( $${5:value} ) {",
|
|
269
|
+
"\t$0",
|
|
270
|
+
"\treturn $${5:value};",
|
|
271
|
+
"}"
|
|
272
|
+
],
|
|
273
|
+
"description": "WordPress filter hook"
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
"WordPress Shortcode": {
|
|
277
|
+
"prefix": "wp-shortcode",
|
|
278
|
+
"body": [
|
|
279
|
+
"add_shortcode( '${1:shortcode_name}', '${2:callback_function}' );",
|
|
280
|
+
"",
|
|
281
|
+
"function ${2:callback_function}( $atts, $content = null ) {",
|
|
282
|
+
"\t$atts = shortcode_atts(",
|
|
283
|
+
"\t\tarray(",
|
|
284
|
+
"\t\t\t'${3:attribute}' => '${4:default_value}',",
|
|
285
|
+
"\t\t),",
|
|
286
|
+
"\t\t$atts,",
|
|
287
|
+
"\t\t'${1:shortcode_name}'",
|
|
288
|
+
"\t);",
|
|
289
|
+
"",
|
|
290
|
+
"\t$0",
|
|
291
|
+
"",
|
|
292
|
+
"\treturn $output;",
|
|
293
|
+
"}"
|
|
294
|
+
],
|
|
295
|
+
"description": "WordPress shortcode"
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
"WordPress AJAX Handler": {
|
|
299
|
+
"prefix": "wp-ajax",
|
|
300
|
+
"body": [
|
|
301
|
+
"add_action( 'wp_ajax_${1:action_name}', '${2:callback_function}' );",
|
|
302
|
+
"add_action( 'wp_ajax_nopriv_${1:action_name}', '${2:callback_function}' );",
|
|
303
|
+
"",
|
|
304
|
+
"function ${2:callback_function}() {",
|
|
305
|
+
"\tcheck_ajax_referer( '${3:nonce_name}', 'nonce' );",
|
|
306
|
+
"",
|
|
307
|
+
"\t$0",
|
|
308
|
+
"",
|
|
309
|
+
"\twp_send_json_success( $data );",
|
|
310
|
+
"}"
|
|
311
|
+
],
|
|
312
|
+
"description": "WordPress AJAX handler"
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
"WordPress REST Endpoint": {
|
|
316
|
+
"prefix": "wp-rest",
|
|
317
|
+
"body": [
|
|
318
|
+
"add_action( 'rest_api_init', '${1:register_endpoint}' );",
|
|
319
|
+
"",
|
|
320
|
+
"function ${1:register_endpoint}() {",
|
|
321
|
+
"\tregister_rest_route(",
|
|
322
|
+
"\t\t'${2:namespace}/v1',",
|
|
323
|
+
"\t\t'/${3:route}',",
|
|
324
|
+
"\t\tarray(",
|
|
325
|
+
"\t\t\t'methods' => '${4:GET}',",
|
|
326
|
+
"\t\t\t'callback' => '${5:callback_function}',",
|
|
327
|
+
"\t\t\t'permission_callback' => '${6:permission_callback}',",
|
|
328
|
+
"\t\t)",
|
|
329
|
+
"\t);",
|
|
330
|
+
"}",
|
|
331
|
+
"",
|
|
332
|
+
"function ${5:callback_function}( $request ) {",
|
|
333
|
+
"\t$0",
|
|
334
|
+
"\treturn rest_ensure_response( $data );",
|
|
335
|
+
"}",
|
|
336
|
+
"",
|
|
337
|
+
"function ${6:permission_callback}() {",
|
|
338
|
+
"\treturn current_user_can( 'edit_posts' );",
|
|
339
|
+
"}"
|
|
340
|
+
],
|
|
341
|
+
"description": "WordPress REST API endpoint"
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
"WordPress Custom Post Type": {
|
|
345
|
+
"prefix": "wp-cpt",
|
|
346
|
+
"body": [
|
|
347
|
+
"add_action( 'init', '${1:register_post_type}' );",
|
|
348
|
+
"",
|
|
349
|
+
"function ${1:register_post_type}() {",
|
|
350
|
+
"\t$labels = array(",
|
|
351
|
+
"\t\t'name' => _x( '${2:Post Type}', 'Post type general name', '${3:textdomain}' ),",
|
|
352
|
+
"\t\t'singular_name' => _x( '${4:Post}', 'Post type singular name', '${3:textdomain}' ),",
|
|
353
|
+
"\t\t'menu_name' => _x( '${2:Post Type}', 'Admin Menu text', '${3:textdomain}' ),",
|
|
354
|
+
"\t\t'add_new' => __( 'Add New', '${3:textdomain}' ),",
|
|
355
|
+
"\t\t'add_new_item' => __( 'Add New ${4:Post}', '${3:textdomain}' ),",
|
|
356
|
+
"\t\t'edit_item' => __( 'Edit ${4:Post}', '${3:textdomain}' ),",
|
|
357
|
+
"\t\t'new_item' => __( 'New ${4:Post}', '${3:textdomain}' ),",
|
|
358
|
+
"\t\t'view_item' => __( 'View ${4:Post}', '${3:textdomain}' ),",
|
|
359
|
+
"\t\t'all_items' => __( 'All ${2:Post Type}', '${3:textdomain}' ),",
|
|
360
|
+
"\t);",
|
|
361
|
+
"",
|
|
362
|
+
"\t$args = array(",
|
|
363
|
+
"\t\t'labels' => $labels,",
|
|
364
|
+
"\t\t'public' => true,",
|
|
365
|
+
"\t\t'has_archive' => true,",
|
|
366
|
+
"\t\t'show_in_rest' => true,",
|
|
367
|
+
"\t\t'supports' => array( 'title', 'editor', 'thumbnail' ),",
|
|
368
|
+
"\t);",
|
|
369
|
+
"",
|
|
370
|
+
"\tregister_post_type( '${5:post_type_slug}', $args );",
|
|
371
|
+
"}"
|
|
372
|
+
],
|
|
373
|
+
"description": "WordPress custom post type"
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
"WordPress Meta Box": {
|
|
377
|
+
"prefix": "wp-metabox",
|
|
378
|
+
"body": [
|
|
379
|
+
"add_action( 'add_meta_boxes', '${1:add_meta_box}' );",
|
|
380
|
+
"",
|
|
381
|
+
"function ${1:add_meta_box}() {",
|
|
382
|
+
"\tadd_meta_box(",
|
|
383
|
+
"\t\t'${2:metabox_id}',",
|
|
384
|
+
"\t\t__( '${3:Meta Box Title}', '${4:textdomain}' ),",
|
|
385
|
+
"\t\t'${5:render_callback}',",
|
|
386
|
+
"\t\t'${6:post}',",
|
|
387
|
+
"\t\t'${7:normal}',",
|
|
388
|
+
"\t\t'${8:default}'",
|
|
389
|
+
"\t);",
|
|
390
|
+
"}",
|
|
391
|
+
"",
|
|
392
|
+
"function ${5:render_callback}( $post ) {",
|
|
393
|
+
"\twp_nonce_field( '${2:metabox_id}_nonce', '${2:metabox_id}_nonce' );",
|
|
394
|
+
"\t$value = get_post_meta( $post->ID, '_${9:meta_key}', true );",
|
|
395
|
+
"\t$0",
|
|
396
|
+
"}",
|
|
397
|
+
"",
|
|
398
|
+
"add_action( 'save_post', '${10:save_meta_box}' );",
|
|
399
|
+
"",
|
|
400
|
+
"function ${10:save_meta_box}( $post_id ) {",
|
|
401
|
+
"\tif ( ! isset( $_POST['${2:metabox_id}_nonce'] ) ) {",
|
|
402
|
+
"\t\treturn;",
|
|
403
|
+
"\t}",
|
|
404
|
+
"",
|
|
405
|
+
"\tif ( ! wp_verify_nonce( $_POST['${2:metabox_id}_nonce'], '${2:metabox_id}_nonce' ) ) {",
|
|
406
|
+
"\t\treturn;",
|
|
407
|
+
"\t}",
|
|
408
|
+
"",
|
|
409
|
+
"\tif ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {",
|
|
410
|
+
"\t\treturn;",
|
|
411
|
+
"\t}",
|
|
412
|
+
"",
|
|
413
|
+
"\tif ( ! current_user_can( 'edit_post', $post_id ) ) {",
|
|
414
|
+
"\t\treturn;",
|
|
415
|
+
"\t}",
|
|
416
|
+
"",
|
|
417
|
+
"\tif ( isset( $_POST['${9:meta_key}'] ) ) {",
|
|
418
|
+
"\t\tupdate_post_meta( $post_id, '_${9:meta_key}', sanitize_text_field( $_POST['${9:meta_key}'] ) );",
|
|
419
|
+
"\t}",
|
|
420
|
+
"}"
|
|
421
|
+
],
|
|
422
|
+
"description": "WordPress meta box"
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
"WordPress Enqueue Script": {
|
|
426
|
+
"prefix": "wp-enqueue-script",
|
|
427
|
+
"body": [
|
|
428
|
+
"add_action( 'wp_enqueue_scripts', '${1:enqueue_scripts}' );",
|
|
429
|
+
"",
|
|
430
|
+
"function ${1:enqueue_scripts}() {",
|
|
431
|
+
"\twp_enqueue_script(",
|
|
432
|
+
"\t\t'${2:handle}',",
|
|
433
|
+
"\t\tplugins_url( '${3:js/script.js}', __FILE__ ),",
|
|
434
|
+
"\t\tarray( '${4:jquery}' ),",
|
|
435
|
+
"\t\t'${5:1.0.0}',",
|
|
436
|
+
"\t\ttrue",
|
|
437
|
+
"\t);",
|
|
438
|
+
"",
|
|
439
|
+
"\twp_localize_script(",
|
|
440
|
+
"\t\t'${2:handle}',",
|
|
441
|
+
"\t\t'${6:objectName}',",
|
|
442
|
+
"\t\tarray(",
|
|
443
|
+
"\t\t\t'ajax_url' => admin_url( 'admin-ajax.php' ),",
|
|
444
|
+
"\t\t\t'nonce' => wp_create_nonce( '${7:nonce_name}' ),",
|
|
445
|
+
"\t\t)",
|
|
446
|
+
"\t);",
|
|
447
|
+
"}"
|
|
448
|
+
],
|
|
449
|
+
"description": "WordPress enqueue script"
|
|
450
|
+
},
|
|
451
|
+
|
|
452
|
+
"WordPress Enqueue Style": {
|
|
453
|
+
"prefix": "wp-enqueue-style",
|
|
454
|
+
"body": [
|
|
455
|
+
"add_action( 'wp_enqueue_scripts', '${1:enqueue_styles}' );",
|
|
456
|
+
"",
|
|
457
|
+
"function ${1:enqueue_styles}() {",
|
|
458
|
+
"\twp_enqueue_style(",
|
|
459
|
+
"\t\t'${2:handle}',",
|
|
460
|
+
"\t\tplugins_url( '${3:css/style.css}', __FILE__ ),",
|
|
461
|
+
"\t\tarray(),",
|
|
462
|
+
"\t\t'${4:1.0.0}'",
|
|
463
|
+
"\t);",
|
|
464
|
+
"}"
|
|
465
|
+
],
|
|
466
|
+
"description": "WordPress enqueue style"
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
## 5. Recommended Extensions
|
|
474
|
+
|
|
475
|
+
### Essential Extensions
|
|
476
|
+
|
|
477
|
+
Install these VS Code extensions for WordPress development:
|
|
478
|
+
|
|
479
|
+
```json
|
|
480
|
+
{
|
|
481
|
+
"recommendations": [
|
|
482
|
+
"bmewburn.vscode-intelephense-client",
|
|
483
|
+
"xdebug.php-debug",
|
|
484
|
+
"wongjn.php-sniffer",
|
|
485
|
+
"valeryanm.vscode-phpsab",
|
|
486
|
+
"neilbrayfield.php-docblocker",
|
|
487
|
+
"junstyle.php-cs-fixer",
|
|
488
|
+
"wordpresstoolbox.wordpress-toolbox",
|
|
489
|
+
"claudiosanches.woocommerce",
|
|
490
|
+
"dbaeumer.vscode-eslint",
|
|
491
|
+
"esbenp.prettier-vscode",
|
|
492
|
+
"stylelint.vscode-stylelint",
|
|
493
|
+
"bradlc.vscode-tailwindcss",
|
|
494
|
+
"editorconfig.editorconfig",
|
|
495
|
+
"mikestead.dotenv",
|
|
496
|
+
"eamodio.gitlens"
|
|
497
|
+
]
|
|
498
|
+
}
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
Save this as `.vscode/extensions.json` in your plugin directory.
|
|
502
|
+
|
|
503
|
+
### Extension Configuration
|
|
504
|
+
|
|
505
|
+
#### Intelephense Settings
|
|
506
|
+
|
|
507
|
+
```json
|
|
508
|
+
{
|
|
509
|
+
"intelephense.stubs": [
|
|
510
|
+
"wordpress",
|
|
511
|
+
"woocommerce",
|
|
512
|
+
"acf-pro",
|
|
513
|
+
"wordpress-globals",
|
|
514
|
+
"wp-cli",
|
|
515
|
+
"genesis",
|
|
516
|
+
"polylang"
|
|
517
|
+
],
|
|
518
|
+
"intelephense.environment.includePaths": [
|
|
519
|
+
"/path/to/wordpress"
|
|
520
|
+
],
|
|
521
|
+
"intelephense.files.maxSize": 5000000
|
|
522
|
+
}
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
#### PHP CodeSniffer Settings
|
|
526
|
+
|
|
527
|
+
```json
|
|
528
|
+
{
|
|
529
|
+
"phpSniffer.standard": "WordPress",
|
|
530
|
+
"phpSniffer.executablesFolder": "vendor/bin/",
|
|
531
|
+
"phpSniffer.autoDetect": true,
|
|
532
|
+
"phpSniffer.run": "onSave"
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
#### PHP CS Fixer Settings
|
|
537
|
+
|
|
538
|
+
```json
|
|
539
|
+
{
|
|
540
|
+
"php-cs-fixer.executablePath": "${workspaceFolder}/vendor/bin/php-cs-fixer",
|
|
541
|
+
"php-cs-fixer.onsave": true,
|
|
542
|
+
"php-cs-fixer.rules": "@WordPress",
|
|
543
|
+
"php-cs-fixer.config": ".php-cs-fixer.dist.php"
|
|
544
|
+
}
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
## 6. Context Menu Integrations
|
|
550
|
+
|
|
551
|
+
### Custom Context Menu Commands
|
|
552
|
+
|
|
553
|
+
Add to `.vscode/settings.json`:
|
|
554
|
+
|
|
555
|
+
```json
|
|
556
|
+
{
|
|
557
|
+
"explorer.fileNesting.enabled": true,
|
|
558
|
+
"explorer.fileNesting.patterns": {
|
|
559
|
+
"*.php": "${capture}.test.php, ${capture}.spec.php",
|
|
560
|
+
"*.js": "${capture}.min.js, ${capture}.map",
|
|
561
|
+
"*.css": "${capture}.min.css, ${capture}.map",
|
|
562
|
+
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml",
|
|
563
|
+
"composer.json": "composer.lock"
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
---
|
|
569
|
+
|
|
570
|
+
## 7. Workspace Settings
|
|
571
|
+
|
|
572
|
+
### Complete .vscode/settings.json
|
|
573
|
+
|
|
574
|
+
Comprehensive VS Code settings for WordPress plugin development:
|
|
575
|
+
|
|
576
|
+
```json
|
|
577
|
+
{
|
|
578
|
+
"editor.tabSize": 4,
|
|
579
|
+
"editor.insertSpaces": false,
|
|
580
|
+
"editor.detectIndentation": true,
|
|
581
|
+
"editor.formatOnSave": true,
|
|
582
|
+
"editor.codeActionsOnSave": {
|
|
583
|
+
"source.fixAll.eslint": true,
|
|
584
|
+
"source.fixAll.stylelint": true
|
|
585
|
+
},
|
|
586
|
+
|
|
587
|
+
"[php]": {
|
|
588
|
+
"editor.defaultFormatter": "bmewburn.vscode-intelephense-client",
|
|
589
|
+
"editor.tabSize": 4,
|
|
590
|
+
"editor.insertSpaces": false
|
|
591
|
+
},
|
|
592
|
+
|
|
593
|
+
"[javascript]": {
|
|
594
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
595
|
+
"editor.tabSize": 2,
|
|
596
|
+
"editor.insertSpaces": true
|
|
597
|
+
},
|
|
598
|
+
|
|
599
|
+
"[json]": {
|
|
600
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
601
|
+
"editor.tabSize": 2,
|
|
602
|
+
"editor.insertSpaces": true
|
|
603
|
+
},
|
|
604
|
+
|
|
605
|
+
"[css]": {
|
|
606
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
607
|
+
"editor.tabSize": 2,
|
|
608
|
+
"editor.insertSpaces": true
|
|
609
|
+
},
|
|
610
|
+
|
|
611
|
+
"[scss]": {
|
|
612
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
613
|
+
"editor.tabSize": 2,
|
|
614
|
+
"editor.insertSpaces": true
|
|
615
|
+
},
|
|
616
|
+
|
|
617
|
+
"php.validate.executablePath": "/usr/bin/php",
|
|
618
|
+
"php.suggest.basic": false,
|
|
619
|
+
|
|
620
|
+
"intelephense.stubs": [
|
|
621
|
+
"wordpress",
|
|
622
|
+
"woocommerce"
|
|
623
|
+
],
|
|
624
|
+
|
|
625
|
+
"phpSniffer.standard": "WordPress",
|
|
626
|
+
"phpSniffer.executablesFolder": "vendor/bin/",
|
|
627
|
+
|
|
628
|
+
"files.associations": {
|
|
629
|
+
"*.php": "php"
|
|
630
|
+
},
|
|
631
|
+
|
|
632
|
+
"files.exclude": {
|
|
633
|
+
"**/node_modules": true,
|
|
634
|
+
"**/vendor": true
|
|
635
|
+
},
|
|
636
|
+
|
|
637
|
+
"search.exclude": {
|
|
638
|
+
"**/node_modules": true,
|
|
639
|
+
"**/vendor": true,
|
|
640
|
+
"**/dist": true,
|
|
641
|
+
"**/build": true
|
|
642
|
+
},
|
|
643
|
+
|
|
644
|
+
"emmet.includeLanguages": {
|
|
645
|
+
"php": "html"
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
---
|
|
651
|
+
|
|
652
|
+
## 8. Keyboard Shortcuts
|
|
653
|
+
|
|
654
|
+
### .vscode/keybindings.json
|
|
655
|
+
|
|
656
|
+
Custom keyboard shortcuts for WordPress development:
|
|
657
|
+
|
|
658
|
+
```json
|
|
659
|
+
[
|
|
660
|
+
{
|
|
661
|
+
"key": "ctrl+shift+t",
|
|
662
|
+
"command": "workbench.action.tasks.runTask",
|
|
663
|
+
"args": "WordPress: Run PHPUnit Tests"
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
"key": "ctrl+shift+c",
|
|
667
|
+
"command": "workbench.action.tasks.runTask",
|
|
668
|
+
"args": "WordPress: Run PHP CodeSniffer"
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
"key": "ctrl+shift+f",
|
|
672
|
+
"command": "workbench.action.tasks.runTask",
|
|
673
|
+
"args": "WordPress: Fix PHP CodeSniffer Issues"
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
"key": "ctrl+shift+b",
|
|
677
|
+
"command": "workbench.action.tasks.runTask",
|
|
678
|
+
"args": "WordPress: Build Assets"
|
|
679
|
+
}
|
|
680
|
+
]
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
---
|
|
684
|
+
|
|
685
|
+
## 9. Project Templates
|
|
686
|
+
|
|
687
|
+
### WordPress Plugin Workspace Template
|
|
688
|
+
|
|
689
|
+
Create a workspace file `.vscode/wordpress-plugin.code-workspace`:
|
|
690
|
+
|
|
691
|
+
```json
|
|
692
|
+
{
|
|
693
|
+
"folders": [
|
|
694
|
+
{
|
|
695
|
+
"path": "."
|
|
696
|
+
}
|
|
697
|
+
],
|
|
698
|
+
"settings": {
|
|
699
|
+
"files.associations": {
|
|
700
|
+
"*.php": "php"
|
|
701
|
+
},
|
|
702
|
+
"intelephense.stubs": [
|
|
703
|
+
"wordpress",
|
|
704
|
+
"woocommerce"
|
|
705
|
+
],
|
|
706
|
+
"phpSniffer.standard": "WordPress"
|
|
707
|
+
},
|
|
708
|
+
"extensions": {
|
|
709
|
+
"recommendations": [
|
|
710
|
+
"bmewburn.vscode-intelephense-client",
|
|
711
|
+
"xdebug.php-debug",
|
|
712
|
+
"wongjn.php-sniffer"
|
|
713
|
+
]
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
---
|
|
719
|
+
|
|
720
|
+
## Summary
|
|
721
|
+
|
|
722
|
+
**Key VS Code configurations for WordPress plugin development:**
|
|
723
|
+
|
|
724
|
+
1. **File associations** - Proper syntax highlighting
|
|
725
|
+
2. **Tasks** - Automated build and test commands
|
|
726
|
+
3. **Snippets** - Quick code generation
|
|
727
|
+
4. **Extensions** - Enhanced development experience
|
|
728
|
+
5. **Debugging** - Xdebug integration
|
|
729
|
+
6. **Code quality** - PHP CodeSniffer integration
|
|
730
|
+
7. **Workspace settings** - Consistent formatting
|
|
731
|
+
|
|
732
|
+
**Quick setup:**
|
|
733
|
+
|
|
734
|
+
```bash
|
|
735
|
+
# Create .vscode directory
|
|
736
|
+
mkdir .vscode
|
|
737
|
+
|
|
738
|
+
# Copy configuration files
|
|
739
|
+
cp examples/vscode/settings.json .vscode/
|
|
740
|
+
cp examples/vscode/tasks.json .vscode/
|
|
741
|
+
cp examples/vscode/launch.json .vscode/
|
|
742
|
+
cp examples/vscode/extensions.json .vscode/
|
|
743
|
+
cp examples/vscode/wordpress.code-snippets .vscode/
|
|
744
|
+
|
|
745
|
+
# Install recommended extensions
|
|
746
|
+
code --install-extension bmewburn.vscode-intelephense-client
|
|
747
|
+
code --install-extension xdebug.php-debug
|
|
748
|
+
code --install-extension wongjn.php-sniffer
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
|