Opened 3 years ago
Last modified 3 years ago
#54954 new defect (bug)
--wp--preset-- variables defaults not being updated by add_theme_support() 'editor-font-sizes' or 'editor-color-palette'
Reported by: | tommusrhodus | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.9 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
Having an issue updating the default values for preset variables, such as font size large
, or color black
Since 5.9 it appears that fonts and colours defined in theme.json will correctly override the default values of --wp--preset-- variables, however those defined via add_theme_support are not, and so the default values are still being used.
This is being triggered by whether or not a theme calls add_theme_support( 'experimental-link-color' )
A simple way to test what's going on here:
- Open a blank install with the Twenty-Twenty-One theme installed.
- Create a new page and add paragraph text with the font size set to
large
and set the background color toblack
- Open
functions.php
and editline 170
to change thelarge
font size, and then editline 203
to change the black color and save.
Result: Paragraph text correctly reflects changes made to font size and color.
- Open functions.php and delete
line 333: add_theme_support( 'experimental-link-color' );
Result: Font size and color fallback to WP default values.
Expected behaviour: Font sizes and colors set via add_theme_support
should continue to work as pre 5.9 without the need to add add_theme_support( 'experimental-link-color' );
Change History (4)
#2
@
3 years ago
I have tracked down the issue to wp_get_global_stylesheet()
https://github.com/tommusrhodus/WordPress/blob/master/wp-includes/global-styles-and-settings.php#L107-L117
In the above lines, the function checks if the theme has theme.json
and if it declares add_theme_support( 'experimental-link-color' )
, if a theme does neither the function does not merge the theme variables into the default variables.
The result is that theme declared variables which share names with WP Presets, do not overwrite those presets unless add_theme_support( 'experimental-link-color' )
is declared in the theme.
This ticket was mentioned in PR #2236 on WordPress/wordpress-develop by tommusrhodus.
3 years ago
#3
- Keywords has-patch added
Since 5.9 it appears that fonts and colours defined in theme.json
will correctly override the default values of --wp--preset--
variables, however those defined via add_theme_support
are not, and so the default values are still being used.
This is being triggered by whether or not a theme calls add_theme_support( 'experimental-link-color' )
A simple way to test what's going on here:
- Open a blank install with the Twenty-Twenty-One theme installed.
- Create a new page and add paragraph text with the font size set to
large
and set the background color toblack
- Open
functions.php
and editline 170
to change the large font size, and then editline 203
to change the black color and save.
Result: Paragraph text correctly reflects changes made to font size and color.
- Open
functions.php
and deleteline 333: add_theme_support( 'experimental-link-color' );
Result: Font size and color fallback to WP default values.
Expected behaviour: Font sizes and colors set via add_theme_support
should continue to work as pre 5.9 without the need to add add_theme_support( 'experimental-link-color' );
or theme.json
This PR removes experimental-link-color
dependancy in wp-includes/global-styles-and-settings.php
for themes to be able to update --wp--preset
variables without the need to setup theme.json
or add theme support for an experimental feature.
Trac ticket: https://core.trac.wordpress.org/ticket/54954
Here's a related ticket I posted on the Gutenberg GitHub repo: https://github.com/WordPress/gutenberg/issues/38252
In WordPress 5.9, only font sizes & colors defined in theme.json will take precedence over WordPress' core global styles with the same name. This is an issue.
At a minimum, in themes that do not have a theme.json file, the font sizes defined in
add_theme_support( 'editor-font-sizes' )
should take precedence over the WordPress core global styles with the same name.A better approach would be to limit the new style updates (and aggressive use of !important) to themes that use theme.json, in the same way that we limit other breaking changes in Gutenberg to themes with a theme.json file (ex: removing the .wp-block-groupinner-container from groups).