WordPress at Your Fingertips
function is not described

WP_Theme_JSON::compute_preset_vars() private WP 5.8.0

Given the block settings, it 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,

)

{} It's a method of the class: WP_Theme_JSON{}

No Hooks.

Return

Array. Returns the modified $declarations.

Usage

$result = WP_Theme_JSON::compute_preset_vars( $settings );
$settings(array) (required)
Settings to process.

Changelog

Since 5.8.0 Introduced.

Code of WP_Theme_JSON::compute_preset_vars() WP 5.8.2

private static function compute_preset_vars( $settings ) {
	$declarations = array();
	foreach ( self::PRESETS_METADATA as $preset ) {
		$preset_per_origin = _wp_array_get( $settings, $preset['path'], array() );
		$preset_by_slug    = self::get_merged_preset_by_slug( $preset_per_origin, $preset['value_key'] );
		foreach ( $preset_by_slug as $slug => $value ) {
			$declarations[] = array(
				'name'  => '--wp--preset--' . $preset['css_var_infix'] . '--' . _wp_to_kebab_case( $slug ),
				'value' => $value,
			);
		}
	}

	return $declarations;
}