PluginProbe
Elementor Website Builder – more than just a page builder / 3.11.2
Elementor Website Builder – more than just a page builder v3.11.2
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | modules/nested-tabs/widgets/nested-tabs.php +265 -411 4.1.03.11.2 View file →
@@ -14,19 +14,18 @@
14 14 use Elementor\Modules\NestedElements\Base\Widget_Nested_Base;
15 15 use Elementor\Modules\NestedElements\Controls\Control_Nested_Repeater;
16 16 use Elementor\Plugin;
17 17 use Elementor\Repeater;
18 +use Elementor\Modules\DynamicTags\Module as TagsModule;
19 +use Elementor\Utils;
20 +use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
18 21
19 22 if ( ! defined( 'ABSPATH' ) ) {
20 - exit; // Exit if accessed directly.
23 + exit; // Exit if accessed directly
21 24 }
22 25
23 26 class NestedTabs extends Widget_Nested_Base {
24 27
25 - private $tab_item_settings = [];
26 - private $optimized_markup = null;
27 - private $widget_container_selector = '';
28 -
29 28 public function get_name() {
30 29 return 'nested-tabs';
31 30 }
32 31
@@ -41,29 +40,13 @@
41 40 public function get_keywords() {
42 41 return [ 'nested', 'tabs', 'accordion', 'toggle' ];
43 42 }
44 43
45 - public function get_style_depends(): array {
46 - return [ 'widget-nested-tabs' ];
47 - }
48 -
49 - public function has_widget_inner_wrapper(): bool {
50 - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
51 - }
52 -
53 - public function show_in_panel(): bool {
54 - return Plugin::$instance->experiments->is_feature_active( 'nested-elements', true );
55 - }
56 -
57 44 protected function tab_content_container( int $index ) {
58 45 return [
59 46 'elType' => 'container',
60 47 'settings' => [
61 - '_title' => sprintf(
62 - /* translators: %d: Tab index. */
63 - __( 'Tab #%d', 'elementor' ),
64 - $index
65 - ),
48 + '_title' => sprintf( __( 'Tab #%s', 'elementor' ), $index ),
66 49 'content_width' => 'full',
67 50 ],
68 51 ];
69 52 }
@@ -80,9 +63,8 @@
80 63 return 'tab_title';
81 64 }
82 65
83 66 protected function get_default_children_title() {
84 - /* translators: %d: Tab index. */
85 67 return esc_html__( 'Tab #%d', 'elementor' );
86 68 }
87 69
88 70 protected function get_default_children_placeholder_selector() {
@@ -93,21 +75,14 @@
93 75 return 'elementor-widget-n-tabs';
94 76 }
95 77
96 78 protected function register_controls() {
97 - if ( null === $this->optimized_markup ) {
98 - $this->optimized_markup = Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ) && ! $this->has_widget_inner_wrapper();
99 - $this->widget_container_selector = $this->optimized_markup ? '' : ' > .elementor-widget-container';
100 - }
101 -
102 79 $start = is_rtl() ? 'right' : 'left';
103 80 $end = is_rtl() ? 'left' : 'right';
104 - $start_logical = is_rtl() ? 'end' : 'start';
105 - $end_logical = is_rtl() ? 'start' : 'end';
106 - $heading_selector_non_touch_device = "{{WRAPPER}}.elementor-widget-n-tabs{$this->widget_container_selector} > .e-n-tabs[data-touch-mode='false'] > .e-n-tabs-heading";
107 - $heading_selector_touch_device = "{{WRAPPER}}.elementor-widget-n-tabs{$this->widget_container_selector} > .e-n-tabs[data-touch-mode='true'] > .e-n-tabs-heading";
108 - $heading_selector = "{{WRAPPER}}.elementor-widget-n-tabs{$this->widget_container_selector} > .e-n-tabs > .e-n-tabs-heading";
109 - $content_selector = ":where( {{WRAPPER}}.elementor-widget-n-tabs{$this->widget_container_selector} > .e-n-tabs > .e-n-tabs-content ) > .e-con";
81 + $tooltip_start = is_rtl() ? esc_html__( 'Right', 'elementor' ) : esc_html__( 'Left', 'elementor' );
82 + $tooltip_end = is_rtl() ? esc_html__( 'Left', 'elementor' ) : esc_html__( 'Right', 'elementor' );
83 + $nested_tabs_heading_selector_class = ':is( {{WRAPPER}} > .elementor-widget-container > .e-n-tabs > .e-n-tabs-heading, {{WRAPPER}} > .elementor-widget-container > .e-n-tabs > .e-n-tabs-content )';
84 + $nested_tabs_content_selector_class = '{{WRAPPER}} > .elementor-widget-container > .e-n-tabs > .e-n-tabs-content';
110 85
111 86 $this->start_controls_section( 'section_tabs', [
112 87 'label' => esc_html__( 'Tabs', 'elementor' ),
113 88 ] );
@@ -155,11 +130,8 @@
155 130 [
156 131 'label' => esc_html__( 'CSS ID', 'elementor' ),
157 132 'type' => Controls_Manager::TEXT,
158 133 'default' => '',
159 - 'ai' => [
160 - 'active' => false,
161 - ],
162 134 'dynamic' => [
163 135 'active' => true,
164 136 ],
165 137 'title' => esc_html__( 'Add your custom id WITHOUT the Pound key. e.g: my-id', 'elementor' ),
@@ -183,53 +155,42 @@
183 155 'tab_title' => esc_html__( 'Tab #3', 'elementor' ),
184 156 ],
185 157 ],
186 158 'title_field' => '{{{ tab_title }}}',
187 - 'button_text' => esc_html__( 'Add Tab', 'elementor' ),
159 + 'button_text' => 'Add Tab',
188 160 ] );
189 161
190 - $styling_block_start = '--n-tabs-direction: column; --n-tabs-heading-direction: row; --n-tabs-heading-width: initial; --n-tabs-title-flex-basis: content; --n-tabs-title-flex-shrink: 0;';
191 - $styling_block_end = '--n-tabs-direction: column-reverse; --n-tabs-heading-direction: row; --n-tabs-heading-width: initial; --n-tabs-title-flex-basis: content; --n-tabs-title-flex-shrink: 0';
192 - $styling_inline_end = '--n-tabs-direction: row-reverse; --n-tabs-heading-direction: column; --n-tabs-heading-width: 240px; --n-tabs-title-flex-basis: initial; --n-tabs-title-flex-shrink: initial;';
193 - $styling_inline_start = '--n-tabs-direction: row; --n-tabs-heading-direction: column; --n-tabs-heading-width: 240px; --n-tabs-title-flex-basis: initial; --n-tabs-title-flex-shrink: initial;';
194 -
195 162 $this->add_responsive_control( 'tabs_direction', [
196 163 'label' => esc_html__( 'Direction', 'elementor' ),
197 164 'type' => Controls_Manager::CHOOSE,
198 165 'options' => [
199 - 'block-start' => [
200 - 'title' => esc_html__( 'Above', 'elementor' ),
166 + 'top' => [
167 + 'title' => esc_html__( 'Top', 'elementor' ),
201 168 'icon' => 'eicon-v-align-top',
202 169 ],
203 - 'block-end' => [
204 - 'title' => esc_html__( 'Below', 'elementor' ),
170 + 'bottom' => [
171 + 'title' => esc_html__( 'Bottom', 'elementor' ),
205 172 'icon' => 'eicon-v-align-bottom',
206 173 ],
207 - 'inline-end' => [
208 - 'title' => esc_html__( 'After', 'elementor' ),
174 + 'end' => [
175 + 'title' => $tooltip_end,
209 176 'icon' => 'eicon-h-align-' . $end,
210 177 ],
211 - 'inline-start' => [
212 - 'title' => esc_html__( 'Before', 'elementor' ),
178 + 'start' => [
179 + 'title' => $tooltip_start,
213 180 'icon' => 'eicon-h-align-' . $start,
214 181 ],
215 182 ],
216 183 'separator' => 'before',
217 184 'selectors_dictionary' => [
218 - 'block-start' => $styling_block_start,
219 - 'block-end' => $styling_block_end,
220 - 'inline-end' => $styling_inline_end,
221 - 'inline-start' => $styling_inline_start,
222 - // Styling duplication for BC reasons.
223 - 'top' => $styling_block_start,
224 - 'bottom' => $styling_block_end,
225 - 'end' => $styling_inline_end,
226 - 'start' => $styling_inline_start,
185 + 'top' => '--n-tabs-direction: column; --n-tabs-heading-direction: row; --n-tabs-heading-width: initial;',
186 + 'bottom' => '--n-tabs-direction: column-reverse; --n-tabs-heading-direction: row; --n-tabs-heading-width: initial;',
187 + 'end' => '--n-tabs-direction: row-reverse; --n-tabs-heading-direction: column; --n-tabs-heading-width: 240px;',
188 + 'start' => '--n-tabs-direction: row; --n-tabs-heading-direction: column; --n-tabs-heading-width: 240px;',
227 189 ],
228 190 'selectors' => [
229 191 '{{WRAPPER}}' => '{{VALUE}}',
230 192 ],
231 - 'control_type' => 'content',
232 193 ] );
233 194
234 195 $this->add_responsive_control( 'tabs_justify_horizontal', [
235 196 'label' => esc_html__( 'Justify', 'elementor' ),
@@ -236,28 +197,28 @@
236 197 'type' => Controls_Manager::CHOOSE,
237 198 'options' => [
238 199 'start' => [
239 200 'title' => esc_html__( 'Start', 'elementor' ),
240 - 'icon' => "eicon-align-$start_logical-h",
201 + 'icon' => 'eicon-flex eicon-align-start-h',
241 202 ],
242 203 'center' => [
243 204 'title' => esc_html__( 'Center', 'elementor' ),
244 - 'icon' => 'eicon-align-center-h',
205 + 'icon' => 'eicon-h-align-center',
245 206 ],
246 207 'end' => [
247 208 'title' => esc_html__( 'End', 'elementor' ),
248 - 'icon' => "eicon-align-$end_logical-h",
209 + 'icon' => 'eicon-flex eicon-align-end-h',
249 210 ],
250 211 'stretch' => [
251 - 'title' => esc_html__( 'Stretch', 'elementor' ),
252 - 'icon' => 'eicon-align-stretch-h',
212 + 'title' => esc_html__( 'Justified', 'elementor' ),
213 + 'icon' => 'eicon-h-align-stretch',
253 214 ],
254 215 ],
255 216 'selectors_dictionary' => [
256 - 'start' => '--n-tabs-heading-justify-content: flex-start; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: center; --n-tabs-title-flex-grow: 0;',
257 - 'center' => '--n-tabs-heading-justify-content: center; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: center; --n-tabs-title-flex-grow: 0;',
258 - 'end' => '--n-tabs-heading-justify-content: flex-end; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: center; --n-tabs-title-flex-grow: 0;',
259 - 'stretch' => '--n-tabs-heading-justify-content: initial; --n-tabs-title-width: 100%; --n-tabs-title-height: initial; --n-tabs-title-align-items: center; --n-tabs-title-flex-grow: 1;',
217 + 'start' => '--n-tabs-heading-justify-content: flex-start; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: center;',
218 + 'center' => '--n-tabs-heading-justify-content: center; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: center;',
219 + 'end' => '--n-tabs-heading-justify-content: flex-end; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: center',
220 + 'stretch' => '--n-tabs-heading-justify-content: initial; --n-tabs-title-width: 100%; --n-tabs-title-height: initial; --n-tabs-title-align-items: center;',
260 221 ],
261 222 'selectors' => [
262 223 '{{WRAPPER}}' => '{{VALUE}}',
263 224 ],
@@ -263,15 +224,12 @@
263 224 ],
264 225 'condition' => [
265 226 'tabs_direction' => [
266 227 '',
267 - 'block-start',
268 - 'block-end',
269 228 'top',
270 229 'bottom',
271 230 ],
272 231 ],
273 - 'frontend_available' => true,
274 232 ] );
275 233
276 234 $this->add_responsive_control( 'tabs_justify_vertical', [
277 235 'label' => esc_html__( 'Justify', 'elementor' ),
@@ -278,28 +236,28 @@
278 236 'type' => Controls_Manager::CHOOSE,
279 237 'options' => [
280 238 'start' => [
281 239 'title' => esc_html__( 'Start', 'elementor' ),
282 - 'icon' => 'eicon-align-start-v',
240 + 'icon' => 'eicon-flex eicon-align-start-v',
283 241 ],
284 242 'center' => [
285 243 'title' => esc_html__( 'Center', 'elementor' ),
286 - 'icon' => 'eicon-align-center-v',
244 + 'icon' => 'eicon-v-align-middle',
287 245 ],
288 246 'end' => [
289 247 'title' => esc_html__( 'End', 'elementor' ),
290 - 'icon' => 'eicon-align-end-v',
248 + 'icon' => 'eicon-flex eicon-align-end-v',
291 249 ],
292 250 'stretch' => [
293 - 'title' => esc_html__( 'Stretch', 'elementor' ),
294 - 'icon' => 'eicon-align-stretch-v',
251 + 'title' => esc_html__( 'Justified', 'elementor' ),
252 + 'icon' => 'eicon-v-align-stretch',
295 253 ],
296 254 ],
297 255 'selectors_dictionary' => [
298 - 'start' => '--n-tabs-heading-justify-content: flex-start; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial; --n-tabs-heading-wrap: wrap; --n-tabs-title-flex-basis: content',
299 - 'center' => '--n-tabs-heading-justify-content: center; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial; --n-tabs-heading-wrap: wrap; --n-tabs-title-flex-basis: content',
300 - 'end' => '--n-tabs-heading-justify-content: flex-end; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial; --n-tabs-heading-wrap: wrap; --n-tabs-title-flex-basis: content',
301 - 'stretch' => '--n-tabs-heading-justify-content: flex-start; --n-tabs-title-width: initial; --n-tabs-title-height: 100%; --n-tabs-title-align-items: center; --n-tabs-heading-wrap: nowrap; --n-tabs-title-flex-basis: auto',
256 + 'start' => '--n-tabs-heading-justify-content: flex-start; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial;',
257 + 'center' => '--n-tabs-heading-justify-content: center; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial;',
258 + 'end' => '--n-tabs-heading-justify-content: flex-end; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial;',
259 + 'stretch' => '--n-tabs-heading-justify-content: flex-start; --n-tabs-title-width: initial; --n-tabs-title-height: 100%; --n-tabs-title-align-items: center;',
302 260 ],
303 261 'selectors' => [
304 262 '{{WRAPPER}}' => '{{VALUE}}',
305 263 ],
@@ -304,10 +262,8 @@
304 262 '{{WRAPPER}}' => '{{VALUE}}',
305 263 ],
306 264 'condition' => [
307 265 'tabs_direction' => [
308 - 'inline-start',
309 - 'inline-end',
310 266 'start',
311 267 'end',
312 268 ],
313 269 ],
@@ -328,16 +284,14 @@
328 284 ],
329 285 'default' => [
330 286 'unit' => '%',
331 287 ],
332 - 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
288 + 'size_units' => [ '%', 'px' ],
333 289 'selectors' => [
334 290 '{{WRAPPER}}' => '--n-tabs-heading-width: {{SIZE}}{{UNIT}}',
335 291 ],
336 292 'condition' => [
337 293 'tabs_direction' => [
338 - 'inline-start',
339 - 'inline-end',
340 294 'start',
341 295 'end',
342 296 ],
343 297 ],
@@ -347,9 +301,9 @@
347 301 'label' => esc_html__( 'Align Title', 'elementor' ),
348 302 'type' => Controls_Manager::CHOOSE,
349 303 'options' => [
350 304 'start' => [
351 - 'title' => esc_html__( 'Start', 'elementor' ),
305 + 'title' => esc_html__( 'Left', 'elementor' ),
352 306 'icon' => 'eicon-text-align-left',
353 307 ],
354 308 'center' => [
355 309 'title' => esc_html__( 'Center', 'elementor' ),
@@ -355,16 +309,16 @@
355 309 'title' => esc_html__( 'Center', 'elementor' ),
356 310 'icon' => 'eicon-text-align-center',
357 311 ],
358 312 'end' => [
359 - 'title' => esc_html__( 'End', 'elementor' ),
313 + 'title' => esc_html__( 'Right', 'elementor' ),
360 314 'icon' => 'eicon-text-align-right',
361 315 ],
362 316 ],
363 317 'selectors_dictionary' => [
364 - 'start' => '--n-tabs-title-justify-content: flex-start; --n-tabs-title-align-items: flex-start; --n-tabs-title-text-align: start;',
365 - 'center' => '--n-tabs-title-justify-content: center; --n-tabs-title-align-items: center; --n-tabs-title-text-align: center;',
366 - 'end' => '--n-tabs-title-justify-content: flex-end; --n-tabs-title-align-items: flex-end; --n-tabs-title-text-align: end;',
318 + 'start' => '--n-tabs-title-justify-content: flex-start; --n-tabs-title-align-items: flex-start;',
319 + 'center' => '--n-tabs-title-justify-content: center; --n-tabs-title-align-items: center;',
320 + 'end' => '--n-tabs-title-justify-content: flex-end; --n-tabs-title-align-items: flex-end;',
367 321 ],
368 322 'selectors' => [
369 323 '{{WRAPPER}}' => '{{VALUE}}',
370 324 ],
@@ -372,45 +326,12 @@
372 326
373 327 $this->end_controls_section();
374 328
375 329 $this->start_controls_section( 'section_tabs_responsive', [
376 - 'label' => esc_html__( 'Additional Settings', 'elementor' ),
330 + 'label' => esc_html__( 'Responsive Settings', 'elementor' ),
377 331 ] );
378 332
379 - $this->add_responsive_control(
380 - 'horizontal_scroll',
381 - [
382 - 'label' => esc_html__( 'Horizontal Scroll', 'elementor' ),
383 - 'type' => Controls_Manager::SELECT,
384 - 'description' => esc_html__( 'Note: Scroll tabs if they don’t fit into their parent container.', 'elementor' ),
385 - 'options' => [
386 - 'disable' => esc_html__( 'Disable', 'elementor' ),
387 - 'enable' => esc_html__( 'Enable', 'elementor' ),
388 - ],
389 - 'default' => 'disable',
390 - 'selectors_dictionary' => [
391 - 'disable' => '--n-tabs-heading-wrap: wrap; --n-tabs-heading-overflow-x: initial; --n-tabs-title-white-space: initial;',
392 - 'enable' => '--n-tabs-heading-wrap: nowrap; --n-tabs-heading-overflow-x: scroll; --n-tabs-title-white-space: nowrap;',
393 - ],
394 - 'selectors' => [
395 - '{{WRAPPER}}' => '{{VALUE}}',
396 - ],
397 - 'frontend_available' => true,
398 - 'condition' => [
399 - 'tabs_direction' => [
400 - '',
401 - 'block-start',
402 - 'block-end',
403 - 'top',
404 - 'bottom',
405 - ],
406 - ],
407 - ]
408 - );
409 -
410 - $dropdown_options = [
411 - 'none' => esc_html__( 'None', 'elementor' ),
412 - ];
333 + $dropdown_options = [];
413 334 $excluded_breakpoints = [
414 335 'laptop',
415 336 'tablet_extra',
416 337 'widescreen',
@@ -452,20 +373,15 @@
452 373
453 374 $this->add_responsive_control( 'tabs_title_space_between', [
454 375 'label' => esc_html__( 'Gap between tabs', 'elementor' ),
455 376 'type' => Controls_Manager::SLIDER,
456 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
457 377 'range' => [
458 378 'px' => [
379 + 'min' => 0,
459 380 'max' => 400,
460 381 ],
461 - 'em' => [
462 - 'max' => 40,
463 - ],
464 - 'rem' => [
465 - 'max' => 40,
466 - ],
467 382 ],
383 + 'size_units' => [ 'px' ],
468 384 'selectors' => [
469 385 '{{WRAPPER}}' => '--n-tabs-title-gap: {{SIZE}}{{UNIT}}',
470 386 ],
471 387 ] );
@@ -472,20 +388,15 @@
472 388
473 389 $this->add_responsive_control( 'tabs_title_spacing', [
474 390 'label' => esc_html__( 'Distance from content', 'elementor' ),
475 391 'type' => Controls_Manager::SLIDER,
476 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
477 392 'range' => [
478 393 'px' => [
394 + 'min' => 0,
479 395 'max' => 400,
480 396 ],
481 - 'em' => [
482 - 'max' => 40,
483 - ],
484 - 'rem' => [
485 - 'max' => 40,
486 - ],
487 397 ],
398 + 'size_units' => [ 'px' ],
488 399 'selectors' => [
489 400 '{{WRAPPER}}' => '--n-tabs-gap: {{SIZE}}{{UNIT}}',
490 401 ],
491 402 ] );
@@ -504,9 +415,9 @@
504 415 [
505 416 'name' => 'tabs_title_background_color',
506 417 'types' => [ 'classic', 'gradient' ],
507 418 'exclude' => [ 'image' ],
508 - 'selector' => "{{WRAPPER}}{$this->widget_container_selector} > .e-n-tabs > .e-n-tabs-heading > .e-n-tab-title[aria-selected='false']:not( :hover )",
419 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover )",
509 420 'fields_options' => [
510 421 'color' => [
511 422 'label' => esc_html__( 'Background Color', 'elementor' ),
512 423 'selectors' => [
@@ -520,9 +431,9 @@
520 431 $this->add_group_control(
521 432 Group_Control_Border::get_type(),
522 433 [
523 434 'name' => 'tabs_title_border',
524 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover )",
435 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover )",
525 436 'fields_options' => [
526 437 'color' => [
527 438 'label' => esc_html__( 'Border Color', 'elementor' ),
528 439 ],
@@ -536,10 +447,11 @@
536 447 $this->add_group_control(
537 448 Group_Control_Box_Shadow::get_type(),
538 449 [
539 450 'name' => 'tabs_title_box_shadow',
451 + 'label' => esc_html__( 'Shadow', 'elementor' ),
540 452 'separator' => 'after',
541 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover )",
453 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover )",
542 454 ]
543 455 );
544 456
545 457 $this->end_controls_tab();
@@ -556,9 +468,9 @@
556 468 [
557 469 'name' => 'tabs_title_background_color_hover',
558 470 'types' => [ 'classic', 'gradient' ],
559 471 'exclude' => [ 'image' ],
560 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
472 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):hover",
561 473 'fields_options' => [
562 474 'background' => [
563 475 'default' => 'classic',
564 476 ],
@@ -578,9 +490,9 @@
578 490 $this->add_group_control(
579 491 Group_Control_Border::get_type(),
580 492 [
581 493 'name' => 'tabs_title_border_hover',
582 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
494 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):hover",
583 495 'fields_options' => [
584 496 'color' => [
585 497 'label' => esc_html__( 'Border Color', 'elementor' ),
586 498 ],
@@ -594,10 +506,11 @@
594 506 $this->add_group_control(
595 507 Group_Control_Box_Shadow::get_type(),
596 508 [
597 509 'name' => 'tabs_title_box_shadow_hover',
510 + 'label' => esc_html__( 'Shadow', 'elementor' ),
598 511 'separator' => 'after',
599 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
512 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):hover",
600 513 ]
601 514 );
602 515
603 516 $this->add_control(
@@ -610,9 +523,9 @@
610 523
611 524 $this->add_control(
612 525 'tabs_title_transition_duration',
613 526 [
614 - 'label' => esc_html__( 'Transition Duration', 'elementor' ) . ' (s)',
527 + 'label' => esc_html__( 'Transition Duration (s)', 'elementor' ),
615 528 'type' => Controls_Manager::SLIDER,
616 529 'selectors' => [
617 530 '{{WRAPPER}}' => '--n-tabs-title-transition: {{SIZE}}s',
618 531 ],
@@ -617,9 +530,8 @@
617 530 '{{WRAPPER}}' => '--n-tabs-title-transition: {{SIZE}}s',
618 531 ],
619 532 'range' => [
620 533 'px' => [
621 - 'min' => 0,
622 534 'max' => 3,
623 535 'step' => 0.1,
624 536 ],
625 537 ],
@@ -640,9 +552,9 @@
640 552 [
641 553 'name' => 'tabs_title_background_color_active',
642 554 'types' => [ 'classic', 'gradient' ],
643 555 'exclude' => [ 'image' ],
644 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"true\"], {$heading_selector_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
556 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
645 557 'fields_options' => [
646 558 'background' => [
647 559 'default' => 'classic',
648 560 ],
@@ -662,9 +574,9 @@
662 574 $this->add_group_control(
663 575 Group_Control_Border::get_type(),
664 576 [
665 577 'name' => 'tabs_title_border_active',
666 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"true\"], {$heading_selector_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
578 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
667 579 'fields_options' => [
668 580 'color' => [
669 581 'label' => esc_html__( 'Border Color', 'elementor' ),
670 582 ],
@@ -678,9 +590,10 @@
678 590 $this->add_group_control(
679 591 Group_Control_Box_Shadow::get_type(),
680 592 [
681 593 'name' => 'tabs_title_box_shadow_active',
682 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"true\"], {$heading_selector_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
594 + 'label' => esc_html__( 'Shadow', 'elementor' ),
595 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
683 596 ]
684 597 );
685 598
686 599 $this->end_controls_tab();
@@ -691,9 +604,9 @@
691 604 'tabs_title_border_radius',
692 605 [
693 606 'label' => esc_html__( 'Border Radius', 'elementor' ),
694 607 'type' => Controls_Manager::DIMENSIONS,
695 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
608 + 'size_units' => [ 'px', 'em', '%', 'rem' ],
696 609 'separator' => 'before',
697 610 'selectors' => [
698 611 '{{WRAPPER}}' => '--n-tabs-title-border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
699 612 ],
@@ -704,9 +617,9 @@
704 617 'padding',
705 618 [
706 619 'label' => esc_html__( 'Padding', 'elementor' ),
707 620 'type' => Controls_Manager::DIMENSIONS,
708 - 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
621 + 'size_units' => [ 'px', 'em', '%', 'rem' ],
709 622 'selectors' => [
710 623 '{{WRAPPER}}' => '--n-tabs-title-padding-top: {{TOP}}{{UNIT}}; --n-tabs-title-padding-right: {{RIGHT}}{{UNIT}}; --n-tabs-title-padding-bottom: {{BOTTOM}}{{UNIT}}; --n-tabs-title-padding-left: {{LEFT}}{{UNIT}};',
711 624 ],
712 625 ]
@@ -723,9 +636,9 @@
723 636 'name' => 'title_typography',
724 637 'global' => [
725 638 'default' => Global_Typography::TYPOGRAPHY_ACCENT,
726 639 ],
727 - 'selector' => "{$heading_selector} > :is( .e-n-tab-title > .e-n-tab-title-text, .e-n-tab-title )",
640 + 'selector' => "{$nested_tabs_heading_selector_class} > :is( .e-n-tab-title > .e-n-tab-title-text, .e-n-tab-title )",
728 641 'fields_options' => [
729 642 'font_size' => [
730 643 'selectors' => [
731 644 '{{WRAPPER}}' => '--n-tabs-title-font-size: {{SIZE}}{{UNIT}}',
@@ -757,9 +670,14 @@
757 670 $this->add_group_control(
758 671 Group_Control_Text_Shadow::get_type(),
759 672 [
760 673 'name' => 'title_text_shadow',
761 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover )",
674 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover )",
675 + 'fields_options' => [
676 + 'text_shadow_type' => [
677 + 'label' => esc_html_x( 'Shadow', 'Text Shadow Control', 'elementor' ),
678 + ],
679 + ],
762 680 ]
763 681 );
764 682
765 683 $this->add_group_control(
@@ -765,9 +683,14 @@
765 683 $this->add_group_control(
766 684 Group_Control_Text_Stroke::get_type(),
767 685 [
768 686 'name' => 'title_text_stroke',
769 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover ) :is( span, a, i )",
687 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover ) :is( span, a, i )",
688 + 'fields_options' => [
689 + 'text_stroke_type' => [
690 + 'label' => esc_html__( 'Stroke', 'elementor' ),
691 + ],
692 + ],
770 693 ]
771 694 );
772 695
773 696 $this->end_controls_tab();
@@ -784,9 +707,9 @@
784 707 [
785 708 'label' => esc_html__( 'Color', 'elementor' ),
786 709 'type' => Controls_Manager::COLOR,
787 710 'selectors' => [
788 - '{{WRAPPER}} [data-touch-mode="false"] .e-n-tab-title[aria-selected="false"]:hover' => '--n-tabs-title-color-hover: {{VALUE}}',
711 + '{{WRAPPER}} .e-n-tab-title:not( .e-active ):hover' => '--n-tabs-title-color-hover: {{VALUE}}',
789 712 ],
790 713 ]
791 714 );
792 715
@@ -793,9 +716,15 @@
793 716 $this->add_group_control(
794 717 Group_Control_Text_Shadow::get_type(),
795 718 [
796 719 'name' => 'title_text_shadow_hover',
797 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
720 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):hover",
721 + 'fields_options' => [
722 + 'text_shadow_type' => [
723 + 'label' => esc_html_x( 'Shadow', 'Text Shadow Control', 'elementor' ),
724 + ],
725 + ],
726 +
798 727 ]
799 728 );
800 729
801 730 $this->add_group_control(
@@ -801,9 +730,14 @@
801 730 $this->add_group_control(
802 731 Group_Control_Text_Stroke::get_type(),
803 732 [
804 733 'name' => 'title_text_stroke_hover',
805 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover :is( span, a, i )",
734 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):hover :is( span, a, i )",
735 + 'fields_options' => [
736 + 'text_stroke_type' => [
737 + 'label' => esc_html__( 'Stroke', 'elementor' ),
738 + ],
739 + ],
806 740 ]
807 741 );
808 742
809 743 $this->end_controls_tab();
@@ -829,9 +763,14 @@
829 763 $this->add_group_control(
830 764 Group_Control_Text_Shadow::get_type(),
831 765 [
832 766 'name' => 'title_text_shadow_active',
833 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"true\"], {$heading_selector_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
767 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
768 + 'fields_options' => [
769 + 'text_shadow_type' => [
770 + 'label' => esc_html_x( 'Shadow', 'Text Shadow Control', 'elementor' ),
771 + ],
772 + ],
834 773 ]
835 774 );
836 775
837 776 $this->add_group_control(
@@ -837,9 +776,14 @@
837 776 $this->add_group_control(
838 777 Group_Control_Text_Stroke::get_type(),
839 778 [
840 779 'name' => 'title_text_stroke_active',
841 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"true\"] :is( span, a, i ), {$heading_selector_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover :is( span, a, i )",
780 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active :is( span, a, i )",
781 + 'fields_options' => [
782 + 'text_stroke_type' => [
783 + 'label' => esc_html__( 'Stroke', 'elementor' ),
784 + ],
785 + ],
842 786 ]
843 787 );
844 788
845 789 $this->end_controls_tab();
@@ -852,45 +796,35 @@
852 796 'label' => esc_html__( 'Icon', 'elementor' ),
853 797 'tab' => Controls_Manager::TAB_STYLE,
854 798 ] );
855 799
856 - $styling_block_start = '--n-tabs-title-direction: column; --n-tabs-icon-order: initial; --n-tabs-title-justify-content-toggle: center; --n-tabs-title-align-items-toggle: initial;';
857 - $styling_block_end = '--n-tabs-title-direction: column; --n-tabs-icon-order: 1; --n-tabs-title-justify-content-toggle: center; --n-tabs-title-align-items-toggle: initial;';
858 - $styling_inline_start = '--n-tabs-title-direction: row; --n-tabs-icon-order: initial; --n-tabs-title-justify-content-toggle: initial; --n-tabs-title-align-items-toggle: center;';
859 - $styling_inline_end = '--n-tabs-title-direction: row; --n-tabs-icon-order: 1; --n-tabs-title-justify-content-toggle: initial; --n-tabs-title-align-items-toggle: center;';
860 -
861 800 $this->add_responsive_control( 'icon_position', [
862 801 'label' => esc_html__( 'Position', 'elementor' ),
863 802 'type' => Controls_Manager::CHOOSE,
864 803 'options' => [
865 - 'block-start' => [
866 - 'title' => esc_html__( 'Above', 'elementor' ),
804 + 'top' => [
805 + 'title' => esc_html__( 'Top', 'elementor' ),
867 806 'icon' => 'eicon-v-align-top',
868 807 ],
869 - 'inline-end' => [
870 - 'title' => esc_html__( 'After', 'elementor' ),
808 + 'end' => [
809 + 'title' => $tooltip_end,
871 810 'icon' => 'eicon-h-align-' . $end,
872 811 ],
873 - 'block-end' => [
874 - 'title' => esc_html__( 'Below', 'elementor' ),
812 + 'bottom' => [
813 + 'title' => esc_html__( 'Bottom', 'elementor' ),
875 814 'icon' => 'eicon-v-align-bottom',
876 815 ],
877 - 'inline-start' => [
878 - 'title' => esc_html__( 'Before', 'elementor' ),
816 + 'start' => [
817 + 'title' => $tooltip_start,
879 818 'icon' => 'eicon-h-align-' . $start,
880 819 ],
881 820 ],
882 821 'selectors_dictionary' => [
883 822 // The toggle variables for 'align items' and 'justify content' have been added to separate the styling of the two 'flex direction' modes.
884 - 'block-start' => $styling_block_start,
885 - 'inline-end' => $styling_inline_end,
886 - 'block-end' => $styling_block_end,
887 - 'inline-start' => $styling_inline_start,
888 - // Styling duplication for BC reasons.
889 - 'top' => $styling_block_start,
890 - 'bottom' => $styling_block_end,
891 - 'start' => $styling_inline_start,
892 - 'end' => $styling_inline_end,
823 + 'top' => '--n-tabs-title-direction: column; --n-tabs-icon-order: initial; --n-tabs-title-justify-content-toggle: center; --n-tabs-title-align-items-toggle: initial;',
824 + 'end' => '--n-tabs-title-direction: row; --n-tabs-icon-order: 1; --n-tabs-title-justify-content-toggle: initial; --n-tabs-title-align-items-toggle: center;',
825 + 'bottom' => '--n-tabs-title-direction: column; --n-tabs-icon-order: 1; --n-tabs-title-justify-content-toggle: center; --n-tabs-title-align-items-toggle: initial;',
826 + 'start' => '--n-tabs-title-direction: row; --n-tabs-icon-order: initial; --n-tabs-title-justify-content-toggle: initial; --n-tabs-title-align-items-toggle: center;',
893 827 ],
894 828 'selectors' => [
895 829 '{{WRAPPER}}' => '{{VALUE}}',
896 830 ],
@@ -900,18 +834,26 @@
900 834 'label' => esc_html__( 'Size', 'elementor' ),
901 835 'type' => Controls_Manager::SLIDER,
902 836 'range' => [
903 837 'px' => [
838 + 'min' => 0,
904 839 'max' => 100,
905 840 ],
906 841 'em' => [
842 + 'min' => 0,
907 843 'max' => 10,
844 + 'step' => 0.1,
908 845 ],
909 846 'rem' => [
847 + 'min' => 0,
910 848 'max' => 10,
849 + 'step' => 0.1,
911 850 ],
912 851 ],
913 - 'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ],
852 + 'default' => [
853 + 'unit' => 'px',
854 + ],
855 + 'size_units' => [ 'px', 'em', 'rem' ],
914 856 'selectors' => [
915 857 '{{WRAPPER}}' => '--n-tabs-icon-size: {{SIZE}}{{UNIT}}',
916 858 ],
917 859 ] );
@@ -920,16 +862,21 @@
920 862 'label' => esc_html__( 'Spacing', 'elementor' ),
921 863 'type' => Controls_Manager::SLIDER,
922 864 'range' => [
923 865 'px' => [
866 + 'min' => 0,
924 867 'max' => 400,
925 868 ],
926 869 'vw' => [
870 + 'min' => 0,
927 871 'max' => 50,
928 872 'step' => 0.1,
929 873 ],
930 874 ],
931 - 'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ],
875 + 'default' => [
876 + 'unit' => 'px',
877 + ],
878 + 'size_units' => [ 'px', 'vw' ],
932 879 'selectors' => [
933 880 '{{WRAPPER}}' => '--n-tabs-icon-gap: {{SIZE}}{{UNIT}}',
934 881 ],
935 882 ] );
@@ -963,9 +910,9 @@
963 910 $this->add_control( 'icon_color_hover', [
964 911 'label' => esc_html__( 'Color', 'elementor' ),
965 912 'type' => Controls_Manager::COLOR,
966 913 'selectors' => [
967 - '{{WRAPPER}} [data-touch-mode="false"] .e-n-tab-title[aria-selected="false"]:hover' => '--n-tabs-icon-color-hover: {{VALUE}};',
914 + '{{WRAPPER}} .e-n-tab-title:not( .e-active ):hover' => '--n-tabs-icon-color-hover: {{VALUE}};',
968 915 ],
969 916 ] );
970 917
971 918 $this->end_controls_tab();
@@ -1001,9 +948,9 @@
1001 948 [
1002 949 'name' => 'box_background_color',
1003 950 'types' => [ 'classic', 'gradient' ],
1004 951 'exclude' => [ 'image' ],
1005 - 'selector' => $content_selector,
952 + 'selector' => "{$nested_tabs_content_selector_class}",
1006 953 'fields_options' => [
1007 954 'color' => [
1008 955 'label' => esc_html__( 'Background Color', 'elementor' ),
1009 956 ],
@@ -1014,9 +961,9 @@
1014 961 $this->add_group_control(
1015 962 Group_Control_Border::get_type(),
1016 963 [
1017 964 'name' => 'box_border',
1018 - 'selector' => $content_selector,
965 + 'selector' => "{$nested_tabs_content_selector_class}",
1019 966 'fields_options' => [
1020 967 'color' => [
1021 968 'label' => esc_html__( 'Border Color', 'elementor' ),
1022 969 ],
@@ -1031,11 +978,11 @@
1031 978 'box_border_radius',
1032 979 [
1033 980 'label' => esc_html__( 'Border Radius', 'elementor' ),
1034 981 'type' => Controls_Manager::DIMENSIONS,
1035 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
982 + 'size_units' => [ 'px', 'em', 'rem' ],
1036 983 'selectors' => [
1037 - $content_selector => '--border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
984 + '{{WRAPPER}}' => '--n-tabs-content-border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1038 985 ],
1039 986 ]
1040 987 );
1041 988
@@ -1042,9 +989,9 @@
1042 989 $this->add_group_control(
1043 990 Group_Control_Box_Shadow::get_type(),
1044 991 [
1045 992 'name' => 'box_shadow_box_shadow',
1046 - 'selector' => $content_selector,
993 + 'selector' => "{$nested_tabs_content_selector_class}",
1047 994 'condition' => [
1048 995 'box_height!' => 'height',
1049 996 ],
1050 997 ]
@@ -1054,11 +1001,11 @@
1054 1001 'box_padding',
1055 1002 [
1056 1003 'label' => esc_html__( 'Padding', 'elementor' ),
1057 1004 'type' => Controls_Manager::DIMENSIONS,
1058 - 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
1005 + 'size_units' => [ 'px', 'em', 'rem' ],
1059 1006 'selectors' => [
1060 - $content_selector => '--padding-top: {{TOP}}{{UNIT}}; --padding-right: {{RIGHT}}{{UNIT}}; --padding-bottom: {{BOTTOM}}{{UNIT}}; --padding-left: {{LEFT}}{{UNIT}};',
1007 + '{{WRAPPER}}' => '--n-tabs-content-padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1061 1008 ],
1062 1009 ]
1063 1010 );
1064 1011
@@ -1064,261 +1011,168 @@
1064 1011
1065 1012 $this->end_controls_section();
1066 1013 }
1067 1014
1068 - protected function render_tab_titles_html( $item_settings ): void {
1069 - $setting_key = $this->get_repeater_setting_key( 'tab_title', 'tabs', $item_settings['index'] );
1070 - $title = $item_settings['item']['tab_title'];
1071 - $css_classes = [ 'e-n-tab-title' ];
1015 + protected function render() {
1016 + // Copied from tabs.php
1017 + $settings = $this->get_settings_for_display();
1018 + $tabs = $settings['tabs'];
1072 1019
1073 - if ( $item_settings['settings']['hover_animation'] ) {
1074 - $css_classes[] = 'elementor-animation-' . $item_settings['settings']['hover_animation'];
1075 - }
1020 + $id_int = substr( $this->get_id_int(), 0, 3 );
1076 1021
1077 - $this->add_render_attribute( $setting_key, [
1078 - 'id' => $item_settings['tab_id'],
1079 - 'data-tab-title-id' => $item_settings['tab_title_id'],
1080 - 'class' => $css_classes,
1081 - 'aria-selected' => 1 === $item_settings['tab_count'] ? 'true' : 'false',
1082 - 'data-tab-index' => $item_settings['tab_count'],
1083 - 'role' => 'tab',
1084 - 'tabindex' => 1 === $item_settings['tab_count'] ? '0' : '-1',
1085 - 'aria-controls' => $item_settings['container_id'],
1086 - 'style' => '--n-tabs-title-order: ' . $item_settings['tab_count'] . ';',
1087 - ] );
1088 - ?>
1089 - <button <?php $this->print_render_attribute_string( $setting_key ); ?>>
1090 - <?php $this->maybe_render_tab_icons_html( $item_settings ); ?>
1091 - <span <?php $this->print_render_attribute_string( 'tab-title-text' ); ?>>
1092 - <?php echo wp_kses_post( $title ); ?>
1093 - </span>
1094 - </button>
1095 - <?php
1096 - }
1022 + $a11y_improvements_experiment = Plugin::$instance->experiments->is_feature_active( 'a11y_improvements' );
1097 1023
1098 - protected function maybe_render_tab_icons_html( $item_settings ): void {
1099 - $icon_settings = $item_settings['item']['tab_icon'];
1100 -
1101 - if ( empty( $icon_settings['value'] ) ) {
1102 - return;
1024 + if ( ! empty( $settings['link'] ) ) {
1025 + $this->add_link_attributes( 'elementor-tabs', $settings['link'] );
1103 1026 }
1104 1027
1105 - $active_icon_settings = $this->is_active_icon_exist( $item_settings['item'] )
1106 - ? $item_settings['item']['tab_icon_active']
1107 - : $icon_settings;
1108 - ?>
1109 - <span <?php $this->print_render_attribute_string( 'tab-icon' ); ?>>
1110 - <?php Icons_Manager::render_icon( $icon_settings, [ 'aria-hidden' => 'true' ] ); ?>
1111 - <?php Icons_Manager::render_icon( $active_icon_settings, [ 'aria-hidden' => 'true' ] ); ?>
1112 - </span>
1113 - <?php
1114 - }
1028 + $this->add_render_attribute( 'elementor-tabs', 'class', 'e-n-tabs' );
1029 + $this->add_render_attribute( 'tab-title-text', 'class', 'e-n-tab-title-text' );
1030 + $this->add_render_attribute( 'tab-icon', 'class', 'e-n-tab-icon' );
1031 + $this->add_render_attribute( 'tab-icon-active', 'class', [ 'e-n-tab-icon', 'e-active' ] );
1115 1032
1116 - protected function render_tab_containers_html( $settings ): void {
1117 - foreach ( $settings['tabs'] as $index => $item ) {
1118 - $item_settings = $this->tab_item_settings[ $index ];
1119 - $this->print_child( $item_settings['index'], $item_settings );
1120 - }
1121 - }
1033 + $tabs_title_html = '';
1034 + $mobile_tabs_title_html = '';
1122 1035
1036 + foreach ( $tabs as $index => $item ) {
1037 + // Tabs title.
1038 + $tab_count = $index + 1;
1039 + $tab_title_setting_key = $this->get_repeater_setting_key( 'tab_title', 'tabs', $index );
1040 + $tab_title = $a11y_improvements_experiment ? $item['tab_title'] : '<a href="">' . $item['tab_title'] . '</a>';
1041 + $tab_title_mobile_setting_key = $this->get_repeater_setting_key( 'tab_title_mobile', 'tabs', $tab_count );
1042 + $tab_title_classes = [ 'e-n-tab-title', 'e-normal' ];
1043 + $tab_title_mobile_classes = [ 'e-n-tab-title', 'e-collapse' ];
1123 1044
1124 - /**
1125 - * Print the content area.
1126 - *
1127 - * @param int $index
1128 - * @param array $item_settings
1129 - */
1130 - public function print_child( $index, $item_settings = [] ) {
1131 - $children = $this->get_children();
1132 - $child_ids = [];
1045 + if ( $settings['hover_animation'] ) {
1046 + array_push( $tab_title_classes, 'elementor-animation-' . $settings['hover_animation'] );
1047 + array_push( $tab_title_mobile_classes, 'elementor-animation-' . $settings['hover_animation'] );
1048 + }
1133 1049
1134 - foreach ( $children as $child ) {
1135 - $child_ids[] = $child->get_id();
1136 - }
1050 + $tab_id = empty( $item['element_id'] ) ? 'e-n-tabs-title-' . $id_int . $tab_count : $item['element_id'];
1137 1051
1138 - // Add data-tab-index attribute to the content area.
1139 - $add_attribute_to_container = function ( $should_render, $container ) use ( $item_settings, $child_ids ) {
1140 - if ( in_array( $container->get_id(), $child_ids ) ) {
1141 - $this->add_attributes_to_container( $container, $item_settings );
1142 - }
1052 + $this->add_render_attribute( $tab_title_setting_key, [
1053 + 'id' => $tab_id,
1054 + 'class' => $tab_title_classes,
1055 + 'aria-selected' => 1 === $tab_count ? 'true' : 'false',
1056 + 'data-tab' => $tab_count,
1057 + 'role' => 'tab',
1058 + 'tabindex' => 1 === $tab_count ? '0' : '-1',
1059 + 'aria-controls' => 'e-n-tab-content-' . $id_int . $tab_count,
1060 + 'aria-expanded' => 'false',
1061 + ] );
1143 1062
1144 - return $should_render;
1145 - };
1063 + $this->add_render_attribute( $tab_title_mobile_setting_key, [
1064 + 'class' => $tab_title_mobile_classes,
1065 + 'aria-selected' => 1 === $tab_count ? 'true' : 'false',
1066 + 'data-tab' => $tab_count,
1067 + 'role' => 'tab',
1068 + 'tabindex' => 1 === $tab_count ? '0' : '-1',
1069 + 'aria-controls' => 'e-n-tab-content-' . $id_int . $tab_count,
1070 + 'aria-expanded' => 'false',
1071 + 'id' => $tab_id . '-accordion',
1072 + ] );
1146 1073
1147 - add_filter( 'elementor/frontend/container/should_render', $add_attribute_to_container, 10, 3 );
1148 - if ( isset( $children[ $index ] ) ) {
1149 - $children[ $index ]->print_element();
1150 - }
1151 - remove_filter( 'elementor/frontend/container/should_render', $add_attribute_to_container );
1152 - }
1074 + $title_render_attributes = $this->get_render_attribute_string( $tab_title_setting_key );
1075 + $mobile_title_attributes = $this->get_render_attribute_string( $tab_title_mobile_setting_key );
1076 + $tab_title_text_class = $this->get_render_attribute_string( 'tab-title-text' );
1077 + $tab_icon_class = $this->get_render_attribute_string( 'tab-icon' );
1153 1078
1154 - protected function add_attributes_to_container( $container, $item_settings ) {
1155 - $container->add_render_attribute( '_wrapper', [
1156 - 'id' => $item_settings['container_id'],
1157 - 'role' => 'tabpanel',
1158 - 'aria-labelledby' => $item_settings['tab_id'],
1159 - 'data-tab-index' => $item_settings['tab_count'],
1160 - 'style' => '--n-tabs-title-order: ' . $item_settings['tab_count'] . ';',
1161 - 'class' => 0 === $item_settings['index'] ? 'e-active' : '',
1162 - ] );
1163 - }
1079 + $icon_html = Icons_Manager::try_get_icon_html( $item['tab_icon'], [ 'aria-hidden' => 'true' ] );
1080 + $icon_active_html = $icon_html;
1164 1081
1165 - protected function render() {
1166 - $settings = $this->get_settings_for_display();
1167 - $widget_number = $this->get_id_int();
1082 + if ( $this->is_active_icon_exist( $item ) ) {
1083 + $icon_active_html = Icons_Manager::try_get_icon_html( $item['tab_icon_active'], [ 'aria-hidden' => 'true' ] );
1084 + }
1168 1085
1169 - if ( ! empty( $settings['link'] ) ) {
1170 - $this->add_link_attributes( 'elementor-tabs', $settings['link'] );
1171 - }
1086 + $tabs_title_html .= "<div {$title_render_attributes}>";
1087 + $tabs_title_html .= "\t<span {$tab_icon_class}>{$icon_html}{$icon_active_html}</span>";
1088 + $tabs_title_html .= "\t<span {$tab_title_text_class}>{$tab_title}</span>";
1089 + $tabs_title_html .= '</div>';
1172 1090
1173 - $this->add_render_attribute( 'elementor-tabs', [
1174 - 'class' => 'e-n-tabs',
1175 - 'data-widget-number' => $widget_number,
1176 - 'aria-label' => esc_html__( 'Tabs. Open items with Enter or Space, close with Escape and navigate using the Arrow keys.', 'elementor' ),
1177 - ] );
1091 + // Tabs content.
1092 + ob_start();
1093 + $this->print_child( $index );
1094 + $tab_content = ob_get_clean();
1178 1095
1179 - $this->add_render_attribute( 'tab-title-text', 'class', 'e-n-tab-title-text' );
1180 - $this->add_render_attribute( 'tab-icon', 'class', 'e-n-tab-icon' );
1181 - $this->add_render_attribute( 'tab-icon-active', 'class', [ 'e-n-tab-icon' ] );
1096 + $mobile_tabs_title_html .= "<div $mobile_title_attributes>";
1097 + $mobile_tabs_title_html .= "\t<span {$tab_icon_class}>{$icon_html}{$icon_active_html}</span>";
1098 + $mobile_tabs_title_html .= "\t<span {$tab_title_text_class}>{$tab_title}</span>";
1099 + $mobile_tabs_title_html .= "</div>$tab_content";
1100 + }
1182 1101 ?>
1183 1102 <div <?php $this->print_render_attribute_string( 'elementor-tabs' ); ?>>
1184 1103 <div class="e-n-tabs-heading" role="tablist">
1185 - <?php
1186 - foreach ( $settings['tabs'] as $index => $item ) {
1187 - $tab_count = $index + 1;
1188 - $tab_title_id = 'e-n-tab-title-' . $widget_number . $tab_count;
1189 - $tab_id = empty( $item['element_id'] )
1190 - ? $tab_title_id
1191 - : $item['element_id'];
1192 -
1193 - $item_settings = [
1194 - 'index' => $index,
1195 - 'tab_count' => $tab_count,
1196 - 'tab_id' => $tab_id,
1197 - 'tab_title_id' => $tab_title_id,
1198 - 'container_id' => 'e-n-tab-content-' . $widget_number . $tab_count,
1199 - 'widget_number' => $widget_number,
1200 - 'item' => $item,
1201 - 'settings' => $settings,
1202 - ];
1203 -
1204 - $this->tab_item_settings[] = $item_settings;
1205 -
1206 - $this->render_tab_titles_html( $item_settings );
1207 - }
1208 - ?>
1104 + <?php echo $tabs_title_html;// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1209 1105 </div>
1210 - <div class="e-n-tabs-content">
1211 - <?php $this->render_tab_containers_html( $settings ); ?>
1106 + <div class="e-n-tabs-content" role="tablist" aria-orientation="vertical">
1107 + <?php echo $mobile_tabs_title_html;// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1212 1108 </div>
1213 1109 </div>
1214 1110 <?php
1215 1111 }
1216 1112
1217 - protected function get_initial_config(): array {
1218 - return array_merge( parent::get_initial_config(), [
1219 - 'support_improved_repeaters' => true,
1220 - 'target_container' => [ '.e-n-tabs-heading' ],
1221 - 'node' => 'button',
1222 - ] );
1223 - }
1224 -
1225 - protected function content_template_single_repeater_item() {
1226 - ?>
1227 - <#
1228 - const tabIndex = view.collection.length,
1229 - elementUid = view.getIDInt().toString(),
1230 - item = data,
1231 - hoverAnimationSetting = view?.container?.settings?.attributes?.hover_animation;
1232 - hoverAnimationClass = hoverAnimationSetting
1233 - ? `elementor-animation-${ hoverAnimationSetting }`
1234 - : '';
1235 - #>
1236 - <?php $this->content_template_single_item( '{{ tabIndex }}', '{{ item }}', '{{ elementUid }}', '{{ hoverAnimationClass }}' );
1237 - }
1238 -
1239 1113 protected function content_template() {
1240 1114 ?>
1241 - <# const elementUid = view.getIDInt().toString(); #>
1242 - <div class="e-n-tabs" data-widget-number="{{ elementUid }}" aria-label="<?php echo esc_html__( 'Tabs. Open items with Enter or Space, close with Escape and navigate using the Arrow keys.', 'elementor' ); ?>">
1243 - <# if ( settings['tabs'] ) { #>
1115 + <div class="e-n-tabs" role="tablist" aria-orientation="vertical">
1116 + <# if ( settings['tabs'] ) {
1117 + const elementUid = view.getIDInt().toString().substr( 0, 3 ); #>
1244 1118 <div class="e-n-tabs-heading" role="tablist">
1245 1119 <# _.each( settings['tabs'], function( item, index ) {
1246 - const tabIndex = index,
1247 - hoverAnimationSetting = settings['hover_animation'],
1248 - hoverAnimationClass = hoverAnimationSetting
1249 - ? `elementor-animation-${ hoverAnimationSetting }`
1250 - : '';
1251 - #>
1252 - <?php $this->content_template_single_item( '{{ tabIndex }}', '{{ item }}', '{{ elementUid }}', '{{ hoverAnimationClass }}' ); ?>
1253 - <# } ); #>
1254 - </div>
1255 - <div class="e-n-tabs-content"></div>
1256 - <# } #>
1257 - </div>
1258 - <?php
1259 - }
1120 + const tabCount = index + 1,
1121 + tabUid = elementUid + tabCount,
1122 + tabWrapperKey = tabUid,
1123 + tabTitleKey = 'tab-title-' + tabUid,
1124 + tabIconKey = 'tab-icon-' + tabUid,
1125 + tabIcon = elementor.helpers.renderIcon( view, item.tab_icon, { 'aria-hidden': true }, 'i' , 'object' ),
1126 + hoverAnimationClass = settings['hover_animation'] ? `elementor-animation-${ settings['hover_animation'] }` : '';
1260 1127
1261 - private function content_template_single_item( $tab_index, $item, $element_uid, $hover_animation_class ) {
1262 - ?>
1263 - <#
1264 - const tabCount = tabIndex + 1,
1265 - tabTitleId = 'e-n-tab-title-' + elementUid + tabCount,
1266 - tabId = item.element_id
1267 - ? item.element_id
1268 - : tabTitleId,
1269 - tabUid = elementUid + tabCount,
1270 - tabIcon = elementor.helpers.renderIcon( view, item.tab_icon, { 'aria-hidden': true }, 'i' , 'object' ),
1271 - activeTabIcon = item.tab_icon_active.value
1272 - ? elementor.helpers.renderIcon( view, item.tab_icon_active, { 'aria-hidden': true }, 'i' , 'object' )
1273 - : tabIcon,
1274 - escapedHoverAnimationClass = _.escape( hoverAnimationClass );
1128 + let tabActiveIcon = tabIcon,
1129 + tabId = 'e-n-tab-title-' + tabUid;
1275 1130
1276 - view.addRenderAttribute( 'tab-title', {
1277 - 'id': tabId,
1278 - 'data-tab-title-id': tabTitleId,
1279 - 'class': [ 'e-n-tab-title',escapedHoverAnimationClass ],
1280 - 'data-tab-index': tabCount,
1281 - 'role': 'tab',
1282 - 'aria-selected': 1 === tabCount ? 'true' : 'false',
1283 - 'tabindex': 1 === tabCount ? '0' : '-1',
1284 - 'aria-controls': 'e-n-tab-content-' + tabUid,
1285 - 'style': '--n-tabs-title-order: ' + tabCount + ';',
1286 - }, null, true );
1131 + if ( '' !== item.tab_icon_active.value ) {
1132 + tabActiveIcon = elementor.helpers.renderIcon( view, item.tab_icon_active, { 'aria-hidden': true }, 'i' , 'object' );
1133 + }
1287 1134
1288 - view.addRenderAttribute( 'tab-title-text', {
1289 - 'class': [ 'e-n-tab-title-text' ],
1290 - 'data-binding-type': 'repeater-item',
1291 - 'data-binding-repeater-name': 'tabs',
1292 - 'data-binding-setting': [ 'tab_title', 'element_id' ],
1293 - 'data-binding-index': tabCount,
1294 - 'data-binding-config': JSON.stringify({
1295 - 'element_id': {
1296 - attr: 'id',
1297 - selector: 'button',
1298 - editType: 'attribute',
1299 - },
1300 - 'tab_title': {
1301 - editType: 'text',
1302 - },
1303 - }),
1304 - }, null, true );
1135 + if ( '' !== item.element_id ) {
1136 + tabId = item.element_id;
1137 + }
1305 1138
1306 - view.addRenderAttribute( 'tab-icon', {
1307 - 'class': [ 'e-n-tab-icon' ],
1308 - 'data-binding-type': 'repeater-item',
1309 - 'data-binding-repeater-name': 'tabs',
1310 - 'data-binding-index': tabCount,
1311 - }, null, true );
1312 - #>
1139 + view.addRenderAttribute( tabWrapperKey, {
1140 + 'id': tabId,
1141 + 'class': [ 'e-n-tab-title','e-normal',hoverAnimationClass ],
1142 + 'data-tab': tabCount,
1143 + 'role': 'tab',
1144 + 'tabindex': 1 === tabCount ? '0' : '-1',
1145 + 'aria-controls': 'e-n-tab-content-' + tabUid,
1146 + 'aria-expanded': 'false',
1147 + } );
1313 1148
1314 - <button {{{ view.getRenderAttributeString( 'tab-title' ) }}}>
1315 - <# if ( !! item.tab_icon.value ) { #>
1316 - <span {{{ view.getRenderAttributeString( 'tab-icon' ) }}}>{{{ tabIcon.value }}}{{{ activeTabIcon.value }}}</span>
1149 + view.addRenderAttribute( tabTitleKey, {
1150 + 'class': [ 'e-n-tab-title-text' ],
1151 + 'data-binding-type': 'repeater-item',
1152 + 'data-binding-repeater-name': 'tabs',
1153 + 'data-binding-setting': [ 'tab_title' ],
1154 + 'data-binding-index': tabCount,
1155 + } );
1156 +
1157 + view.addRenderAttribute( tabIconKey, {
1158 + 'class': [ 'e-n-tab-icon' ],
1159 + 'data-binding-type': 'repeater-item',
1160 + 'data-binding-repeater-name': 'tabs',
1161 + 'data-binding-setting': [ 'tab_icon.value', 'tab_icon_active.value' ],
1162 + 'data-binding-index': tabCount,
1163 + } );
1164 + #>
1165 + <div {{{ view.getRenderAttributeString( tabWrapperKey ) }}}>
1166 + <span {{{ view.getRenderAttributeString( tabIconKey ) }}}>{{{ tabIcon.value }}}{{{ tabActiveIcon.value }}}</span>
1167 + <span {{{ view.getRenderAttributeString( tabTitleKey ) }}}>{{{ item.tab_title }}}</span>
1168 + </div>
1169 + <# } ); #>
1170 + </div>
1171 + <div class="e-n-tabs-content">
1172 + </div>
1317 1173 <# } #>
1318 -
1319 - <span {{{ view.getRenderAttributeString( 'tab-title-text' ) }}}>{{{ item.tab_title }}}</span>
1320 - </button>
1174 + </div>
1321 1175 <?php
1322 1176 }
1323 1177
1324 1178 /**