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

In this article

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

VersionDescription
5.9.0Introduced.

User Contributed Notes

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