Skip to content

Commit

Permalink
Update: Automatically migrate global styles user database data on the…
Browse files Browse the repository at this point in the history
… rest endpoint.
  • Loading branch information
jorgefilipecosta committed Nov 22, 2021
1 parent e31d431 commit acd2881
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -216,8 +216,12 @@ protected function prepare_item_for_database( $request ) {
* @return WP_REST_Response $data
*/
public function prepare_item_for_response( $post, $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$config = json_decode( $post->post_content, true );
$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;
if( $is_global_styles_user_theme_json ) {
$config = ( new WP_Theme_JSON_Gutenberg( $raw_config, 'user' ) )->get_raw_data();
}

$fields = $this->get_fields_for_response( $request );

Expand Down

0 comments on commit acd2881

Please sign in to comment.