WP_Style_Engine::get_css_var_value() – Util: Generates a CSS var string, e.g., var(–wp–preset–color–background) from a preset string such as `var:preset|space|50`.

You appear to be a bot. Output may be restricted

Description

Util: Generates a CSS var string, e.g., var(–wp–preset–color–background) from a preset string such as `var:preset|space|50`.

Usage

$string = WP_Style_Engine::get_css_var_value( $style_value, $css_vars );

Parameters

$style_value
( string ) required – A single css preset value.
$css_vars
( string[] ) required – An associate array of css var patterns used to generate the var string.

Returns

string The css var, or an empty string if no match for slug found.

Source

File name: wordpress/wp-includes/style-engine/class-wp-style-engine.php


Lines:

1 to 14 of 14
  protected static function get_css_var_value( $style_value, $css_vars ) {
    foreach ( $css_vars as  $property_key => $css_var_pattern ) {
      $slug = static::get_slug_from_preset_value( $style_value, $property_key );
      if ( static::is_valid_style_value( $slug ) ) {
        $var = strtr(
          $css_var_pattern,
          array( '$slug' => $slug )
        );
        return "var($var)";
      }
    }
    return '';
  }
 

 View on GitHub View on Trac