WP_Theme_JSON::get_block_classes( array $style_nodes ): string

In this article

Converts each style section into a list of rulesets containing the block styles to be appended to the stylesheet.

Description

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; }

Parameters

$style_nodesarrayrequired
Nodes with styles.

Return

string The new stylesheet.

Source

if ( ! is_array( $tree ) ) {
	return $tree;
}

foreach ( $tree as $key => $value ) {
	// Remove keys not in the schema or with null/empty values.
	if ( ! array_key_exists( $key, $schema ) ) {
		unset( $tree[ $key ] );
		continue;
	}

	if ( is_array( $schema[ $key ] ) ) {

Changelog

VersionDescription
6.1.0Moved most internal logic to get_styles_for_block().
5.9.0Renamed from get_block_styles() to get_block_classes() and no longer returns preset classes.
Removed the $setting_nodes parameter.
5.8.0Introduced.

User Contributed Notes

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