@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.
Files changed (79) hide show
  1. package/augment-extensions/domain-rules/wordpress/README.md +163 -0
  2. package/augment-extensions/domain-rules/wordpress/module.json +32 -0
  3. package/augment-extensions/domain-rules/wordpress/rules/coding-standards.md +617 -0
  4. package/augment-extensions/domain-rules/wordpress/rules/directory-structure.md +270 -0
  5. package/augment-extensions/domain-rules/wordpress/rules/file-patterns.md +423 -0
  6. package/augment-extensions/domain-rules/wordpress/rules/gutenberg-blocks.md +493 -0
  7. package/augment-extensions/domain-rules/wordpress/rules/performance.md +568 -0
  8. package/augment-extensions/domain-rules/wordpress/rules/plugin-development.md +510 -0
  9. package/augment-extensions/domain-rules/wordpress/rules/project-detection.md +251 -0
  10. package/augment-extensions/domain-rules/wordpress/rules/rest-api.md +501 -0
  11. package/augment-extensions/domain-rules/wordpress/rules/security.md +564 -0
  12. package/augment-extensions/domain-rules/wordpress/rules/theme-development.md +388 -0
  13. package/augment-extensions/domain-rules/wordpress/rules/woocommerce.md +441 -0
  14. package/augment-extensions/domain-rules/wordpress-plugin/README.md +139 -0
  15. package/augment-extensions/domain-rules/wordpress-plugin/examples/ajax-plugin.md +1599 -0
  16. package/augment-extensions/domain-rules/wordpress-plugin/examples/custom-post-type-plugin.md +1727 -0
  17. package/augment-extensions/domain-rules/wordpress-plugin/examples/gutenberg-block-plugin.md +428 -0
  18. package/augment-extensions/domain-rules/wordpress-plugin/examples/gutenberg-block.md +422 -0
  19. package/augment-extensions/domain-rules/wordpress-plugin/examples/mvc-plugin.md +1623 -0
  20. package/augment-extensions/domain-rules/wordpress-plugin/examples/object-oriented-plugin.md +1343 -0
  21. package/augment-extensions/domain-rules/wordpress-plugin/examples/rest-endpoint.md +734 -0
  22. package/augment-extensions/domain-rules/wordpress-plugin/examples/settings-page-plugin.md +1350 -0
  23. package/augment-extensions/domain-rules/wordpress-plugin/examples/simple-procedural-plugin.md +503 -0
  24. package/augment-extensions/domain-rules/wordpress-plugin/examples/singleton-plugin.md +971 -0
  25. package/augment-extensions/domain-rules/wordpress-plugin/module.json +53 -0
  26. package/augment-extensions/domain-rules/wordpress-plugin/rules/activation-hooks.md +770 -0
  27. package/augment-extensions/domain-rules/wordpress-plugin/rules/admin-interface.md +874 -0
  28. package/augment-extensions/domain-rules/wordpress-plugin/rules/ajax-handlers.md +629 -0
  29. package/augment-extensions/domain-rules/wordpress-plugin/rules/asset-management.md +559 -0
  30. package/augment-extensions/domain-rules/wordpress-plugin/rules/context-providers.md +709 -0
  31. package/augment-extensions/domain-rules/wordpress-plugin/rules/cron-jobs.md +736 -0
  32. package/augment-extensions/domain-rules/wordpress-plugin/rules/database-management.md +1057 -0
  33. package/augment-extensions/domain-rules/wordpress-plugin/rules/documentation-standards.md +463 -0
  34. package/augment-extensions/domain-rules/wordpress-plugin/rules/frontend-functionality.md +478 -0
  35. package/augment-extensions/domain-rules/wordpress-plugin/rules/gutenberg-blocks.md +818 -0
  36. package/augment-extensions/domain-rules/wordpress-plugin/rules/internationalization.md +416 -0
  37. package/augment-extensions/domain-rules/wordpress-plugin/rules/migration.md +667 -0
  38. package/augment-extensions/domain-rules/wordpress-plugin/rules/performance-optimization.md +878 -0
  39. package/augment-extensions/domain-rules/wordpress-plugin/rules/plugin-architecture.md +693 -0
  40. package/augment-extensions/domain-rules/wordpress-plugin/rules/plugin-structure.md +352 -0
  41. package/augment-extensions/domain-rules/wordpress-plugin/rules/rest-api.md +818 -0
  42. package/augment-extensions/domain-rules/wordpress-plugin/rules/scaffolding-workflow.md +624 -0
  43. package/augment-extensions/domain-rules/wordpress-plugin/rules/security-best-practices.md +866 -0
  44. package/augment-extensions/domain-rules/wordpress-plugin/rules/testing-patterns.md +1165 -0
  45. package/augment-extensions/domain-rules/wordpress-plugin/rules/testing.md +414 -0
  46. package/augment-extensions/domain-rules/wordpress-plugin/rules/vscode-integration.md +751 -0
  47. package/augment-extensions/domain-rules/wordpress-plugin/rules/woocommerce-integration.md +949 -0
  48. package/augment-extensions/domain-rules/wordpress-plugin/rules/wordpress-org-submission.md +458 -0
  49. package/augment-extensions/examples/gutenberg-block-plugin/README.md +101 -0
  50. package/augment-extensions/examples/gutenberg-block-plugin/examples/testimonial-block.md +428 -0
  51. package/augment-extensions/examples/gutenberg-block-plugin/module.json +40 -0
  52. package/augment-extensions/examples/rest-api-plugin/README.md +98 -0
  53. package/augment-extensions/examples/rest-api-plugin/examples/task-manager-api.md +1299 -0
  54. package/augment-extensions/examples/rest-api-plugin/module.json +40 -0
  55. package/augment-extensions/examples/woocommerce-extension/README.md +98 -0
  56. package/augment-extensions/examples/woocommerce-extension/examples/product-customizer.md +763 -0
  57. package/augment-extensions/examples/woocommerce-extension/module.json +40 -0
  58. package/augment-extensions/workflows/wordpress-plugin/README.md +232 -0
  59. package/augment-extensions/workflows/wordpress-plugin/ai-prompts.md +839 -0
  60. package/augment-extensions/workflows/wordpress-plugin/bead-decomposition-patterns.md +854 -0
  61. package/augment-extensions/workflows/wordpress-plugin/examples/complete-plugin-example.md +540 -0
  62. package/augment-extensions/workflows/wordpress-plugin/examples/custom-post-type-example.md +1083 -0
  63. package/augment-extensions/workflows/wordpress-plugin/examples/feature-addition-workflow.md +669 -0
  64. package/augment-extensions/workflows/wordpress-plugin/examples/plugin-creation-workflow.md +597 -0
  65. package/augment-extensions/workflows/wordpress-plugin/examples/secure-form-handler-example.md +925 -0
  66. package/augment-extensions/workflows/wordpress-plugin/examples/security-audit-workflow.md +752 -0
  67. package/augment-extensions/workflows/wordpress-plugin/examples/wordpress-org-submission-workflow.md +773 -0
  68. package/augment-extensions/workflows/wordpress-plugin/module.json +49 -0
  69. package/augment-extensions/workflows/wordpress-plugin/rules/best-practices.md +942 -0
  70. package/augment-extensions/workflows/wordpress-plugin/rules/development-workflow.md +702 -0
  71. package/augment-extensions/workflows/wordpress-plugin/rules/submission-workflow.md +728 -0
  72. package/augment-extensions/workflows/wordpress-plugin/rules/testing-workflow.md +775 -0
  73. package/cli/dist/cli.js +5 -1
  74. package/cli/dist/cli.js.map +1 -1
  75. package/cli/dist/commands/show.d.ts.map +1 -1
  76. package/cli/dist/commands/show.js +41 -0
  77. package/cli/dist/commands/show.js.map +1 -1
  78. package/modules.md +52 -0
  79. package/package.json +1 -1
