Repository navigation
Description
This issue is coming out of a discussion in the Make WordPress Slack Outreach Channel where we discussed some of the reasons why we are not ready to adopt pattern overrides on custom build projects.
Currently, pattern overrides is limited to only a small set of core blocks that have handling for their block bindings HTML replacement handled manually. With that, we have opted not to expose the mechanisms to create blocks that make use of the Pattern Overrides feature publicly until the HTML API lands in core.
However, we just realized that this limitation to wait on the HTML API only really applies to static blocks (ones that serialize their HTML to the database). For dynamic blocks (block rendered via a render_callback in PHP) this limitation does not exist.
Because of that I would propose that we open up the block bindings / pattern overrides feature for custom blocks that use dynamic rendering.
How to achieve that:
First we would need to find a way to indicate which attributes of which blocks actually allow to be bound to something. Currently, this is managed in a hard-coded list. #64756 explores adding a bindable decorator to the attributes definition which could be used to get that list dynamically.
Once we know which attributes of which blocks support bindings, we would need to also use that to handle saving attributes / passing in the correct value of attributes correctly in the editor.
And finally, we can use that same bindable key to replace https://github.com/WordPress/wordpress-develop/blob/e569967ee45e23186f6aa7f479fcb48a7511436b/src/wp-includes/class-wp-block.php#L246-L251 with the dynamic lookup of supported bindings.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields✅ Done
Activity
[-]Open up "Pattern Overrides" and therefore intern block bindings to custom **dynamic** blocks[/-][+]Open up "Pattern Overrides" and therefore intern block bindings to custom dynamic blocks[/+]fabiankaegy commentedon Aug 28, 2024
CC: @gziolo @SantosGuillamot since you participated in the conversation in slack :) Would love to get your take on whether I captured things correctly here and to fill in all the nuances that I am missing
bph commentedon Aug 28, 2024
Also pinging the outreach group @WordPress/outreach to chime in especially on use cases and further thoughts.
fabiankaegy commentedon Aug 28, 2024
I can chime in and provide some use case examples also :)
First of all, pretty much all blocks we built on custom sites are dynamic block. The reason for this is mostly due to design flexibility with continually changing design requirements.
Some examples of these custom blocks we have on pretty much every project:
Post Picker block
We have a post picker block that works similar to the post template of the core query. So you can use any of the post level blocks within that block to manage your layout. But instead of being defined by a query, the user can manually search for any articles on their site and reference it. Under the hood all we store in the blocks attributes are the
postIdandpostType.It would be super valuable to be able to use this post picker in a synced pattern and then enable overrides so that a user is still able to change the post that gets displayed (this happens via the blocks toolbar and already is setup to work in content only locking)
Icon block
Similar to the above example we have an Icon block. This icon block allows the user to pick from a predefined set of icons that we bundle with the theme. All we store is the name of the icon.
It would be great be to able to use that inside a synced pattern and enable overrides so that the user can still change the actual icon that should be used whilst all the design options of how large, what color, etc the icon is are still synced.
The end goal that would the make this feature soooooo much more powerful is to allow for all of this in Synced Theme Patterns (#59272)
colorful-tones commentedon Sep 10, 2024
I can certainly see how this would be useful. Having the allowed blocks hard-coded is not ideal.
I am confused by
I thought the HTML API was stable and released back in WP 6.2? 😕
gziolo commentedon Sep 10, 2024
That was HTML Tag Processor in WP 6.2. We are talking about HTML Processor and two features it will allow to support -
setInnerHTMLmethod and the ability to convert schema defined by block attributes into the query that should find the proper location in the instance of HTML API:gutenberg/packages/block-library/src/image/block.json
Lines 50 to 56 in 07c7821
Which would be equivalent to JavaScript:
gutenberg/packages/block-library/src/image/block.json
Lines 31 to 36 in 07c7821
Which would be equivalent to JavaScript:
mtias commentedon Sep 11, 2024
One addendum on the point of
role: 'content'—it's not really about serializing static content but about signaling what part of the block should be considered user content so it can be kept while transformed into another block (as part of a larger pattern; without having to know to / from attribute mapping), swapped with another source (bindings), surfaced in content-only scenarios while other roles are discarded, etc.I'd really like to focus on the semantics of the role and avoid introducing decorator flags like "bindable". The ideal state of this setup is that the role of an attribute signals everything necessary for augmentation.
This will be an important aspect of multilingual as well. The attributes designated as "content" would be the immediate candidates for localization.
The more this is architected around the topology of the role itself and less about operational flags the more it simplifies adoption and the overall clarity for extenders. It's a do more with less kind of thing.
15 remaining items
gziolo commentedon Sep 23, 2025
@ockham is actively working on a task that potentially allows filtering on the server of the list of block attributes with Block Bindings support in a way that gets reflected on the client. Once it's implemented and consolidated with Pattern Overrides, then we potentially could have this functionality ready. However, it's still in the exploration phase, so we need a few more days before we can make the final decision. Related PR:
ockham commentedon Sep 23, 2025
👋 Here's the GB counterpart PR: #71820 (which is even more important, since that's what's needed to pick up the server list on the client side). Still WIP 😄
ryanwelcher commentedon Sep 29, 2025
Reviewed in the scrub today. There seems to be forward momentum.
t-hamano commentedon Oct 13, 2025
This issue was featured on today's Bug Scrub. It looks like #71820 has been merged, but can we move this issue forward?
gziolo commentedon Oct 13, 2025
@ockham might know best, but my understanding is that it still needs some refactors because Pattern Overrides on the client maintain their own allow list for block types and its attributes, and some planned tasks for Block Bindings in WP 6.9 will fix it. We will also need to add e2e test covering it so we can satisfy the promise before advertising it to the larger audience.
t-hamano commentedon Oct 20, 2025
This issue was featured on today's Bug Scrub. Should we punt this ticket to 7.0?
t-hamano commentedon Oct 21, 2025
Since 6.9 Beta1 is just around the corner, I'd like to punt this issue to 7.0. Please let me know if I've missed anything.
cbravobernal commentedon Oct 21, 2025
Thanks @t-hamano and sorry for not answering at time. Yes, let's punt it, as still requires some work to do.
We need to review it as now there is a filter to add more support for block attributes.
ockham commentedon Oct 21, 2025
What Carlos said. FWIW, we came close to landing a solution that would have used the list of blocks that are supported by block bindings as provided by the server to determine if a block supports pattern overrides. However, we realized that these two things aren't entirely identical -- notable exceptions being the Navigation Link and Navigation Submenu blocks, which as of 6.9 will support Block Bindings -- but would conflict with Pattern Overrides. We decided that we'd need to keep the lists separate after all, and will look into an extensibility mechanism for Pattern Overrides for 7.0.