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

In this article

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

) {
	// Iterate over each of the styling rules and substitute non-string values such as `null` with the real `blockGap` value.
	foreach ( $spacing_rule['rules'] as $css_property => $css_value ) {
		$current_css_value = is_string( $css_value ) ? $css_value : $block_gap_value;
		if ( static::is_safe_css_declaration( $css_property, $current_css_value ) ) {
			$declarations[] = array(
				'name'  => $css_property,
				'value' => $current_css_value,
			);
		}
	}

	if ( ! $has_block_gap_support ) {
		// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
		$format          = static::ROOT_BLOCK_SELECTOR === $selector ? ':where(.%2$s%3$s)' : ':where(%1$s.%2$s%3$s)';

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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