WP_Theme_JSON::get_preset_classes( array $setting_nodes, string[] $origins ): string

Creates new rulesets as classes for each preset value such as:

Description

.has-value-color { color: value; }

.has-value-background-color { background-color: value; }

.has-value-font-size { font-size: value; }

.has-value-gradient-background { background: value; }

p.has-value-gradient-background { background: value; }

Parameters

$setting_nodesarrayrequired
Nodes with settings.
$originsstring[]required
List of origins to process presets from.

Return

string The new stylesheet.

Source

protected function get_preset_classes( $setting_nodes, $origins ) {
	$preset_rules = '';

	foreach ( $setting_nodes as $metadata ) {
		if ( null === $metadata['selector'] ) {
			continue;
		}

		$selector      = $metadata['selector'];
		$node          = _wp_array_get( $this->theme_json, $metadata['path'], array() );
		$preset_rules .= static::compute_preset_classes( $node, $selector, $origins );
	}

	return $preset_rules;
}

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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