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

In this article

Given a settings array, returns the generated rulesets for the preset classes.

Parameters

$settingsarrayrequired
Settings to process.
$selectorstringrequired
Selector wrapping the classes.
$originsstring[]required
List of origins to process.

Return

string The result of processing the presets.

Source

				'title' => isset( $item['title'] ) ? $item['title'] : '',
				'area'  => isset( $item['area'] ) ? $item['area'] : '',
			);
		}
	}
	return $template_parts;
}

/**
 * Converts each style section into a list of rulesets
 * containing the block styles to be appended to the stylesheet.
 *
 * See glossary at https://developer.mozilla.org/en-US/docs/Web/CSS/Syntax
 *
 * For each section this creates a new ruleset such as:
 *
 *   block-selector {
 *     style-property-one: value;
 *   }
 *
 * @since 5.8.0 As `get_block_styles()`.
 * @since 5.9.0 Renamed from `get_block_styles()` to `get_block_classes()`
 *              and no longer returns preset classes.
 *              Removed the `$setting_nodes` parameter.
 * @since 6.1.0 Moved most internal logic to `get_styles_for_block()`.
 *
 * @param array $style_nodes Nodes with styles.
 * @return string The new stylesheet.
 */
protected function get_block_classes( $style_nodes ) {
	$block_rules = '';

	foreach ( $style_nodes as $metadata ) {
		if ( null === $metadata['selector'] ) {

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.