Skip to content

Commit

Permalink
Update: Migrate global styles user database data on the rest endpoint (
Browse files Browse the repository at this point in the history
…#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>
  • Loading branch information
2 people authored and noisysocks committed Nov 28, 2021
1 parent 682d39e commit 4e523e2
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
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 = array();
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 4e523e2

Please sign in to comment.