W3cubDocs

/WordPress

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

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

Version Description
5.9.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json/get_name_from_defaults