@@ -0,0 +1,493 @@
1
+ # Gutenberg Block Development Workflow
2
+
3
+ ## Overview
4
+
5
+ This document provides step-by-step workflows for developing custom Gutenberg blocks using modern WordPress block development tools.
6
+
7
+ ## Workflow 1: Create New Block with @wordpress/create-block
8
+
9
+ ### Step 1: Initialize Block
10
+
11
+ ```bash
12
+ # Navigate to plugins directory
13
+ cd wp-content/plugins
14
+
15
+ # Create new block (interactive)
16
+ npx @wordpress/create-block my-custom-block
17
+
18
+ # Or with options
19
+ npx @wordpress/create-block my-custom-block \
20
+ --namespace="my-company" \
21
+ --title="My Custom Block" \
22
+ --category="widgets" \
23
+ --template="@wordpress/create-block/block-template"
24
+ ```
25
+
26
+ This creates:
27
+ ```
28
+ my-custom-block/
29
+ ├── build/ # Compiled files (gitignored)
30
+ ├── src/ # Source files
31
+ │ ├── index.js # Block registration
32
+ │ ├── edit.js # Editor component
33
+ │ ├── save.js # Save function
34
+ │ ├── style.scss # Frontend styles
35
+ │ └── editor.scss # Editor styles
36
+ ├── block.json # Block metadata
37
+ ├── my-custom-block.php # Main plugin file
38
+ ├── package.json # Dependencies
39
+ └── readme.txt # Plugin readme
40
+ ```
41
+
42
+ ### Step 2: Configure block.json
43
+
44
+ **block.json**:
45
+ ```json
46
+ {
47
+ "$schema": "https://schemas.wp.org/trunk/block.json",
48
+ "apiVersion": 2,
49
+ "name": "my-company/my-custom-block",
50
+ "version": "1.0.0",
51
+ "title": "My Custom Block",
52
+ "category": "widgets",
53
+ "icon": "smiley",
54
+ "description": "A custom Gutenberg block",
55
+ "keywords": ["custom", "block"],
56
+ "supports": {
57
+ "html": false,
58
+ "align": true,
59
+ "color": {
60
+ "background": true,
61
+ "text": true
62
+ },
63
+ "spacing": {
64
+ "padding": true,
65
+ "margin": true
66
+ }
67
+ },
68
+ "attributes": {
69
+ "content": {
70
+ "type": "string",
71
+ "source": "html",
72
+ "selector": "p"
73
+ },
74
+ "alignment": {
75
+ "type": "string",
76
+ "default": "left"
77
+ }
78
+ },
79
+ "example": {
80
+ "attributes": {
81
+ "content": "This is example content"
82
+ }
83
+ },
84
+ "textdomain": "my-custom-block",
85
+ "editorScript": "file:./index.js",
86
+ "editorStyle": "file:./index.css",
87
+ "style": "file:./style-index.css"
88
+ }
89
+ ```
90
+
91
+ ### Step 3: Implement Edit Component
92
+
93
+ **src/edit.js**:
94
+ ```jsx
95
+ import { __ } from '@wordpress/i18n';
96
+ import { useBlockProps, RichText, AlignmentToolbar, BlockControls } from '@wordpress/block-editor';
97
+ import './editor.scss';
98
+
99
+ export default function Edit({ attributes, setAttributes }) {
100
+ const { content, alignment } = attributes;
101
+
102
+ const blockProps = useBlockProps({
103
+ className: `has-text-align-${alignment}`,
104
+ });
105
+
106
+ return (
107
+ <>
108
+ <BlockControls>
109
+ <AlignmentToolbar
110
+ value={alignment}
111
+ onChange={(newAlignment) => setAttributes({ alignment: newAlignment })}
112
+ />
113
+ </BlockControls>
114
+
115
+ <div {...blockProps}>
116
+ <RichText
117
+ tagName="p"
118
+ value={content}
119
+ onChange={(newContent) => setAttributes({ content: newContent })}
120
+ placeholder={__('Enter your content...', 'my-custom-block')}
121
+ />
122
+ </div>
123
+ </>
124
+ );
125
+ }
126
+ ```
127
+
128
+ ### Step 4: Implement Save Function
129
+
130
+ **src/save.js**:
131
+ ```jsx
132
+ import { useBlockProps, RichText } from '@wordpress/block-editor';
133
+
134
+ export default function save({ attributes }) {
135
+ const { content, alignment } = attributes;
136
+
137
+ const blockProps = useBlockProps.save({
138
+ className: `has-text-align-${alignment}`,
139
+ });
140
+
141
+ return (
142
+ <div {...blockProps}>
143
+ <RichText.Content tagName="p" value={content} />
144
+ </div>
145
+ );
146
+ }
147
+ ```
148
+
149
+ ### Step 5: Register Block
150
+
151
+ **src/index.js**:
152
+ ```js
153
+ import { registerBlockType } from '@wordpress/blocks';
154
+ import './style.scss';
155
+ import Edit from './edit';
156
+ import save from './save';
157
+ import metadata from './block.json';
158
+
159
+ registerBlockType(metadata.name, {
160
+ edit: Edit,
161
+ save,
162
+ });
163
+ ```
164
+
165
+ ### Step 6: Build and Test
166
+
167
+ ```bash
168
+ # Development mode (watch for changes)
169
+ npm start
170
+
171
+ # Production build
172
+ npm run build
173
+ ```
174
+
175
+ Activate the plugin in WordPress admin and test the block in the editor.
176
+
177
+ ## Workflow 2: Add Block Controls and Settings
178
+
179
+ ### Inspector Controls (Sidebar)
180
+
181
+ **src/edit.js**:
182
+ ```jsx
183
+ import { InspectorControls } from '@wordpress/block-editor';
184
+ import { PanelBody, TextControl, ToggleControl, RangeControl } from '@wordpress/components';
185
+
186
+ export default function Edit({ attributes, setAttributes }) {
187
+ const { content, showIcon, iconSize } = attributes;
188
+
189
+ return (
190
+ <>
191
+ <InspectorControls>
192
+ <PanelBody title={__('Settings', 'my-custom-block')}>
193
+ <ToggleControl
194
+ label={__('Show Icon', 'my-custom-block')}
195
+ checked={showIcon}
196
+ onChange={(value) => setAttributes({ showIcon: value })}
197
+ />
198
+
199
+ {showIcon && (
200
+ <RangeControl
201
+ label={__('Icon Size', 'my-custom-block')}
202
+ value={iconSize}
203
+ onChange={(value) => setAttributes({ iconSize: value })}
204
+ min={10}
205
+ max={100}
206
+ />
207
+ )}
208
+
209
+ <TextControl
210
+ label={__('Custom Class', 'my-custom-block')}
211
+ value={attributes.customClass}
212
+ onChange={(value) => setAttributes({ customClass: value })}
213
+ />
214
+ </PanelBody>
215
+ </InspectorControls>
216
+
217
+ {/* Block content */}
218
+ </>
219
+ );
220
+ }
221
+ ```
222
+
223
+ ### Block Toolbar Controls
224
+
225
+ ```jsx
226
+ import { BlockControls, AlignmentToolbar } from '@wordpress/block-editor';
227
+ import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
228
+
229
+ <BlockControls>
230
+ <AlignmentToolbar
231
+ value={alignment}
232
+ onChange={(newAlignment) => setAttributes({ alignment: newAlignment })}
233
+ />
234
+
235
+ <ToolbarGroup>
236
+ <ToolbarButton
237
+ icon="admin-links"
238
+ label={__('Add Link', 'my-custom-block')}
239
+ onClick={() => setAttributes({ hasLink: !hasLink })}
240
+ isActive={hasLink}
241
+ />
242
+ </ToolbarGroup>
243
+ </BlockControls>
244
+ ```
245
+
246
+ ## Workflow 3: Dynamic Blocks (Server-Side Rendering)
247
+
248
+ ### Step 1: Configure block.json for Dynamic Block
249
+
250
+ ```json
251
+ {
252
+ "apiVersion": 2,
253
+ "name": "my-company/dynamic-block",
254
+ "title": "Dynamic Block",
255
+ "category": "widgets",
256
+ "attributes": {
257
+ "numberOfPosts": {
258
+ "type": "number",
259
+ "default": 5
260
+ }
261
+ },
262
+ "editorScript": "file:./index.js",
263
+ "render": "file:./render.php"
264
+ }
265
+ ```
266
+
267
+ ### Step 2: Create Render Template
268
+
269
+ **src/render.php**:
270
+ ```php
271
+ <?php
272
+ /**
273
+ * Server-side rendering for dynamic block
274
+ *
275
+ * @param array $attributes Block attributes
276
+ * @param string $content Block content
277
+ * @param WP_Block $block Block instance
278
+ */
279
+
280
+ $number_of_posts = isset( $attributes['numberOfPosts'] ) ? absint( $attributes['numberOfPosts'] ) : 5;
281
+
282
+ $args = array(
283
+ 'posts_per_page' => $number_of_posts,
284
+ 'post_status' => 'publish',
285
+ );
286
+
287
+ $query = new WP_Query( $args );
288
+
289
+ if ( ! $query->have_posts() ) {
290
+ return '<p>' . __( 'No posts found.', 'my-custom-block' ) . '</p>';
291
+ }
292
+
293
+ $output = '<div ' . get_block_wrapper_attributes() . '>';
294
+ $output .= '<ul class="dynamic-block-list">';
295
+
296
+ while ( $query->have_posts() ) {
297
+ $query->the_post();
298
+ $output .= '<li>';
299
+ $output .= '<a href="' . esc_url( get_permalink() ) . '">';
300
+ $output .= esc_html( get_the_title() );
301
+ $output .= '</a>';
302
+ $output .= '</li>';
303
+ }
304
+
305
+ $output .= '</ul>';
306
+ $output .= '</div>';
307
+
308
+ wp_reset_postdata();
309
+
310
+ echo $output;
311
+ ```
312
+
313
+ ### Step 3: Create Edit Component for Dynamic Block
314
+
315
+ **src/edit.js**:
316
+ ```jsx
317
+ import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
318
+ import { PanelBody, RangeControl } from '@wordpress/components';
319
+ import { useSelect } from '@wordpress/data';
320
+ import { __ } from '@wordpress/i18n';
321
+
322
+ export default function Edit({ attributes, setAttributes }) {
323
+ const { numberOfPosts } = attributes;
324
+
325
+ const posts = useSelect((select) => {
326
+ return select('core').getEntityRecords('postType', 'post', {
327
+ per_page: numberOfPosts,
328
+ });
329
+ }, [numberOfPosts]);
330
+
331
+ const blockProps = useBlockProps();
332
+
333
+ return (
334
+ <>
335
+ <InspectorControls>
336
+ <PanelBody title={__('Settings', 'my-custom-block')}>
337
+ <RangeControl
338
+ label={__('Number of Posts', 'my-custom-block')}
339
+ value={numberOfPosts}
340
+ onChange={(value) => setAttributes({ numberOfPosts: value })}
341
+ min={1}
342
+ max={10}
343
+ />
344
+ </PanelBody>
345
+ </InspectorControls>
346
+
347
+ <div {...blockProps}>
348
+ {!posts && <p>{__('Loading...', 'my-custom-block')}</p>}
349
+
350
+ {posts && posts.length === 0 && (
351
+ <p>{__('No posts found.', 'my-custom-block')}</p>
352
+ )}
353
+
354
+ {posts && posts.length > 0 && (
355
+ <ul className="dynamic-block-list">
356
+ {posts.map((post) => (
357
+ <li key={post.id}>
358
+ <a href={post.link}>{post.title.rendered}</a>
359
+ </li>
360
+ ))}
361
+ </ul>
362
+ )}
363
+ </div>
364
+ </>
365
+ );
366
+ }
367
+ ```
368
+
369
+ ### Step 4: No Save Function for Dynamic Blocks
370
+
371
+ **src/save.js**:
372
+ ```jsx
373
+ // Dynamic blocks don't need a save function
374
+ export default function save() {
375
+ return null;
376
+ }
377
+ ```
378
+
379
+ ## Workflow 4: Block Variations and Styles
380
+
381
+ ### Block Variations
382
+
383
+ **src/index.js**:
384
+ ```js
385
+ import { registerBlockType, registerBlockVariation } from '@wordpress/blocks';
386
+
387
+ registerBlockType(metadata.name, {
388
+ edit: Edit,
389
+ save,
390
+ });
391
+
392
+ // Register variations
393
+ registerBlockVariation('my-company/my-custom-block', {
394
+ name: 'highlighted',
395
+ title: __('Highlighted Block', 'my-custom-block'),
396
+ description: __('A highlighted version of the block', 'my-custom-block'),
397
+ icon: 'star-filled',
398
+ attributes: {
399
+ className: 'is-style-highlighted',
400
+ },
401
+ });
402
+ ```
403
+
404
+ ### Block Styles
405
+
406
+ **src/index.js**:
407
+ ```js
408
+ import { registerBlockStyle } from '@wordpress/blocks';
409
+
410
+ registerBlockStyle('my-company/my-custom-block', {
411
+ name: 'rounded',
412
+ label: __('Rounded', 'my-custom-block'),
413
+ });
414
+
415
+ registerBlockStyle('my-company/my-custom-block', {
416
+ name: 'shadow',
417
+ label: __('Shadow', 'my-custom-block'),
418
+ });
419
+ ```
420
+
421
+ **src/style.scss**:
422
+ ```scss
423
+ .wp-block-my-company-my-custom-block {
424
+ &.is-style-rounded {
425
+ border-radius: 10px;
426
+ }
427
+
428
+ &.is-style-shadow {
429
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
430
+ }
431
+ }
432
+ ```
433
+
434
+ ## Testing and Production
435
+
436
+ ### Development Workflow
437
+
438
+ ```bash
439
+ # Start development server
440
+ npm start
441
+
442
+ # This watches for changes and rebuilds automatically
443
+ ```
444
+
445
+ ### Production Build
446
+
447
+ ```bash
448
+ # Build for production
449
+ npm run build
450
+
451
+ # This creates optimized files in build/ directory
452
+ ```
453
+
454
+ ### Testing Checklist
455
+
456
+ ✅ Block appears in inserter
457
+ ✅ Block can be inserted into editor
458
+ ✅ All controls work correctly
459
+ ✅ Block saves and loads correctly
460
+ ✅ Frontend display matches editor
461
+ ✅ Styles load correctly
462
+ ✅ Block works in different contexts (posts, pages, widgets)
463
+ ✅ Block is accessible (keyboard navigation, screen readers)
464
+ ✅ Block works with different themes
465
+ ✅ No console errors
466
+
467
+ ## Best Practices
468
+
469
+ ### DO
470
+
471
+ ✅ Use `block.json` for metadata
472
+ ✅ Use `@wordpress/scripts` for building
473
+ ✅ Follow WordPress coding standards
474
+ ✅ Use translation functions
475
+ ✅ Provide block examples
476
+ ✅ Support common block features (align, color, spacing)
477
+ ✅ Test with different themes
478
+ ✅ Optimize for performance
479
+ ✅ Document block usage
480
+ ✅ Version control source files, not build files
481
+
482
+ ### DON'T
483
+
484
+ ❌ Hardcode values that should be configurable
485
+ ❌ Use inline styles
486
+ ❌ Ignore accessibility
487
+ ❌ Skip error handling
488
+ ❌ Commit build files to version control
489
+ ❌ Use deprecated WordPress functions
490
+ ❌ Forget to sanitize/escape data
491
+ ❌ Create overly complex blocks
492
+ ❌ Ignore mobile responsiveness
493
+