Skip to content

Commit c0da87e

Browse files
authored
Merge branch 'main' into feature/MOOSE-360/refactor-horizontal-tabs-block
2 parents 83d1a16 + f622a24 commit c0da87e

File tree

9 files changed

+452
-250
lines changed

9 files changed

+452
-250
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ item (Added, Changed, Depreciated, Removed, Fixed, Security).
66

77
## [2026.03]
88

9-
- Refactor Horizontal Tabs block into a dynamic block. Add reordering functionality.
9+
- Updated: Refactor Horizontal Tabs block into a dynamic block. Add reordering functionality.
10+
- Updated: Refactor Vertical Tabs block to dynamic block; allow sorting.
1011

1112
## [2026.02]
1213
- Added: `moderntribe/tribe_embed` composer package v1.1.0.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
"wpengine/advanced-custom-fields-pro": "^6.4"
134134
},
135135
"extra": {
136-
"wordpress-version": "6.9.1",
136+
"wordpress-version": "6.9.4",
137137
"installer-paths": {
138138
"wp-content/plugins/{$name}": [
139139
"type:wordpress-plugin"
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Tribe\Plugin\Components\Blocks;
4+
5+
use Tribe\Plugin\Components\Abstracts\Abstract_Block_Controller;
6+
7+
/**
8+
* Controller for the Vertical Tabs block.
9+
* Builds tab data from inner blocks (saved order).
10+
*/
11+
class Vertical_Tabs_Block_Controller extends Abstract_Block_Controller {
12+
13+
/**
14+
* Tab items built from inner blocks.
15+
*
16+
* @var array<int, array{id: string, buttonId: string, title: string, content: string}>
17+
*/
18+
protected array $tabs = [];
19+
20+
protected \WP_Block $block;
21+
22+
public function __construct( array $args = [] ) {
23+
parent::__construct( $args );
24+
25+
$this->block = $args['block'] ?? new \WP_Block( [ 'blockName' => 'tribe/vertical-tabs' ] );
26+
$this->tabs = $this->build_tabs_from_inner_blocks();
27+
}
28+
29+
/**
30+
* @return array<int, array{id: string, buttonId: string, title: string, content: string}>
31+
*/
32+
public function get_tabs(): array {
33+
return $this->tabs;
34+
}
35+
36+
/**
37+
* Whether the given tab (by index) should be selected. First tab is always active on the front-end.
38+
*/
39+
public function is_tab_selected( int $index ): bool {
40+
return $index === 0;
41+
}
42+
43+
/**
44+
* Build tab list from parsed inner blocks (preserves saved order).
45+
*
46+
* @return array<int, array{id: string, buttonId: string, title: string, content: string}>
47+
*/
48+
protected function build_tabs_from_inner_blocks(): array {
49+
$block = $this->block->parsed_block;
50+
$inner_blocks = $block['innerBlocks'] ?? [];
51+
$tabs = [];
52+
53+
foreach ( $inner_blocks as $inner ) {
54+
if ( ( $inner['blockName'] ?? '' ) !== 'tribe/vertical-tab' ) {
55+
continue;
56+
}
57+
58+
$attrs = $inner['attrs'] ?? [];
59+
$id = $attrs['blockId'] ?? '';
60+
$title = $attrs['title'] ?? '';
61+
$content = $attrs['content'] ?? '';
62+
63+
$tabs[] = [
64+
'id' => $id,
65+
'buttonId' => 'vt-button-' . $id,
66+
'title' => $title !== '' ? $title : __( 'Tab Heading', 'tribe' ),
67+
'content' => $content,
68+
];
69+
}
70+
71+
return $tabs;
72+
}
73+
74+
}

wp-content/themes/core/blocks/tribe/vertical-tabs/_variables.pcss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@
99
--vertical-tabs-border-color: var(--color-black-20);
1010
--vertical-tabs-border-selected-color: var(--color-blue);
1111
--vertical-tabs-title-selected-color: var(--color-blue);
12+
--vertical-tabs-editor-grab-icon-color: var(--color-black);
13+
--vertical-tabs-editor-grab-icon-hover-color: var(--color-neutral-80);
14+
--vertical-tabs-editor-delete-icon-color: var(--color-alert-error);
15+
--vertical-tabs-editor-delete-icon-hover-color: var(--color-alert-error-dark);
1216
}
1317

1418
:--dark-themes {
1519
--vertical-tabs-border-color: var(--color-white-20);
1620
--vertical-tabs-border-selected-color: var(--color-white);
1721
--vertical-tabs-title-selected-color: var(--color-white);
22+
--vertical-tabs-editor-grab-icon-color: var(--color-white);
23+
--vertical-tabs-editor-grab-icon-hover-color: var(--color-neutral-20);
24+
--vertical-tabs-editor-delete-icon-color: var(--color-white);
25+
--vertical-tabs-editor-delete-icon-hover-color: var(--color-neutral-20);
1826
}

wp-content/themes/core/blocks/tribe/vertical-tabs/block.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,9 @@
88
"icon": "align-pull-right",
99
"description": "Tab content displayed vertically",
1010
"attributes": {
11-
"blockUpdated": {
12-
"type": "string",
13-
"default": ""
14-
},
1511
"currentActiveTabInstanceId": {
1612
"type": "string",
1713
"default": ""
18-
},
19-
"tabs": {
20-
"type": "array",
21-
"default": []
2214
}
2315
},
2416
"supports": {

0 commit comments

Comments
 (0)