On this page
WP_Style_Engine::get_css_var_value( string $style_value, string[] $css_vars ): string
Util: Generates a CSS var string, e.g., var(–wp–preset–color–background) from a preset string such as var:preset|space|50.
Parameters
$style_valuestring Required-
A single css preset value.
$css_varsstring[] Required-
An associate array of css var patterns used to generate the var string.
Return
string The css var, or an empty string if no match for slug found.
Source
File: wp-includes/style-engine/class-wp-style-engine.php. View all references
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 '';
}
Changelog
| Version | Description |
|---|---|
| 6.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_style_engine/get_css_var_value