-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Do not add unregistered style variations to the theme.json schema #49807
Conversation
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.
Thanks for addressing this! I can partially reproduce the issue on trunk with empty theme, though I can't see the styles for the unregistered variation being output anywhere. I do see the PHP warning and the site editor doesn't load.
In this branch, the warning you mention goes away, and the site editor loads, but I see another warning in the post editor:
Warning: Undefined array key "unregistered" in /var/www/html/wp-includes/class-wp-theme-json.php on line 2219
Also editing existing style variations no longer works (see comment below)
c1bd5f3
to
abd3b46
Compare
@tellthemachines ok, this should be ready now. Updated the issue description with better test instructions and other notes. Hope this helps! |
24da4fb
to
41f50bb
Compare
Flaky tests detected in 41f50bb. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4722396270
|
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.
Re-testing confirms all is now working correctly. Thanks for adding a test! Code lgtm ✅
@oandregal would this fix the fact that I'm seeing "Property variations not allowed." in VS Code for v2 of the theme.json schema when running WP 6.2 stable? Just wondering if I should open another separate issue for that. Thanks! |
@colorful-tones no, that's a different thing. I see @tellthemachines declared the variations in the schema file in the PR that introduced the feature. I don't use this feature myself, neither I am very familiar with it, so I can't tell if anything else is needed. Perhaps @ajlende knows. |
@colorful-tones I can't reproduce that locally on VSCode 🤔 |
@tellthemachines Sorry for the delay. I believe it is likely that I was not testing against the latest |
Backport PR at WordPress/wordpress-develop#4554 |
Follow-up to #46343
What?
This PR makes sure unregistered block style variations are not part of the internal
theme.json
schema, so they are ignored before processing any data coming fromtheme.json
.Why?
theme.json
dataset.How?
By making sure the style variation is not added to the allowed list, unless it's registered for that particular block.
Testing Instructions
WP_DEBUG
to true.theme.json
of TwentyTwentyThree:The expected result is that:
{ background-color: red; color: blue}
(note the lack of CSS selector).class-wp-theme-json-gutenberg.php
. Intrunk
, you'll see something like this:Verify that upon updating the colors of the style variation via the global styles sidebar (blocks > quote > style variation plain), the user-provided colors are rendered everywhere (front & editors).
Note that by adding an unregistered variation, the core class
class-wp-theme-json.php
will still throw an error. This is expected. It'll be fixed when this PR is backported to core.