#60525 closed defect (bug) (fixed)
Block Bindings: Let the source extend the `uses_context` in the block type
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.5 | Priority: | normal |
| Severity: | normal | Version: | 6.5 |
| Component: | Editor | Keywords: | has-patch has-unit-tests commit |
| Focuses: | Cc: |
Description (last modified by )
While testing Block Bindings API, we realized that we don't have a robust mechanism for extending block context of supported block types. The approach to manually update every block type's usesContext in block.json file doesn’t scale at all. Hardocing the list of injected useContext entries is also limiting. We decided to formalize it in the registration of the block bindings source. This way, every author of the block bindings source can decide what entries from the block context they want to consume.
Related changes proposed are also in the Gutenberg plugin: https://github.com/WordPress/gutenberg/pull/58554.
Change History (9)
This ticket was mentioned in PR #6079 on WordPress/wordpress-develop by @santosguillamot.
2 years ago
#1
#4
@
2 years ago
- Summary changed from Block Bindings: to Block Bindings: Let the source extend the `uses_context` in the block type
This ticket was mentioned in Slack in #core by gziolo. View the logs.
2 years ago
@santosguillamot commented on PR #6079:
2 years ago
#6
I've created a bunch of tests to check uses_context:
2 years ago
#9
Committed with https://core.trac.wordpress.org/changeset/57641.
This pull request adds some logic to add the necessary
uses_contextdefined by block bindings sources. Each source defines the context it needs and it is added to the blocks that are using the block bindings API.Apart from that, it adapts the post meta and pattern overrides sources for this change.
Finally, it removes the
pattern/overridesfrom theblock.jsonbecause it is handled this way now.### Testing instructions
Post meta source test
Pattern overrides test
---
Trac ticket: https://core.trac.wordpress.org/ticket/60525