Repository navigation
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Superseded by #14301, which reworks this change after review: the token keeps its HTML in a private property instead of a static registry, unserializing a token leaves it inert with a notice instead of throwing, |
Adds server-side processing for the new
data-wp-htmldirective, whose client implementation was merged in WordPress/gutenberg#83092, so that trusted HTML produced in PHP is present in the server-rendered page, including insidedata-wp-eachitems.What it adds
wp_interactivity_as_dangerous_html( string $html ): returns an opaqueWP_Interactivity_Dangerous_HTMLtoken. The token holds no HTML; the server records the HTML against the token's identity for the current request.data-wp-htmldirective processor. When the reference resolves to a token, the element's content is replaced with its HTML, byte for byte. The element keeps its tag and attributes, and its other directives are processed as usual.Behavior
_doing_it_wrong()notice is raised when the value is not a token, when the element cannot hold content (void elements andscript,style,textarea,title,iframe,noembed,noframes,xmp), or when the element also carriesdata-wp-textor is atemplatewithdata-wp-each.nullor unresolved values are silent.Implementation notes
The processor writes an inert placeholder comment as the element's content, and
process_directives()swaps the trusted HTML in with a singlestrtr()pass once processing has finished. Core therefore never tokenizes the trusted HTML, and the processing loop,data-wp-each, and the balanced-tag helper are unchanged. A newset_raw_content_between_balanced_tags()helper writes the placeholder without escaping.Testing
PHPUnit only; hydration in the browser is covered by the Gutenberg PR.
New test classes:
Tests_Interactivity_API_WpInteractivityAsDangerousHtml,Tests_WP_Interactivity_API_WP_HTML,Tests_WP_Interactivity_API_Client_Data_WP_HTML, plus new cases inwpInteractivityAPIDirectivesProcessor.php.Trac ticket: https://core.trac.wordpress.org/ticket/66246
Use of AI Tools
AI assistance: Yes
Tool(s): OpenCode, running an autonomous multi-agent pipeline (Radical Pipelines) that wrote and reviewed each stage separately
Model(s): Claude Opus 5.5, Claude Sonnet 5.5, GPT-6 Astra, GPT-6.1 Sol
Used for: This pull request was authored by AI end to end: specification and design (Claude Opus 5.5), implementation plan (Claude Opus 5.5), implementation and PHPUnit tests (GPT-6.1 Sol), inline documentation (Claude Sonnet 5.5), and the reviews of every stage (GPT-6 Astra and GPT-6.1 Sol). Orchestration used Claude Opus 5.5. I have reviewed the result and take responsibility for it.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.