wp_get_global_styles: return the standard format for CSS Custom Properties#4556
wp_get_global_styles: return the standard format for CSS Custom Properties#4556oandregal wants to merge 4 commits intoWordPress:trunkfrom oandregal:update/transform-to-standard-form
wp_get_global_styles: return the standard format for CSS Custom Properties#4556Conversation
tellthemachines
left a comment
There was a problem hiding this comment.
Code looks good and testing steps are returning the expected values. Just one (tiny, non-blocking) question below!
| * | ||
| * @since 5.9.0 | ||
| * @since 6.3.0 the internal format "var:preset|color|secondary" is always resolved | ||
| * to the standard form "var(--wp--preset--font-size--small)". |
There was a problem hiding this comment.
Do we really need this comment given there are no actual changes to this function? I'm assuming that returning the internal notation was a bug 😄 as I don't see the behaviour documented anywhere.
There was a problem hiding this comment.
This is a hard one. I suppose the comment is helpful in clarifying the behavior so consumers using different versions of WordPress can prepare accordingly: they have to do the conversion themselves in versions <6.3. Unless this change is backported to any older version that is also affected 🤔
For the purposes of 6.3 beta, I'm going to merge this as it is, but we can iterate / create follow-ups after.
|
Committed at https://core.trac.wordpress.org/changeset/55959 |
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