-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backport wp_get_global_styles
: allow transforming CSS Custom Properties to the corresponding raw values
#4656
Backport wp_get_global_styles
: allow transforming CSS Custom Properties to the corresponding raw values
#4656
Conversation
I'm seeing an error This is unrelated to this code change. Note that the new parameter for I've also seen it failing in |
Shared in |
Looking good to me. I tried with some other blocks, without array(2) {
["typography"]=>
array(1) {
["fontSize"]=>
string(35) "var(--wp--preset--font-size--large)"
}
["spacing"]=>
array(1) {
["margin"]=>
array(1) {
["bottom"]=>
string(30) "var(--wp--preset--spacing--40)"
}
}
} with array(2) {
["typography"]=>
array(1) {
["fontSize"]=>
string(60) "clamp(1.75rem, 1.75rem + ((1vw - 0.2rem) * 0.227), 1.875rem)"
}
["spacing"]=>
array(1) {
["margin"]=>
array(1) {
["bottom"]=>
string(55) "clamp(1.8rem, 1.8rem + ((1vw - 0.48rem) * 2.885), 3rem)"
}
}
} As well as passing no All presets are resolved. I can't see any regressions in existing theme json functionality. |
The E2E tests have been flaky for most of the week. Agree that they're not related to this PR. Once the refs to |
Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM and testing the output of
wp_get_global_styles( array(), array(
'block_name' => 'core/post-terms',
'transforms' => array( 'resolve-variables' )
)
)
works as expected!
Committed in https://core.trac.wordpress.org/changeset/55986. Trac is having a hard time listing the revision 55986, so the link may not work inmediately. Apparently (slack thread), it's something that happens from time to time and will be listed after the next commit. |
Trac ticket https://core.trac.wordpress.org/ticket/58588
Related Gutenberg ticket WordPress/gutenberg#49712
This PR backports WordPress/gutenberg#50484
What?
This PR addresses the changes explained in the corresponding trac and gutenberg tickets by introducing the
transforms
key to the$context
parameter as part ofwp_get_global_styles
function:From a
theme.json
that contains the following data:Using the public API to retrieve styles:
should return:
And using the normal path (note there's no
transforms
key):should return the Custom CSS Property as before:
Why?
There are some usages of the
wp_get_global_styles
where the consumer is interested in the values of the CSS rules and not the variables.How?
By adding a new
transform
key to the existing$context
parameter in thewp_get_global_styles
function.Testing Instructions
transforms
key. For example, paste the following infunctions.php
of the theme:The expected output is the value of the small font-size property.
Commit