PluginProbe
Elementor Website Builder – more than just a page builder / 3.14.0-beta4
Elementor Website Builder – more than just a page builder v3.14.0-beta4
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 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 All 457 releases
← All changes | modules/nested-tabs/widgets/nested-tabs.php +246 -372 4.3.4 → 3.14.0-beta4 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( 'container' );
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 = ':where( {{WRAPPER}} > .elementor-widget-container > .e-n-tabs > .e-n-tabs-content ) > .e-con';
110 85
111 86 $this->start_controls_section( 'section_tabs', [
112 87 'label' => esc_html__( 'Tabs', 'elementor' ),
113 88 ] );
@@ -183,53 +158,42 @@
183 158 'tab_title' => esc_html__( 'Tab #3', 'elementor' ),
184 159 ],
185 160 ],
186 161 'title_field' => '{{{ tab_title }}}',
187 - 'button_text' => esc_html__( 'Add Tab', 'elementor' ),
162 + 'button_text' => 'Add Tab',
188 163 ] );
189 164
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 165 $this->add_responsive_control( 'tabs_direction', [
196 166 'label' => esc_html__( 'Direction', 'elementor' ),
197 167 'type' => Controls_Manager::CHOOSE,
198 168 'options' => [
199 - 'block-start' => [
200 - 'title' => esc_html__( 'Above', 'elementor' ),
169 + 'top' => [
170 + 'title' => esc_html__( 'Top', 'elementor' ),
201 171 'icon' => 'eicon-v-align-top',
202 172 ],
203 - 'block-end' => [
204 - 'title' => esc_html__( 'Below', 'elementor' ),
173 + 'bottom' => [
174 + 'title' => esc_html__( 'Bottom', 'elementor' ),
205 175 'icon' => 'eicon-v-align-bottom',
206 176 ],
207 - 'inline-end' => [
208 - 'title' => esc_html__( 'After', 'elementor' ),
177 + 'end' => [
178 + 'title' => $tooltip_end,
209 179 'icon' => 'eicon-h-align-' . $end,
210 180 ],
211 - 'inline-start' => [
212 - 'title' => esc_html__( 'Before', 'elementor' ),
181 + 'start' => [
182 + 'title' => $tooltip_start,
213 183 'icon' => 'eicon-h-align-' . $start,
214 184 ],
215 185 ],
216 186 'separator' => 'before',
217 187 '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,
188 + 'top' => '--n-tabs-direction: column; --n-tabs-heading-direction: row; --n-tabs-heading-width: initial;',
189 + 'bottom' => '--n-tabs-direction: column-reverse; --n-tabs-heading-direction: row; --n-tabs-heading-width: initial;',
190 + 'end' => '--n-tabs-direction: row-reverse; --n-tabs-heading-direction: column; --n-tabs-heading-width: 240px;',
191 + 'start' => '--n-tabs-direction: row; --n-tabs-heading-direction: column; --n-tabs-heading-width: 240px;',
227 192 ],
228 193 'selectors' => [
229 194 '{{WRAPPER}}' => '{{VALUE}}',
230 195 ],
231 - 'control_type' => 'content',
232 196 ] );
233 197
234 198 $this->add_responsive_control( 'tabs_justify_horizontal', [
235 199 'label' => esc_html__( 'Justify', 'elementor' ),
@@ -236,21 +200,21 @@
236 200 'type' => Controls_Manager::CHOOSE,
237 201 'options' => [
238 202 'start' => [
239 203 'title' => esc_html__( 'Start', 'elementor' ),
240 - 'icon' => "eicon-align-$start_logical-h",
204 + 'icon' => 'eicon-flex eicon-align-start-h',
241 205 ],
242 206 'center' => [
243 207 'title' => esc_html__( 'Center', 'elementor' ),
244 - 'icon' => 'eicon-align-center-h',
208 + 'icon' => 'eicon-h-align-center',
245 209 ],
246 210 'end' => [
247 211 'title' => esc_html__( 'End', 'elementor' ),
248 - 'icon' => "eicon-align-$end_logical-h",
212 + 'icon' => 'eicon-flex eicon-align-end-h',
249 213 ],
250 214 'stretch' => [
251 - 'title' => esc_html__( 'Stretch', 'elementor' ),
252 - 'icon' => 'eicon-align-stretch-h',
215 + 'title' => esc_html__( 'Justified', 'elementor' ),
216 + 'icon' => 'eicon-h-align-stretch',
253 217 ],
254 218 ],
255 219 'selectors_dictionary' => [
256 220 '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;',
@@ -263,10 +227,8 @@
263 227 ],
264 228 'condition' => [
265 229 'tabs_direction' => [
266 230 '',
267 - 'block-start',
268 - 'block-end',
269 231 'top',
270 232 'bottom',
271 233 ],
272 234 ],
@@ -278,28 +240,28 @@
278 240 'type' => Controls_Manager::CHOOSE,
279 241 'options' => [
280 242 'start' => [
281 243 'title' => esc_html__( 'Start', 'elementor' ),
282 - 'icon' => 'eicon-align-start-v',
244 + 'icon' => 'eicon-flex eicon-align-start-v',
283 245 ],
284 246 'center' => [
285 247 'title' => esc_html__( 'Center', 'elementor' ),
286 - 'icon' => 'eicon-align-center-v',
248 + 'icon' => 'eicon-v-align-middle',
287 249 ],
288 250 'end' => [
289 251 'title' => esc_html__( 'End', 'elementor' ),
290 - 'icon' => 'eicon-align-end-v',
252 + 'icon' => 'eicon-flex eicon-align-end-v',
291 253 ],
292 254 'stretch' => [
293 - 'title' => esc_html__( 'Stretch', 'elementor' ),
294 - 'icon' => 'eicon-align-stretch-v',
255 + 'title' => esc_html__( 'Justified', 'elementor' ),
256 + 'icon' => 'eicon-v-align-stretch',
295 257 ],
296 258 ],
297 259 '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',
260 + 'start' => '--n-tabs-heading-justify-content: flex-start; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial;',
261 + 'center' => '--n-tabs-heading-justify-content: center; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial;',
262 + 'end' => '--n-tabs-heading-justify-content: flex-end; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial;',
263 + '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 264 ],
303 265 'selectors' => [
304 266 '{{WRAPPER}}' => '{{VALUE}}',
305 267 ],
@@ -304,10 +266,8 @@
304 266 '{{WRAPPER}}' => '{{VALUE}}',
305 267 ],
306 268 'condition' => [
307 269 'tabs_direction' => [
308 - 'inline-start',
309 - 'inline-end',
310 270 'start',
311 271 'end',
312 272 ],
313 273 ],
@@ -334,10 +294,8 @@
334 294 '{{WRAPPER}}' => '--n-tabs-heading-width: {{SIZE}}{{UNIT}}',
335 295 ],
336 296 'condition' => [
337 297 'tabs_direction' => [
338 - 'inline-start',
339 - 'inline-end',
340 298 'start',
341 299 'end',
342 300 ],
343 301 ],
@@ -347,9 +305,9 @@
347 305 'label' => esc_html__( 'Align Title', 'elementor' ),
348 306 'type' => Controls_Manager::CHOOSE,
349 307 'options' => [
350 308 'start' => [
351 - 'title' => esc_html__( 'Start', 'elementor' ),
309 + 'title' => esc_html__( 'Left', 'elementor' ),
352 310 'icon' => 'eicon-text-align-left',
353 311 ],
354 312 'center' => [
355 313 'title' => esc_html__( 'Center', 'elementor' ),
@@ -355,16 +313,16 @@
355 313 'title' => esc_html__( 'Center', 'elementor' ),
356 314 'icon' => 'eicon-text-align-center',
357 315 ],
358 316 'end' => [
359 - 'title' => esc_html__( 'End', 'elementor' ),
317 + 'title' => esc_html__( 'Right', 'elementor' ),
360 318 'icon' => 'eicon-text-align-right',
361 319 ],
362 320 ],
363 321 '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;',
322 + 'start' => '--n-tabs-title-justify-content: flex-start; --n-tabs-title-align-items: flex-start;',
323 + 'center' => '--n-tabs-title-justify-content: center; --n-tabs-title-align-items: center;',
324 + 'end' => '--n-tabs-title-justify-content: flex-end; --n-tabs-title-align-items: flex-end;',
367 325 ],
368 326 'selectors' => [
369 327 '{{WRAPPER}}' => '{{VALUE}}',
370 328 ],
@@ -387,24 +345,15 @@
387 345 'enable' => esc_html__( 'Enable', 'elementor' ),
388 346 ],
389 347 'default' => 'disable',
390 348 '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;',
349 + 'disable' => '--n-tabs-heading-wrap: wrap; --n-tabs-heading-overflow-x: initial;',
350 + 'enable' => '--n-tabs-heading-wrap: nowrap; --n-tabs-heading-overflow-x: scroll;',
393 351 ],
394 352 'selectors' => [
395 353 '{{WRAPPER}}' => '{{VALUE}}',
396 354 ],
397 355 'frontend_available' => true,
398 - 'condition' => [
399 - 'tabs_direction' => [
400 - '',
401 - 'block-start',
402 - 'block-end',
403 - 'top',
404 - 'bottom',
405 - ],
406 - ],
407 356 ]
408 357 );
409 358
410 359 $dropdown_options = [
@@ -452,20 +401,15 @@
452 401
453 402 $this->add_responsive_control( 'tabs_title_space_between', [
454 403 'label' => esc_html__( 'Gap between tabs', 'elementor' ),
455 404 'type' => Controls_Manager::SLIDER,
456 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
457 405 'range' => [
458 406 'px' => [
407 + 'min' => 0,
459 408 'max' => 400,
460 409 ],
461 - 'em' => [
462 - 'max' => 40,
463 - ],
464 - 'rem' => [
465 - 'max' => 40,
466 - ],
467 410 ],
411 + 'size_units' => [ 'px' ],
468 412 'selectors' => [
469 413 '{{WRAPPER}}' => '--n-tabs-title-gap: {{SIZE}}{{UNIT}}',
470 414 ],
471 415 ] );
@@ -472,20 +416,15 @@
472 416
473 417 $this->add_responsive_control( 'tabs_title_spacing', [
474 418 'label' => esc_html__( 'Distance from content', 'elementor' ),
475 419 'type' => Controls_Manager::SLIDER,
476 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
477 420 'range' => [
478 421 'px' => [
422 + 'min' => 0,
479 423 'max' => 400,
480 424 ],
481 - 'em' => [
482 - 'max' => 40,
483 - ],
484 - 'rem' => [
485 - 'max' => 40,
486 - ],
487 425 ],
426 + 'size_units' => [ 'px' ],
488 427 'selectors' => [
489 428 '{{WRAPPER}}' => '--n-tabs-gap: {{SIZE}}{{UNIT}}',
490 429 ],
491 430 ] );
@@ -504,9 +443,9 @@
504 443 [
505 444 'name' => 'tabs_title_background_color',
506 445 'types' => [ 'classic', 'gradient' ],
507 446 '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 )",
447 + 'selector' => ':is( {{WRAPPER}} > .elementor-widget-container > .e-n-tabs > .e-n-tabs-heading > .e-n-tab-title:not( .e-active ):not( :hover ), {{WRAPPER}} > .elementor-widget-container > .e-n-tabs > .e-n-tabs-content > .e-n-tab-title:not( .e-active ) )',
509 448 'fields_options' => [
510 449 'color' => [
511 450 'label' => esc_html__( 'Background Color', 'elementor' ),
512 451 'selectors' => [
@@ -520,9 +459,9 @@
520 459 $this->add_group_control(
521 460 Group_Control_Border::get_type(),
522 461 [
523 462 'name' => 'tabs_title_border',
524 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover )",
463 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover )",
525 464 'fields_options' => [
526 465 'color' => [
527 466 'label' => esc_html__( 'Border Color', 'elementor' ),
528 467 ],
@@ -536,10 +475,11 @@
536 475 $this->add_group_control(
537 476 Group_Control_Box_Shadow::get_type(),
538 477 [
539 478 'name' => 'tabs_title_box_shadow',
479 + 'label' => esc_html__( 'Shadow', 'elementor' ),
540 480 'separator' => 'after',
541 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover )",
481 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover )",
542 482 ]
543 483 );
544 484
545 485 $this->end_controls_tab();
@@ -556,9 +496,9 @@
556 496 [
557 497 'name' => 'tabs_title_background_color_hover',
558 498 'types' => [ 'classic', 'gradient' ],
559 499 'exclude' => [ 'image' ],
560 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
500 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-normal:not( .e-active ):hover",
561 501 'fields_options' => [
562 502 'background' => [
563 503 'default' => 'classic',
564 504 ],
@@ -578,9 +518,9 @@
578 518 $this->add_group_control(
579 519 Group_Control_Border::get_type(),
580 520 [
581 521 'name' => 'tabs_title_border_hover',
582 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
522 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-normal:not( .e-active ):hover",
583 523 'fields_options' => [
584 524 'color' => [
585 525 'label' => esc_html__( 'Border Color', 'elementor' ),
586 526 ],
@@ -594,10 +534,11 @@
594 534 $this->add_group_control(
595 535 Group_Control_Box_Shadow::get_type(),
596 536 [
597 537 'name' => 'tabs_title_box_shadow_hover',
538 + 'label' => esc_html__( 'Shadow', 'elementor' ),
598 539 'separator' => 'after',
599 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
540 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-normal:not( .e-active ):hover",
600 541 ]
601 542 );
602 543
603 544 $this->add_control(
@@ -617,9 +558,8 @@
617 558 '{{WRAPPER}}' => '--n-tabs-title-transition: {{SIZE}}s',
618 559 ],
619 560 'range' => [
620 561 'px' => [
621 - 'min' => 0,
622 562 'max' => 3,
623 563 'step' => 0.1,
624 564 ],
625 565 ],
@@ -640,9 +580,9 @@
640 580 [
641 581 'name' => 'tabs_title_background_color_active',
642 582 'types' => [ 'classic', 'gradient' ],
643 583 '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",
584 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
645 585 'fields_options' => [
646 586 'background' => [
647 587 'default' => 'classic',
648 588 ],
@@ -662,9 +602,9 @@
662 602 $this->add_group_control(
663 603 Group_Control_Border::get_type(),
664 604 [
665 605 '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",
606 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
667 607 'fields_options' => [
668 608 'color' => [
669 609 'label' => esc_html__( 'Border Color', 'elementor' ),
670 610 ],
@@ -678,9 +618,10 @@
678 618 $this->add_group_control(
679 619 Group_Control_Box_Shadow::get_type(),
680 620 [
681 621 '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",
622 + 'label' => esc_html__( 'Shadow', 'elementor' ),
623 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
683 624 ]
684 625 );
685 626
686 627 $this->end_controls_tab();
@@ -723,9 +664,9 @@
723 664 'name' => 'title_typography',
724 665 'global' => [
725 666 'default' => Global_Typography::TYPOGRAPHY_ACCENT,
726 667 ],
727 - 'selector' => "{$heading_selector} > :is( .e-n-tab-title > .e-n-tab-title-text, .e-n-tab-title )",
668 + 'selector' => "{$nested_tabs_heading_selector_class} > :is( .e-n-tab-title > .e-n-tab-title-text, .e-n-tab-title )",
728 669 'fields_options' => [
729 670 'font_size' => [
730 671 'selectors' => [
731 672 '{{WRAPPER}}' => '--n-tabs-title-font-size: {{SIZE}}{{UNIT}}',
@@ -757,9 +698,14 @@
757 698 $this->add_group_control(
758 699 Group_Control_Text_Shadow::get_type(),
759 700 [
760 701 'name' => 'title_text_shadow',
761 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover )",
702 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover )",
703 + 'fields_options' => [
704 + 'text_shadow_type' => [
705 + 'label' => esc_html_x( 'Shadow', 'Text Shadow Control', 'elementor' ),
706 + ],
707 + ],
762 708 ]
763 709 );
764 710
765 711 $this->add_group_control(
@@ -765,9 +711,14 @@
765 711 $this->add_group_control(
766 712 Group_Control_Text_Stroke::get_type(),
767 713 [
768 714 'name' => 'title_text_stroke',
769 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover ) :is( span, a, i )",
715 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover ) :is( span, a, i )",
716 + 'fields_options' => [
717 + 'text_stroke_type' => [
718 + 'label' => esc_html__( 'Stroke', 'elementor' ),
719 + ],
720 + ],
770 721 ]
771 722 );
772 723
773 724 $this->end_controls_tab();
@@ -784,9 +735,9 @@
784 735 [
785 736 'label' => esc_html__( 'Color', 'elementor' ),
786 737 'type' => Controls_Manager::COLOR,
787 738 'selectors' => [
788 - '{{WRAPPER}} [data-touch-mode="false"] .e-n-tab-title[aria-selected="false"]:hover' => '--n-tabs-title-color-hover: {{VALUE}}',
739 + '{{WRAPPER}} .e-normal:not( .e-active ):hover' => '--n-tabs-title-color-hover: {{VALUE}}',
789 740 ],
790 741 ]
791 742 );
792 743
@@ -793,9 +744,15 @@
793 744 $this->add_group_control(
794 745 Group_Control_Text_Shadow::get_type(),
795 746 [
796 747 'name' => 'title_text_shadow_hover',
797 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
748 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-normal:not( .e-active ):hover",
749 + 'fields_options' => [
750 + 'text_shadow_type' => [
751 + 'label' => esc_html_x( 'Shadow', 'Text Shadow Control', 'elementor' ),
752 + ],
753 + ],
754 +
798 755 ]
799 756 );
800 757
801 758 $this->add_group_control(
@@ -801,9 +758,14 @@
801 758 $this->add_group_control(
802 759 Group_Control_Text_Stroke::get_type(),
803 760 [
804 761 'name' => 'title_text_stroke_hover',
805 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover :is( span, a, i )",
762 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-normal:not( .e-active ):hover :is( span, a, i )",
763 + 'fields_options' => [
764 + 'text_stroke_type' => [
765 + 'label' => esc_html__( 'Stroke', 'elementor' ),
766 + ],
767 + ],
806 768 ]
807 769 );
808 770
809 771 $this->end_controls_tab();
@@ -829,9 +791,14 @@
829 791 $this->add_group_control(
830 792 Group_Control_Text_Shadow::get_type(),
831 793 [
832 794 '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",
795 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
796 + 'fields_options' => [
797 + 'text_shadow_type' => [
798 + 'label' => esc_html_x( 'Shadow', 'Text Shadow Control', 'elementor' ),
799 + ],
800 + ],
834 801 ]
835 802 );
836 803
837 804 $this->add_group_control(
@@ -837,9 +804,14 @@
837 804 $this->add_group_control(
838 805 Group_Control_Text_Stroke::get_type(),
839 806 [
840 807 '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 )",
808 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active :is( span, a, i )",
809 + 'fields_options' => [
810 + 'text_stroke_type' => [
811 + 'label' => esc_html__( 'Stroke', 'elementor' ),
812 + ],
813 + ],
842 814 ]
843 815 );
844 816
845 817 $this->end_controls_tab();
@@ -852,45 +824,35 @@
852 824 'label' => esc_html__( 'Icon', 'elementor' ),
853 825 'tab' => Controls_Manager::TAB_STYLE,
854 826 ] );
855 827
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 828 $this->add_responsive_control( 'icon_position', [
862 829 'label' => esc_html__( 'Position', 'elementor' ),
863 830 'type' => Controls_Manager::CHOOSE,
864 831 'options' => [
865 - 'block-start' => [
866 - 'title' => esc_html__( 'Above', 'elementor' ),
832 + 'top' => [
833 + 'title' => esc_html__( 'Top', 'elementor' ),
867 834 'icon' => 'eicon-v-align-top',
868 835 ],
869 - 'inline-end' => [
870 - 'title' => esc_html__( 'After', 'elementor' ),
836 + 'end' => [
837 + 'title' => $tooltip_end,
871 838 'icon' => 'eicon-h-align-' . $end,
872 839 ],
873 - 'block-end' => [
874 - 'title' => esc_html__( 'Below', 'elementor' ),
840 + 'bottom' => [
841 + 'title' => esc_html__( 'Bottom', 'elementor' ),
875 842 'icon' => 'eicon-v-align-bottom',
876 843 ],
877 - 'inline-start' => [
878 - 'title' => esc_html__( 'Before', 'elementor' ),
844 + 'start' => [
845 + 'title' => $tooltip_start,
879 846 'icon' => 'eicon-h-align-' . $start,
880 847 ],
881 848 ],
882 849 'selectors_dictionary' => [
883 850 // 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,
851 + '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;',
852 + '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;',
853 + '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;',
854 + '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 855 ],
894 856 'selectors' => [
895 857 '{{WRAPPER}}' => '{{VALUE}}',
896 858 ],
@@ -900,15 +862,20 @@
900 862 'label' => esc_html__( 'Size', 'elementor' ),
901 863 'type' => Controls_Manager::SLIDER,
902 864 'range' => [
903 865 'px' => [
866 + 'min' => 0,
904 867 'max' => 100,
905 868 ],
906 869 'em' => [
870 + 'min' => 0,
907 871 'max' => 10,
872 + 'step' => 0.1,
908 873 ],
909 874 'rem' => [
875 + 'min' => 0,
910 876 'max' => 10,
877 + 'step' => 0.1,
911 878 ],
912 879 ],
913 880 'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ],
914 881 'selectors' => [
@@ -920,11 +887,13 @@
920 887 'label' => esc_html__( 'Spacing', 'elementor' ),
921 888 'type' => Controls_Manager::SLIDER,
922 889 'range' => [
923 890 'px' => [
891 + 'min' => 0,
924 892 'max' => 400,
925 893 ],
926 894 'vw' => [
895 + 'min' => 0,
927 896 'max' => 50,
928 897 'step' => 0.1,
929 898 ],
930 899 ],
@@ -963,9 +932,9 @@
963 932 $this->add_control( 'icon_color_hover', [
964 933 'label' => esc_html__( 'Color', 'elementor' ),
965 934 'type' => Controls_Manager::COLOR,
966 935 'selectors' => [
967 - '{{WRAPPER}} [data-touch-mode="false"] .e-n-tab-title[aria-selected="false"]:hover' => '--n-tabs-icon-color-hover: {{VALUE}};',
936 + '{{WRAPPER}} .e-normal:not( .e-active ):hover' => '--n-tabs-icon-color-hover: {{VALUE}};',
968 937 ],
969 938 ] );
970 939
971 940 $this->end_controls_tab();
@@ -1001,9 +970,9 @@
1001 970 [
1002 971 'name' => 'box_background_color',
1003 972 'types' => [ 'classic', 'gradient' ],
1004 973 'exclude' => [ 'image' ],
1005 - 'selector' => $content_selector,
974 + 'selector' => $nested_tabs_content_selector_class,
1006 975 'fields_options' => [
1007 976 'color' => [
1008 977 'label' => esc_html__( 'Background Color', 'elementor' ),
1009 978 ],
@@ -1014,9 +983,9 @@
1014 983 $this->add_group_control(
1015 984 Group_Control_Border::get_type(),
1016 985 [
1017 986 'name' => 'box_border',
1018 - 'selector' => $content_selector,
987 + 'selector' => $nested_tabs_content_selector_class,
1019 988 'fields_options' => [
1020 989 'color' => [
1021 990 'label' => esc_html__( 'Border Color', 'elementor' ),
1022 991 ],
@@ -1033,9 +1002,9 @@
1033 1002 'label' => esc_html__( 'Border Radius', 'elementor' ),
1034 1003 'type' => Controls_Manager::DIMENSIONS,
1035 1004 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1036 1005 'selectors' => [
1037 - $content_selector => '--border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1006 + $nested_tabs_content_selector_class => '--border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1038 1007 ],
1039 1008 ]
1040 1009 );
1041 1010
@@ -1042,9 +1011,9 @@
1042 1011 $this->add_group_control(
1043 1012 Group_Control_Box_Shadow::get_type(),
1044 1013 [
1045 1014 'name' => 'box_shadow_box_shadow',
1046 - 'selector' => $content_selector,
1015 + 'selector' => $nested_tabs_content_selector_class,
1047 1016 'condition' => [
1048 1017 'box_height!' => 'height',
1049 1018 ],
1050 1019 ]
@@ -1056,9 +1025,9 @@
1056 1025 'label' => esc_html__( 'Padding', 'elementor' ),
1057 1026 'type' => Controls_Manager::DIMENSIONS,
1058 1027 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
1059 1028 'selectors' => [
1060 - $content_selector => '--padding-top: {{TOP}}{{UNIT}}; --padding-right: {{RIGHT}}{{UNIT}}; --padding-bottom: {{BOTTOM}}{{UNIT}}; --padding-left: {{LEFT}}{{UNIT}};',
1029 + $nested_tabs_content_selector_class => '--padding-top: {{TOP}}{{UNIT}}; --padding-right: {{RIGHT}}{{UNIT}}; --padding-bottom: {{BOTTOM}}{{UNIT}}; --padding-left: {{LEFT}}{{UNIT}};',
1061 1030 ],
1062 1031 ]
1063 1032 );
1064 1033
@@ -1064,261 +1033,166 @@
1064 1033
1065 1034 $this->end_controls_section();
1066 1035 }
1067 1036
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' ];
1037 + protected function render() {
1038 + // Copied from tabs.php
1039 + $settings = $this->get_settings_for_display();
1040 + $tabs = $settings['tabs'];
1072 1041
1073 - if ( $item_settings['settings']['hover_animation'] ) {
1074 - $css_classes[] = 'elementor-animation-' . $item_settings['settings']['hover_animation'];
1042 + $id_int = substr( $this->get_id_int(), 0, 3 );
1043 +
1044 + if ( ! empty( $settings['link'] ) ) {
1045 + $this->add_link_attributes( 'elementor-tabs', $settings['link'] );
1075 1046 }
1076 1047
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 - }
1048 + $this->add_render_attribute( 'elementor-tabs', 'class', 'e-n-tabs' );
1049 + $this->add_render_attribute( 'tab-title-text', 'class', 'e-n-tab-title-text' );
1050 + $this->add_render_attribute( 'tab-icon', 'class', 'e-n-tab-icon' );
1051 + $this->add_render_attribute( 'tab-icon-active', 'class', [ 'e-n-tab-icon', 'e-active' ] );
1097 1052
1098 - protected function maybe_render_tab_icons_html( $item_settings ): void {
1099 - $icon_settings = $item_settings['item']['tab_icon'];
1053 + $tabs_title_html = '';
1054 + $mobile_tabs_title_html = '';
1100 1055
1101 - if ( empty( $icon_settings['value'] ) ) {
1102 - return;
1103 - }
1056 + foreach ( $tabs as $index => $item ) {
1057 + // Tabs title.
1058 + $tab_count = $index + 1;
1059 + $tab_title_setting_key = $this->get_repeater_setting_key( 'tab_title', 'tabs', $index );
1060 + $tab_title = $item['tab_title'];
1061 + $tab_title_mobile_setting_key = $this->get_repeater_setting_key( 'tab_title_mobile', 'tabs', $tab_count );
1062 + $tab_title_classes = [ 'e-n-tab-title', 'e-normal' ];
1063 + $tab_title_mobile_classes = [ 'e-n-tab-title', 'e-collapse' ];
1104 1064
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 - }
1065 + if ( $settings['hover_animation'] ) {
1066 + array_push( $tab_title_classes, 'elementor-animation-' . $settings['hover_animation'] );
1067 + array_push( $tab_title_mobile_classes, 'elementor-animation-' . $settings['hover_animation'] );
1068 + }
1115 1069
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 - }
1070 + $tab_id = empty( $item['element_id'] ) ? 'e-n-tabs-title-' . $id_int . $tab_count : $item['element_id'];
1122 1071
1072 + $this->add_render_attribute( $tab_title_setting_key, [
1073 + 'id' => $tab_id,
1074 + 'class' => $tab_title_classes,
1075 + 'aria-selected' => 1 === $tab_count ? 'true' : 'false',
1076 + 'data-tab' => $tab_count,
1077 + 'role' => 'tab',
1078 + 'tabindex' => 1 === $tab_count ? '0' : '-1',
1079 + 'aria-controls' => 'e-n-tab-content-' . $id_int . $tab_count,
1080 + 'aria-expanded' => 'false',
1081 + ] );
1123 1082
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 = [];
1083 + $this->add_render_attribute( $tab_title_mobile_setting_key, [
1084 + 'class' => $tab_title_mobile_classes,
1085 + 'aria-selected' => 1 === $tab_count ? 'true' : 'false',
1086 + 'data-tab' => $tab_count,
1087 + 'role' => 'tab',
1088 + 'tabindex' => 1 === $tab_count ? '0' : '-1',
1089 + 'aria-controls' => 'e-n-tab-content-' . $id_int . $tab_count,
1090 + 'aria-expanded' => 'false',
1091 + 'id' => $tab_id . '-accordion',
1092 + ] );
1133 1093
1134 - foreach ( $children as $child ) {
1135 - $child_ids[] = $child->get_id();
1136 - }
1094 + $title_render_attributes = $this->get_render_attribute_string( $tab_title_setting_key );
1095 + $mobile_title_attributes = $this->get_render_attribute_string( $tab_title_mobile_setting_key );
1096 + $tab_title_text_class = $this->get_render_attribute_string( 'tab-title-text' );
1097 + $tab_icon_class = $this->get_render_attribute_string( 'tab-icon' );
1137 1098
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 );
1099 + $icon_html = Icons_Manager::try_get_icon_html( $item['tab_icon'], [ 'aria-hidden' => 'true' ] );
1100 + $icon_active_html = $icon_html;
1101 +
1102 + if ( $this->is_active_icon_exist( $item ) ) {
1103 + $icon_active_html = Icons_Manager::try_get_icon_html( $item['tab_icon_active'], [ 'aria-hidden' => 'true' ] );
1142 1104 }
1143 1105
1144 - return $should_render;
1145 - };
1106 + $tabs_title_html .= "<div {$title_render_attributes}>";
1107 + $tabs_title_html .= "\t<span {$tab_icon_class}>{$icon_html}{$icon_active_html}</span>";
1108 + $tabs_title_html .= "\t<span {$tab_title_text_class}>{$tab_title}</span>";
1109 + $tabs_title_html .= '</div>';
1146 1110
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 - }
1111 + // Tabs content.
1112 + ob_start();
1113 + $this->print_child( $index );
1114 + $tab_content = ob_get_clean();
1153 1115
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 - }
1164 -
1165 - protected function render() {
1166 - $settings = $this->get_settings_for_display();
1167 - $widget_number = $this->get_id_int();
1168 -
1169 - if ( ! empty( $settings['link'] ) ) {
1170 - $this->add_link_attributes( 'elementor-tabs', $settings['link'] );
1116 + $mobile_tabs_title_html .= "<div $mobile_title_attributes>";
1117 + $mobile_tabs_title_html .= "\t<span {$tab_icon_class}>{$icon_html}{$icon_active_html}</span>";
1118 + $mobile_tabs_title_html .= "\t<span {$tab_title_text_class}>{$tab_title}</span>";
1119 + $mobile_tabs_title_html .= "</div>$tab_content";
1171 1120 }
1172 -
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 - ] );
1178 -
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' ] );
1182 1121 ?>
1183 1122 <div <?php $this->print_render_attribute_string( 'elementor-tabs' ); ?>>
1184 1123 <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 - ?>
1124 + <?php echo $tabs_title_html;// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1209 1125 </div>
1210 - <div class="e-n-tabs-content">
1211 - <?php $this->render_tab_containers_html( $settings ); ?>
1126 + <div class="e-n-tabs-content" role="tablist" aria-orientation="vertical">
1127 + <?php echo $mobile_tabs_title_html;// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1212 1128 </div>
1213 1129 </div>
1214 1130 <?php
1215 1131 }
1216 1132
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 1133 protected function content_template() {
1240 1134 ?>
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'] ) { #>
1135 + <div class="e-n-tabs" role="tablist" aria-orientation="vertical">
1136 + <# if ( settings['tabs'] ) {
1137 + const elementUid = view.getIDInt().toString().substr( 0, 3 ); #>
1244 1138 <div class="e-n-tabs-heading" role="tablist">
1245 1139 <# _.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 - }
1140 + const tabCount = index + 1,
1141 + tabUid = elementUid + tabCount,
1142 + tabWrapperKey = tabUid,
1143 + tabTitleKey = 'tab-title-' + tabUid,
1144 + tabIconKey = 'tab-icon-' + tabUid,
1145 + tabIcon = elementor.helpers.renderIcon( view, item.tab_icon, { 'aria-hidden': true }, 'i' , 'object' ),
1146 + hoverAnimationClass = settings['hover_animation'] ? `elementor-animation-${ settings['hover_animation'] }` : '';
1260 1147
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 );
1148 + let tabActiveIcon = tabIcon,
1149 + tabId = 'e-n-tab-title-' + tabUid;
1275 1150
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 );
1151 + if ( '' !== item.tab_icon_active.value ) {
1152 + tabActiveIcon = elementor.helpers.renderIcon( view, item.tab_icon_active, { 'aria-hidden': true }, 'i' , 'object' );
1153 + }
1287 1154
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 );
1155 + if ( '' !== item.element_id ) {
1156 + tabId = item.element_id;
1157 + }
1305 1158
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 - #>
1159 + view.addRenderAttribute( tabWrapperKey, {
1160 + 'id': tabId,
1161 + 'class': [ 'e-n-tab-title','e-normal',hoverAnimationClass ],
1162 + 'data-tab': tabCount,
1163 + 'role': 'tab',
1164 + 'tabindex': 1 === tabCount ? '0' : '-1',
1165 + 'aria-controls': 'e-n-tab-content-' + tabUid,
1166 + 'aria-expanded': 'false',
1167 + } );
1313 1168
1314 - <button {{{ view.getRenderAttributeString( 'tab-title' ) }}}>
1315 - <# if ( !! item.tab_icon.value ) { #>
1316 - <span {{{ view.getRenderAttributeString( 'tab-icon' ) }}}>{{{ tabIcon.value }}}{{{ activeTabIcon.value }}}</span>
1169 + view.addRenderAttribute( tabTitleKey, {
1170 + 'class': [ 'e-n-tab-title-text' ],
1171 + 'data-binding-type': 'repeater-item',
1172 + 'data-binding-repeater-name': 'tabs',
1173 + 'data-binding-setting': [ 'tab_title' ],
1174 + 'data-binding-index': tabCount,
1175 + } );
1176 +
1177 + view.addRenderAttribute( tabIconKey, {
1178 + 'class': [ 'e-n-tab-icon' ],
1179 + 'data-binding-type': 'repeater-item',
1180 + 'data-binding-repeater-name': 'tabs',
1181 + 'data-binding-setting': [ 'tab_icon.value', 'tab_icon_active.value' ],
1182 + 'data-binding-index': tabCount,
1183 + } );
1184 + #>
1185 + <div {{{ view.getRenderAttributeString( tabWrapperKey ) }}}>
1186 + <span {{{ view.getRenderAttributeString( tabIconKey ) }}}>{{{ tabIcon.value }}}{{{ tabActiveIcon.value }}}</span>
1187 + <span {{{ view.getRenderAttributeString( tabTitleKey ) }}}>{{{ item.tab_title }}}</span>
1188 + </div>
1189 + <# } ); #>
1190 + </div>
1191 + <div class="e-n-tabs-content">
1192 + </div>
1317 1193 <# } #>
1318 -
1319 - <span {{{ view.getRenderAttributeString( 'tab-title-text' ) }}}>{{{ item.tab_title }}}</span>
1320 - </button>
1194 + </div>
1321 1195 <?php
1322 1196 }
1323 1197
1324 1198 /**