WP_Theme_JSON::resolve_variables() – Resolves the values of CSS variables in the given styles.

You appear to be a bot. Output may be restricted

Description

Resolves the values of CSS variables in the given styles.

Usage

$WP_Theme_JSON = WP_Theme_JSON::resolve_variables( $theme_json );

Parameters

$theme_json
( WP_Theme_JSON ) required – The theme json resolver.

Returns

WP_Theme_JSON The $theme_json with resolved variables.

Source

File name: wordpress/wp-includes/class-wp-theme-json.php
Lines:

1 to 18 of 18
  public static function resolve_variables( $theme_json ) {
    $settings    = $theme_json->get_settings();
    $styles      = $theme_json->get_raw_data()['styles'];
    $preset_vars = static::compute_preset_vars( $settings, static::VALID_ORIGINS );
    $theme_vars  = static::compute_theme_vars( $settings );
    $vars        = array_reduce(
      array_merge( $preset_vars, $theme_vars ),
      function ( $carry, $item ) {
        $name                    = $item['name'];
        $carry[ "var({$name})" ] = $item['value'];
        return $carry;
      },
      array()
    );

    $theme_json->theme_json['styles'] = self::convert_variables_to_value( $styles, $vars );
    return $theme_json;
  }
 

 View on GitHub View on Trac