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

		// Compute declarations for remaining styles not covered by feature level selectors.
		$style_variation_declarations[ $style_variation['selector'] ] = static::compute_style_properties( $style_variation_node, $settings, null, $this->theme_json );
		// Store custom CSS for the style variation.
		if ( isset( $style_variation_node['css'] ) ) {
			$style_variation_custom_css[ $style_variation['selector'] ] = $this->process_blocks_custom_css( $style_variation_node['css'], $style_variation['selector'] );
		}
	}
}
/*
 * Get a reference to element name from path.
 * $block_metadata['path'] = array( 'styles','elements','link' );
 * Make sure that $block_metadata['path'] describes an element node, like [ 'styles', 'element', 'link' ].
 * Skip non-element paths like just ['styles'].
 */
$is_processing_element = in_array( 'elements', $block_metadata['path'], true );

$current_element = $is_processing_element ? $block_metadata['path'][ count( $block_metadata['path'] ) - 1 ] : null;

$element_pseudo_allowed = array();

if ( isset( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ] ) ) {
	$element_pseudo_allowed = static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ];
}

/*
 * Check for allowed pseudo classes (e.g. ":hover") from the $selector ("a:hover").
 * This also resets the array keys.

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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