W3cubDocs

/WordPress

WP_Theme_JSON::get_default_slugs( array $data, array $node_path ): array

Returns the default slugs for all the presets in an associative array whose keys are the preset paths and the leafs is the list of slugs.

Description

For example:

array(
  'color' => array(
    'palette'   => array( 'slug-1', 'slug-2' ),
    'gradients' => array( 'slug-3', 'slug-4' ),
  ),
)

Parameters

$dataarrayrequired
A theme.json like structure.
$node_patharrayrequired
The path to inspect. It’s 'settings' by default.

Return

array

Source

	$nodes[] = array(
		'path' => $node_path,
	);
	continue;
}

$nodes[] = array(
	'path'     => $node_path,
	'selector' => $selectors[ $name ]['elements'][ $element ],
);

// Handle any pseudo selectors for the element.
if ( isset( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] ) ) {
	foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) {
		if ( isset( $theme_json['styles']['blocks'][ $name ]['elements'][ $element ][ $pseudo_selector ] ) ) {
			$node_path = array( 'styles', 'blocks', $name, 'elements', $element );
			if ( $include_node_paths_only ) {
				$nodes[] = array(
					'path' => $node_path,
				);
				continue;
			}

			$nodes[] = array(
				'path'     => $node_path,
				'selector' => static::append_to_selector( $selectors[ $name ]['elements'][ $element ], $pseudo_selector ),
			);

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_default_slugs