PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.2
Elementor Website Builder – more than just a page builder v4.2.2
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 4.0.7 All 451 releases
elementor / includes / widgets / toggle.php

toggle.php in Elementor Website Builder – more than just a page builder 4.2.2, at includes/widgets/toggle.php

764 lines 20.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
9 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
10
11 /**
12 * Elementor toggle widget.
13 *
14 * Elementor widget that displays a collapsible display of content in an toggle
15 * style, allowing the user to open multiple items.
16 *
17 * @since 1.0.0
18 */
19 class Widget_Toggle extends Widget_Base {
20
21 /**
22 * Get widget name.
23 *
24 * Retrieve toggle widget name.
25 *
26 * @since 1.0.0
27 * @access public
28 *
29 * @return string Widget name.
30 */
31 public function get_name() {
32 return 'toggle';
33 }
34
35 /**
36 * Get widget title.
37 *
38 * Retrieve toggle widget title.
39 *
40 * @since 1.0.0
41 * @access public
42 *
43 * @return string Widget title.
44 */
45 public function get_title() {
46 return esc_html__( 'Toggle', 'elementor' );
47 }
48
49 /**
50 * Get widget icon.
51 *
52 * Retrieve toggle widget icon.
53 *
54 * @since 1.0.0
55 * @access public
56 *
57 * @return string Widget icon.
58 */
59 public function get_icon() {
60 return 'eicon-toggle';
61 }
62
63 /**
64 * Get widget keywords.
65 *
66 * Retrieve the list of keywords the widget belongs to.
67 *
68 * @since 2.1.0
69 * @access public
70 *
71 * @return array Widget keywords.
72 */
73 public function get_keywords() {
74 return [ 'tabs', 'accordion', 'toggle' ];
75 }
76
77 protected function is_dynamic_content(): bool {
78 return false;
79 }
80
81 /**
82 * Get style dependencies.
83 *
84 * Retrieve the list of style dependencies the widget requires.
85 *
86 * @since 3.24.0
87 * @access public
88 *
89 * @return array Widget style dependencies.
90 */
91 public function get_style_depends(): array {
92 return [ 'widget-toggle' ];
93 }
94
95 /**
96 * Hide widget from panel.
97 *
98 * Hide the toggle widget from the panel if nested-accordion experiment is active.
99 *
100 * @since 3.15.0
101 * @return bool
102 */
103 public function show_in_panel(): bool {
104 return ! Plugin::$instance->experiments->is_feature_active( 'nested-elements', true );
105 }
106
107 public function has_widget_inner_wrapper(): bool {
108 return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
109 }
110
111 /**
112 * Register toggle widget controls.
113 *
114 * Adds different input fields to allow the user to change and customize the widget settings.
115 *
116 * @since 3.1.0
117 * @access protected
118 */
119 protected function register_controls() {
120 $this->start_controls_section(
121 'section_toggle',
122 [
123 'label' => esc_html__( 'Toggle', 'elementor' ),
124 ]
125 );
126
127 $repeater = new Repeater();
128
129 $repeater->add_control(
130 'tab_title',
131 [
132 'label' => esc_html__( 'Title', 'elementor' ),
133 'type' => Controls_Manager::TEXT,
134 'default' => esc_html__( 'Toggle Title', 'elementor' ),
135 'label_block' => true,
136 'dynamic' => [
137 'active' => true,
138 ],
139 ]
140 );
141
142 $repeater->add_control(
143 'tab_content',
144 [
145 'label' => esc_html__( 'Content', 'elementor' ),
146 'type' => Controls_Manager::WYSIWYG,
147 'default' => esc_html__( 'Toggle Content', 'elementor' ),
148 'dynamic' => [
149 'active' => true,
150 ],
151 ]
152 );
153
154 if ( Plugin::$instance->widgets_manager->get_widget_types( 'nested-accordion' ) ) {
155 $this->add_deprecation_message(
156 '3.15.0',
157 esc_html__(
158 'You are currently editing a Toggle widget in its old version. Drag a new Accordion widget onto your page to use a newer version, providing nested capabilities.',
159 'elementor'
160 ),
161 'nested-accordion'
162 );
163 }
164
165 $this->add_control(
166 'tabs',
167 [
168 'label' => esc_html__( 'Toggle Items', 'elementor' ),
169 'type' => Controls_Manager::REPEATER,
170 'fields' => $repeater->get_controls(),
171 'default' => [
172 [
173 'tab_title' => esc_html__( 'Toggle #1', 'elementor' ),
174 'tab_content' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.', 'elementor' ),
175 ],
176 [
177 'tab_title' => esc_html__( 'Toggle #2', 'elementor' ),
178 'tab_content' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.', 'elementor' ),
179 ],
180 ],
181 'title_field' => '{{{ tab_title }}}',
182 ]
183 );
184
185 $this->add_control(
186 'selected_icon',
187 [
188 'label' => esc_html__( 'Icon', 'elementor' ),
189 'type' => Controls_Manager::ICONS,
190 'separator' => 'before',
191 'fa4compatibility' => 'icon',
192 'default' => [
193 'value' => 'fas fa-caret' . ( is_rtl() ? '-left' : '-right' ),
194 'library' => 'fa-solid',
195 ],
196 'recommended' => [
197 'fa-solid' => [
198 'chevron-down',
199 'angle-down',
200 'angle-double-down',
201 'caret-down',
202 'caret-square-down',
203 ],
204 'fa-regular' => [
205 'caret-square-down',
206 ],
207 ],
208 'label_block' => false,
209 'skin' => 'inline',
210 ]
211 );
212
213 $this->add_control(
214 'selected_active_icon',
215 [
216 'label' => esc_html__( 'Active Icon', 'elementor' ),
217 'type' => Controls_Manager::ICONS,
218 'fa4compatibility' => 'icon_active',
219 'default' => [
220 'value' => 'fas fa-caret-up',
221 'library' => 'fa-solid',
222 ],
223 'recommended' => [
224 'fa-solid' => [
225 'chevron-up',
226 'angle-up',
227 'angle-double-up',
228 'caret-up',
229 'caret-square-up',
230 ],
231 'fa-regular' => [
232 'caret-square-up',
233 ],
234 ],
235 'skin' => 'inline',
236 'label_block' => false,
237 'condition' => [
238 'selected_icon[value]!' => '',
239 ],
240 ]
241 );
242
243 $this->add_control(
244 'title_html_tag',
245 [
246 'label' => esc_html__( 'Title HTML Tag', 'elementor' ),
247 'type' => Controls_Manager::SELECT,
248 'options' => [
249 'h1' => 'H1',
250 'h2' => 'H2',
251 'h3' => 'H3',
252 'h4' => 'H4',
253 'h5' => 'H5',
254 'h6' => 'H6',
255 'div' => 'div',
256 ],
257 'default' => 'div',
258 'separator' => 'before',
259 ]
260 );
261
262 $this->add_control(
263 'faq_schema',
264 [
265 'label' => esc_html__( 'FAQ Schema', 'elementor' ),
266 'type' => Controls_Manager::SWITCHER,
267 'separator' => 'before',
268 ]
269 );
270
271 $this->end_controls_section();
272
273 $this->start_controls_section(
274 'section_toggle_style',
275 [
276 'label' => esc_html__( 'Toggle', 'elementor' ),
277 'tab' => Controls_Manager::TAB_STYLE,
278 ]
279 );
280
281 $this->add_control(
282 'border_width',
283 [
284 'label' => esc_html__( 'Border Width', 'elementor' ),
285 'type' => Controls_Manager::SLIDER,
286 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
287 'range' => [
288 'px' => [
289 'max' => 20,
290 ],
291 'em' => [
292 'max' => 2,
293 ],
294 ],
295 'selectors' => [
296 '{{WRAPPER}} .elementor-tab-title' => 'border-width: {{SIZE}}{{UNIT}};',
297 '{{WRAPPER}} .elementor-tab-content' => 'border-width: {{SIZE}}{{UNIT}};',
298 ],
299 ]
300 );
301
302 $this->add_control(
303 'border_color',
304 [
305 'label' => esc_html__( 'Border Color', 'elementor' ),
306 'type' => Controls_Manager::COLOR,
307 'selectors' => [
308 '{{WRAPPER}} .elementor-tab-content' => 'border-block-end-color: {{VALUE}};',
309 '{{WRAPPER}} .elementor-tab-title' => 'border-color: {{VALUE}};',
310 ],
311 ]
312 );
313
314 $this->add_responsive_control(
315 'space_between',
316 [
317 'label' => esc_html__( 'Space Between', 'elementor' ),
318 'type' => Controls_Manager::SLIDER,
319 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
320 'range' => [
321 'px' => [
322 'max' => 100,
323 ],
324 'em' => [
325 'max' => 10,
326 ],
327 'rem' => [
328 'max' => 10,
329 ],
330 ],
331 'selectors' => [
332 '{{WRAPPER}} .elementor-toggle-item:not(:last-child)' => 'margin-block-end: {{SIZE}}{{UNIT}}',
333 ],
334 ]
335 );
336
337 $this->add_group_control(
338 Group_Control_Box_Shadow::get_type(),
339 [
340 'name' => 'box_shadow',
341 'selector' => '{{WRAPPER}} .elementor-toggle-item',
342 ]
343 );
344
345 $this->end_controls_section();
346
347 $this->start_controls_section(
348 'section_toggle_style_title',
349 [
350 'label' => esc_html__( 'Title', 'elementor' ),
351 'tab' => Controls_Manager::TAB_STYLE,
352 ]
353 );
354
355 $this->add_control(
356 'title_background',
357 [
358 'label' => esc_html__( 'Background', 'elementor' ),
359 'type' => Controls_Manager::COLOR,
360 'selectors' => [
361 '{{WRAPPER}} .elementor-tab-title' => 'background-color: {{VALUE}};',
362 ],
363 ]
364 );
365
366 // The title selector specificity is to override Theme Style
367 $this->add_control(
368 'title_color',
369 [
370 'label' => esc_html__( 'Color', 'elementor' ),
371 'type' => Controls_Manager::COLOR,
372 'selectors' => [
373 '{{WRAPPER}} .elementor-toggle-title, {{WRAPPER}} .elementor-toggle-icon' => 'color: {{VALUE}};',
374 '{{WRAPPER}} .elementor-toggle-icon svg' => 'fill: {{VALUE}};',
375 ],
376 'global' => [
377 'default' => Global_Colors::COLOR_PRIMARY,
378 ],
379 ]
380 );
381
382 $this->add_control(
383 'tab_active_color',
384 [
385 'label' => esc_html__( 'Active Color', 'elementor' ),
386 'type' => Controls_Manager::COLOR,
387 'selectors' => [
388 '{{WRAPPER}} .elementor-tab-title.elementor-active a, {{WRAPPER}} .elementor-tab-title.elementor-active .elementor-toggle-icon' => 'color: {{VALUE}};',
389 ],
390 'global' => [
391 'default' => Global_Colors::COLOR_ACCENT,
392 ],
393 ]
394 );
395
396 $this->add_group_control(
397 Group_Control_Typography::get_type(),
398 [
399 'name' => 'title_typography',
400 'selector' => '{{WRAPPER}} .elementor-toggle-title',
401 'global' => [
402 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
403 ],
404 ]
405 );
406
407 $this->add_group_control(
408 Group_Control_Text_Shadow::get_type(),
409 [
410 'name' => 'title_shadow',
411 'selector' => '{{WRAPPER}} .elementor-toggle-title',
412 ]
413 );
414
415 $this->add_responsive_control(
416 'title_padding',
417 [
418 'label' => esc_html__( 'Padding', 'elementor' ),
419 'type' => Controls_Manager::DIMENSIONS,
420 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
421 'selectors' => [
422 '{{WRAPPER}} .elementor-tab-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
423 ],
424 ]
425 );
426
427 $this->end_controls_section();
428
429 $this->start_controls_section(
430 'section_toggle_style_icon',
431 [
432 'label' => esc_html__( 'Icon', 'elementor' ),
433 'tab' => Controls_Manager::TAB_STYLE,
434 'condition' => [
435 'selected_icon[value]!' => '',
436 ],
437 ]
438 );
439
440 $this->add_control(
441 'icon_align',
442 [
443 'label' => esc_html__( 'Alignment', 'elementor' ),
444 'type' => Controls_Manager::CHOOSE,
445 'options' => [
446 'left' => [
447 'title' => esc_html__( 'Start', 'elementor' ),
448 'icon' => 'eicon-h-align-left',
449 ],
450 'right' => [
451 'title' => esc_html__( 'End', 'elementor' ),
452 'icon' => 'eicon-h-align-right',
453 ],
454 ],
455 'default' => is_rtl() ? 'right' : 'left',
456 'toggle' => false,
457 ]
458 );
459
460 $this->add_control(
461 'icon_color',
462 [
463 'label' => esc_html__( 'Color', 'elementor' ),
464 'type' => Controls_Manager::COLOR,
465 'selectors' => [
466 '{{WRAPPER}} .elementor-tab-title .elementor-toggle-icon i:before' => 'color: {{VALUE}};',
467 '{{WRAPPER}} .elementor-tab-title .elementor-toggle-icon svg' => 'fill: {{VALUE}};',
468 ],
469 ]
470 );
471
472 $this->add_control(
473 'icon_active_color',
474 [
475 'label' => esc_html__( 'Active Color', 'elementor' ),
476 'type' => Controls_Manager::COLOR,
477 'selectors' => [
478 '{{WRAPPER}} .elementor-tab-title.elementor-active .elementor-toggle-icon i:before' => 'color: {{VALUE}};',
479 '{{WRAPPER}} .elementor-tab-title.elementor-active .elementor-toggle-icon svg' => 'fill: {{VALUE}};',
480 ],
481 ]
482 );
483
484 $this->add_responsive_control(
485 'icon_space',
486 [
487 'label' => esc_html__( 'Spacing', 'elementor' ),
488 'type' => Controls_Manager::SLIDER,
489 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
490 'range' => [
491 'px' => [
492 'max' => 100,
493 ],
494 'em' => [
495 'max' => 10,
496 ],
497 'rem' => [
498 'max' => 10,
499 ],
500 ],
501 'selectors' => [
502 '{{WRAPPER}} .elementor-toggle-icon' => 'margin-inline-end: {{SIZE}}{{UNIT}};',
503 ],
504 ]
505 );
506
507 $this->end_controls_section();
508
509 $this->start_controls_section(
510 'section_toggle_style_content',
511 [
512 'label' => esc_html__( 'Content', 'elementor' ),
513 'tab' => Controls_Manager::TAB_STYLE,
514 ]
515 );
516
517 $this->add_control(
518 'content_background_color',
519 [
520 'label' => esc_html__( 'Background', 'elementor' ),
521 'type' => Controls_Manager::COLOR,
522 'selectors' => [
523 '{{WRAPPER}} .elementor-tab-content' => 'background-color: {{VALUE}};',
524 ],
525 ]
526 );
527
528 $this->add_control(
529 'content_color',
530 [
531 'label' => esc_html__( 'Color', 'elementor' ),
532 'type' => Controls_Manager::COLOR,
533 'selectors' => [
534 '{{WRAPPER}} .elementor-tab-content' => 'color: {{VALUE}};',
535 ],
536 'global' => [
537 'default' => Global_Colors::COLOR_TEXT,
538 ],
539 ]
540 );
541
542 $this->add_group_control(
543 Group_Control_Typography::get_type(),
544 [
545 'name' => 'content_typography',
546 'selector' => '{{WRAPPER}} .elementor-tab-content',
547 'global' => [
548 'default' => Global_Typography::TYPOGRAPHY_TEXT,
549 ],
550 ]
551 );
552
553 $this->add_group_control(
554 Group_Control_Text_Shadow::get_type(),
555 [
556 'name' => 'content_shadow',
557 'selector' => '{{WRAPPER}} .elementor-tab-content',
558 ]
559 );
560
561 $this->add_responsive_control(
562 'content_padding',
563 [
564 'label' => esc_html__( 'Padding', 'elementor' ),
565 'type' => Controls_Manager::DIMENSIONS,
566 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
567 'selectors' => [
568 '{{WRAPPER}} .elementor-tab-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
569 ],
570 ]
571 );
572
573 $this->end_controls_section();
574 }
575
576 /**
577 * Render toggle widget output on the frontend.
578 *
579 * Written in PHP and used to generate the final HTML.
580 *
581 * @since 1.0.0
582 * @access protected
583 */
584 protected function render() {
585 $settings = $this->get_settings_for_display();
586
587 $id_int = substr( $this->get_id_int(), 0, 3 );
588 $migrated = isset( $settings['__fa4_migrated']['selected_icon'] );
589
590 if ( ! isset( $settings['icon'] ) && ! Icons_Manager::is_migration_allowed() ) {
591 // @todo: remove when deprecated
592 // added as bc in 2.6
593 // add old default
594 $settings['icon'] = 'fa fa-caret' . ( is_rtl() ? '-left' : '-right' );
595 $settings['icon_active'] = 'fa fa-caret-up';
596 $settings['icon_align'] = $this->get_settings( 'icon_align' );
597 }
598
599 $is_new = empty( $settings['icon'] ) && Icons_Manager::is_migration_allowed();
600 $has_icon = ( ! $is_new || ! empty( $settings['selected_icon']['value'] ) );
601
602 ?>
603 <div class="elementor-toggle">
604 <?php
605 foreach ( $settings['tabs'] as $index => $item ) :
606 $tab_count = $index + 1;
607
608 $tab_title_setting_key = $this->get_repeater_setting_key( 'tab_title', 'tabs', $index );
609
610 $tab_content_setting_key = $this->get_repeater_setting_key( 'tab_content', 'tabs', $index );
611
612 $this->add_render_attribute( $tab_title_setting_key, [
613 'id' => 'elementor-tab-title-' . $id_int . $tab_count,
614 'class' => [ 'elementor-tab-title' ],
615 'data-tab' => $tab_count,
616 'role' => 'button',
617 'aria-controls' => 'elementor-tab-content-' . $id_int . $tab_count,
618 'aria-expanded' => 'false',
619 ] );
620
621 $this->add_render_attribute( $tab_content_setting_key, [
622 'id' => 'elementor-tab-content-' . $id_int . $tab_count,
623 'class' => [ 'elementor-tab-content', 'elementor-clearfix' ],
624 'data-tab' => $tab_count,
625 'role' => 'region',
626 'aria-labelledby' => 'elementor-tab-title-' . $id_int . $tab_count,
627 ] );
628
629 $this->add_inline_editing_attributes( $tab_content_setting_key, 'advanced' );
630 ?>
631 <div class="elementor-toggle-item">
632 <<?php Utils::print_validated_html_tag( $settings['title_html_tag'] ); ?> <?php $this->print_render_attribute_string( $tab_title_setting_key ); ?>>
633 <?php if ( $has_icon ) : ?>
634 <span class="elementor-toggle-icon elementor-toggle-icon-<?php echo esc_attr( $settings['icon_align'] ); ?>" aria-hidden="true">
635 <?php
636 if ( $is_new || $migrated ) { ?>
637 <span class="elementor-toggle-icon-closed"><?php Icons_Manager::render_icon( $settings['selected_icon'] ); ?></span>
638 <span class="elementor-toggle-icon-opened"><?php Icons_Manager::render_icon( $settings['selected_active_icon'], [ 'class' => 'elementor-toggle-icon-opened' ] ); ?></span>
639 <?php } else { ?>
640 <i class="elementor-toggle-icon-closed <?php echo esc_attr( $settings['icon'] ); ?>"></i>
641 <i class="elementor-toggle-icon-opened <?php echo esc_attr( $settings['icon_active'] ); ?>"></i>
642 <?php } ?>
643 </span>
644 <?php endif; ?>
645 <a class="elementor-toggle-title" tabindex="0"><?php $this->print_unescaped_setting( 'tab_title', 'tabs', $index ); ?></a>
646 </<?php Utils::print_validated_html_tag( $settings['title_html_tag'] ); ?>>
647
648 <div <?php $this->print_render_attribute_string( $tab_content_setting_key ); ?>><?php Utils::print_unescaped_internal_string( $this->parse_text_editor( $item['tab_content'] ) ); ?></div>
649 </div>
650 <?php endforeach; ?>
651 <?php
652 if ( isset( $settings['faq_schema'] ) && 'yes' === $settings['faq_schema'] ) {
653 $json = [
654 '@context' => 'https://schema.org',
655 '@type' => 'FAQPage',
656 'mainEntity' => [],
657 ];
658
659 foreach ( $settings['tabs'] as $index => $item ) {
660 $json['mainEntity'][] = [
661 '@type' => 'Question',
662 'name' => wp_strip_all_tags( $item['tab_title'] ),
663 'acceptedAnswer' => [
664 '@type' => 'Answer',
665 'text' => $this->parse_text_editor( $item['tab_content'] ),
666 ],
667 ];
668 }
669 ?>
670 <script type="application/ld+json"><?php echo wp_json_encode( $json ); ?></script>
671 <?php } ?>
672 </div>
673 <?php
674 }
675
676 /**
677 * Render toggle widget output in the editor.
678 *
679 * Written as a Backbone JavaScript template and used to generate the live preview.
680 *
681 * @since 2.9.0
682 * @access protected
683 */
684 protected function content_template() {
685 ?>
686 <div class="elementor-toggle">
687 <#
688 if ( settings.tabs ) {
689 var tabindex = view.getIDInt().toString().substr( 0, 3 ),
690 iconHTML = elementor.helpers.renderIcon( view, settings.selected_icon, {}, 'i' , 'object' ),
691 iconActiveHTML = elementor.helpers.renderIcon( view, settings.selected_active_icon, {}, 'i' , 'object' ),
692 migrated = elementor.helpers.isIconMigrated( settings, 'selected_icon' ),
693 titleHTMLTag = elementor.helpers.validateHTMLTag( settings.title_html_tag );
694
695 _.each( settings.tabs, function( item, index ) {
696 var tabCount = index + 1,
697 tabTitleKey = view.getRepeaterSettingKey( 'tab_title', 'tabs', index ),
698 tabContentKey = view.getRepeaterSettingKey( 'tab_content', 'tabs', index );
699
700 view.addRenderAttribute( tabTitleKey, {
701 'id': 'elementor-tab-title-' + tabindex + tabCount,
702 'class': [ 'elementor-tab-title' ],
703 'data-tab': tabCount,
704 'role': 'button',
705 'aria-controls': 'elementor-tab-content-' + tabindex + tabCount,
706 'aria-expanded': 'false',
707 } );
708
709 view.addRenderAttribute( tabContentKey, {
710 'id': 'elementor-tab-content-' + tabindex + tabCount,
711 'class': [ 'elementor-tab-content', 'elementor-clearfix' ],
712 'data-tab': tabCount,
713 'role': 'region',
714 'aria-labelledby': 'elementor-tab-title-' + tabindex + tabCount
715 } );
716
717 view.addInlineEditingAttributes( tabContentKey, 'advanced' );
718 #>
719 <div class="elementor-toggle-item">
720 <{{{ titleHTMLTag }}} {{{ view.getRenderAttributeString( tabTitleKey ) }}}>
721 <# if ( settings.icon || settings.selected_icon ) { #>
722 <span class="elementor-toggle-icon elementor-toggle-icon-{{ settings.icon_align }}" aria-hidden="true">
723 <# if ( iconHTML && iconHTML.rendered && ( ! settings.icon || migrated ) ) { #>
724 <span class="elementor-toggle-icon-closed">{{{ iconHTML.value }}}</span>
725 <span class="elementor-toggle-icon-opened">{{{ iconActiveHTML.value }}}</span>
726 <# } else { #>
727 <i class="elementor-toggle-icon-closed {{ settings.icon }}"></i>
728 <i class="elementor-toggle-icon-opened {{ settings.icon_active }}"></i>
729 <# } #>
730 </span>
731 <# } #>
732 <a class="elementor-toggle-title" tabindex="0">{{{ item.tab_title }}}</a>
733 </{{{ titleHTMLTag }}}>
734 <div {{{ view.getRenderAttributeString( tabContentKey ) }}}>{{{ item.tab_content }}}</div>
735 </div>
736 <#
737 } );
738 } #>
739 </div>
740 <?php
741 }
742
743 public function render_markdown(): string {
744 $settings = $this->get_settings_for_display();
745 if ( empty( $settings['tabs'] ) ) {
746 return '';
747 }
748 $sections = [];
749 foreach ( $settings['tabs'] as $item ) {
750 $title = Utils::html_to_plain_text( $item['tab_title'] ?? '' );
751 $content = \Elementor\Modules\MarkdownRender\Html_To_Markdown::convert( $item['tab_content'] ?? '' );
752 if ( empty( $title ) && empty( $content ) ) {
753 continue;
754 }
755 $section = '### ' . $title;
756 if ( ! empty( $content ) ) {
757 $section .= "\n\n" . $content;
758 }
759 $sections[] = $section;
760 }
761 return implode( "\n\n", $sections );
762 }
763 }
764