WP_Theme_JSON::compute_preset_vars( array $settings, array $origins ): array

Given the block settings, extracts the CSS Custom Properties for the presets and adds them to the $declarations array following the format:


Description

array( ‘name’ => ‘property_name’, ‘value’ => ‘property_value, )


Top ↑

Parameters

$settings array Required
Settings to process.
$origins array Required
List of origins to process.

Top ↑

Return

array The modified $declarations.


Top ↑

Source

File: wp-includes/class-wp-theme-json.php. View all references

protected static function compute_preset_vars( $settings, $origins ) {
	$declarations = array();
	foreach ( static::PRESETS_METADATA as $preset_metadata ) {
		$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;
}

Top ↑

Changelog

Changelog
Version Description
5.9.0 Added the $origins parameter.
5.8.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.