WP_Theme_JSON::resolve_variables()
Resolves the values of CSS variables in the given styles.
Метод класса: WP_Theme_JSON{}
Хуков нет.
Возвращает
WP_Theme_JSON
. The $theme_json with resolved variables.
Использование
$result = WP_Theme_JSON::resolve_variables( $theme_json );
- $theme_json(WP_Theme_JSON) (обязательный)
- The theme json resolver.
Список изменений
С версии 6.3.0 | Введена. |
Код WP_Theme_JSON::resolve_variables() WP Theme JSON::resolve variables WP 6.6.2
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; }