Ignore unregistered style variations from theme.json#4554
Ignore unregistered style variations from theme.json#4554oandregal wants to merge 3 commits intoWordPress:trunkfrom oandregal:update/theme-json-unregistered-style-variations
theme.json#4554Conversation
tellthemachines
left a comment
There was a problem hiding this comment.
Code changes look good (they match the original PR)
Testing in the post editor with the provided variations added to TT3 I can confirm the styles don't load in trunk and a few "undefined index" warnings pop up. With this branch, there are no warnings and the styles are loaded correctly.
I wasn't able to test on the site editor because it's not working on my local dev env; the page is unresponsive and there's a console error Uncaught TypeError: t.toString is not a function at e.stringifyFunction (<anonymous>:1:4066)
I'll give it a go again tomorrow or perhaps someone else can help test? Unless this is an actual problem with trunk and not just my local env acting up 😅
|
@tellthemachines would you be able to test the site editor again and report back? It works fine for me. |
tellthemachines
left a comment
There was a problem hiding this comment.
Thanks for the PR @oandregal !
I've retested and can confirm that everything is working correctly in the site editor - with the provided theme.json code sample, plain quote styles display correctly and there are no PHP warnings output.
|
Commited at https://core.trac.wordpress.org/changeset/55912 |
Trac ticket https://core.trac.wordpress.org/ticket/58462
Backports WordPress/gutenberg#49807
What?
This PR makes sure unregistered block style variations are ignored before processing any data coming from
theme.json.Why?
theme.jsondataset.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_DEBUGto true.theme.jsonof TwentyTwentyThree:{ "styles": { "blocks": { "core/quote": { "variations": { "plain": { "color": { "background": "indigo", "text": "gold" } }, "unregistered": { "color": { "background": "red", "text": "blue" } } } } } } }The expected result is that:
wp-block-quote-inline-cssstylesheet in the front-end doesn't have a style rule such as{ background-color: red; color: blue}(note the lack of CSS selector).class-wp-theme-json.phpfor the editors or front. 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).
Commit message