Repository navigation
Conversation
The bootstrap payload is identical for every snippet on every post, so keying its script ID by post ID served no purpose. Use one global ID and render the tag only on the first call, so a page with several code descriptions still holds a single element with that ID.
adamziel
changed the base branch from
add/php-snippet-wordpress-bootstrap
to
trunk
August 14, 2026 13:04
Contributor
Author
|
Closing in favor of #579, which now includes the |
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.
Readers of Code Reference examples should see and edit only the code that documents the API—not the Playground-specific
require '/wordpress/wp-load.php';boilerplate—while still running examples with WordPress loaded, including after editing them.This wires the theme side of WordPress/wordpress-playground#4261:
+jsonscript type, matching how the block already emits snippet code and expected output.JSON_HEX_TAGkeeps<escaped so the payload remains inert in HTML.run-before="#wporg-code-snippet-run-before"andphp-fragmenton every<php-snippet>emitted by the code-description block, including placeholder-placed and appended-fallback snippets.The shared script is a complete PHP file with its own opening tag. Parser-provided examples remain fragments, so
php-fragmentadds their opening tag without displaying it in the editor.This depends on WordPress/wordpress-playground#4262 and should land after that component change.
The Playground-handbook import path (
inc/import-playground.php) remains untouched. Those embeds reproduce Playground documentation examples authored for their own execution context.Testing
Import parser data containing interactive snippets, open a Code Reference page, and confirm the page source contains exactly one
wporg-code-snippet-run-beforescript; every<php-snippet>carries the matchingrun-beforeattribute andphp-fragment; and examples run with WordPress loaded while displaying no opening tag orwp-load.phpboilerplate.