WP_Theme_JSON::compute_preset_vars( array $settings, string[] $origins ): array

In this article

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, )

Parameters

$settingsarrayrequired
Settings to process.
$originsstring[]required
List of origins to process.

Return

array The modified $declarations.

Source

// Skip outputting base styles for flow and constrained layout types if theme doesn't support theme.json. The 'base-layout-styles' type flags this.
if ( in_array( 'base-layout-styles', $types, true ) && ( 'default' === $layout_definition['name'] || 'constrained' === $layout_definition['name'] ) ) {
	continue;
}

if (
	isset( $base_style_rule['selector'] ) &&
	preg_match( $layout_selector_pattern, $base_style_rule['selector'] ) &&
	! empty( $base_style_rule['rules'] )
) {
	foreach ( $base_style_rule['rules'] as $css_property => $css_value ) {
		// Skip rules that reference content size or wide size if they are not defined in the theme.json.
		if (
			is_string( $css_value ) &&

Changelog

VersionDescription
5.9.0Added the $origins parameter.
5.8.0Introduced.

User Contributed Notes

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