WP_Theme_JSON::get_block_element_selectors( string $root_selector ): array

In this article

Generates all the element selectors for a block.

Parameters

$root_selectorstringrequired
The block’s root CSS selector.

Return

array The block’s element selectors.

Source

 *
 * @return array The custom selectors set by the block.
 */
protected static function get_block_selectors( $block_type, $root_selector ) {
	if ( ! empty( $block_type->selectors ) ) {
		return $block_type->selectors;
	}

	$selectors = array( 'root' => $root_selector );
	foreach ( static::BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS as $key => $feature ) {
		$feature_selector = wp_get_block_css_selector( $block_type, $key );
		if ( null !== $feature_selector ) {
			$selectors[ $feature ] = array( 'root' => $feature_selector );
		}
	}

	return $selectors;
}

/**
 * Generates all the element selectors for a block.
 *

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

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