WP_Theme_JSON::get_property_value( array $styles, array $path )
This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Returns the style property for the given path.
Description
It also converts CSS Custom Property stored as "var:preset|color|secondary" to the form "–wp–preset–color–secondary".
Parameters
- $styles
-
(array) (Required) Styles subtree.
- $path
-
(array) (Required) Which property to process.
Return
(string) Style property value.
Source
File: wp-includes/class-wp-theme-json.php
private static function get_property_value( $styles, $path ) { $value = _wp_array_get( $styles, $path, '' ); if ( '' === $value ) { return $value; } $prefix = 'var:'; $prefix_len = strlen( $prefix ); $token_in = '|'; $token_out = '--'; if ( 0 === strncmp( $value, $prefix, $prefix_len ) ) { $unwrapped_name = str_replace( $token_in, $token_out, substr( $value, $prefix_len ) ); $value = "var(--wp--$unwrapped_name)"; } return $value; }
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |
© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json/get_property_value