From a7fef2793b750d2e46f6d22aba22d3329b4dc713 Mon Sep 17 00:00:00 2001 From: Jorge Date: Wed, 24 Nov 2021 11:08:50 +0000 Subject: [PATCH] Fix: Color palette is not being stored --- lib/class-wp-theme-json-gutenberg.php | 3 ++- .../class-gutenberg-rest-global-styles-controller.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 4f92540feaab..37ae67175339 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -303,7 +303,8 @@ public function __construct( $theme_json = array(), $origin = 'theme' ) { $path = array_merge( $node['path'], $preset_metadata['path'] ); $preset = _wp_array_get( $this->theme_json, $path, null ); if ( null !== $preset ) { - if ( 'user' !== $origin || isset( $preset[0] ) ) { + // If the preset is not already keyed by origin. + if ( isset( $preset[0] ) || empty( $preset ) ) { _wp_array_set( $this->theme_json, $path, array( $origin => $preset ) ); } } diff --git a/lib/compat/wordpress-5.9/class-gutenberg-rest-global-styles-controller.php b/lib/compat/wordpress-5.9/class-gutenberg-rest-global-styles-controller.php index 1dc749164a16..ed255143cbe6 100644 --- a/lib/compat/wordpress-5.9/class-gutenberg-rest-global-styles-controller.php +++ b/lib/compat/wordpress-5.9/class-gutenberg-rest-global-styles-controller.php @@ -220,7 +220,7 @@ public function prepare_item_for_response( $post, $request ) { // phpcs:ignore V $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(); + $config = ( new WP_Theme_JSON_Gutenberg( $raw_config, 'custom' ) )->get_raw_data(); } $fields = $this->get_fields_for_response( $request );