-
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.json: Allow passing filename as variations
field
#6668
block.json: Allow passing filename as variations
field
#6668
Conversation
variations
field to block.json
variations
field to block.jsonvariations
field
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. |
94999b4
to
f9de198
Compare
041b751
to
c10602d
Compare
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. |
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.
That looks like nice enhancement. We will need some changes also on the editor side:
- extend block.json schema to cover the string value
- add simple logic that ignores the file path when consuming the metadata from JS as it can’t process PHP file - for WordPress context it’s going to be handled on the server anyway
That's handled in WordPress/gutenberg#62092. I'm going to extend that PR to also implement the logic from this PR in the 6.7 compat layer, and to include changes to block variation docs.
👍 |
72a0384
to
5d1eaca
Compare
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 had one minor comment regarding enforcing file:
prefix for paths. However, conceptually everything looks great. I like how this proposal abstracts the usage of lazy evaluated definition of block variations.
It even made me wonder, whether we should do a similar trick with variations_callback
for the block variations defined as an array in block.json
.
Thank you! I changed the unit test according to your suggestion 😊 (The code I was using for the Since we're still in Beta, I'm planning to wait for RC1 (after which a branch for 6.6 should be created) before I commit this change to
You mean so that all variations aren't loaded and built right away if they're specified in |
Yes, it sounds like a great plan.
Yes, that would be an enhancement specific only to |
Thank you @gziolo! I'll have to re-review this PR now that I've landed the GB counterpart, to see if any changes need carrying over. |
9a30fb2
to
e7128b3
Compare
Alright, looks like it doesn't need any changes. I'll land it 😊 |
Committed to Core in https://core.trac.wordpress.org/changeset/58801. |
Thanks for committing this early in the 6.7 cycle ❤️ |
Modeled after https://core.trac.wordpress.org/changeset/54132/, which introduced the
render
field forblock.json
, as a way to point to a PHP file instead of providing arender_callback
.The main difference to the
variations
andvariation_callback
fields is that thevariations
field already existed prior to this PR, and it can be used to provide the static list of variations (i.e., an array). This PR makes it so that the field can be alternatively set to a string, which will be interpreted as the filename of the PHP file generating the variations.Trac ticket: https://core.trac.wordpress.org/ticket/61280
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.