WP_Theme_JSON::compute_preset_vars()protected staticWP 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,

)

{} Это метод класса: WP_Theme_JSON{}

Хуков нет.

Возвращает

Массив. Returns the modified $declarations.

Использование

$result = WP_Theme_JSON::compute_preset_vars( $settings, $origins );
$settings(массив) (обязательный)
Settings to process.
$origins(массив) (обязательный)
List of origins to process.

Список изменений

С версии 5.8.0 Введена.
С версии 5.9.0 Added the $origins parameter.

Код WP_Theme_JSON::compute_preset_vars() WP 6.0.2

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;
}