From bcb6c73e1fb8b87a6d1061dc74701e7be11e8411 Mon Sep 17 00:00:00 2001 From: Sam Najian Date: Mon, 19 Jun 2023 09:05:11 +0200 Subject: [PATCH] Make sure WP_Theme_JSON_Gutenberg::resolve_variables returns $theme_json --- lib/class-wp-theme-json-gutenberg.php | 5 +++-- phpunit/class-wp-theme-json-test.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 46a282981b8880..7313afeba91bca 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -3699,7 +3699,7 @@ private static function convert_variables_to_value( $styles, $values ) { * @since 6.3.0 * @param WP_Theme_JSON_Gutenberg $theme_json The theme json resolver. * - * @return array The styles with the variables replaced with their values. + * @return WP_Theme_JSON_Gutenberg The $theme_json with resolved variables. */ public static function resolve_variables( $theme_json ) { $settings = $theme_json->get_settings(); @@ -3716,7 +3716,8 @@ function( $carry, $item ) { array() ); - return self::convert_variables_to_value( $styles, $vars ); + $theme_json->theme_json['styles'] = self::convert_variables_to_value( $styles, $vars ); + return $theme_json; } } diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index ed6b76c5991cb1..bd1d578a1297b6 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -2135,7 +2135,7 @@ public function test_resolve_variables() { ) ); - $styles = $theme_json::resolve_variables( $theme_json ); + $styles = $theme_json::resolve_variables( $theme_json )->get_raw_data()['styles']; $this->assertEquals( $primary_color, $styles['color']['background'], 'Top level: Assert values are converted' ); $this->assertEquals( $raw_color_value, $styles['color']['text'], 'Top level: Assert raw values stay intact' );