-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update: Migrate global styles user database data on the rest endpoint #36747
Update: Migrate global styles user database data on the rest endpoint #36747
Conversation
4ffbe2f
to
acd2881
Compare
$is_global_styles_user_theme_json = isset( $config['isGlobalStylesUserThemeJSON'] ) && true === $config['isGlobalStylesUserThemeJSON']; | ||
$raw_config = json_decode( $post->post_content, true ); | ||
$is_global_styles_user_theme_json = isset( $raw_config['isGlobalStylesUserThemeJSON'] ) && true === $raw_config['isGlobalStylesUserThemeJSON']; | ||
$config; |
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.
Is this supposed to be set to something?
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.
No, it is not I'm just instantiating the variable because it is used outside the if condition where we set the variable.
Feels like this would be a good candidate for wrapping up into a standalone function? |
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 fixes the issue I ran to as well. We need this fix asap to continue iterating on the GS code so I'm approving this.
I agree some of this code could be improved to be packed in utility functions. We can probably use the WP_Theme_JSON_Resolver::get_user_data
and similar functions. Can be done in a follow-up PR to unblock related work.
Related #36584 |
…#36747) * Update: Automatically migrate global styles user database data on the rest endpoint. * Fix lint issues Co-authored-by: André <583546+oandregal@users.noreply.github.com>
After merging #36674, I noticed although we were back-compatible on the frontend we were not being back-compatible on the site editor because our migration logic was not being called on the rest endpoint. This PR fixes the issue and makes sure that the data returned by the endpoint passes by the WP_Theme_JSON_Gutenberg constructor which includes migration and back-compatibility logic.
How has this been tested?
I made the global styles CPT equal to:
To force global styles CPT to have the previous value I changed show_ui to true in lib/class-wp-theme-json-resolver-gutenberg.php and opened the CPT on the editor and pasted the data. Changing the post using phpmyadmin or a similar tool is also ok.
I opened the site editor and verified everything looks as excepted and the palette provided is assumed to be the user one.