claude-plugin-wordpress-manager 1.4.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 (142) hide show
  1. package/.claude-plugin/plugin.json +19 -0
  2. package/.mcp.json +19 -0
  3. package/CHANGELOG.md +62 -0
  4. package/LICENSE +69 -0
  5. package/README.md +213 -0
  6. package/agents/wp-content-strategist.md +148 -0
  7. package/agents/wp-deployment-engineer.md +93 -0
  8. package/agents/wp-performance-optimizer.md +198 -0
  9. package/agents/wp-security-auditor.md +161 -0
  10. package/agents/wp-site-manager.md +109 -0
  11. package/commands/wp-audit.md +37 -0
  12. package/commands/wp-backup.md +45 -0
  13. package/commands/wp-deploy.md +38 -0
  14. package/commands/wp-setup.md +64 -0
  15. package/commands/wp-status.md +53 -0
  16. package/docs/GUIDE.md +1190 -0
  17. package/hooks/hooks.json +57 -0
  18. package/hooks/scripts/backup-reminder.sh +29 -0
  19. package/hooks/scripts/pre-deploy-check.sh +49 -0
  20. package/package.json +46 -0
  21. package/scripts/health-check.sh +110 -0
  22. package/scripts/validate-wp-operation.sh +115 -0
  23. package/servers/wp-rest-bridge/build/server.d.ts +2 -0
  24. package/servers/wp-rest-bridge/build/server.js +74 -0
  25. package/servers/wp-rest-bridge/build/tools/comments.d.ts +227 -0
  26. package/servers/wp-rest-bridge/build/tools/comments.js +192 -0
  27. package/servers/wp-rest-bridge/build/tools/index.d.ts +919 -0
  28. package/servers/wp-rest-bridge/build/tools/index.js +30 -0
  29. package/servers/wp-rest-bridge/build/tools/media.d.ts +174 -0
  30. package/servers/wp-rest-bridge/build/tools/media.js +247 -0
  31. package/servers/wp-rest-bridge/build/tools/plugin-repository.d.ts +62 -0
  32. package/servers/wp-rest-bridge/build/tools/plugin-repository.js +149 -0
  33. package/servers/wp-rest-bridge/build/tools/plugins.d.ts +153 -0
  34. package/servers/wp-rest-bridge/build/tools/plugins.js +175 -0
  35. package/servers/wp-rest-bridge/build/tools/search.d.ts +44 -0
  36. package/servers/wp-rest-bridge/build/tools/search.js +44 -0
  37. package/servers/wp-rest-bridge/build/tools/unified-content.d.ts +328 -0
  38. package/servers/wp-rest-bridge/build/tools/unified-content.js +628 -0
  39. package/servers/wp-rest-bridge/build/tools/unified-taxonomies.d.ts +244 -0
  40. package/servers/wp-rest-bridge/build/tools/unified-taxonomies.js +492 -0
  41. package/servers/wp-rest-bridge/build/tools/users.d.ts +269 -0
  42. package/servers/wp-rest-bridge/build/tools/users.js +226 -0
  43. package/servers/wp-rest-bridge/build/types.d.ts +151 -0
  44. package/servers/wp-rest-bridge/build/types.js +2 -0
  45. package/servers/wp-rest-bridge/build/wordpress.d.ts +48 -0
  46. package/servers/wp-rest-bridge/build/wordpress.js +305 -0
  47. package/servers/wp-rest-bridge/package.json +27 -0
  48. package/skills/wordpress-router/SKILL.md +78 -0
  49. package/skills/wordpress-router/references/decision-tree.md +88 -0
  50. package/skills/wp-abilities-api/SKILL.md +97 -0
  51. package/skills/wp-abilities-api/references/php-registration.md +67 -0
  52. package/skills/wp-abilities-api/references/rest-api.md +13 -0
  53. package/skills/wp-audit/SKILL.md +114 -0
  54. package/skills/wp-audit/references/performance-checklist.md +113 -0
  55. package/skills/wp-audit/references/security-checklist.md +95 -0
  56. package/skills/wp-audit/references/seo-checklist.md +128 -0
  57. package/skills/wp-backup/SKILL.md +87 -0
  58. package/skills/wp-backup/references/backup-strategies.md +116 -0
  59. package/skills/wp-backup/references/restore-procedures.md +129 -0
  60. package/skills/wp-block-development/SKILL.md +176 -0
  61. package/skills/wp-block-development/references/attributes-and-serialization.md +22 -0
  62. package/skills/wp-block-development/references/block-json.md +49 -0
  63. package/skills/wp-block-development/references/creating-new-blocks.md +46 -0
  64. package/skills/wp-block-development/references/debugging.md +36 -0
  65. package/skills/wp-block-development/references/deprecations.md +24 -0
  66. package/skills/wp-block-development/references/dynamic-rendering.md +23 -0
  67. package/skills/wp-block-development/references/inner-blocks.md +25 -0
  68. package/skills/wp-block-development/references/registration.md +30 -0
  69. package/skills/wp-block-development/references/supports-and-wrappers.md +18 -0
  70. package/skills/wp-block-development/references/tooling-and-testing.md +21 -0
  71. package/skills/wp-block-development/scripts/list_blocks.mjs +121 -0
  72. package/skills/wp-block-themes/SKILL.md +118 -0
  73. package/skills/wp-block-themes/references/creating-new-block-theme.md +37 -0
  74. package/skills/wp-block-themes/references/debugging.md +24 -0
  75. package/skills/wp-block-themes/references/patterns.md +18 -0
  76. package/skills/wp-block-themes/references/style-variations.md +14 -0
  77. package/skills/wp-block-themes/references/templates-and-parts.md +16 -0
  78. package/skills/wp-block-themes/references/theme-json.md +59 -0
  79. package/skills/wp-block-themes/scripts/detect_block_themes.mjs +117 -0
  80. package/skills/wp-content/SKILL.md +103 -0
  81. package/skills/wp-content/references/content-templates.md +230 -0
  82. package/skills/wp-content/references/seo-optimization.md +169 -0
  83. package/skills/wp-deploy/SKILL.md +52 -0
  84. package/skills/wp-deploy/references/hostinger-deploy.md +51 -0
  85. package/skills/wp-deploy/references/ssh-deploy.md +63 -0
  86. package/skills/wp-interactivity-api/SKILL.md +181 -0
  87. package/skills/wp-interactivity-api/references/debugging.md +29 -0
  88. package/skills/wp-interactivity-api/references/directives-quickref.md +30 -0
  89. package/skills/wp-interactivity-api/references/server-side-rendering.md +310 -0
  90. package/skills/wp-migrate/SKILL.md +100 -0
  91. package/skills/wp-migrate/references/cross-platform.md +104 -0
  92. package/skills/wp-migrate/references/hostinger-migration.md +86 -0
  93. package/skills/wp-performance/SKILL.md +148 -0
  94. package/skills/wp-performance/references/autoload-options.md +24 -0
  95. package/skills/wp-performance/references/cron.md +20 -0
  96. package/skills/wp-performance/references/database.md +20 -0
  97. package/skills/wp-performance/references/http-api.md +15 -0
  98. package/skills/wp-performance/references/measurement.md +21 -0
  99. package/skills/wp-performance/references/object-cache.md +24 -0
  100. package/skills/wp-performance/references/query-monitor-headless.md +38 -0
  101. package/skills/wp-performance/references/server-timing.md +22 -0
  102. package/skills/wp-performance/references/wp-cli-doctor.md +24 -0
  103. package/skills/wp-performance/references/wp-cli-profile.md +32 -0
  104. package/skills/wp-performance/scripts/perf_inspect.mjs +128 -0
  105. package/skills/wp-phpstan/SKILL.md +99 -0
  106. package/skills/wp-phpstan/references/configuration.md +52 -0
  107. package/skills/wp-phpstan/references/third-party-classes.md +76 -0
  108. package/skills/wp-phpstan/references/wordpress-annotations.md +124 -0
  109. package/skills/wp-phpstan/scripts/phpstan_inspect.mjs +263 -0
  110. package/skills/wp-playground/SKILL.md +103 -0
  111. package/skills/wp-playground/references/blueprints.md +36 -0
  112. package/skills/wp-playground/references/cli-commands.md +39 -0
  113. package/skills/wp-playground/references/debugging.md +16 -0
  114. package/skills/wp-plugin-development/SKILL.md +114 -0
  115. package/skills/wp-plugin-development/references/data-and-cron.md +19 -0
  116. package/skills/wp-plugin-development/references/debugging.md +19 -0
  117. package/skills/wp-plugin-development/references/lifecycle.md +33 -0
  118. package/skills/wp-plugin-development/references/security.md +29 -0
  119. package/skills/wp-plugin-development/references/settings-api.md +22 -0
  120. package/skills/wp-plugin-development/references/structure.md +16 -0
  121. package/skills/wp-plugin-development/scripts/detect_plugins.mjs +122 -0
  122. package/skills/wp-project-triage/SKILL.md +40 -0
  123. package/skills/wp-project-triage/references/triage.schema.json +143 -0
  124. package/skills/wp-project-triage/scripts/detect_wp_project.mjs +592 -0
  125. package/skills/wp-rest-api/SKILL.md +116 -0
  126. package/skills/wp-rest-api/references/authentication.md +18 -0
  127. package/skills/wp-rest-api/references/custom-content-types.md +20 -0
  128. package/skills/wp-rest-api/references/discovery-and-params.md +20 -0
  129. package/skills/wp-rest-api/references/responses-and-fields.md +30 -0
  130. package/skills/wp-rest-api/references/routes-and-endpoints.md +36 -0
  131. package/skills/wp-rest-api/references/schema.md +22 -0
  132. package/skills/wp-wpcli-and-ops/SKILL.md +125 -0
  133. package/skills/wp-wpcli-and-ops/references/automation.md +30 -0
  134. package/skills/wp-wpcli-and-ops/references/cron-and-cache.md +23 -0
  135. package/skills/wp-wpcli-and-ops/references/debugging.md +17 -0
  136. package/skills/wp-wpcli-and-ops/references/multisite.md +22 -0
  137. package/skills/wp-wpcli-and-ops/references/packages-and-updates.md +22 -0
  138. package/skills/wp-wpcli-and-ops/references/safety.md +30 -0
  139. package/skills/wp-wpcli-and-ops/references/search-replace.md +40 -0
  140. package/skills/wp-wpcli-and-ops/scripts/wpcli_inspect.mjs +90 -0
  141. package/skills/wpds/SKILL.md +60 -0
  142. package/skills/wpds/references/wpds-mcp-setup.md +59 -0
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: wp-interactivity-api
3
+ description: "Use when building or debugging WordPress Interactivity API features (data-wp-* directives, @wordpress/interactivity store/state/actions, block viewScriptModule integration, wp_interactivity_*()) including performance, hydration, and directive behavior."
4
+ compatibility: "Targets WordPress 6.9+ (PHP 7.2.24+). Filesystem-based agent with bash + node. Some workflows require WP-CLI."
5
+ version: 1.0.0
6
+ source: "WordPress/agent-skills (GPL-2.0-or-later)"
7
+ ---
8
+
9
+ # WP Interactivity API
10
+
11
+ ## When to use
12
+
13
+ Use this skill when the user mentions:
14
+
15
+ - Interactivity API, `@wordpress/interactivity`,
16
+ - `data-wp-interactive`, `data-wp-on--*`, `data-wp-bind--*`, `data-wp-context`,
17
+ - block `viewScriptModule` / module-based view scripts,
18
+ - hydration issues or “directives don’t fire”.
19
+
20
+ ## Inputs required
21
+
22
+ - Repo root + triage output (`wp-project-triage`).
23
+ - Which block/theme/plugin surfaces are affected (frontend, editor, both).
24
+ - Any constraints: WP version, whether modules are supported in the build.
25
+
26
+ ## Procedure
27
+
28
+ ### 1) Detect existing usage + integration style
29
+
30
+ Search for:
31
+
32
+ - `data-wp-interactive`
33
+ - `@wordpress/interactivity`
34
+ - `viewScriptModule`
35
+
36
+ Decide:
37
+
38
+ - Is this a block providing interactivity via `block.json` view script module?
39
+ - Is this theme-level interactivity?
40
+ - Is this plugin-side “enhance existing markup” usage?
41
+
42
+ If you’re creating a new interactive block (not just debugging), prefer the official scaffold template:
43
+
44
+ - `@wordpress/create-block-interactive-template` (via `@wordpress/create-block`)
45
+
46
+ ### 2) Identify the store(s)
47
+
48
+ Locate store definitions and confirm:
49
+
50
+ - state shape,
51
+ - actions (mutations),
52
+ - callbacks/event handlers used by `data-wp-on--*`.
53
+
54
+ ### 3) Server-side rendering (best practice)
55
+
56
+ **Pre-render HTML on the server** before outputting to ensure:
57
+
58
+ - Correct initial state in the HTML before JavaScript loads (no layout shift).
59
+ - SEO benefits and faster perceived load time.
60
+ - Seamless hydration when the client-side JavaScript takes over.
61
+
62
+ #### Enable server directive processing
63
+
64
+ For components using `block.json`, add `supports.interactivity`:
65
+
66
+ ```json
67
+ {
68
+ "supports": {
69
+ "interactivity": true
70
+ }
71
+ }
72
+ ```
73
+
74
+ For themes/plugins without `block.json`, use `wp_interactivity_process_directives()` to process directives.
75
+
76
+ #### Initialize state/context in PHP
77
+
78
+ Use `wp_interactivity_state()` to define initial global state:
79
+
80
+ ```php
81
+ wp_interactivity_state( 'myPlugin', array(
82
+ 'items' => array( 'Apple', 'Banana', 'Cherry' ),
83
+ 'hasItems' => true,
84
+ ));
85
+ ```
86
+
87
+ For local context, use `wp_interactivity_data_wp_context()`:
88
+
89
+ ```php
90
+ <?php
91
+ $context = array( 'isOpen' => false );
92
+ ?>
93
+ <div <?php echo wp_interactivity_data_wp_context( $context ); ?>>
94
+ ...
95
+ </div>
96
+ ```
97
+
98
+ #### Define derived state in PHP
99
+
100
+ When derived state affects initial HTML rendering, replicate the logic in PHP:
101
+
102
+ ```php
103
+ wp_interactivity_state( 'myPlugin', array(
104
+ 'items' => array( 'Apple', 'Banana' ),
105
+ 'hasItems' => function() {
106
+ $state = wp_interactivity_state();
107
+ return count( $state['items'] ) > 0;
108
+ }
109
+ ));
110
+ ```
111
+
112
+ This ensures directives like `data-wp-bind--hidden="!state.hasItems"` render correctly on first load.
113
+
114
+ For detailed examples and patterns, see `references/server-side-rendering.md`.
115
+
116
+ ### 4) Implement or change directives safely
117
+
118
+ When touching markup directives:
119
+
120
+ - keep directive usage minimal and scoped,
121
+ - prefer stable data attributes that map clearly to store state,
122
+ - ensure server-rendered markup + client hydration align.
123
+
124
+ **WordPress 6.9 changes:**
125
+
126
+ - **`data-wp-ignore` is deprecated** and will be removed in future versions. It broke context inheritance and caused issues with client-side navigation. Avoid using it.
127
+ - **Unique directive IDs**: Multiple directives of the same type can now exist on one element using the `---` separator (e.g., `data-wp-on--click---plugin-a="..."` and `data-wp-on--click---plugin-b="..."`).
128
+ - **New TypeScript types**: `AsyncAction<ReturnType>` and `TypeYield<T>` help with async action typing.
129
+
130
+ For quick directive reminders, see `references/directives-quickref.md`.
131
+
132
+ ### 5) Build/tooling alignment
133
+
134
+ Verify the repo supports the required module build path:
135
+
136
+ - if it uses `@wordpress/scripts`, prefer its conventions.
137
+ - if it uses custom bundling, confirm module output is supported.
138
+
139
+ ### 6) Debug common failure modes
140
+
141
+ If “nothing happens” on interaction:
142
+
143
+ - confirm the `viewScriptModule` is enqueued/loaded,
144
+ - confirm the DOM element has `data-wp-interactive`,
145
+ - confirm the store namespace matches the directive’s value,
146
+ - confirm there are no JS errors before hydration.
147
+
148
+ See `references/debugging.md`.
149
+
150
+ ## Verification
151
+
152
+ - `wp-project-triage` indicates `signals.usesInteractivityApi: true` after your change (if applicable).
153
+ - Manual smoke test: directive triggers and state updates as expected.
154
+ - If tests exist: add/extend Playwright E2E around the interaction path.
155
+
156
+ ## Failure modes / debugging
157
+
158
+ - Directives present but inert:
159
+ - view script not loading, wrong module entrypoint, or missing `data-wp-interactive`.
160
+ - Hydration mismatch / flicker:
161
+ - server markup differs from client expectations; simplify or align initial state.
162
+ - derived state not defined in PHP: use `wp_interactivity_state()` with closures.
163
+ - Initial content missing or wrong:
164
+ - `supports.interactivity` not set in `block.json` (for blocks).
165
+ - `wp_interactivity_process_directives()` not called (for themes/plugins).
166
+ - state/context not initialized in PHP before render.
167
+ - Layout shift on load:
168
+ - derived state like `state.hasItems` missing on server, causing `hidden` attribute to be absent.
169
+ - Performance regressions:
170
+ - overly broad interactive roots; scope interactivity to smaller subtrees.
171
+ - Client-side navigation issues (WordPress 6.9):
172
+ - `getServerState()` and `getServerContext()` now reset between page transitions—ensure your code doesn't assume stale values persist.
173
+ - Router regions now support `attachTo` for rendering overlays (modals, pop-ups) dynamically.
174
+
175
+ ## Escalation
176
+
177
+ - If repo build constraints are unclear, ask: "Is this using `@wordpress/scripts` or a custom bundler (webpack/vite)?"
178
+ - Consult:
179
+ - `references/server-side-rendering.md`
180
+ - `references/directives-quickref.md`
181
+ - `references/debugging.md`
@@ -0,0 +1,29 @@
1
+ # Debugging checklist
2
+
3
+ 1. Confirm the interactive root exists in the rendered HTML (`data-wp-interactive`).
4
+ 2. Confirm the view script module is loaded (network + source maps).
5
+ 3. Confirm store namespace matches what markup expects.
6
+ 4. Check console for errors before any interaction.
7
+ 5. Reduce scope:
8
+ - temporarily remove directives to isolate which directive/store path breaks.
9
+ 6. If hydration mismatch occurs:
10
+ - ensure initial state/context matches server markup.
11
+
12
+ ## WordPress 6.9 specific issues
13
+
14
+ **State not persisting across navigation:**
15
+ - `getServerState()` and `getServerContext()` now reset between client-side page transitions.
16
+ - If you relied on stale values persisting, refactor to use the store's reactive state instead.
17
+
18
+ **Multiple plugins conflicting on same element:**
19
+ - Use unique directive IDs with the `---` separator to avoid attribute collisions.
20
+ - Example: `data-wp-on--click---my-plugin="actions.handle"`
21
+
22
+ **`data-wp-ignore` not working:**
23
+ - This directive is deprecated in 6.9 and will be removed. It caused context inheritance and navigation bugs.
24
+ - Find an alternative approach (conditional rendering, separate interactive regions).
25
+
26
+ **Router regions / overlays not rendering:**
27
+ - WordPress 6.9 adds `attachTo` property for router regions to render overlays anywhere on the page.
28
+ - Ensure nested router regions are properly structured.
29
+
@@ -0,0 +1,30 @@
1
+ # Directives quick reference (high level)
2
+
3
+ Common directives to recognize in markup:
4
+
5
+ - `data-wp-interactive`: declares an interactive region (and often a store namespace).
6
+ - `data-wp-context`: provides server-rendered context/state.
7
+ - `data-wp-on--event`: attaches event handlers (e.g. `click`, `submit`).
8
+ - `data-wp-on-async--event`: async event handlers (preferred for most actions).
9
+ - `data-wp-bind--attr`: binds DOM attributes to state.
10
+ - `data-wp-class--name`: toggles CSS classes based on state.
11
+
12
+ Use these as search anchors when triaging bugs.
13
+
14
+ ## Unique directive IDs (WordPress 6.9+)
15
+
16
+ HTML doesn't allow duplicate attributes. To attach multiple handlers of the same type from different plugins, use the `---` separator:
17
+
18
+ ```html
19
+ <button
20
+ data-wp-on--click---plugin-a="actions.handleA"
21
+ data-wp-on--click---plugin-b="actions.handleB"
22
+ >
23
+ ```
24
+
25
+ Both handlers will fire. The ID after `---` must be unique per element.
26
+
27
+ ## Deprecated directive
28
+
29
+ - **`data-wp-ignore`**: Deprecated in WordPress 6.9. It was intended to prevent hydration of a region but broke context inheritance and client-side navigation. Will be removed in future versions. Avoid using it.
30
+
@@ -0,0 +1,310 @@
1
+ # Server-Side Rendering for Interactivity API
2
+
3
+ - **Faster initial render**: HTML arrives ready with correct values.
4
+ - **No layout shift**: Hidden elements stay hidden from the first paint.
5
+ - **SEO benefits**: Search engines see fully rendered content.
6
+ - **Graceful degradation**: Content displays correctly even before JavaScript loads.
7
+
8
+ ## Setup Requirements
9
+
10
+ ### 1. Enable Server Directive Processing
11
+
12
+ **For components using `block.json`:**
13
+
14
+ ```json
15
+ {
16
+ "supports": {
17
+ "interactivity": true
18
+ }
19
+ }
20
+ ```
21
+
22
+ **For themes/plugins without `block.json`:**
23
+
24
+ Use `wp_interactivity_process_directives()` to manually process directives (see "Themes and Plugins without block.json" section below).
25
+
26
+ ### 2. Initialize Global State with `wp_interactivity_state()`
27
+
28
+ Define initial state values in PHP before rendering:
29
+
30
+ ```php
31
+ wp_interactivity_state( 'myPlugin', array(
32
+ 'fruits' => array( 'Apple', 'Banana', 'Cherry' ),
33
+ 'isLoading' => false,
34
+ 'count' => 3,
35
+ ));
36
+ ```
37
+
38
+ The state is serialized and available to client JavaScript automatically.
39
+
40
+ ### 3. Initialize Local Context with `wp_interactivity_data_wp_context()`
41
+
42
+ For element-scoped context:
43
+
44
+ ```php
45
+ <?php
46
+ $context = array(
47
+ 'isOpen' => false,
48
+ 'itemId' => 42,
49
+ 'itemName' => 'Example',
50
+ );
51
+ ?>
52
+ <div
53
+ data-wp-interactive="myPlugin"
54
+ <?php echo wp_interactivity_data_wp_context( $context ); ?>
55
+ >
56
+ <button data-wp-on-async--click="actions.toggle">
57
+ Toggle
58
+ </button>
59
+ <div data-wp-bind--hidden="!context.isOpen">
60
+ Content for <?php echo esc_html( $context['itemName'] ); ?>
61
+ </div>
62
+ </div>
63
+ ```
64
+
65
+ ## Derived State on the Server
66
+
67
+ When derived state affects the initial HTML, define it in PHP to avoid layout shifts.
68
+
69
+ ### Static Derived State
70
+
71
+ When the derived value is known at render time:
72
+
73
+ ```php
74
+ $fruits = array( 'Apple', 'Banana', 'Cherry' );
75
+ $hasFruits = count( $fruits ) > 0;
76
+
77
+ wp_interactivity_state( 'myPlugin', array(
78
+ 'fruits' => $fruits,
79
+ 'hasFruits' => $hasFruits,
80
+ ));
81
+ ```
82
+
83
+ ### Dynamic Derived State (using closures)
84
+
85
+ When the value depends on context (e.g., inside `data-wp-each` loops):
86
+
87
+ ```php
88
+ wp_interactivity_state( 'myPlugin', array(
89
+ 'fruits' => array( 'apple', 'banana', 'cherry' ),
90
+ 'shoppingList' => array( 'apple', 'cherry' ),
91
+ 'onShoppingList' => function() {
92
+ $state = wp_interactivity_state();
93
+ $context = wp_interactivity_get_context();
94
+ return in_array( $context['item'], $state['shoppingList'] ) ? 'Yes' : 'No';
95
+ },
96
+ ));
97
+ ```
98
+
99
+ The closure is evaluated during directive processing for each element.
100
+
101
+ ## Complete Example: List with Server Rendering
102
+
103
+ ### PHP (render callback or template)
104
+
105
+ ```php
106
+ <?php
107
+ $fruits = array( 'Apple', 'Banana', 'Cherry' );
108
+
109
+ wp_interactivity_state( 'myFruitPlugin', array(
110
+ 'fruits' => $fruits,
111
+ 'hasFruits' => count( $fruits ) > 0,
112
+ 'mango' => __( 'Mango' ),
113
+ ));
114
+ ?>
115
+
116
+ <div data-wp-interactive="myFruitPlugin">
117
+ <button data-wp-on-async--click="actions.addMango">
118
+ <?php esc_html_e( 'Add Mango' ); ?>
119
+ </button>
120
+ <button data-wp-on-async--click="actions.clearAll">
121
+ <?php esc_html_e( 'Clear All' ); ?>
122
+ </button>
123
+
124
+ <ul data-wp-bind--hidden="!state.hasFruits">
125
+ <template data-wp-each="state.fruits">
126
+ <li data-wp-text="context.item"></li>
127
+ </template>
128
+ </ul>
129
+
130
+ <p data-wp-bind--hidden="state.hasFruits">
131
+ <?php esc_html_e( 'No fruits available.' ); ?>
132
+ </p>
133
+ </div>
134
+ ```
135
+
136
+ ### JavaScript (view.js)
137
+
138
+ ```javascript
139
+ import { store, getContext } from '@wordpress/interactivity';
140
+
141
+ const { state } = store( 'myFruitPlugin', {
142
+ state: {
143
+ get hasFruits() {
144
+ return state.fruits.length > 0;
145
+ },
146
+ },
147
+ actions: {
148
+ addMango() {
149
+ state.fruits.push( state.mango );
150
+ },
151
+ clearAll() {
152
+ state.fruits = [];
153
+ },
154
+ },
155
+ });
156
+ ```
157
+
158
+ ### Rendered Output (initial HTML)
159
+
160
+ ```html
161
+ <div data-wp-interactive="myFruitPlugin">
162
+ <button data-wp-on-async--click="actions.addMango">Add Mango</button>
163
+ <button data-wp-on-async--click="actions.clearAll">Clear All</button>
164
+
165
+ <ul>
166
+ <li>Apple</li>
167
+ <li>Banana</li>
168
+ <li>Cherry</li>
169
+ </ul>
170
+
171
+ <p hidden>No fruits available.</p>
172
+ </div>
173
+ ```
174
+
175
+ The `hidden` attribute is added server-side because `state.hasFruits` is true.
176
+
177
+ ## Serializing Values for Client Use
178
+
179
+ Use `wp_interactivity_state()` to pass server values to client JavaScript:
180
+
181
+ ### Translations
182
+
183
+ ```php
184
+ wp_interactivity_state( 'myPlugin', array(
185
+ 'labels' => array(
186
+ 'add' => __( 'Add Item', 'textdomain' ),
187
+ 'remove' => __( 'Remove Item', 'textdomain' ),
188
+ 'empty' => __( 'No items found', 'textdomain' ),
189
+ ),
190
+ ));
191
+ ```
192
+
193
+ ### Ajax URLs and Nonces
194
+
195
+ ```php
196
+ wp_interactivity_state( 'myPlugin', array(
197
+ 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
198
+ 'nonce' => wp_create_nonce( 'myPlugin_nonce' ),
199
+ 'restUrl' => rest_url( 'myPlugin/v1/' ),
200
+ ));
201
+ ```
202
+
203
+ ### Client Usage
204
+
205
+ ```javascript
206
+ const { state } = store( 'myPlugin', {
207
+ actions: {
208
+ *fetchData() {
209
+ const formData = new FormData();
210
+ formData.append( 'action', 'my_action' );
211
+ formData.append( '_ajax_nonce', state.nonce );
212
+
213
+ const response = yield fetch( state.ajaxUrl, {
214
+ method: 'POST',
215
+ body: formData,
216
+ });
217
+ return yield response.json();
218
+ },
219
+ },
220
+ });
221
+ ```
222
+
223
+ ## Themes and Plugins without block.json
224
+
225
+ For themes or plugins not using `block.json`, use `wp_interactivity_process_directives()`:
226
+
227
+ ```php
228
+ <?php
229
+ wp_interactivity_state( 'myTheme', array(
230
+ 'menuOpen' => false,
231
+ ));
232
+
233
+ ob_start();
234
+ ?>
235
+
236
+ <nav
237
+ data-wp-interactive="myTheme"
238
+ data-wp-class--is-open="state.menuOpen"
239
+ >
240
+ <button data-wp-on-async--click="actions.toggleMenu">
241
+ Menu
242
+ </button>
243
+ <ul data-wp-bind--hidden="!state.menuOpen">
244
+ <li><a href="/">Home</a></li>
245
+ <li><a href="/about">About</a></li>
246
+ </ul>
247
+ </nav>
248
+
249
+ <?php
250
+ $html = ob_get_clean();
251
+ echo wp_interactivity_process_directives( $html );
252
+ ```
253
+
254
+ Only call `wp_interactivity_process_directives()` once at the outermost template level.
255
+
256
+ ## PHP Helper Functions Reference
257
+
258
+ | Function | Purpose |
259
+ |----------|---------|
260
+ | `wp_interactivity_state( $namespace, $state )` | Initialize/get global state for a namespace |
261
+ | `wp_interactivity_data_wp_context( $context )` | Generate `data-wp-context` attribute |
262
+ | `wp_interactivity_get_context( $namespace )` | Get current context during directive processing |
263
+ | `wp_interactivity_process_directives( $html )` | Manually process directives (themes/plugins) |
264
+
265
+ ## Common Pitfalls
266
+
267
+ ### Server Directive Processing Not Enabled
268
+
269
+ **For `block.json` users:** Without `supports.interactivity`, directives are not processed:
270
+
271
+ ```json
272
+ {
273
+ "supports": {
274
+ "interactivity": true
275
+ }
276
+ }
277
+ ```
278
+
279
+ **For themes/plugins:** Ensure `wp_interactivity_process_directives()` is called on the HTML output.
280
+
281
+ ### Derived State Missing on Server
282
+
283
+ If `state.hasFruits` is only defined in JavaScript, the `hidden` attribute won't be set:
284
+
285
+ ```html
286
+ <!-- Without server state: shows briefly then hides (layout shift) -->
287
+ <p data-wp-bind--hidden="state.hasFruits">No fruits</p>
288
+ ```
289
+
290
+ ### State Not Matching Client Expectations
291
+
292
+ Ensure PHP and JavaScript derived state logic matches:
293
+
294
+ ```php
295
+ // PHP
296
+ 'hasFruits' => count( $fruits ) > 0,
297
+ ```
298
+
299
+ ```javascript
300
+ // JavaScript - must match PHP logic
301
+ get hasFruits() {
302
+ return state.fruits.length > 0;
303
+ }
304
+ ```
305
+
306
+ ## External References
307
+
308
+ - [WordPress: Server-side rendering](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/core-concepts/server-side-rendering/)
309
+ - [WordPress: Understanding global state, local context and derived state](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/core-concepts/undestanding-global-state-local-context-and-derived-state/)
310
+ - [WordPress: Interactivity API Reference](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/api-reference/)
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: wp-migrate
3
+ description: This skill should be used when the user asks to "migrate a site", "move
4
+ WordPress", "transfer my site", "clone site", "copy site to new hosting", or mentions
5
+ any WordPress migration between hosts or platforms. Covers full site, content-only,
6
+ and database migrations.
7
+ version: 1.0.0
8
+ ---
9
+
10
+ # WordPress Migration Skill
11
+
12
+ ## Overview
13
+
14
+ Guides WordPress site migrations between hosting providers, platforms, and environments. Supports full-site, content-only, and staging-to-production migrations.
15
+
16
+ ## When to Use
17
+
18
+ - User wants to move a WordPress site to new hosting
19
+ - User needs to clone a site for staging/development
20
+ - User wants to migrate from WordPress.com to self-hosted
21
+ - User needs to transfer content between WordPress installations
22
+ - User is consolidating multiple sites
23
+
24
+ ## Migration Decision Tree
25
+
26
+ 1. **What is the source?**
27
+ - WordPress self-hosted → Full site or content export
28
+ - WordPress.com → WXR export or WordPress.com MCP
29
+ - Static site → Fresh WordPress installation + content import
30
+
31
+ 2. **What is the destination?**
32
+ - Hostinger → Use `hosting_importWordpressWebsite` (preferred)
33
+ - Other hosting → Use SSH/SFTP transfer
34
+ - WordPress.com → Content import via WP admin
35
+
36
+ 3. **What scope?**
37
+ - Full site (files + database + config) → Full migration
38
+ - Content only (posts, pages, media) → WXR or API transfer
39
+ - Theme/plugins only → Selective file transfer
40
+
41
+ ## Migration Workflows
42
+
43
+ ### Full Site Migration to Hostinger
44
+ 1. **Backup source**: Database dump + wp-content archive
45
+ 2. **Prepare archive**: Combine into single zip/tar.gz
46
+ 3. **Import**: Use `hosting_importWordpressWebsite` with archive + SQL dump
47
+ 4. **DNS update**: Point domain to new hosting
48
+ 5. **Verify**: Check site loads correctly on new host
49
+
50
+ ### Content-Only Migration (API-based)
51
+ 1. **Connect both sites**: Ensure both are in `WP_SITES_CONFIG`
52
+ 2. **Export from source**: Use `list_content` to enumerate all content
53
+ 3. **Transform**: Adapt URLs, media references
54
+ 4. **Import to destination**: Use `create_content` for each item
55
+ 5. **Transfer media**: Download and re-upload media files
56
+ 6. **Verify**: Check content integrity and links
57
+
58
+ ### WordPress.com to Self-Hosted
59
+ 1. **Export from WordPress.com**: WXR export via wp-admin or WP.com MCP
60
+ 2. **Prepare destination**: Fresh WordPress on Hostinger
61
+ 3. **Import**: Use WordPress Importer plugin or API
62
+ 4. **Redirect**: Set up domain forwarding from WordPress.com
63
+
64
+ ## Pre-Migration Checklist
65
+
66
+ - [ ] Full backup of source site created and verified
67
+ - [ ] Full backup of destination site (if not empty)
68
+ - [ ] DNS TTL lowered to 300 (5 min) at least 24h before migration
69
+ - [ ] All credentials documented (source + destination)
70
+ - [ ] Plugin list documented (to reinstall if needed)
71
+ - [ ] Custom configuration noted (wp-config.php settings)
72
+ - [ ] SSL certificate ready for new hosting
73
+ - [ ] User informed about expected downtime
74
+
75
+ ## Post-Migration Checklist
76
+
77
+ - [ ] Site loads on new hosting
78
+ - [ ] All pages and posts accessible
79
+ - [ ] Media files loading correctly
80
+ - [ ] Forms and interactive features working
81
+ - [ ] SSL/HTTPS working
82
+ - [ ] DNS propagation verified
83
+ - [ ] Search and replace for old URLs completed
84
+ - [ ] Caching cleared and rebuilt
85
+ - [ ] Search Console updated with new sitemap
86
+ - [ ] Old hosting cancelled or archived
87
+
88
+ ## Safety
89
+
90
+ - ALWAYS backup before migration — both source AND destination
91
+ - NEVER delete the source site until migration is fully verified
92
+ - DNS changes take 24-72 hours to propagate worldwide
93
+ - Test the migrated site using hosts file or staging URL before DNS switch
94
+ - Keep source accessible for at least 1 week after migration
95
+
96
+ ## Additional Resources
97
+
98
+ ### Reference Files
99
+ - **`references/hostinger-migration.md`** - Hostinger-specific migration procedures
100
+ - **`references/cross-platform.md`** - Cross-platform migration strategies