Skip to content

Commit

Permalink
Make sure WP_Theme_JSON_Gutenberg::resolve_variables returns $theme_json
Browse files Browse the repository at this point in the history
  • Loading branch information
samnajian committed Jun 19, 2023
1 parent ddef167 commit bcb6c73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}

}
2 changes: 1 addition & 1 deletion phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down

0 comments on commit bcb6c73

Please sign in to comment.