wordpress-agent-kit 0.5.1 → 0.6.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 (132) hide show
  1. package/.agents/skills/wp-bootstrap/SKILL.md +314 -0
  2. package/.agents/skills/wp-bootstrap/references/composer-setup.md +275 -0
  3. package/.agents/skills/wp-bootstrap/references/monorepo-patterns.md +184 -0
  4. package/.agents/skills/wp-bootstrap/scripts/bootstrap.sh +151 -0
  5. package/.agents/skills/wp-bootstrap/scripts/detect-structure.mjs +466 -0
  6. package/.agents/skills/wp-bootstrap/scripts/package-wp.sh +173 -0
  7. package/.agents/skills/wp-bootstrap/scripts/playground-start.sh +148 -0
  8. package/.agents/skills/wp-bootstrap/scripts/playground-verify.sh +165 -0
  9. package/.agents/skills/wp-bootstrap/scripts/setup-github.sh +417 -0
  10. package/.agents/skills/wp-wpengine/SKILL.md +76 -12
  11. package/.agents/skills/wp-wpengine/references/github-actions-deploy.md +16 -9
  12. package/README.md +1 -1
  13. package/dist/cli.js +2 -0
  14. package/dist/commands/bootstrap.js +105 -0
  15. package/dist/lib/api.js +1 -0
  16. package/dist/lib/bootstrap.js +352 -0
  17. package/extensions/wp-agent-kit/index.ts +143 -3
  18. package/package.json +1 -1
  19. package/skills-custom/wp-bootstrap/SKILL.md +314 -0
  20. package/skills-custom/wp-bootstrap/references/composer-setup.md +275 -0
  21. package/skills-custom/wp-bootstrap/references/monorepo-patterns.md +184 -0
  22. package/skills-custom/wp-bootstrap/scripts/bootstrap.sh +151 -0
  23. package/skills-custom/wp-bootstrap/scripts/detect-structure.mjs +466 -0
  24. package/skills-custom/wp-bootstrap/scripts/package-wp.sh +173 -0
  25. package/skills-custom/wp-bootstrap/scripts/playground-start.sh +148 -0
  26. package/skills-custom/wp-bootstrap/scripts/playground-verify.sh +165 -0
  27. package/skills-custom/wp-bootstrap/scripts/setup-github.sh +417 -0
  28. package/skills-custom/wp-wpengine/SKILL.md +76 -12
  29. package/skills-custom/wp-wpengine/references/github-actions-deploy.md +16 -9
  30. package/.github/skills/blueprint/SKILL.md +0 -418
  31. package/.github/skills/wordpress-router/SKILL.md +0 -52
  32. package/.github/skills/wordpress-router/references/decision-tree.md +0 -55
  33. package/.github/skills/wp-abilities-api/SKILL.md +0 -108
  34. package/.github/skills/wp-abilities-api/references/delegate-helper-pattern.md +0 -241
  35. package/.github/skills/wp-abilities-api/references/domain-vs-projection.md +0 -113
  36. package/.github/skills/wp-abilities-api/references/error-code-vocabulary.md +0 -123
  37. package/.github/skills/wp-abilities-api/references/grouping-heuristic.md +0 -89
  38. package/.github/skills/wp-abilities-api/references/input-schema-gotchas.md +0 -265
  39. package/.github/skills/wp-abilities-api/references/php-registration.md +0 -94
  40. package/.github/skills/wp-abilities-api/references/plugin-family-patterns.md +0 -233
  41. package/.github/skills/wp-abilities-api/references/rest-api.md +0 -13
  42. package/.github/skills/wp-abilities-api/references/shared-core-service.md +0 -184
  43. package/.github/skills/wp-abilities-audit/SKILL.md +0 -199
  44. package/.github/skills/wp-abilities-audit/references/audit-schema.md +0 -300
  45. package/.github/skills/wp-abilities-audit/references/capability-gate-tracing.md +0 -197
  46. package/.github/skills/wp-abilities-audit/references/controller-enumeration.md +0 -116
  47. package/.github/skills/wp-abilities-verify/SKILL.md +0 -215
  48. package/.github/skills/wp-abilities-verify/references/annotation-correctness.md +0 -154
  49. package/.github/skills/wp-abilities-verify/references/audit-schema-validation.md +0 -131
  50. package/.github/skills/wp-abilities-verify/references/permission-roundtrip.md +0 -190
  51. package/.github/skills/wp-abilities-verify/references/runtime-harness.md +0 -462
  52. package/.github/skills/wp-abilities-verify/references/schema-lints.md +0 -118
  53. package/.github/skills/wp-abilities-verify/references/static-enumeration.md +0 -126
  54. package/.github/skills/wp-block-development/SKILL.md +0 -175
  55. package/.github/skills/wp-block-development/references/attributes-and-serialization.md +0 -22
  56. package/.github/skills/wp-block-development/references/block-json.md +0 -49
  57. package/.github/skills/wp-block-development/references/creating-new-blocks.md +0 -46
  58. package/.github/skills/wp-block-development/references/debugging.md +0 -36
  59. package/.github/skills/wp-block-development/references/deprecations.md +0 -24
  60. package/.github/skills/wp-block-development/references/dynamic-rendering.md +0 -23
  61. package/.github/skills/wp-block-development/references/inner-blocks.md +0 -25
  62. package/.github/skills/wp-block-development/references/registration.md +0 -30
  63. package/.github/skills/wp-block-development/references/supports-and-wrappers.md +0 -18
  64. package/.github/skills/wp-block-development/references/tooling-and-testing.md +0 -21
  65. package/.github/skills/wp-block-development/scripts/list_blocks.mjs +0 -121
  66. package/.github/skills/wp-block-themes/SKILL.md +0 -117
  67. package/.github/skills/wp-block-themes/references/creating-new-block-theme.md +0 -37
  68. package/.github/skills/wp-block-themes/references/debugging.md +0 -24
  69. package/.github/skills/wp-block-themes/references/patterns.md +0 -18
  70. package/.github/skills/wp-block-themes/references/style-variations.md +0 -14
  71. package/.github/skills/wp-block-themes/references/templates-and-parts.md +0 -16
  72. package/.github/skills/wp-block-themes/references/theme-json.md +0 -59
  73. package/.github/skills/wp-block-themes/scripts/detect_block_themes.mjs +0 -117
  74. package/.github/skills/wp-interactivity-api/SKILL.md +0 -180
  75. package/.github/skills/wp-interactivity-api/references/debugging.md +0 -29
  76. package/.github/skills/wp-interactivity-api/references/directives-quickref.md +0 -30
  77. package/.github/skills/wp-interactivity-api/references/server-side-rendering.md +0 -310
  78. package/.github/skills/wp-performance/SKILL.md +0 -147
  79. package/.github/skills/wp-performance/references/autoload-options.md +0 -24
  80. package/.github/skills/wp-performance/references/cron.md +0 -20
  81. package/.github/skills/wp-performance/references/database.md +0 -20
  82. package/.github/skills/wp-performance/references/http-api.md +0 -15
  83. package/.github/skills/wp-performance/references/measurement.md +0 -21
  84. package/.github/skills/wp-performance/references/object-cache.md +0 -24
  85. package/.github/skills/wp-performance/references/query-monitor-headless.md +0 -38
  86. package/.github/skills/wp-performance/references/server-timing.md +0 -22
  87. package/.github/skills/wp-performance/references/wp-cli-doctor.md +0 -24
  88. package/.github/skills/wp-performance/references/wp-cli-profile.md +0 -32
  89. package/.github/skills/wp-performance/scripts/perf_inspect.mjs +0 -128
  90. package/.github/skills/wp-phpstan/SKILL.md +0 -98
  91. package/.github/skills/wp-phpstan/references/configuration.md +0 -52
  92. package/.github/skills/wp-phpstan/references/third-party-classes.md +0 -76
  93. package/.github/skills/wp-phpstan/references/wordpress-annotations.md +0 -124
  94. package/.github/skills/wp-phpstan/scripts/phpstan_inspect.mjs +0 -263
  95. package/.github/skills/wp-playground/SKILL.md +0 -233
  96. package/.github/skills/wp-playground/references/blueprints.md +0 -36
  97. package/.github/skills/wp-playground/references/cli-commands.md +0 -39
  98. package/.github/skills/wp-playground/references/debugging.md +0 -16
  99. package/.github/skills/wp-playground/references/e2e-playwright.md +0 -115
  100. package/.github/skills/wp-plugin-development/SKILL.md +0 -113
  101. package/.github/skills/wp-plugin-development/references/data-and-cron.md +0 -19
  102. package/.github/skills/wp-plugin-development/references/debugging.md +0 -19
  103. package/.github/skills/wp-plugin-development/references/lifecycle.md +0 -33
  104. package/.github/skills/wp-plugin-development/references/security.md +0 -29
  105. package/.github/skills/wp-plugin-development/references/settings-api.md +0 -22
  106. package/.github/skills/wp-plugin-development/references/structure.md +0 -16
  107. package/.github/skills/wp-plugin-development/scripts/detect_plugins.mjs +0 -122
  108. package/.github/skills/wp-plugin-directory-guidelines/SKILL.md +0 -133
  109. package/.github/skills/wp-plugin-directory-guidelines/references/gpl-compliance.md +0 -217
  110. package/.github/skills/wp-plugin-directory-guidelines/references/guideline-review-checklist.md +0 -592
  111. package/.github/skills/wp-plugin-directory-guidelines/references/naming-rules.md +0 -121
  112. package/.github/skills/wp-project-triage/SKILL.md +0 -39
  113. package/.github/skills/wp-project-triage/references/triage.schema.json +0 -143
  114. package/.github/skills/wp-project-triage/scripts/detect_wp_project.mjs +0 -610
  115. package/.github/skills/wp-rest-api/SKILL.md +0 -115
  116. package/.github/skills/wp-rest-api/references/authentication.md +0 -18
  117. package/.github/skills/wp-rest-api/references/custom-content-types.md +0 -20
  118. package/.github/skills/wp-rest-api/references/discovery-and-params.md +0 -20
  119. package/.github/skills/wp-rest-api/references/responses-and-fields.md +0 -30
  120. package/.github/skills/wp-rest-api/references/routes-and-endpoints.md +0 -36
  121. package/.github/skills/wp-rest-api/references/schema.md +0 -22
  122. package/.github/skills/wp-wpcli-and-ops/SKILL.md +0 -124
  123. package/.github/skills/wp-wpcli-and-ops/references/automation.md +0 -30
  124. package/.github/skills/wp-wpcli-and-ops/references/cron-and-cache.md +0 -23
  125. package/.github/skills/wp-wpcli-and-ops/references/debugging.md +0 -17
  126. package/.github/skills/wp-wpcli-and-ops/references/multisite.md +0 -22
  127. package/.github/skills/wp-wpcli-and-ops/references/packages-and-updates.md +0 -22
  128. package/.github/skills/wp-wpcli-and-ops/references/safety.md +0 -30
  129. package/.github/skills/wp-wpcli-and-ops/references/search-replace.md +0 -40
  130. package/.github/skills/wp-wpcli-and-ops/scripts/wpcli_inspect.mjs +0 -90
  131. package/.github/skills/wp-wpengine/SKILL.md +0 -127
  132. package/.github/skills/wpds/SKILL.md +0 -59
