WP_Theme_JSON::get_block_selectors
Returns the selectors metadata for a block.
Метод класса: WP_Theme_JSON{}
Хуков нет.
Возвращает
Массив. The custom selectors set by the block.
Использование
$result = WP_Theme_JSON::get_block_selectors( $block_type, $root_selector );
- $block_type(объект) (обязательный)
- The block type.
- $root_selector(строка) (обязательный)
- The block's root selector.
Список изменений
| С версии 6.3.0 | Введена. |
Код WP_Theme_JSON::get_block_selectors() WP Theme JSON::get block selectors WP 7.0
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;
}