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

	continue;
}
$nested_selector = $part[0];
$css_value       = $part[1];

/*
 * Handle pseudo elements such as ::before, ::after etc. Regex will also
 * capture any leading combinator such as >, +, or ~, as well as spaces.
 * This allows pseudo elements as descendants e.g. `.parent ::before`.
 */
$matches            = array();
$has_pseudo_element = preg_match( '/([>+~\s]*::[a-zA-Z-]+)/', $nested_selector, $matches );
$pseudo_part        = $has_pseudo_element ? $matches[1] : '';
$nested_selector    = $has_pseudo_element ? str_replace( $pseudo_part, '', $nested_selector ) : $nested_selector;

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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