Skip to content

Open up "Pattern Overrides" and therefore intern block bindings to custom dynamic blocks #64870

Open
@fabiankaegy

Description

@fabiankaegy

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status

      🏈 Punted to 6.8

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions