WP_Theme_JSON::get_name_from_defaults( string $slug, array $base_path ): string|null

In this article

Gets a default‘s preset name by a provided slug.

Parameters

$slugstringrequired
The slug we want to find a match from default presets.
$base_patharrayrequired
The path to inspect. It’s 'settings' by default.

Return

string|null

Source

/**
 * Gets the CSS rules for a particular block from theme.json.
 *
 * @since 6.1.0
 * @since 6.6.0 Setting a min-height of HTML when root styles have a background gradient or image.
 *              Updated general global styles specificity to 0-1-0.
 *              Fixed custom CSS output in block style variations.
 *
 * @param array $block_metadata Metadata about the block to get styles for.
 *
 * @return string Styles for the block.
 */
public function get_styles_for_block( $block_metadata ) {
	$node                 = _wp_array_get( $this->theme_json, $block_metadata['path'], array() );

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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