PluginProbe
Elementor Website Builder – more than just a page builder / 3.13.2
Elementor Website Builder – more than just a page builder v3.13.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 +247 -396 4.1.0-dev23.13.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 = ':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,15 +227,12 @@
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 ],
273 - 'frontend_available' => true,
274 235 ] );
275 236
276 237 $this->add_responsive_control( 'tabs_justify_vertical', [
277 238 'label' => esc_html__( 'Justify', 'elementor' ),
@@ -278,28 +239,28 @@
278 239 'type' => Controls_Manager::CHOOSE,
279 240 'options' => [
280 241 'start' => [
281 242 'title' => esc_html__( 'Start', 'elementor' ),
282 - 'icon' => 'eicon-align-start-v',
243 + 'icon' => 'eicon-flex eicon-align-start-v',
283 244 ],
284 245 'center' => [
285 246 'title' => esc_html__( 'Center', 'elementor' ),
286 - 'icon' => 'eicon-align-center-v',
247 + 'icon' => 'eicon-v-align-middle',
287 248 ],
288 249 'end' => [
289 250 'title' => esc_html__( 'End', 'elementor' ),
290 - 'icon' => 'eicon-align-end-v',
251 + 'icon' => 'eicon-flex eicon-align-end-v',
291 252 ],
292 253 'stretch' => [
293 - 'title' => esc_html__( 'Stretch', 'elementor' ),
294 - 'icon' => 'eicon-align-stretch-v',
254 + 'title' => esc_html__( 'Justified', 'elementor' ),
255 + 'icon' => 'eicon-v-align-stretch',
295 256 ],
296 257 ],
297 258 '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',
259 + 'start' => '--n-tabs-heading-justify-content: flex-start; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial;',
260 + 'center' => '--n-tabs-heading-justify-content: center; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial;',
261 + 'end' => '--n-tabs-heading-justify-content: flex-end; --n-tabs-title-width: initial; --n-tabs-title-height: initial; --n-tabs-title-align-items: initial;',
262 + '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 263 ],
303 264 'selectors' => [
304 265 '{{WRAPPER}}' => '{{VALUE}}',
305 266 ],
@@ -304,10 +265,8 @@
304 265 '{{WRAPPER}}' => '{{VALUE}}',
305 266 ],
306 267 'condition' => [
307 268 'tabs_direction' => [
308 - 'inline-start',
309 - 'inline-end',
310 269 'start',
311 270 'end',
312 271 ],
313 272 ],
@@ -334,10 +293,8 @@
334 293 '{{WRAPPER}}' => '--n-tabs-heading-width: {{SIZE}}{{UNIT}}',
335 294 ],
336 295 'condition' => [
337 296 'tabs_direction' => [
338 - 'inline-start',
339 - 'inline-end',
340 297 'start',
341 298 'end',
342 299 ],
343 300 ],
@@ -347,9 +304,9 @@
347 304 'label' => esc_html__( 'Align Title', 'elementor' ),
348 305 'type' => Controls_Manager::CHOOSE,
349 306 'options' => [
350 307 'start' => [
351 - 'title' => esc_html__( 'Start', 'elementor' ),
308 + 'title' => esc_html__( 'Left', 'elementor' ),
352 309 'icon' => 'eicon-text-align-left',
353 310 ],
354 311 'center' => [
355 312 'title' => esc_html__( 'Center', 'elementor' ),
@@ -355,16 +312,16 @@
355 312 'title' => esc_html__( 'Center', 'elementor' ),
356 313 'icon' => 'eicon-text-align-center',
357 314 ],
358 315 'end' => [
359 - 'title' => esc_html__( 'End', 'elementor' ),
316 + 'title' => esc_html__( 'Right', 'elementor' ),
360 317 'icon' => 'eicon-text-align-right',
361 318 ],
362 319 ],
363 320 '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;',
321 + 'start' => '--n-tabs-title-justify-content: flex-start; --n-tabs-title-align-items: flex-start;',
322 + 'center' => '--n-tabs-title-justify-content: center; --n-tabs-title-align-items: center;',
323 + 'end' => '--n-tabs-title-justify-content: flex-end; --n-tabs-title-align-items: flex-end;',
367 324 ],
368 325 'selectors' => [
369 326 '{{WRAPPER}}' => '{{VALUE}}',
370 327 ],
@@ -372,45 +329,12 @@
372 329
373 330 $this->end_controls_section();
374 331
375 332 $this->start_controls_section( 'section_tabs_responsive', [
376 - 'label' => esc_html__( 'Additional Settings', 'elementor' ),
333 + 'label' => esc_html__( 'Responsive Settings', 'elementor' ),
377 334 ] );
378 335
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 - ];
336 + $dropdown_options = [];
413 337 $excluded_breakpoints = [
414 338 'laptop',
415 339 'tablet_extra',
416 340 'widescreen',
@@ -452,20 +376,15 @@
452 376
453 377 $this->add_responsive_control( 'tabs_title_space_between', [
454 378 'label' => esc_html__( 'Gap between tabs', 'elementor' ),
455 379 'type' => Controls_Manager::SLIDER,
456 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
457 380 'range' => [
458 381 'px' => [
382 + 'min' => 0,
459 383 'max' => 400,
460 384 ],
461 - 'em' => [
462 - 'max' => 40,
463 - ],
464 - 'rem' => [
465 - 'max' => 40,
466 - ],
467 385 ],
386 + 'size_units' => [ 'px' ],
468 387 'selectors' => [
469 388 '{{WRAPPER}}' => '--n-tabs-title-gap: {{SIZE}}{{UNIT}}',
470 389 ],
471 390 ] );
@@ -472,20 +391,15 @@
472 391
473 392 $this->add_responsive_control( 'tabs_title_spacing', [
474 393 'label' => esc_html__( 'Distance from content', 'elementor' ),
475 394 'type' => Controls_Manager::SLIDER,
476 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
477 395 'range' => [
478 396 'px' => [
397 + 'min' => 0,
479 398 'max' => 400,
480 399 ],
481 - 'em' => [
482 - 'max' => 40,
483 - ],
484 - 'rem' => [
485 - 'max' => 40,
486 - ],
487 400 ],
401 + 'size_units' => [ 'px' ],
488 402 'selectors' => [
489 403 '{{WRAPPER}}' => '--n-tabs-gap: {{SIZE}}{{UNIT}}',
490 404 ],
491 405 ] );
@@ -504,9 +418,9 @@
504 418 [
505 419 'name' => 'tabs_title_background_color',
506 420 'types' => [ 'classic', 'gradient' ],
507 421 '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 )",
422 + '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 423 'fields_options' => [
510 424 'color' => [
511 425 'label' => esc_html__( 'Background Color', 'elementor' ),
512 426 'selectors' => [
@@ -520,9 +434,9 @@
520 434 $this->add_group_control(
521 435 Group_Control_Border::get_type(),
522 436 [
523 437 'name' => 'tabs_title_border',
524 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover )",
438 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover )",
525 439 'fields_options' => [
526 440 'color' => [
527 441 'label' => esc_html__( 'Border Color', 'elementor' ),
528 442 ],
@@ -536,10 +450,11 @@
536 450 $this->add_group_control(
537 451 Group_Control_Box_Shadow::get_type(),
538 452 [
539 453 'name' => 'tabs_title_box_shadow',
454 + 'label' => esc_html__( 'Shadow', 'elementor' ),
540 455 'separator' => 'after',
541 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover )",
456 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover )",
542 457 ]
543 458 );
544 459
545 460 $this->end_controls_tab();
@@ -556,9 +471,9 @@
556 471 [
557 472 'name' => 'tabs_title_background_color_hover',
558 473 'types' => [ 'classic', 'gradient' ],
559 474 'exclude' => [ 'image' ],
560 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
475 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-normal:not( .e-active ):hover",
561 476 'fields_options' => [
562 477 'background' => [
563 478 'default' => 'classic',
564 479 ],
@@ -578,9 +493,9 @@
578 493 $this->add_group_control(
579 494 Group_Control_Border::get_type(),
580 495 [
581 496 'name' => 'tabs_title_border_hover',
582 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
497 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-normal:not( .e-active ):hover",
583 498 'fields_options' => [
584 499 'color' => [
585 500 'label' => esc_html__( 'Border Color', 'elementor' ),
586 501 ],
@@ -594,10 +509,11 @@
594 509 $this->add_group_control(
595 510 Group_Control_Box_Shadow::get_type(),
596 511 [
597 512 'name' => 'tabs_title_box_shadow_hover',
513 + 'label' => esc_html__( 'Shadow', 'elementor' ),
598 514 'separator' => 'after',
599 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
515 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-normal:not( .e-active ):hover",
600 516 ]
601 517 );
602 518
603 519 $this->add_control(
@@ -617,9 +533,8 @@
617 533 '{{WRAPPER}}' => '--n-tabs-title-transition: {{SIZE}}s',
618 534 ],
619 535 'range' => [
620 536 'px' => [
621 - 'min' => 0,
622 537 'max' => 3,
623 538 'step' => 0.1,
624 539 ],
625 540 ],
@@ -640,9 +555,9 @@
640 555 [
641 556 'name' => 'tabs_title_background_color_active',
642 557 'types' => [ 'classic', 'gradient' ],
643 558 '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",
559 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
645 560 'fields_options' => [
646 561 'background' => [
647 562 'default' => 'classic',
648 563 ],
@@ -662,9 +577,9 @@
662 577 $this->add_group_control(
663 578 Group_Control_Border::get_type(),
664 579 [
665 580 '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",
581 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
667 582 'fields_options' => [
668 583 'color' => [
669 584 'label' => esc_html__( 'Border Color', 'elementor' ),
670 585 ],
@@ -678,9 +593,10 @@
678 593 $this->add_group_control(
679 594 Group_Control_Box_Shadow::get_type(),
680 595 [
681 596 '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",
597 + 'label' => esc_html__( 'Shadow', 'elementor' ),
598 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
683 599 ]
684 600 );
685 601
686 602 $this->end_controls_tab();
@@ -723,9 +639,9 @@
723 639 'name' => 'title_typography',
724 640 'global' => [
725 641 'default' => Global_Typography::TYPOGRAPHY_ACCENT,
726 642 ],
727 - 'selector' => "{$heading_selector} > :is( .e-n-tab-title > .e-n-tab-title-text, .e-n-tab-title )",
643 + 'selector' => "{$nested_tabs_heading_selector_class} > :is( .e-n-tab-title > .e-n-tab-title-text, .e-n-tab-title )",
728 644 'fields_options' => [
729 645 'font_size' => [
730 646 'selectors' => [
731 647 '{{WRAPPER}}' => '--n-tabs-title-font-size: {{SIZE}}{{UNIT}}',
@@ -757,9 +673,14 @@
757 673 $this->add_group_control(
758 674 Group_Control_Text_Shadow::get_type(),
759 675 [
760 676 'name' => 'title_text_shadow',
761 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover )",
677 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover )",
678 + 'fields_options' => [
679 + 'text_shadow_type' => [
680 + 'label' => esc_html_x( 'Shadow', 'Text Shadow Control', 'elementor' ),
681 + ],
682 + ],
762 683 ]
763 684 );
764 685
765 686 $this->add_group_control(
@@ -765,9 +686,14 @@
765 686 $this->add_group_control(
766 687 Group_Control_Text_Stroke::get_type(),
767 688 [
768 689 'name' => 'title_text_stroke',
769 - 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover ) :is( span, a, i )",
690 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title:not( .e-active ):not( :hover ) :is( span, a, i )",
691 + 'fields_options' => [
692 + 'text_stroke_type' => [
693 + 'label' => esc_html__( 'Stroke', 'elementor' ),
694 + ],
695 + ],
770 696 ]
771 697 );
772 698
773 699 $this->end_controls_tab();
@@ -784,9 +710,9 @@
784 710 [
785 711 'label' => esc_html__( 'Color', 'elementor' ),
786 712 'type' => Controls_Manager::COLOR,
787 713 'selectors' => [
788 - '{{WRAPPER}} [data-touch-mode="false"] .e-n-tab-title[aria-selected="false"]:hover' => '--n-tabs-title-color-hover: {{VALUE}}',
714 + '{{WRAPPER}} .e-normal:not( .e-active ):hover' => '--n-tabs-title-color-hover: {{VALUE}}',
789 715 ],
790 716 ]
791 717 );
792 718
@@ -793,9 +719,15 @@
793 719 $this->add_group_control(
794 720 Group_Control_Text_Shadow::get_type(),
795 721 [
796 722 'name' => 'title_text_shadow_hover',
797 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
723 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-normal:not( .e-active ):hover",
724 + 'fields_options' => [
725 + 'text_shadow_type' => [
726 + 'label' => esc_html_x( 'Shadow', 'Text Shadow Control', 'elementor' ),
727 + ],
728 + ],
729 +
798 730 ]
799 731 );
800 732
801 733 $this->add_group_control(
@@ -801,9 +733,14 @@
801 733 $this->add_group_control(
802 734 Group_Control_Text_Stroke::get_type(),
803 735 [
804 736 'name' => 'title_text_stroke_hover',
805 - 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover :is( span, a, i )",
737 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-normal:not( .e-active ):hover :is( span, a, i )",
738 + 'fields_options' => [
739 + 'text_stroke_type' => [
740 + 'label' => esc_html__( 'Stroke', 'elementor' ),
741 + ],
742 + ],
806 743 ]
807 744 );
808 745
809 746 $this->end_controls_tab();
@@ -829,9 +766,14 @@
829 766 $this->add_group_control(
830 767 Group_Control_Text_Shadow::get_type(),
831 768 [
832 769 '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",
770 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active",
771 + 'fields_options' => [
772 + 'text_shadow_type' => [
773 + 'label' => esc_html_x( 'Shadow', 'Text Shadow Control', 'elementor' ),
774 + ],
775 + ],
834 776 ]
835 777 );
836 778
837 779 $this->add_group_control(
@@ -837,9 +779,14 @@
837 779 $this->add_group_control(
838 780 Group_Control_Text_Stroke::get_type(),
839 781 [
840 782 '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 )",
783 + 'selector' => "{$nested_tabs_heading_selector_class} > .e-n-tab-title.e-active :is( span, a, i )",
784 + 'fields_options' => [
785 + 'text_stroke_type' => [
786 + 'label' => esc_html__( 'Stroke', 'elementor' ),
787 + ],
788 + ],
842 789 ]
843 790 );
844 791
845 792 $this->end_controls_tab();
@@ -852,45 +799,35 @@
852 799 'label' => esc_html__( 'Icon', 'elementor' ),
853 800 'tab' => Controls_Manager::TAB_STYLE,
854 801 ] );
855 802
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 803 $this->add_responsive_control( 'icon_position', [
862 804 'label' => esc_html__( 'Position', 'elementor' ),
863 805 'type' => Controls_Manager::CHOOSE,
864 806 'options' => [
865 - 'block-start' => [
866 - 'title' => esc_html__( 'Above', 'elementor' ),
807 + 'top' => [
808 + 'title' => esc_html__( 'Top', 'elementor' ),
867 809 'icon' => 'eicon-v-align-top',
868 810 ],
869 - 'inline-end' => [
870 - 'title' => esc_html__( 'After', 'elementor' ),
811 + 'end' => [
812 + 'title' => $tooltip_end,
871 813 'icon' => 'eicon-h-align-' . $end,
872 814 ],
873 - 'block-end' => [
874 - 'title' => esc_html__( 'Below', 'elementor' ),
815 + 'bottom' => [
816 + 'title' => esc_html__( 'Bottom', 'elementor' ),
875 817 'icon' => 'eicon-v-align-bottom',
876 818 ],
877 - 'inline-start' => [
878 - 'title' => esc_html__( 'Before', 'elementor' ),
819 + 'start' => [
820 + 'title' => $tooltip_start,
879 821 'icon' => 'eicon-h-align-' . $start,
880 822 ],
881 823 ],
882 824 'selectors_dictionary' => [
883 825 // 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,
826 + '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;',
827 + '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;',
828 + '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;',
829 + '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 830 ],
894 831 'selectors' => [
895 832 '{{WRAPPER}}' => '{{VALUE}}',
896 833 ],
@@ -900,15 +837,20 @@
900 837 'label' => esc_html__( 'Size', 'elementor' ),
901 838 'type' => Controls_Manager::SLIDER,
902 839 'range' => [
903 840 'px' => [
841 + 'min' => 0,
904 842 'max' => 100,
905 843 ],
906 844 'em' => [
845 + 'min' => 0,
907 846 'max' => 10,
847 + 'step' => 0.1,
908 848 ],
909 849 'rem' => [
850 + 'min' => 0,
910 851 'max' => 10,
852 + 'step' => 0.1,
911 853 ],
912 854 ],
913 855 'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ],
914 856 'selectors' => [
@@ -920,11 +862,13 @@
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 ],
@@ -963,9 +907,9 @@
963 907 $this->add_control( 'icon_color_hover', [
964 908 'label' => esc_html__( 'Color', 'elementor' ),
965 909 'type' => Controls_Manager::COLOR,
966 910 'selectors' => [
967 - '{{WRAPPER}} [data-touch-mode="false"] .e-n-tab-title[aria-selected="false"]:hover' => '--n-tabs-icon-color-hover: {{VALUE}};',
911 + '{{WRAPPER}} .e-normal:not( .e-active ):hover' => '--n-tabs-icon-color-hover: {{VALUE}};',
968 912 ],
969 913 ] );
970 914
971 915 $this->end_controls_tab();
@@ -1001,9 +945,9 @@
1001 945 [
1002 946 'name' => 'box_background_color',
1003 947 'types' => [ 'classic', 'gradient' ],
1004 948 'exclude' => [ 'image' ],
1005 - 'selector' => $content_selector,
949 + 'selector' => $nested_tabs_content_selector_class,
1006 950 'fields_options' => [
1007 951 'color' => [
1008 952 'label' => esc_html__( 'Background Color', 'elementor' ),
1009 953 ],
@@ -1014,9 +958,9 @@
1014 958 $this->add_group_control(
1015 959 Group_Control_Border::get_type(),
1016 960 [
1017 961 'name' => 'box_border',
1018 - 'selector' => $content_selector,
962 + 'selector' => $nested_tabs_content_selector_class,
1019 963 'fields_options' => [
1020 964 'color' => [
1021 965 'label' => esc_html__( 'Border Color', 'elementor' ),
1022 966 ],
@@ -1033,9 +977,9 @@
1033 977 'label' => esc_html__( 'Border Radius', 'elementor' ),
1034 978 'type' => Controls_Manager::DIMENSIONS,
1035 979 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1036 980 'selectors' => [
1037 - $content_selector => '--border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
981 + $nested_tabs_content_selector_class => '--border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1038 982 ],
1039 983 ]
1040 984 );
1041 985
@@ -1042,9 +986,9 @@
1042 986 $this->add_group_control(
1043 987 Group_Control_Box_Shadow::get_type(),
1044 988 [
1045 989 'name' => 'box_shadow_box_shadow',
1046 - 'selector' => $content_selector,
990 + 'selector' => $nested_tabs_content_selector_class,
1047 991 'condition' => [
1048 992 'box_height!' => 'height',
1049 993 ],
1050 994 ]
@@ -1056,9 +1000,9 @@
1056 1000 'label' => esc_html__( 'Padding', 'elementor' ),
1057 1001 'type' => Controls_Manager::DIMENSIONS,
1058 1002 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
1059 1003 'selectors' => [
1060 - $content_selector => '--padding-top: {{TOP}}{{UNIT}}; --padding-right: {{RIGHT}}{{UNIT}}; --padding-bottom: {{BOTTOM}}{{UNIT}}; --padding-left: {{LEFT}}{{UNIT}};',
1004 + $nested_tabs_content_selector_class => '--padding-top: {{TOP}}{{UNIT}}; --padding-right: {{RIGHT}}{{UNIT}}; --padding-bottom: {{BOTTOM}}{{UNIT}}; --padding-left: {{LEFT}}{{UNIT}};',
1061 1005 ],
1062 1006 ]
1063 1007 );
1064 1008
@@ -1064,261 +1008,168 @@
1064 1008
1065 1009 $this->end_controls_section();
1066 1010 }
1067 1011
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' ];
1012 + protected function render() {
1013 + // Copied from tabs.php
1014 + $settings = $this->get_settings_for_display();
1015 + $tabs = $settings['tabs'];
1072 1016
1073 - if ( $item_settings['settings']['hover_animation'] ) {
1074 - $css_classes[] = 'elementor-animation-' . $item_settings['settings']['hover_animation'];
1075 - }
1017 + $id_int = substr( $this->get_id_int(), 0, 3 );
1076 1018
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 - }
1019 + $a11y_improvements_experiment = Plugin::$instance->experiments->is_feature_active( 'a11y_improvements' );
1097 1020
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;
1021 + if ( ! empty( $settings['link'] ) ) {
1022 + $this->add_link_attributes( 'elementor-tabs', $settings['link'] );
1103 1023 }
1104 1024
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 - }
1025 + $this->add_render_attribute( 'elementor-tabs', 'class', 'e-n-tabs' );
1026 + $this->add_render_attribute( 'tab-title-text', 'class', 'e-n-tab-title-text' );
1027 + $this->add_render_attribute( 'tab-icon', 'class', 'e-n-tab-icon' );
1028 + $this->add_render_attribute( 'tab-icon-active', 'class', [ 'e-n-tab-icon', 'e-active' ] );
1115 1029
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 - }
1030 + $tabs_title_html = '';
1031 + $mobile_tabs_title_html = '';
1122 1032
1033 + foreach ( $tabs as $index => $item ) {
1034 + // Tabs title.
1035 + $tab_count = $index + 1;
1036 + $tab_title_setting_key = $this->get_repeater_setting_key( 'tab_title', 'tabs', $index );
1037 + $tab_title = $a11y_improvements_experiment ? $item['tab_title'] : '<a href="">' . $item['tab_title'] . '</a>';
1038 + $tab_title_mobile_setting_key = $this->get_repeater_setting_key( 'tab_title_mobile', 'tabs', $tab_count );
1039 + $tab_title_classes = [ 'e-n-tab-title', 'e-normal' ];
1040 + $tab_title_mobile_classes = [ 'e-n-tab-title', 'e-collapse' ];
1123 1041
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 = [];
1042 + if ( $settings['hover_animation'] ) {
1043 + array_push( $tab_title_classes, 'elementor-animation-' . $settings['hover_animation'] );
1044 + array_push( $tab_title_mobile_classes, 'elementor-animation-' . $settings['hover_animation'] );
1045 + }
1133 1046
1134 - foreach ( $children as $child ) {
1135 - $child_ids[] = $child->get_id();
1136 - }
1047 + $tab_id = empty( $item['element_id'] ) ? 'e-n-tabs-title-' . $id_int . $tab_count : $item['element_id'];
1137 1048
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 - }
1049 + $this->add_render_attribute( $tab_title_setting_key, [
1050 + 'id' => $tab_id,
1051 + 'class' => $tab_title_classes,
1052 + 'aria-selected' => 1 === $tab_count ? 'true' : 'false',
1053 + 'data-tab' => $tab_count,
1054 + 'role' => 'tab',
1055 + 'tabindex' => 1 === $tab_count ? '0' : '-1',
1056 + 'aria-controls' => 'e-n-tab-content-' . $id_int . $tab_count,
1057 + 'aria-expanded' => 'false',
1058 + ] );
1143 1059
1144 - return $should_render;
1145 - };
1060 + $this->add_render_attribute( $tab_title_mobile_setting_key, [
1061 + 'class' => $tab_title_mobile_classes,
1062 + 'aria-selected' => 1 === $tab_count ? 'true' : 'false',
1063 + 'data-tab' => $tab_count,
1064 + 'role' => 'tab',
1065 + 'tabindex' => 1 === $tab_count ? '0' : '-1',
1066 + 'aria-controls' => 'e-n-tab-content-' . $id_int . $tab_count,
1067 + 'aria-expanded' => 'false',
1068 + 'id' => $tab_id . '-accordion',
1069 + ] );
1146 1070
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 - }
1071 + $title_render_attributes = $this->get_render_attribute_string( $tab_title_setting_key );
1072 + $mobile_title_attributes = $this->get_render_attribute_string( $tab_title_mobile_setting_key );
1073 + $tab_title_text_class = $this->get_render_attribute_string( 'tab-title-text' );
1074 + $tab_icon_class = $this->get_render_attribute_string( 'tab-icon' );
1153 1075
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 - }
1076 + $icon_html = Icons_Manager::try_get_icon_html( $item['tab_icon'], [ 'aria-hidden' => 'true' ] );
1077 + $icon_active_html = $icon_html;
1164 1078
1165 - protected function render() {
1166 - $settings = $this->get_settings_for_display();
1167 - $widget_number = $this->get_id_int();
1079 + if ( $this->is_active_icon_exist( $item ) ) {
1080 + $icon_active_html = Icons_Manager::try_get_icon_html( $item['tab_icon_active'], [ 'aria-hidden' => 'true' ] );
1081 + }
1168 1082
1169 - if ( ! empty( $settings['link'] ) ) {
1170 - $this->add_link_attributes( 'elementor-tabs', $settings['link'] );
1171 - }
1083 + $tabs_title_html .= "<div {$title_render_attributes}>";
1084 + $tabs_title_html .= "\t<span {$tab_icon_class}>{$icon_html}{$icon_active_html}</span>";
1085 + $tabs_title_html .= "\t<span {$tab_title_text_class}>{$tab_title}</span>";
1086 + $tabs_title_html .= '</div>';
1172 1087
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 - ] );
1088 + // Tabs content.
1089 + ob_start();
1090 + $this->print_child( $index );
1091 + $tab_content = ob_get_clean();
1178 1092
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' ] );
1093 + $mobile_tabs_title_html .= "<div $mobile_title_attributes>";
1094 + $mobile_tabs_title_html .= "\t<span {$tab_icon_class}>{$icon_html}{$icon_active_html}</span>";
1095 + $mobile_tabs_title_html .= "\t<span {$tab_title_text_class}>{$tab_title}</span>";
1096 + $mobile_tabs_title_html .= "</div>$tab_content";
1097 + }
1182 1098 ?>
1183 1099 <div <?php $this->print_render_attribute_string( 'elementor-tabs' ); ?>>
1184 1100 <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 - ?>
1101 + <?php echo $tabs_title_html;// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1209 1102 </div>
1210 - <div class="e-n-tabs-content">
1211 - <?php $this->render_tab_containers_html( $settings ); ?>
1103 + <div class="e-n-tabs-content" role="tablist" aria-orientation="vertical">
1104 + <?php echo $mobile_tabs_title_html;// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1212 1105 </div>
1213 1106 </div>
1214 1107 <?php
1215 1108 }
1216 1109
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 1110 protected function content_template() {
1240 1111 ?>
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'] ) { #>
1112 + <div class="e-n-tabs" role="tablist" aria-orientation="vertical">
1113 + <# if ( settings['tabs'] ) {
1114 + const elementUid = view.getIDInt().toString().substr( 0, 3 ); #>
1244 1115 <div class="e-n-tabs-heading" role="tablist">
1245 1116 <# _.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 - }
1117 + const tabCount = index + 1,
1118 + tabUid = elementUid + tabCount,
1119 + tabWrapperKey = tabUid,
1120 + tabTitleKey = 'tab-title-' + tabUid,
1121 + tabIconKey = 'tab-icon-' + tabUid,
1122 + tabIcon = elementor.helpers.renderIcon( view, item.tab_icon, { 'aria-hidden': true }, 'i' , 'object' ),
1123 + hoverAnimationClass = settings['hover_animation'] ? `elementor-animation-${ settings['hover_animation'] }` : '';
1260 1124
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 );
1125 + let tabActiveIcon = tabIcon,
1126 + tabId = 'e-n-tab-title-' + tabUid;
1275 1127
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 );
1128 + if ( '' !== item.tab_icon_active.value ) {
1129 + tabActiveIcon = elementor.helpers.renderIcon( view, item.tab_icon_active, { 'aria-hidden': true }, 'i' , 'object' );
1130 + }
1287 1131
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 );
1132 + if ( '' !== item.element_id ) {
1133 + tabId = item.element_id;
1134 + }
1305 1135
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 - #>
1136 + view.addRenderAttribute( tabWrapperKey, {
1137 + 'id': tabId,
1138 + 'class': [ 'e-n-tab-title','e-normal',hoverAnimationClass ],
1139 + 'data-tab': tabCount,
1140 + 'role': 'tab',
1141 + 'tabindex': 1 === tabCount ? '0' : '-1',
1142 + 'aria-controls': 'e-n-tab-content-' + tabUid,
1143 + 'aria-expanded': 'false',
1144 + } );
1313 1145
1314 - <button {{{ view.getRenderAttributeString( 'tab-title' ) }}}>
1315 - <# if ( !! item.tab_icon.value ) { #>
1316 - <span {{{ view.getRenderAttributeString( 'tab-icon' ) }}}>{{{ tabIcon.value }}}{{{ activeTabIcon.value }}}</span>
1146 + view.addRenderAttribute( tabTitleKey, {
1147 + 'class': [ 'e-n-tab-title-text' ],
1148 + 'data-binding-type': 'repeater-item',
1149 + 'data-binding-repeater-name': 'tabs',
1150 + 'data-binding-setting': [ 'tab_title' ],
1151 + 'data-binding-index': tabCount,
1152 + } );
1153 +
1154 + view.addRenderAttribute( tabIconKey, {
1155 + 'class': [ 'e-n-tab-icon' ],
1156 + 'data-binding-type': 'repeater-item',
1157 + 'data-binding-repeater-name': 'tabs',
1158 + 'data-binding-setting': [ 'tab_icon.value', 'tab_icon_active.value' ],
1159 + 'data-binding-index': tabCount,
1160 + } );
1161 + #>
1162 + <div {{{ view.getRenderAttributeString( tabWrapperKey ) }}}>
1163 + <span {{{ view.getRenderAttributeString( tabIconKey ) }}}>{{{ tabIcon.value }}}{{{ tabActiveIcon.value }}}</span>
1164 + <span {{{ view.getRenderAttributeString( tabTitleKey ) }}}>{{{ item.tab_title }}}</span>
1165 + </div>
1166 + <# } ); #>
1167 + </div>
1168 + <div class="e-n-tabs-content">
1169 + </div>
1317 1170 <# } #>
1318 -
1319 - <span {{{ view.getRenderAttributeString( 'tab-title-text' ) }}}>{{{ item.tab_title }}}</span>
1320 - </button>
1171 + </div>
1321 1172 <?php
1322 1173 }
1323 1174
1324 1175 /**