Repository navigation
Block Bindings: Support innerBlocks bindings on the Group and Column blocks - #15164
Draft
cbravobernal wants to merge 19 commits into
Draft
cbravobernal wants to merge 19 commits into
cbravobernal wants to merge 19 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
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. |
…n blocks. A block bindings source can now supply the inner blocks of a Group or Column block through `metadata.bindings.innerBlocks`. The value is serialized block markup, which replaces the block's own inner blocks before they render. An empty string leaves the block without inner blocks, and any other value keeps its own. The markup is sanitized with `wp_kses_post()`, as bound rich text already is, and its custom CSS is removed. Supplied blocks can't bind their own inner blocks, so that sources can't expand each other forever. The editor isn't offered `innerBlocks` yet, as it doesn't render these bindings. Backports WordPress/gutenberg#85568. Fixes #66415. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cbravobernal
force-pushed
the
add/inner-blocks-bindings
branch
from
October 29, 2026 14:13
e561be2 to
417cff4
Compare
… has no blocks. The property is declared as a `WP_Block_List`, so assigning an empty array fails PHPStan's `assign.propertyType` check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bound inner blocks render inside `do_blocks()`, after `WP_Embed` has run its `[embed]` shortcode on the content, like the synced pattern block does for its own content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moves the explanations into docblocks, and tests that the embeds of the value survive sanitizing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Open
5 tasks
…g request, and let trusted sources skip kses. Ports the latest changes of the Gutenberg PR: - A value is block markup when the first delimiter WP_Block_Processor finds, after whitespace-only HTML, opens a block, which matches what parse_blocks() reads as a block. - Instead of removing the innerBlocks bindings of every supplied block, a binding is skipped, without asking its source, only while the inner blocks a source supplied for the same request render: the same source, arguments, and the context the source uses. Sources whose values bind each other's, directly or through content that loads as it renders, still can't render forever, and nested bindings that ask something else resolve. - The `block_bindings_sanitize_inner_blocks` filter lets a source whose markup comes from trusted code keep it as supplied. Custom CSS is removed either way. - The tests no longer assert with regular expressions. See WordPress/gutenberg#85568. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
20 tasks
…value, and key requests by attributes too. A block whose inner content held only block slots, with no wrapper markup, crashed when its source supplied no inner blocks: the empty inner content never reached the block instance, which rendered its old slots against an empty list of inner blocks. The instance now gets its inner content and HTML directly. The request a binding is skipped for also includes the attributes of the block, since a source may read them, like the pattern overrides source reads the name of the block. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MCeAiscBeSgrKjrPgYBr1b
…ders a Group unchanged. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MCeAiscBeSgrKjrPgYBr1b
…n, compare requests regardless of key order, and place inner blocks in the last element. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MCeAisD5bTZvgFGutfYV55
…ad of walking the call stack. `WP_Block::render()` now stops tracking the inner blocks a source supplied in a `finally` block, so a block that stops rendering with an exception is forgotten on the spot. The static method that walked `debug_backtrace()` to find such blocks on the next binding is gone. The exception test covers the new path: without the `finally`, it fails. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
…up and Column blocks. `get_block_editor_settings()` removed `innerBlocks` from every block type, so a block that added it through `block_bindings_supported_attributes` lost it in the editor. It now touches only the two block types Core adds the attribute to. A test registers such a block and checks that the editor still offers it. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
…tead of a regex handler. The embed test registered an embed handler with a regular expression. The `[embed]` shortcode and the bare URL both reach `wp_oembed_get()`, whose `pre_oembed_result` filter returns the test iframe before any provider lookup, so the test no longer needs one. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
…accept. A top-level supplied block fails when the bound block's `allowedBlocks` (block type or attribute) leaves it out, or when its own `parent` or `ancestor` leaves out the bound block. One failure rejects the whole value and the fallback inner blocks render. Nested blocks aren't checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd block. Same budget as Gutenberg: the `block_bindings_inner_blocks_budget` filter, 100 by default. It resets at the outermost bound block and counts every bound block that gets inner blocks below it. Once it's spent, the block keeps its own inner blocks. Without it, a value whose bindings ask for it again with other arguments renders once for every order they can nest in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`excerpt_remove_blocks()` renders a block bound for `innerBlocks` as on the front end, so the binding resolves with the same sanitizing and loop checks. Blocks the excerpt doesn't allow render nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…get. A value the allowed blocks check rejects doesn't count against `block_bindings_inner_blocks_budget`, so a later allowed value at the same budget still renders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…llowed blocks check. The allowed blocks check skipped every supplied chunk without a block name, so a bound block with `allowedBlocks` rendered loose HTML it would reject as a block. HTML outside any block now counts as `core/freeform`, unless it is only whitespace. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Trac ticket: https://core.trac.wordpress.org/ticket/66415
What?
Lets a block bindings source supply the inner blocks of a Group or Column block through
metadata.bindings.innerBlocks. Backports the server part of WordPress/gutenberg#85568.How?
WP_Block::process_block_bindings()handlesinnerBlocksitself and calls a new privatereplace_inner_blocks(), instead of treating it as an attribute.wp_kses_post(), as bound rich text already is, unless the source returns false from the newblock_bindings_sanitize_inner_blocksfilter. The supplied blocks lose their custom CSS either way.render()forgets the block in afinallyblock, so a caught exception doesn't leave it counted as rendering.WP_HTML_Processor. An empty legacy Group gets them inside its inner container.__defaultpattern overrides bindings never expand toinnerBlocks.get_block_editor_settings()leavesinnerBlocksout for the Group and Column blocks, as the editor doesn't render these bindings yet.Changes since the last review
render()forgets the supplied inner blocks in afinallyblock, in place of a method that walkeddebug_backtrace().get_block_editor_settings()only removesinnerBlocksfrom the Group and Column blocks.pre_oembed_resultinstead of a regex embed handler.Each one adds or keeps a test that fails without it.
Testing
npm run test:php -- --group block-bindings: the newtests/phpunit/tests/block-bindings/innerBlocks.phpcovers the value contract, sanitizing, recursion, placement and the editor settings.Replaces #12432, which backported an earlier design.
🤖 Generated with Claude Code