diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 4f92540feaab9..37ae671753391 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 1dc749164a162..ed255143cbe61 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 );