From b7714fee96933fffb536db1467ebd8acda88290c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Fri, 7 May 2021 16:55:14 +0200 Subject: [PATCH] Chore: remove declarations so API has coherence (#31596) --- lib/class-wp-theme-json.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/class-wp-theme-json.php b/lib/class-wp-theme-json.php index 2c90c1bb9f452..7ef83033b771a 100644 --- a/lib/class-wp-theme-json.php +++ b/lib/class-wp-theme-json.php @@ -660,12 +660,12 @@ private static function compute_preset_classes( $settings, $selector ) { * ) * ``` * - * @param array $declarations Holds the existing declarations. * @param array $settings Settings to process. * * @return array Returns the modified $declarations. */ - private static function compute_preset_vars( $declarations, $settings ) { + private static function compute_preset_vars( $settings ) { + $declarations = array(); foreach ( self::PRESETS_METADATA as $preset ) { $values = _wp_array_get( $settings, $preset['path'], array() ); foreach ( $values as $value ) { @@ -691,12 +691,12 @@ private static function compute_preset_vars( $declarations, $settings ) { * ) * ``` * - * @param array $declarations Holds the existing declarations. * @param array $settings Settings to process. * * @return array Returns the modified $declarations. */ - private static function compute_theme_vars( $declarations, $settings ) { + private static function compute_theme_vars( $settings ) { + $declarations = array(); $custom_values = _wp_array_get( $settings, array( 'custom' ), array() ); $css_vars = self::flatten_tree( $custom_values ); foreach ( $css_vars as $key => $value ) { @@ -776,9 +776,7 @@ private function get_css_variables( $nodes ) { $selector = $metadata['selector']; $node = _wp_array_get( $this->theme_json, $metadata['path'], array() ); - $declarations = array(); - $declarations = self::compute_preset_vars( array(), $node ); - $declarations = self::compute_theme_vars( $declarations, $node ); + $declarations = array_merge( self::compute_preset_vars( $node ), self::compute_theme_vars( $node ) ); $stylesheet .= self::to_ruleset( $selector, $declarations ); }