WP_Theme_JSON::compute_preset_vars( array $settings, string[] $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, )

Parameters

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

Return

array The modified $declarations.

Source

/**
 * Transforms a slug into a CSS Custom Property.
 *
 * @since 5.9.0
 *
 * @param string $input String to replace.
 * @param string $slug  The slug value to use to generate the custom property.
 * @return string The CSS Custom Property. Something along the lines of `--wp--preset--color--black`.
 */
protected static function replace_slug_in_string( $input, $slug ) {
	return strtr( $input, array( '$slug' => $slug ) );
}

/**

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.