-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block Bindings: Add context needed by block bindings sources during its processing #6456
Conversation
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 Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very promising.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to provide an alternative way to expose the uses_context
defined for the block binding sources to the client. Previously it was handled through the block type definitions exposed on the server. In the revised approach, that information is only available on the server, so that might have some implications on how existing block binding sources work in the editor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments related to the idea to expose setting for block bindings together with the editor settings.
Is it okay to use editor settings for that? Any other alternative?
We are using the same approach for many editor features so that should be acceptable approach.
18c83aa
to
6f0a931
Compare
I've moved the logic to expose bindings in the editor settings to this other pull request: #7020. The idea is to keep this one to change the way the context is handled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
@peterwilsoncc opened #7226 where he started the process of syncing WordPress packages to WordPress core for the WP 6.7 release. Once that lands, this PR needs to be rebased as it already reports some merge conflicts and it will be ready to commit. |
Happy to rebase, review and test it once is ready. |
It’s time to rebase this branch and commit changes 🚀 |
986ff29
to
757e9b6
Compare
Rebased done 🙂 Let's see if tests pass, but I believe this should be ready. I'm testing now if it works as expected. |
I've been manually testing it and it looks good. If I connect an image to a custom field it shows the connected value in both the editor and in the frontend (server processing). |
Committed with https://core.trac.wordpress.org/changeset/59080. |
Trac ticket: https://core.trac.wordpress.org/ticket/61642
What?
Block bindings sources sometimes need to access some context that is not initially available in the block. Right now, we are extending it when the source is registered. This pull request moves the logic so it is added when the block bindings are processed. This means:
How?
Instead of using the
get_block_type_uses_context
created back then for this use case, use theavailable_context
in the block class during bindings processing.I assume it is not possible to remove that filter because of backward-compatibility.
Testing instructions