WP_Theme_JSON::compute_theme_vars()protected staticWP 5.8.0

Given an array of settings, extracts the CSS Custom Properties for the custom values 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_theme_vars( $settings );
$settings(array) (required)
Settings to process.

Changelog

Since 5.8.0 Introduced.

WP_Theme_JSON::compute_theme_vars() code WP 6.6.2

protected static function compute_theme_vars( $settings ) {
	$declarations  = array();
	$custom_values = isset( $settings['custom'] ) ? $settings['custom'] : array();
	$css_vars      = static::flatten_tree( $custom_values );
	foreach ( $css_vars as $key => $value ) {
		$declarations[] = array(
			'name'  => '--wp--custom--' . $key,
			'value' => $value,
		);
	}

	return $declarations;
}