Skip to content

Conversation

@ockham
Copy link
Contributor

@ockham ockham commented Aug 28, 2025

What?

Gutenberg port of WordPress/wordpress-develop#9469 (and WordPress/wordpress-develop#9392).

Why?

For backwards compatibility.

How?

Largely by copying WP_Block's process_block_bindings and replace_html methods (plus some tweaks to allow accessing some of its protected properties), and calling them from a filter that's hooked to render_block. Some optimizations are made to avoid running code redundantly for block attributes that are already handled by WP 6.8.

Testing Instructions

Test both against Core trunk, and 6.8.

Verify that block bindings and pattern override still work as before. For manual smoke testing, follow e.g. the testing instructions of the Date block.

There is ample unit test coverage, largely obtained by copying this file from Core, and some tweaks to it to make sure unit tests pass for a newly added test/block that isn't present in 6.8. (Those test tweaks -- which make the unit tests a bit less verbose and redundant IMO -- are being backported to Core in WordPress/wordpress-develop#9748.)

@ockham ockham self-assigned this Aug 28, 2025
@ockham ockham added [Block] Post Date Affects the Post Date Block [Feature] Block bindings [Type] Enhancement A suggestion for improvement. labels Aug 28, 2025
@github-actions
Copy link

github-actions bot commented Sep 1, 2025

Flaky tests detected in 30680fe.
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/17489806332
📝 Reported issues:

@ockham
Copy link
Contributor Author

ockham commented Sep 5, 2025

Tests are copied from Core, with some additional changes made here. They are being synced back in WordPress/wordpress-develop#9748.

One difference in the GB version is that I've removed the @since @ticket references in ca7d426 and 4556ab5, respectively. We can revert either commit if we'd like to keep them.

@ockham ockham marked this pull request as ready for review September 5, 2025 09:51
@github-actions
Copy link

github-actions bot commented Sep 5, 2025

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: ockham <[email protected]>
Co-authored-by: cbravobernal <[email protected]>

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

Copy link
Contributor

@cbravobernal cbravobernal left a comment

Choose a reason for hiding this comment

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

Work as expected.

@cbravobernal cbravobernal merged commit c33f7be into trunk Sep 8, 2025
95 of 113 checks passed
@cbravobernal cbravobernal deleted the add/block-bindings-fallback branch September 8, 2025 12:44
@github-actions github-actions bot added this to the Gutenberg 21.7 milestone Sep 8, 2025
adamsilverstein pushed a commit to adamsilverstein/gutenberg that referenced this pull request Sep 11, 2025
…dPress#71389)

* Block Bindings: Add fallback

* Block Bindings: Use fallback for Date block

* Add backport changelog

* In tests, set datetime attribute indirectly.

* Extract and process context

* Add test coverage for new Block Bindings features

* Apply new Block Bindings logic to core/button block

* Move remove_filter() from tear_down to wpTearDownAfterClass

* Guard render_callback against unset attribute

* Minor comment clarification

* No need to add filter during setup

* Massage code to look more like Core

* Remove attributes that were handled by 6.8 early

* Update pattern overrides test to make sure they work with newly supported block attributes

* Implement support for pattern overrides in fallback

* Whitespace tweaks

* Update context test to make sure they work with newly supported block attributes

* Add block_bindings_supported_attributes filter during setup, absorb test into data provider

* Whitespace

* Switch another test to test/block

* Remove unnecessary source declaration

* Merge context tests

* Merge tests for different get_value_callbacks

* Move block_bindings_supported_attributes filter to set_up()

* Add PHPDoc for set_up

* Remove @SInCE PHPDocs

* Remove @ticket references from PHPDoc in tests

* Shut up WPCS

* Remove obsolete function parameter
@cbravobernal cbravobernal mentioned this pull request Oct 3, 2025
31 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Post Date Affects the Post Date Block [Feature] Block bindings [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants