WP_Theme_JSON::get_block_selectors
Returns the selectors metadata for a block.
Method of the class: WP_Theme_JSON{}
No Hooks.
Returns
Array. The custom selectors set by the block.
Usage
$result = WP_Theme_JSON::get_block_selectors( $block_type, $root_selector );
- $block_type(object) (required)
- The block type.
- $root_selector(string) (required)
- The block's root selector.
Changelog
| Since 6.3.0 | Introduced. |
WP_Theme_JSON::get_block_selectors() WP Theme JSON::get block selectors code WP 6.9.1
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;
}