Repository navigation
Abilities API: Insert hooked blocks into the raw content of core/content-query. - #16287
jorgefilipecosta wants to merge 2 commits into
Conversation
…tent-query`. The rendered content of a post includes the blocks hooked to its blocks through Block Hooks, but the raw content held only the stored markup. A client that edited the raw content could not remove a hooked block, and adding it by hand rendered it twice. The raw content now includes the hooked blocks, and each anchor block lists them in its `metadata.ignoredHookedBlocks` attribute.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
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. |
Follow up to #16028 (comment)
What
content.renderedofcore/content-queryincludes the blocks hooked through Block Hooks, butcontent.rawwas the stored markup, so a client editing the raw content could not remove a hooked block, and adding it by hand rendered it twice.content.rawnow includes the hooked blocks, and each anchor block lists them inmetadata.ignoredHookedBlocks._wp_ignored_hooked_blockspost meta and is not returned.content.renderedis unchanged and renders each hooked block once.How
class-wp-abilities-content.php: newget_raw_content()runs the raw content throughapply_block_hooks_to_content_from_post_object()withinsert_hooked_blocks_and_set_ignored_hooked_blocks_metadata; empty content is returned as is.wpRegisterCoreContentAbility.php: tests for each hooked position, content without hooks (block and classic), and posts that already list the hooked block as ignored (anchor metadata and post meta).The change and this description were drafted with AI assistance (Claude Code) and reviewed by me.
Testing
Verify unit tests are passing:
Trac ticket: https://core.trac.wordpress.org/ticket/66847