Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

WP_Theme_JSON::get_block_styles() WordPress Method

The WP_Theme_JSON::get_block_styles() function gets an array of block styles for the theme.

WP_Theme_JSON::get_block_styles( array $style_nodes, array $setting_nodes ) #

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

Additionally, it’ll also create new rulesets as classes for each preset value such as:

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

Top ↑

Parameters

$style_nodes

(array)(Required)Nodes with styles.

$setting_nodes

(array)(Required)Nodes with settings.


Top ↑

Return

(string) The new stylesheet.


Top ↑

Source

File: wp-includes/class-wp-theme-json.php

	 *       },
	 *       'core/heading': {
	 *         'selector': 'h1',
	 *         'elements': {}
	 *       },
	 *       'core/image': {
	 *         'selector': '.wp-block-image',
	 *         'duotone': 'img',
	 *         'elements': {}
	 *       }
	 *     }
	 *
	 * @since 5.8.0
	 * @since 5.9.0 Added `duotone` key with CSS selector.
	 *
	 * @return array Block metadata.
	 */
	protected static function get_blocks_metadata() {
		if ( null !== static::$blocks_metadata ) {
			return static::$blocks_metadata;
		}

		static::$blocks_metadata = array();

		$registry = WP_Block_Type_Registry::get_instance();
		$blocks   = $registry->get_all_registered();

Top ↑

Changelog

Changelog
VersionDescription
5.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.