@@ -1,118 +0,0 @@
1
- # Schema Lints
2
-
3
- Static lints against an ability's `input_schema`. Schema hygiene is
4
- about *agent legibility*: orchestrating agents read the schema to
5
- figure out how to call the ability. A schema that's hard to parse,
6
- ambiguous, or misleading wastes turns even when the ability itself
7
- works.
8
-
9
- These lints are six small principles. Apply them by reading the
10
- schema, not by mechanically grepping — most plugins use enough
11
- formatting variety that grep recipes drift.
12
-
13
- ## Lint 1 — `additionalProperties: false` for object schemas
14
-
15
- For top-level `'type' => 'object'` schemas, declare
16
- `'additionalProperties' => false` unless you deliberately accept
17
- extras. Without this, an agent passing a typo (`par_page` instead of
18
- `per_page`) gets accepted silently and falls through to the backing,
19
- which ignores the unknown key.
20
-
21
- - `additionalProperties: false` declared → OK.
22
- - `additionalProperties: true` declared → WARN, unless the schema is
23
- for genuinely free-form metadata (payment custom fields, form
24
- free-text); document the reason inline.
25
- - Not declared on an object schema → WARN.
26
- - Non-object root (string with enum, integer, etc.) → N/A. The lint
27
- applies only to objects.
28
-
29
- ## Lint 2 — every required field has a non-empty description
30
-
31
- For each entry in `required`, the matching `properties` entry must
32
- declare a non-empty `description`. Required fields are where agents
33
- most need guidance; an opaque required key forces the agent to guess
34
- from the field name alone. Empty / missing → FAIL.
35
-
36
- Optional-field descriptions are nice-to-have — absence is WARN.
37
-
38
- ## Lint 3 — enums are non-empty
39
-
40
- `'enum' => []` accepts no values, rejecting every input. Almost always
41
- a bug. → FAIL.
42
-
43
- A single-value enum (`'enum' => [ 'pending' ]`) is legal but unusual;
44
- WARN and prompt for review — often a copy-paste that lost the other
45
- values.
46
-
47
- ## Lint 4 — no `$ref`
48
-
49
- Agents read the schema via REST introspection. A `$ref` forces the
50
- agent to follow a reference to see the field shape — wastes a turn and
51
- often breaks because the referenced schema isn't in the same document.
52
- Inline the shape instead.
53
-
54
- Any `'$ref'` in the schema → FAIL.
55
-
56
- ## Lint 5 — defaults are statically constant
57
-
58
- Each `'default'` value must evaluate to the same shape on every call:
59
-
60
- - Scalar literals — `true`, `false`, integer, float, quoted string,
61
- `null` → OK.
62
- - Empty or all-literal arrays — `[]`, `array()`, `[ 'a', 'b' ]` → OK.
63
- - Literal cast to an empty object — `(object) array()`, `(object) []`
64
- → OK. This is the recommended top-level default for zero-arg-allowed
65
- abilities; see
66
- `../../wp-abilities-api/references/input-schema-gotchas.md` §4.
67
- - `new stdClass()` with no arguments → OK.
68
- - A function call (`gmdate('c')`, `wp_generate_uuid4()`, `time()`),
69
- variable reference, or other computed expression → FAIL.
70
-
71
- The principle: defaults that vary per call are both non-deterministic
72
- and surprising to agents that expect defaults to be static.
73
-
74
- ## Lint 6 — `reference_ability: true` implies no required inputs
75
-
76
- If an audit doc is provided and an ability has
77
- `reference_ability: true`, its `input_schema.required` array must be
78
- empty or absent. The reference ability is the smallest, safest
79
- bootstrap call an implementer lands first; it must work with
80
- `execute([])`. Required inputs on the reference ability → FAIL.
81
-
82
- (No audit provided → this lint is skipped — no reference ability is
83
- declared.)
84
-
85
- ## Cross-reference: gotchas 1-3 (callback hardening) and gotcha 4 (structural default)
86
-
87
- Static lints catch shape; the four runtime gotchas in
88
- `../../wp-abilities-api/references/input-schema-gotchas.md` split into
89
- two kinds.
90
-
91
- Gotchas 1-3 need defensive code in the execute callback —
92
- `array_key_exists` instead of `isset`-only for property defaults,
93
- pagination key translation, ID validation that accepts `"0"`. These
94
- are runtime behaviors the callback itself must handle; static schema
95
- lints can't enforce them.
96
-
97
- Gotcha 4 — the direct vs indirect invocation strictness — is what
98
- motivates the `(object) array()` top-level default that Lint 5
99
- explicitly accepts. This one IS structural and Lint 5 carries the
100
- enforcement.
101
-
102
- ## Output format
103
-
104
- ```markdown
105
- ## Schema lints
106
-
107
- | Ability | Lint | Result | Detail |
108
- |---|---|---|---|
109
- | <ability> | additionalProperties (object schemas) | WARN | not declared on object schema |
110
- | <ability> | required-field descriptions | OK | 3/3 required fields documented |
111
- | <ability> | enum non-empty | OK | no enums |
112
- | <ability> | no $ref | OK | inline |
113
- | <ability> | static defaults | FAIL | `created_at` uses `gmdate('c')` |
114
- | <ability> | reference_ability implies no required | N/A | not reference ability |
115
- ```
116
-
117
- A FAIL on any lint flips that ability to FAIL in the run summary.
118
- WARNs surface but don't block.
@@ -1,126 +0,0 @@
1
- # Static Enumeration
2
-
3
- Enumerate a plugin's abilities from source, with no running
4
- environment. Static enumeration is necessarily best-effort — PHP's
5
- dynamism (variable indirection, runtime-conditional registration)
6
- means a complete inventory only comes from a live `wp_get_abilities()`
7
- call. When static and runtime inventories diverge, trust runtime;
8
- static drives the diff so the reviewer knows where to look.
9
-
10
- ## Typical registration shape
11
-
12
- ```php
13
- wp_register_ability(
14
- '<plugin-slug>/<ability-name>',
15
- array(
16
- 'label' => __( '...', '<text-domain>' ),
17
- 'description' => __( '...', '<text-domain>' ),
18
- 'category' => '<category-slug>',
19
- 'input_schema' => array( /* ... */ ),
20
- 'execute_callback' => array( self::class, 'execute_my_ability' ),
21
- 'permission_callback' => array( self::class, 'check_permission' ),
22
- 'meta' => array(
23
- 'annotations' => array(
24
- 'readonly' => true,
25
- 'destructive' => false,
26
- 'idempotent' => true,
27
- ),
28
- 'show_in_rest' => true,
29
- ),
30
- )
31
- );
32
- ```
33
-
34
- ## Step 1 — find every registration call
35
-
36
- ```bash
37
- grep -rn --include='*.php' 'wp_register_ability\s*(' <plugin-root>/
38
- ```
39
-
40
- Zero hits → return a clear "no abilities registered" report per
41
- SKILL.md "Failure modes." Don't fabricate an empty inventory.
42
-
43
- ## Step 2 — extract each ability name
44
-
45
- The first argument is the ability name — usually a literal string.
46
- Real-world formatting splits the call across lines (the example
47
- above is itself multi-line), so single-line regexes miss common
48
- cases. Use a multi-line tool:
49
-
50
- ```bash
51
- # ripgrep with --multiline + PCRE2 captures the name regardless of line break:
52
- rg --multiline --pcre2 --type=php -n \
53
- "wp_register_ability\s*\(\s*['\"]([^'\"]+)['\"]" <plugin-root>/
54
-
55
- # Fallbacks: pcregrep -M, perl -0777.
56
- ```
57
-
58
- If the first argument is a variable or constant
59
- (`wp_register_ability( $name, ... )`,
60
- `wp_register_ability( MyPlugin\NAME, ... )`), trace it: a recent
61
- assignment in the same function or a class constant usually resolves;
62
- a name computed in a loop won't, in which case flag the limitation and
63
- recommend runtime mode for authoritative enumeration.
64
-
65
- ## Step 3 — extract the annotation block
66
-
67
- Annotations live at `meta.annotations.{readonly,destructive,idempotent}`.
68
- For each registration, read the array literal forward until the
69
- matching close. Common shapes:
70
-
71
- - Multi-line literal (most common).
72
- - Short-form one-liner.
73
- - Helper method (`'annotations' => self::annotations_for_read()`) —
74
- resolve the helper if it returns a literal; otherwise mark
75
- `<unresolved>` and run the adversarial check against the callback
76
- alone.
77
- - Class constant (`'annotations' => self::READONLY_ANNOTATIONS`) —
78
- resolve the constant.
79
-
80
- Record `ability_name → declared_annotations`.
81
-
82
- ## Step 4 — follow `execute_callback` to its body
83
-
84
- `execute_callback` is one of:
85
-
86
- ```php
87
- 'execute_callback' => array( self::class, 'execute_get_things' ),
88
- 'execute_callback' => array( My_Class::class, 'execute_get_things' ),
89
- 'execute_callback' => array( $this, 'execute_get_things' ),
90
- 'execute_callback' => 'my_plugin_execute_get_things', // top-level function
91
- 'execute_callback' => function ( $input ) { /* ... */ }, // closure
92
- ```
93
-
94
- Resolve the reference to its source location: file + start line + end
95
- line. The annotation-correctness, schema-lint, and permission checks
96
- all operate on that byte range.
97
-
98
- ## Limits of static enumeration
99
-
100
- Cases where the inventory is incomplete or ambiguous:
101
-
102
- - Variable-indirected names (`foreach` over a slug list).
103
- - Variable-indirected annotations (built from config).
104
- - Conditional registration (`if ( feature_enabled() )`).
105
- - Variable-indirected callbacks (`array( $this, $callback_name )`).
106
-
107
- Record each in the report's "Static enumeration limitations" section
108
- and recommend a runtime-mode rerun for the authoritative inventory.
109
-
110
- ## Output format
111
-
112
- ```markdown
113
- ## Static inventory
114
-
115
- Found <N> ability registrations across <M> files:
116
-
117
- | Ability | Source file | Registration line | Callback file | Callback lines |
118
- |---|---|---|---|---|
119
- | myplugin/get-foo | src/Abilities.php | 42 | src/Abilities.php | 102-134 |
120
- | myplugin/submit-bar | src/Abilities.php | 68 | src/Services/Bar.php | 58-91 |
121
-
122
- ### Limitations
123
-
124
- - <ability>: annotations built dynamically in `annotations_for_read()`;
125
- recommend runtime mode for annotation cross-check.
126
- ```
@@ -1,175 +0,0 @@
1
- ---
2
- name: wp-block-development
3
- description: "Use when developing WordPress (Gutenberg) blocks: block.json metadata, register_block_type(_from_metadata), attributes/serialization, supports, dynamic rendering (render.php/render_callback), deprecations/migrations, viewScript vs viewScriptModule, and @wordpress/scripts/@wordpress/create-block build and test workflows."
4
- license: GPL-2.0-or-later
5
- compatibility: "Targets WordPress 6.9+ (PHP 7.2.24+). Filesystem-based agent with bash + node. Some workflows require WP-CLI."
6
- ---
7
-
8
- # WP Block Development
9
-
10
- ## When to use
11
-
12
- Use this skill for block work such as:
13
-
14
- - creating a new block, or updating an existing one
15
- - changing `block.json` (scripts/styles/supports/attributes/render/viewScriptModule)
16
- - fixing “block invalid / not saving / attributes not persisting”
17
- - adding dynamic rendering (`render.php` / `render_callback`)
18
- - block deprecations and migrations (`deprecated` versions)
19
- - build tooling for blocks (`@wordpress/scripts`, `@wordpress/create-block`, `wp-env`)
20
-
21
- ## Inputs required
22
-
23
- - Repo root and target (plugin vs theme vs full site).
24
- - The block name/namespace and where it lives (path to `block.json` if known).
25
- - Target WordPress version range (especially if using modules / `viewScriptModule`).
26
-
27
- ## Procedure
28
-
29
- ### 0) Triage and locate blocks
30
-
31
- 1. Run triage:
32
- - `node skills/wp-project-triage/scripts/detect_wp_project.mjs`
33
- 2. List blocks (deterministic scan):
34
- - `node skills/wp-block-development/scripts/list_blocks.mjs`
35
- 3. Identify the block root (directory containing `block.json`) you’re changing.
36
-
37
- If this repo is a full site (`wp-content/` present), be explicit about *which* plugin/theme contains the block.
38
-
39
- ### 1) Create a new block (if needed)
40
-
41
- If you are creating a new block, prefer scaffolding rather than hand-rolling structure:
42
-
43
- - Use `@wordpress/create-block` to scaffold a modern block/plugin setup.
44
- - If you need Interactivity API from day 1, use the interactive template.
45
-
46
- Read:
47
- - `references/creating-new-blocks.md`
48
-
49
- After scaffolding:
50
-
51
- 1. Re-run the block list script and confirm the new block root.
52
- 2. Continue with the remaining steps (model choice, metadata, registration, serialization).
53
-
54
- ### 2) Ensure apiVersion 3 (WordPress 6.9+)
55
-
56
- WordPress 6.9 enforces `apiVersion: 3` in the block.json schema. Blocks with apiVersion 2 or lower trigger console warnings when `SCRIPT_DEBUG` is enabled.
57
-
58
- **Why this matters:**
59
- - WordPress 7.0 will run the post editor in an iframe regardless of block apiVersion.
60
- - apiVersion 3 ensures your block works correctly inside the iframed editor (style isolation, viewport units, media queries).
61
-
62
- **Migration:** Changing from version 2 to 3 is usually as simple as updating the `apiVersion` field in `block.json`. However:
63
- - Test in a local environment with the iframe editor enabled.
64
- - Ensure any style handles are included in `block.json` (styles missing from the iframe won't apply).
65
- - Third-party scripts attached to a specific `window` may have scoping issues.
66
-
67
- Read:
68
- - `references/block-json.md` (apiVersion and schema details)
69
-
70
- ### 3) Pick the right block model
71
-
72
- - **Static block** (markup saved into post content): implement `save()`; keep attributes serialization stable.
73
- - **Dynamic block** (server-rendered): use `render` in `block.json` (or `render_callback` in PHP) and keep `save()` minimal or `null`.
74
- - **Interactive frontend behavior**:
75
- - Prefer `viewScriptModule` for modern module-based view scripts where supported.
76
- - If you're working primarily on `data-wp-*` directives or stores, also use `wp-interactivity-api`.
77
-
78
- ### 4) Update `block.json` safely
79
-
80
- Make changes in the block’s `block.json`, then confirm registration matches metadata.
81
-
82
- For field-by-field guidance, read:
83
- - `references/block-json.md`
84
-
85
- Common pitfalls:
86
-
87
- - changing `name` breaks compatibility (treat it as stable API)
88
- - changing saved markup without adding `deprecated` causes “Invalid block”
89
- - adding attributes without defining source/serialization correctly causes “attribute not saving”
90
-
91
- ### 5) Register the block (server-side preferred)
92
-
93
- Prefer PHP registration using metadata, especially when:
94
-
95
- - you need dynamic rendering
96
- - you need translations (`wp_set_script_translations`)
97
- - you need conditional asset loading
98
-
99
- Read and apply:
100
- - `references/registration.md`
101
-
102
- ### 6) Implement edit/save/render patterns
103
-
104
- Follow wrapper attribute best practices:
105
-
106
- - Editor: `useBlockProps()`
107
- - Static save: `useBlockProps.save()`
108
- - Dynamic render (PHP): `get_block_wrapper_attributes()`
109
-
110
- Read:
111
- - `references/supports-and-wrappers.md`
112
- - `references/dynamic-rendering.md` (if dynamic)
113
-
114
- ### 7) Inner blocks (block composition)
115
-
116
- If your block is a “container” that nests other blocks, treat Inner Blocks as a first-class feature:
117
-
118
- - Use `useInnerBlocksProps()` to integrate inner blocks with wrapper props.
119
- - Keep migrations in mind if you change inner markup.
120
-
121
- Read:
122
- - `references/inner-blocks.md`
123
-
124
- ### 8) Attributes and serialization
125
-
126
- Before changing attributes:
127
-
128
- - confirm where the attribute value lives (comment delimiter vs HTML vs context)
129
- - avoid the deprecated `meta` attribute source
130
-
131
- Read:
132
- - `references/attributes-and-serialization.md`
133
-
134
- ### 9) Migrations and deprecations (avoid "Invalid block")
135
-
136
- If you change saved markup or attributes:
137
-
138
- 1. Add a `deprecated` entry (newest → oldest).
139
- 2. Provide `save` for old versions and an optional `migrate` to normalize attributes.
140
-
141
- Read:
142
- - `references/deprecations.md`
143
-
144
- ### 10) Tooling and verification commands
145
-
146
- Prefer whatever the repo already uses:
147
-
148
- - `@wordpress/scripts` (common) → run existing npm scripts
149
- - `wp-env` (common) → use for local WP + E2E
150
-
151
- Read:
152
- - `references/tooling-and-testing.md`
153
-
154
- ## Verification
155
-
156
- - Block appears in inserter and inserts successfully.
157
- - Saving + reloading does not create “Invalid block”.
158
- - Frontend output matches expectations (static: saved markup; dynamic: server output).
159
- - Assets load where expected (editor vs frontend).
160
- - Run the repo’s lint/build/tests that triage recommends.
161
-
162
- ## Failure modes / debugging
163
-
164
- If something fails, start here:
165
-
166
- - `references/debugging.md` (common failures + fastest checks)
167
- - `references/attributes-and-serialization.md` (attributes not saving)
168
- - `references/deprecations.md` (invalid block after change)
169
-
170
- ## Escalation
171
-
172
- If you’re uncertain about upstream behavior/version support, consult canonical docs first:
173
-
174
- - WordPress Developer Resources (Block Editor Handbook, Theme Handbook, Plugin Handbook)
175
- - Gutenberg repo docs for bleeding-edge behaviors
@@ -1,22 +0,0 @@
1
- # Attributes and serialization
2
-
3
- Use this file when attributes aren’t saving, content becomes “Invalid block”, or you’re changing markup.
4
-
5
- ## How attributes persist
6
-
7
- Attributes can come from:
8
-
9
- - the comment delimiter JSON (common and stable)
10
- - the block’s saved HTML (from tags/attributes)
11
- - context
12
-
13
- Read the canonical guide for supported `source`/`selector`/`attribute` patterns:
14
-
15
- - https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/
16
-
17
- ## Common pitfalls
18
-
19
- - Changing saved HTML without a `deprecated` version breaks existing posts.
20
- - Using the `meta` attribute source (deprecated) causes long-term pain; avoid it.
21
- - Choosing brittle selectors leads to attributes “not found” when markup changes slightly.
22
-
@@ -1,49 +0,0 @@
1
- # `block.json` (metadata) guidance
2
-
3
- Use this file when you’re editing `block.json` fields or choosing between script/styles fields.
4
-
5
- ## Practical rules
6
-
7
- - Treat `name` as stable API (renaming breaks existing content).
8
- - Prefer adding new functionality without changing saved markup; if markup must change, add a `deprecated` version.
9
- - Keep assets scoped: editor assets should not ship to frontend unless needed.
10
-
11
- ## API version + schema
12
-
13
- **WordPress 6.9+ requires apiVersion 3.** The block.json schema now only validates blocks with `apiVersion: 3`. Older versions (1 or 2) trigger console warnings when `SCRIPT_DEBUG` is enabled.
14
-
15
- **Why apiVersion 3 matters:**
16
- - The post editor will be iframed if all registered blocks have apiVersion 3+.
17
- - WordPress 7.0 will always use the iframe editor regardless of apiVersion.
18
- - Benefits: style isolation (admin CSS won't affect editor content), correct viewport units (vw, vh), native media queries.
19
-
20
- **Migration checklist:**
21
- 1. Update `apiVersion` to `3` in block.json.
22
- 2. Ensure all style handles are declared in block.json (styles not included won't load in the iframe).
23
- 3. Test blocks that rely on third-party scripts (window scoping may differ).
24
- 4. Add a `$schema` to improve editor tooling and validation.
25
-
26
- References:
27
-
28
- - Block metadata: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/
29
- - Block API versions: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/
30
- - Iframe migration guide: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/block-migration-for-iframe-editor-compatibility/
31
- - Block schema index: https://schemas.wp.org/
32
-
33
- ## Modern asset fields to know
34
-
35
- This is not a full schema; it’s a “what matters in practice” list:
36
-
37
- - `editorScript` / `editorStyle`: editor-only assets.
38
- - `script` / `style`: shared assets.
39
- - `viewScript` / `viewStyle`: frontend view assets.
40
- - `viewScriptModule`: module-based frontend scripts (newer WP).
41
- - `render`: points to a PHP render file for dynamic blocks (newer WP).
42
-
43
- ## Helpful upstream references
44
-
45
- - Block metadata reference (block.json):
46
- - https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/
47
- - Block.json schema (editor tooling):
48
- - https://schemas.wp.org/trunk/block.json
49
-
@@ -1,46 +0,0 @@
1
- # Creating new blocks (scaffolding)
2
-
3
- Use this file when you are creating a new block (or a new block plugin) from scratch.
4
-
5
- ## Preferred path: `@wordpress/create-block`
6
-
7
- `@wordpress/create-block` scaffolds a modern block setup that tends to track current best practices.
8
-
9
- Typical options to decide up front:
10
-
11
- - TypeScript vs JavaScript
12
- - Static vs dynamic (`render.php` / server rendering)
13
- - Whether the block should be interactive on the frontend
14
-
15
- Canonical docs:
16
-
17
- - https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/
18
-
19
- ## “Most up-to-date” interactive blocks
20
-
21
- For a modern interactive block, prefer the official Interactivity API template:
22
-
23
- - Template: `@wordpress/create-block-interactive-template`
24
-
25
- This template is designed to integrate:
26
-
27
- - Interactivity API directives (`data-wp-*`)
28
- - module-based view scripts (`viewScriptModule`)
29
- - server rendering (`render.php`)
30
-
31
- References:
32
-
33
- - https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/
34
- - https://make.wordpress.org/core/2024/03/04/a-first-look-at-the-interactivity-api-in-wordpress-6-5/
35
-
36
- ## Manual fallback (when scaffolding is not available)
37
-
38
- If you cannot run `create-block` (no Node tooling or restricted network):
39
-
40
- 1. Create a plugin or theme location that will register the block.
41
- 2. Create a block folder with a valid `block.json`.
42
- 3. Register via `register_block_type_from_metadata()` in PHP.
43
- 4. Add editor JS and (optionally) frontend view assets.
44
-
45
- Then follow the rest of `wp-block-development` for metadata, registration, and serialization.
46
-
@@ -1,36 +0,0 @@
1
- # Debugging quick routes
2
-
3
- ## Block doesn’t appear in inserter
4
-
5
- - Confirm `block.json` `name` is valid and the block is registered.
6
- - Confirm build output exists and scripts are enqueued.
7
- - If using PHP registration, confirm `register_block_type_from_metadata()` runs (wrong hook/file not loaded is common).
8
-
9
- ## “This block contains unexpected or invalid content”
10
-
11
- - You changed saved markup or attribute parsing.
12
- - Add `deprecated` versions and a migration path.
13
- - Reproduce with an old post containing the previous markup.
14
-
15
- ## Attributes not saving
16
-
17
- - Confirm attribute definition matches actual markup.
18
- - If the value is in delimiter JSON, avoid brittle selectors.
19
- - Avoid `meta` attribute source (deprecated).
20
-
21
- ## Console warnings about apiVersion (WordPress 6.9+)
22
-
23
- If you see "The block 'namespace/block' is registered with API version 2 or lower":
24
-
25
- - Update `apiVersion` to `3` in block.json.
26
- - This warning only appears when `SCRIPT_DEBUG` is true.
27
- - WordPress 7.0 will require apiVersion 3 for proper iframe editor support.
28
-
29
- ## Styles not applying in editor (apiVersion 3 / iframe)
30
-
31
- If styles work on frontend but not in the editor:
32
-
33
- - Ensure style handles are declared in block.json (`editorStyle`, `style`).
34
- - Styles not included in block.json won't load inside the iframed editor.
35
- - Check for Dashicons or other dependencies that need explicit inclusion.
36
-
@@ -1,24 +0,0 @@
1
- # Deprecations and migrations
2
-
3
- Use this file when you must change saved markup or attribute shapes without breaking existing content.
4
-
5
- ## `deprecated` basics
6
-
7
- Block deprecations are handled in JS block registration.
8
-
9
- - Add older implementations to `deprecated` (newest → oldest).
10
- - Each deprecated entry can include:
11
- - `attributes`
12
- - `supports`
13
- - `save`
14
- - `migrate`
15
-
16
- Upstream reference:
17
-
18
- - https://developer.wordpress.org/block-editor/reference-guides/block-api/block-deprecation/
19
-
20
- ## Practical guardrails
21
-
22
- - Keep fixtures: store example content for each deprecated version.
23
- - When in doubt, add a migration path rather than silently changing selectors.
24
-
@@ -1,23 +0,0 @@
1
- # Dynamic blocks (server rendering)
2
-
3
- Use this file when converting a block to dynamic, or debugging frontend output mismatch.
4
-
5
- ## Choose the mechanism
6
-
7
- - Prefer `render` in `block.json` (dynamic render file).
8
- - Alternative: pass `render_callback` when registering the block in PHP.
9
-
10
- ## Wrapper attributes
11
-
12
- In PHP render output, always use:
13
-
14
- - `get_block_wrapper_attributes()`
15
-
16
- This preserves support-generated classes/styles.
17
-
18
- ## Practical checklist
19
-
20
- - Ensure PHP file exists and is reachable from the block root.
21
- - Ensure registration runs on every request (not only in admin).
22
- - Keep `save()` empty or `null` for fully dynamic output, unless you intentionally save fallback markup.
23
-
@@ -1,25 +0,0 @@
1
- # Inner Blocks (nested blocks)
2
-
3
- Use this file when your block contains other blocks (container blocks).
4
-
5
- ## Canonical references
6
-
7
- - Nested blocks guide: https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/
8
- - `@wordpress/block-editor` package: https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/
9
- - Block supports: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/
10
-
11
- ## Practical patterns
12
-
13
- - Editor:
14
- - Use `useInnerBlocksProps( useBlockProps(), { ... } )` to combine wrapper props with inner blocks.
15
- - Use templates/allowed blocks only when you have a clear UX reason (too strict is frustrating).
16
- - Save:
17
- - Use `useInnerBlocksProps.save( useBlockProps.save(), { ... } )` if you need wrapper props.
18
- - Output nested content via `<InnerBlocks.Content />` when appropriate.
19
-
20
- ## Common pitfalls
21
-
22
- - Only one `InnerBlocks` should exist per block.
23
- - Changing the wrapper structure that contains inner blocks can invalidate existing content; consider deprecations/migrations.
24
- - If you need to constrain allowed blocks, prefer doing it intentionally and documenting why.
25
-
@@ -1,30 +0,0 @@
1
- # Registration patterns (PHP-first)
2
-
3
- Use this file when you need to register blocks robustly across repo types (plugin/theme/site).
4
-
5
- ## Prefer metadata registration
6
-
7
- Prefer:
8
-
9
- - `register_block_type_from_metadata( $path_to_block_dir, $args = [] )`
10
-
11
- Why:
12
-
13
- - keeps metadata authoritative (`block.json`)
14
- - supports dynamic render (`render`) and other metadata-driven fields
15
- - enables cleaner asset handling
16
-
17
- Upstream reference:
18
-
19
- - https://developer.wordpress.org/reference/functions/register_block_type_from_metadata/
20
-
21
- ## Where to register
22
-
23
- - Plugins: register on `init` in the main plugin bootstrap or a dedicated loader.
24
- - Themes: register on `init` (or `after_setup_theme` if you need theme supports first), but keep it predictable.
25
-
26
- ## Dynamic render mapping
27
-
28
- If `block.json` includes `render`, ensure the file exists relative to the block root.
29
- Inside the render file, use `get_block_wrapper_attributes()` for wrapper attributes.
30
-