* *
[child panels]
* * * @param array $attrs Block attributes. * @param string $content Rendered child panels. * @param object $block Parsed block. * @param object $elements Module elements helper. * * @return string */ public static function render_callback($attrs, $content, $block, $elements) { $advanced = $attrs['module']['advanced'] ?? []; $wrapper_class = self::wrapper_class($advanced); // Build the nav from the child tab titles. $inner_blocks = $block->parsed_block['innerBlocks'] ?? []; $nav_items = ''; $index = 0; foreach ($inner_blocks as $inner_block) { $title = $inner_block['attrs']['title']['innerContent']['desktop']['value'] ?? ''; if ('' === $title) { $title = sprintf('Tab %d', $index + 1); } $is_active = 0 === $index; $active = $is_active ? ' dtq-tabs__nav-item--active' : ''; // Roving tabindex: only the selected tab is in the tab order; the // rest are reached with the arrow keys (handled in frontend.js). // aria-controls / aria-labelledby are wired up there too, because the // panels are rendered by the child modules and their ids are not // known here. $nav_items .= sprintf( '', $active, (int) $index, esc_html(wp_strip_all_tags($title)), $is_active ? '0' : '-1', $is_active ? 'true' : 'false' ); $index++; } $nav_html = sprintf('', $nav_items); $panels_html = sprintf('
%1$s
', $content); $tabs_html = sprintf( '
%2$s%3$s
', esc_attr($wrapper_class), $nav_html, $panels_html ); return Module::render( [ 'orderIndex' => $block->parsed_block['orderIndex'] ?? 0, 'storeInstance' => $block->parsed_block['storeInstance'] ?? null, 'id' => $block->parsed_block['id'], 'name' => $block->block_type->name, 'moduleCategory' => $block->block_type->category, 'attrs' => $attrs, 'elements' => $elements, 'classnamesFunction' => [self::class, 'module_classnames'], 'stylesComponent' => [self::class, 'module_styles'], 'scriptDataComponent' => [self::class, 'module_script_data'], 'children' => [ $elements->style_components(['attrName' => 'module']), $tabs_html, ], ] ); } }