wp_get_global_styles: return the standard format for CSS Custom Properties
#4556
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Trac ticket https://core.trac.wordpress.org/ticket/58467
Backports WordPress/gutenberg#50366 and WordPress/gutenberg#50527
Part of WordPress/gutenberg#45171
What?
This PR fixes
wp_get_global_stylesso that it always return the standard format for CSS Custom Properties. For atheme.jsondataset with the following data:the
wp_get_global_stylesfunction should return:Why?
See WordPress/gutenberg#49693 The internal syntax shouldn't leak out, so consumers of this function only have to deal with the standard CSS Custom format.
How?
This PR extract the already existing logic that converts
var:preset|color|secondarytovar(--wp--preset--font-size--small)to a separate method, then uses the same method to sanitize the output ofwp_get_global_stylesto only include custom CSS variables and not internal variable syntax.Testing Instructions
theme.json.styles.blocks:wp_get_global_stylesfunctions to retrieve those styles. For example, paste the following infunctions.phpof the theme:The result will be:
( [typography] => Array( [fontSize] => var(--wp--preset--font-size--small) ) [color] => Array( [background] => var:preset|color|secondary ) )when it should have been
( [typography] => Array( [fontSize] => var(--wp--preset--font-size--small) ) [color] => Array( [background] => var(--wp--preset--color--secondary) ) )Note the
color.backgroundvalue. It should return the value in a valid CSS value, not the shortened internal format.Commit message