block_core_tabs_provide_context()
Filter to provide tabs list context to core/tabs and core/tab-list blocks. It is more performant to do this here, once, rather than in the tabs render and tabs context filters. In this way core/tabs is both a provider and a consumer of the core/tabs-list context.
Хуков нет.
Возвращает
array. Modified context.
Использование
block_core_tabs_provide_context( $context, $parsed_block ): array;
- $context(массив) (обязательный)
- Default block context.
- $parsed_block(массив) (обязательный)
- The block being rendered.
Список изменений
| С версии 7.1.0 | Введена. |
Код block_core_tabs_provide_context() block core tabs provide context WP 7.1.2
function block_core_tabs_provide_context( array $context, array $parsed_block ): array {
if ( 'core/tabs' === $parsed_block['blockName'] ) {
// Generate a unique ID for the tabs instance first, so it can be used
// to derive stable tab IDs.
$tabs_id = $parsed_block['attrs']['anchor'] ?? wp_unique_id( 'tabs_' );
$tabs_list = block_core_tabs_generate_tabs_list( $parsed_block['innerBlocks'] ?? array(), $tabs_id );
$context['core/tabs-list'] = $tabs_list;
$context['core/tabs-id'] = $tabs_id;
}
return $context;
}