feat: add modern WP API scaffolds, enum-constrained inputs - #57
Open
Adi-ty wants to merge 2 commits into
Open
Conversation
Add the remaining scaffolds from the modern-WP-API story: wp/block-interactive (Interactivity API; no-op below WP 6.5) reuses the block-dynamic Blocks wiring anchor, wp-api/block-bindings registers a Block Bindings source (no-op below WP 6.5), and wp-api/script-module registers a Script Module only once its build output exists (no 404 on a clean checkout). Each follows the registrable/Services layout and stays no-op on the WP versions that lack the API. Inputs now support an `enum`: resolved values are checked post-transform and rejected with EINVALIDINPUT, carrying the reportable `invalid` payload; validate-time checks reject malformed enums and defaults outside their own enum. wp-api/speculation pins mode/eagerness via these to the values core 6.8 actually accepts.
Adi-ty
marked this pull request as ready for review
August 19, 2026 09:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Adds the three remaining modern-WP-API scaffolds —
wp/block-interactive,wp-api/block-bindings,wp-api/script-module— each no-op below the WP release that introduced its API, plusenum-constrained scaffold inputs.Closes
Closes rtcamp/wp-devtools#61
Changes
wp/block-interactive— Interactivity API block:block.json(supports.interactivity,viewScriptModule),render.phpdirectives,view.jsstore, registrar. Reuses thewp/block-dynamicBlocks anchor.wp-api/block-bindings— Block Bindings source with core's exactget_value_callbacksignature and a post-meta lookup.wp-api/script-module— Script Module; registers only once the build output exists, so a clean checkout never ships a 404<script type="module">tag.enum; resolved values are checked post-transform and rejected withEINVALIDINPUTcarryinginvalid[] = { key, value, allowed }.wp-api/speculationpinsmode/eagernesswith it.How I verified
npm run check— 706 tests, 50 suites, lint clean.wp-tooling validate— 38/38. Rendered into a real plugin under wp-env: PHPCSrtCampWPand PHPStan clean, generated PHPUnit green (script-module green both with and without a build). Scaffold skill evals: 46/46.Acceptance criteria
bundled-manifests.test.js, including a non-includes/PSR-4 root)mode/eagernessvalidated against the byte-exact enum core accepts## UnreleasedReviewer notes
dirname()shallower than the path derivation:plugin_dir_url()returns the directory holding the file you pass it, sodirname( __DIR__ )yields the plugin root. Usingdirname( __DIR__, 2 )there resolves to/plugins/<build_dir>/…and 404s every request. Documented onget_module_url(); the test asserts the URL stays inside the plugin directory.src/scaffolds/registry.js:1080), so a manifest pins what renders rather than what the caller typed. Deliberate — flag it in review if you'd rather validate the raw supplied value.