-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix/wp get global styles for custom props returns internal variable #50366
Merged
oandregal
merged 11 commits into
WordPress:trunk
from
samnajian:fix/wp_get_global_styles-for-custom-props-returns-internal-variable
May 10, 2023
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5a53d35
Extract logic that converts internal props to css variables
samnajian de1f077
Convert the internal css variables to css custom variables
samnajian 02fb5c2
Add test to assert internal css syntax is converted to CSS variable
samnajian b4b0823
Define gutenberg_get_global_styles and update usages
samnajian b035fb6
Make sure variation styles are includes when sanitizing
samnajian 9564374
Add correct since annotation to gutenberg_get_global_styles
samnajian a6b0e78
Add descriptive since annotation to gutenberg_get_global_styles
samnajian a19f470
Remove usage of convert_custom_properties from get_property_value
samnajian 1250ec9
Apply improvements suggested in PR review
samnajian 5833401
Simplify sanitize_variables and update usage
samnajian 92ed17b
Rename sanitize_variables to resolve_custom_css_format
samnajian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Once introduced in WP Core, this modifies the value format for the returned styles from
wp_get_global_styles()
. As such, it is a backwards-compatibility (BC) break for extenders expecting and using this structure.The result could mean broken styling experiences for users.
Is this a truly a bugfix, meaning
wp_get_global_styles()
should always have returned the style value structure? Or is this a new improvement to avoid leaking internal structures?cc @oandregal
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.
This is why I think it's a fine change.
Let say we had the following input:
Before this PR, the output of
wp_get_global_styles
would be:After this PR, the output of
wp_get_global_styles
would be:Before this PR, the consumers had to deal with two formats:
var(--wp--preset--color--secondary)
andvar:preset|color|secondary
, as a possible representation of the same value.After this PR, they only have to deal with one format that's been always present:
var(--wp--preset--color--secondary)
. I don't remember when thevar:preset|color|secondary
was introduced for people to use intheme.json
but it was later and added as a convenience. It should have never leaked to consumers, in my view. I did some quick search but didn't find when it was, I can do some archeology if this is important.An important note is that the format doesn't carry any meaning about where this data comes from. Any origin (default, block, theme, user) can use
var:preset|color|secondary
. Consumers cannot use that format as a hint of it being data from the user origin.Does this help?