Skip to content

Block Bindings: Add server support for innerBlocks bindings - #79939

Closed
cbravobernal wants to merge 6 commits into
trunkfrom
add/61225-innerblocks-bindings-server
Closed

cbravobernal wants to merge 6 commits into
trunkfrom
add/61225-innerblocks-bindings-server

Conversation

@cbravobernal

@cbravobernal cbravobernal commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

I think this server flow presents better what it does rather than AI gen description.

Complete server flow

Saved block markup
│
▼
WordPress parses fallback children
│
▼
Is metadata.bindings.innerBlocks eligible?
│
├── No ──► Render normal fallback children
│
▼
Is the block nested?
│
├── Yes ─► render_block_data path
│ Find child WP_Block and inherited context
│
└── No ──► pre_render_block takeover
Reproduce data/context filters
│
▼
Call the registered source
│
├── null/non-string ─► Keep fallback
├── '' ──────────────► Render empty area
└── markup string ───► Parse replacement blocks
│
▼
Rebuild innerBlocks + innerContent + innerHTML
│
▼
Render replacement children inside the original host wrapper

AI Description

What?

Adds the Gutenberg-only server half of the experimental innerBlocks binding for WP 7.2 and registers it behind a user-enabled Gutenberg experiment.

A standard, otherwise-uncontrolled InnerBlocks host may resolve its children from a registered source. The shared value contract is deliberate: a serialized block-markup string replaces fallback children; null, undefined, and other non-string values fall back to the hosts own children; '' is intentionally empty. The server does not apply a different source-value transformation than the editor.

Nested resolution uses render_block_data. The necessary top-level pre_render_block shim mirrors the render_block() tail because a plugin cannot extend WP_Block; that code would move into Core if the experiment is adopted.

Experimental first slice and caveats

  • This is Gutenberg-only and loaded only when the user enables the Inner block bindings for synced patterns experiment. The experiment injects the blockBindingsInnerBlocks editor setting for WP 7.2; Core remains inert and there is no Core sync in this stack.
  • This is mechanism only. There is no authoring UI yet: a plugin or pre-authored block markup must supply the metadata.bindings.innerBlocks descriptor.
  • It supports one ordinary, static, otherwise-uncontrolled InnerBlocks area. core/html, hosts with multiple or interleaved structural areas, and caller-controlled InnerBlocks areas are excluded.
  • A nonempty source value for a static host that was initially empty fails closed, because parser output has no child placeholder to replace. Supporting that case, core/html, or multiple structural areas needs a separate HTML API design to identify and replace the right slot safely; this experiment must not infer it from arbitrary HTML or use regex.
  • Sources own the serialized-markup contract. The experiment does not establish a separate source-specific sanitization policy or a server-only markup rewrite.
  • Read-only sources and sources without a supported write-back path are not designed yet. This is not a noneditable-host feature.
  • It establishes no generic structural-recursion policy. Future recursive sources need a concrete reproducer and a bounded design before support is added.
  • Direct release keeps the current children, but manual detach/rebind flows and complex source/history/undo combinations are outside the supported contract for this first slice.

Stack: #79855 → this PR → #79940 → #79852.

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Flaky tests detected in ab2ab5d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29247289172
📝 Reported issues:

Base automatically changed from update/shared-block-bindings-context to trunk July 7, 2026 15:48
@cbravobernal
cbravobernal force-pushed the add/61225-innerblocks-bindings-server branch 3 times, most recently from f5a7683 to 97ff55e Compare July 9, 2026 09:21
@cbravobernal cbravobernal added No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Enhancement A suggestion for improvement. [Feature] Block bindings labels Jul 9, 2026
@cbravobernal cbravobernal self-assigned this Jul 9, 2026
@cbravobernal
cbravobernal requested a review from Copilot July 10, 2026 09:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds experimental PHP/server-side rendering support for metadata.bindings.innerBlocks so core blocks can have their child block tree supplied by the core/pattern-overrides bindings source during frontend rendering.

Changes:

  • Introduces a server-side render_block_data / pre_render_block implementation to resolve and substitute bound innerBlocks (including wrapper preservation via innerContent rebuilding).
  • Adds PHPUnit coverage for inner-block substitution behavior (fallback vs empty vs substituted, context inheritance, static wrapper preservation, recursion via nested bindings).
  • Adds PHPUnit coverage to ensure core/list-item reconciliation behaves correctly when both content and innerBlocks bindings are present.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
lib/load.php Loads the new experimental innerBlocks bindings server support.
lib/experimental/block-bindings-inner-blocks.php Implements innerBlocks binding gating, substitution, wrapper preservation, and top-level handling.
phpunit/block-bindings-innerblocks-test.php Adds extensive unit tests for innerBlocks substitution, wrapper preservation, and context behavior.
phpunit/block-bindings-list-item-test.php Adds tests ensuring list-item shim behavior doesn’t double-render or drop substituted children.

@cbravobernal
cbravobernal force-pushed the add/61225-innerblocks-bindings-server branch 5 times, most recently from 4acacda to 639c56c Compare July 10, 2026 21:54
@cbravobernal
cbravobernal marked this pull request as ready for review July 13, 2026 08:40
@github-actions

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@cbravobernal
cbravobernal force-pushed the add/61225-innerblocks-bindings-server branch 2 times, most recently from e92a1e4 to 0e019cf Compare July 13, 2026 09:40
@cbravobernal
cbravobernal enabled auto-merge (squash) July 14, 2026 19:25
@cbravobernal
cbravobernal requested a review from ockham July 14, 2026 19:25
@cbravobernal
cbravobernal force-pushed the add/61225-innerblocks-bindings-server branch from ec4924c to a13722d Compare July 14, 2026 19:27
@cbravobernal

Copy link
Copy Markdown
Contributor Author

Closing in favor of #85568, which renders innerBlocks bindings on the server behind the gutenberg-inner-blocks-bindings experiment. The editor part will come in a follow-up PR.

auto-merge was automatically disabled November 17, 2026 17:17

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Block bindings No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants