wpseek.com
A WordPress-centric search engine for devs and theme authors
block_core_tabs_render_block_callback › WordPress Function
Since7.1.0
Deprecatedn/a
› block_core_tabs_render_block_callback ( $attributes, $content, $block )
| Parameters: (3) |
|
| Returns: |
|
| Defined at: |
|
| Codex: |
Render callback for core/tabs.
Source
function block_core_tabs_render_block_callback( array $attributes, string $content, \WP_Block $block ): string {
$active_tab_index = $attributes['activeTabIndex'] ?? 0;
$tabs_list = $block->context['core/tabs-list'] ?? array();
$tabs_id = $block->context['core/tabs-id'] ?? null;
if ( empty( $tabs_id ) ) {
// If malformed tabs, return early to avoid errors.
return '';
}
$tag_processor = new WP_HTML_Tag_Processor( $content );
$tag_processor->next_tag( array( 'class_name' => 'wp-block-tabs' ) );
$tag_processor->set_attribute( 'data-wp-interactive', 'core/tabs' );
$tag_processor->set_attribute(
'data-wp-context',
wp_json_encode(
array(
'tabsId' => $tabs_id,
'activeTabIndex' => $active_tab_index,
)
)
);
$tag_processor->set_attribute( 'data-wp-init', 'callbacks.onTabsInit' );
$tag_processor->set_attribute( 'data-wp-on--keydown', 'actions.handleTabKeyDown' );
$output = $tag_processor->get_updated_html();
/**
* Builds a client side state for just this tabs instance, so each
* core/tabs block manages its own state, like context.
*/
wp_interactivity_state(
'core/tabs',
array(
$tabs_id => $tabs_list,
)
);
return $output;
}