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

	foreach ( $style_nodes as $metadata ) {
		if ( null === $metadata['selector'] ) {
			continue;
		}
		$block_rules .= static::get_styles_for_block( $metadata );
	}

	return $block_rules;
}

/**
 * Gets the CSS layout rules for a particular block from theme.json layout definitions.
 *
 * @since 6.1.0
 * @since 6.3.0 Reduced specificity for layout margin rules.
 * @since 6.5.1 Only output rules referencing content and wide sizes when values exist.
 * @since 6.5.3 Add types parameter to check if only base layout styles are needed.
 * @since 6.6.0 Updated layout style specificity to be compatible with overall 0-1-0 specificity in global styles.
 *
 * @param array $block_metadata Metadata about the block to get styles for.
 * @param array $types          Optional. Types of styles to output. If empty, all styles will be output.
 * @return string Layout styles for the block.
 */
protected function get_layout_styles( $block_metadata, $types = array() ) {
	$block_rules = '';
	$block_type  = null;

	// Skip outputting layout styles if explicitly disabled.
	if ( current_theme_supports( 'disable-layout-styles' ) ) {
		return $block_rules;
	}

	if ( isset( $block_metadata['name'] ) ) {
		$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_metadata['name'] );

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.