-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 Type: Add selectors to block.json schema #3942
Block Type: Add selectors to block.json schema #3942
Conversation
Hi @aaronrobertshaw! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making. More information about how GitHub pull requests can be used to contribute to WordPress can be found in this blog post. Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook. If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook. The Developer Hub also documents the various coding standards that are followed:
Thank you, |
It's nearly ready from my perspective. I left my comments, and deciding on the default value is the only important thing. |
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 is ready to go. We will need to wait with the commit until changes in the Gutenberg plugin land and the release cycle for WordPress 6.2 is finished. Feel free to remind me to to commit it to WordPress core when the time comes 😄
@gziolo there have been a few changes here. I've added a second property to block types for editor-only selectors. Some background for this change can be found over on the related Gutenberg PR (WordPress/gutenberg#46496 (comment)). Essentially, we went with the second property to match the existing |
39bdd89
to
635ffee
Compare
Sounds good, and the code changes look correct. I'm not sure why e2e tests failed on CI but I restarted the job to see if that was only an incident. |
Seems like you had the magic touch 🪄 I'd already re-run it twice before rebasing the PR and having it fail again. |
src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php
Outdated
Show resolved
Hide resolved
👍 Thanks for the feedback @hellofromtonya. I believe I've addressed all of that now in 82d1762 |
There were some concerns raised around introducing support for editor-only selectors on the Gutenberg PR. For the time being, we'll remove that editor-only support so it can be discussed further and added at a future date. As such, I've reverted the addition of editor selectors to block types here. |
@aaronrobertshaw, it's been a while since all the changes landed in the Gutenberg plugin. Do you think it's good to go for WordPress core? The code changes look good. |
Thanks for the nudge @gziolo! After the removal of the editor-only selectors from this API, it doesn't seem like there is a great appetite yet to see them return. I suspect it might take some time to find solutions to the issues facing editor-only selectors. Given that, I believe the changes here are stable and as you note the Selectors API landed in Gutenberg 15.5 so they've in the wild for a little while. There's no objections from my end to see this land in core 🙂 |
Committed with https://core.trac.wordpress.org/changeset/55673. |
This PR adds support for the new
selectors
property. It adds it to the allowed metadata when registering a block type, makes theWP_Block_Type
class aware of it, exposes it through the block types REST API, and theget_block_editor_server_block_settings
function.There is a corresponding Gutenberg PR (WordPress/gutenberg#46496) that stabilizes the block.json
selectors
API and in part depends upon the changes here.Trac ticket: https://core.trac.wordpress.org/ticket/57585
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.