Block level settings: remove WP filters in Gutenberg#49598
Conversation
…we don't double up on styles when the plugin is active.
|
Flaky tests detected in eae4665. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4615028665
|
There was a problem hiding this comment.
Thanks for tidying this up @ramonjd!
✅ Confirmed that on trunk the style tag and its contents is output twice
✅ With this PR applied, the style tag is only output once
Unrelated to this PR, it looks like this block support's feature is only supported on the site frontend and not within the post or site editors? At any rate, there's no difference in behaviour to the editor with this PR so that's a little off topic for now 😄
LGTM! ✨
I noticed that too and assumed that it was just implemented to be a theme.json API for now. Maybe @jorgefilipecosta can confirm. Thanks a lot for testing!! |
What?
Remove the corresponding WP filters in the plugin for
_gutenberg_add_block_level_presets_classso that we don't double up on block level settings styles when the plugin is active.Why?
#42124 introduced two hooks for
_gutenberg_add_block_level_presets_classto print block level settings stylesheets to the page.These changes were backported to Core in WordPress/wordpress-develop#4013.
Now, when running the plugin in WordPress 6.3-alpha-55628 the style block is output twice.
How?
Removing the WP filters:
Testing Instructions
Here is some test HTML :
And don't forget the theme.json with the block-level CSS settings.
Example theme.json
{ "$schema": "https://schemas.wp.org/trunk/theme.json", "version": 2, "settings": { "appearanceTools": true, "layout": { "contentSize": "840px", "wideSize": "1100px" }, "color": { "palette": [ { "slug": "global-aquamarine", "color": "aquamarine", "name": "Global aquamarine" }, { "slug": "global-pink", "color": "pink", "name": "Global Pink" } ] }, "blocks": { "core/button": { "color": { "palette": { "custom": [ { "slug": "button-red", "color": "red", "name": "button red" }, { "slug": "button-blue", "color": "blue", "name": "button blue" } ] } } }, "core/paragraph": { "color": { "palette": { "custom": [ { "slug": "paragraph-red", "color": "red", "name": "paragraph red" }, { "slug": "paragraph-blue", "color": "blue", "name": "paragraph blue" } ] } } } } }, "styles": { "color": { "background": "var(--wp--preset--color--global-aquamarine)", "text": "var(--wp--preset--color--global-pink)" } }, "patterns": [ "short-text-surrounded-by-round-images", "partner-logos" ] }Check that the resulting CSS is not output twice.