WP_Theme_JSON::compute_preset_vars()
Given the block settings, extracts the CSS Custom Properties for the presets and adds them to the $declarations array following the format:
array( 'name' => 'property_name', 'value' => 'property_value,
)
Method of the class: WP_Theme_JSON{}
No Hooks.
Return
Array
. The modified $declarations.
Usage
$result = WP_Theme_JSON::compute_preset_vars( $settings, $origins );
- $settings(array) (required)
- Settings to process.
- $origins(string[]) (required)
- List of origins to process.
Changelog
Since 5.8.0 | Introduced. |
Since 5.9.0 | Added the $origins parameter. |
WP_Theme_JSON::compute_preset_vars() WP Theme JSON::compute preset vars code WP 6.5.2
protected static function compute_preset_vars( $settings, $origins ) { $declarations = array(); foreach ( static::PRESETS_METADATA as $preset_metadata ) { if ( empty( $preset_metadata['css_vars'] ) ) { continue; } $values_by_slug = static::get_settings_values_by_slug( $settings, $preset_metadata, $origins ); foreach ( $values_by_slug as $slug => $value ) { $declarations[] = array( 'name' => static::replace_slug_in_string( $preset_metadata['css_vars'], $slug ), 'value' => $value, ); } } return $declarations; }