-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Global Styles: Fix registration of theme style variation defined block styles #62495
Global Styles: Fix registration of theme style variation defined block styles #62495
Conversation
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/class-wp-rest-global-styles-controller-gutenberg.php ❔ phpunit/class-wp-rest-global-styles-controller-gutenberg-test.php |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
This will be included in the existing backport: WordPress/wordpress-develop#6756. |
…k styles (WordPress#62495) Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: oandregal <oandregal@git.wordpress.org>
Addresses WordPress/wordpress-develop#6756 (comment)
What?
Ensures theme style variation defined block style variations are supported when saving global styles via the the REST API.
Why?
If block style variations aren't registered they are stripping out during the sanitization of theme json data. This makes it appear as though global style customizations have been lost until the editor is reloaded.
How?
When a theme style variation is selected, its values are copied into the user origin data to be saved. This includes the shared block style variation definitions that need registering.
The REST API has been updated to register shared block style variations prior to saving the global styles. This maintains the data for variations they weren't able to be registered via the normal
init
filter.Testing Instructions
styles/ember.json
(theme style variation) file, paste the following under styles.blocks.variations:VariationDark
variation by going to "Global Styles > Blocks > Group > VariationDark". Modify the background color to something else.npm run test:unit:php:base -- --filter WP_REST_Global_Styles_Controller_Gutenberg_Test::test_update_item_with_custom_block_style_variations
Screenshots or screencast
Screen.Recording.2024-06-12.at.12.26.30.PM.mp4
Screen.Recording.2024-06-12.at.12.25.44.PM.mp4