← All changes
|
modules/nested-accordion/widgets/nested-accordion.php
+35
-65
4.3.1
→
3.25.2
View file →
| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | use Elementor\Utils; |
| 15 | 15 | use Elementor\Group_Control_Text_Stroke; |
| 16 | 16 | |
| 17 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | - exit; // Exit if accessed directly. | |
| 18 | + exit; // Exit if accessed directly | |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Elementor Nested Accordion widget. |
| @@ -27,15 +27,8 @@ | ||
| 27 | 27 | * @since 3.15.0 |
| 28 | 28 | */ |
| 29 | 29 | class Nested_Accordion extends Widget_Nested_Base { |
| 30 | 30 | |
| 31 | - private $optimized_markup = null; | |
| 32 | - private $widget_container_selector = ''; | |
| 33 | - | |
| 34 | - protected function is_dynamic_content(): bool { | |
| 35 | - return true; | |
| 36 | - } | |
| 37 | - | |
| 38 | 31 | public function get_name() { |
| 39 | 32 | return 'nested-accordion'; |
| 40 | 33 | } |
| 41 | 34 | |
| @@ -55,24 +48,16 @@ | ||
| 55 | 48 | return [ 'widget-nested-accordion' ]; |
| 56 | 49 | } |
| 57 | 50 | |
| 58 | 51 | public function show_in_panel(): bool { |
| 59 | - return Plugin::$instance->experiments->is_feature_active( 'container' ); | |
| 52 | + return Plugin::$instance->experiments->is_feature_active( 'nested-elements' ); | |
| 60 | 53 | } |
| 61 | 54 | |
| 62 | - public function has_widget_inner_wrapper(): bool { | |
| 63 | - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); | |
| 64 | - } | |
| 65 | - | |
| 66 | 55 | protected function item_content_container( int $index ) { |
| 67 | 56 | return [ |
| 68 | 57 | 'elType' => 'container', |
| 69 | 58 | 'settings' => [ |
| 70 | - '_title' => sprintf( | |
| 71 | - /* translators: %d: Item index. */ | |
| 72 | - __( 'item #%d', 'elementor' ), | |
| 73 | - $index | |
| 74 | - ), | |
| 59 | + '_title' => sprintf( __( 'item #%s', 'elementor' ), $index ), | |
| 75 | 60 | 'content_width' => 'full', |
| 76 | 61 | ], |
| 77 | 62 | ]; |
| 78 | 63 | } |
| @@ -89,9 +74,8 @@ | ||
| 89 | 74 | return 'item_title'; |
| 90 | 75 | } |
| 91 | 76 | |
| 92 | 77 | protected function get_default_children_title() { |
| 93 | - /* translators: %d: Item index. */ | |
| 94 | 78 | return esc_html__( 'Item #%d', 'elementor' ); |
| 95 | 79 | } |
| 96 | 80 | |
| 97 | 81 | protected function get_default_children_placeholder_selector() { |
| @@ -106,13 +90,8 @@ | ||
| 106 | 90 | return 'elementor-widget-n-accordion'; |
| 107 | 91 | } |
| 108 | 92 | |
| 109 | 93 | protected function register_controls() { |
| 110 | - if ( null === $this->optimized_markup ) { | |
| 111 | - $this->optimized_markup = Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ) && ! $this->has_widget_inner_wrapper(); | |
| 112 | - $this->widget_container_selector = $this->optimized_markup ? '' : ' > .elementor-widget-container'; | |
| 113 | - } | |
| 114 | - | |
| 115 | 94 | $this->start_controls_section( 'section_items', [ |
| 116 | 95 | 'label' => esc_html__( 'Layout', 'elementor' ), |
| 117 | 96 | ] ); |
| 118 | 97 | |
| @@ -166,9 +145,9 @@ | ||
| 166 | 145 | 'item_title' => esc_html__( 'Item #3', 'elementor' ), |
| 167 | 146 | ], |
| 168 | 147 | ], |
| 169 | 148 | 'title_field' => '{{{ item_title }}}', |
| 170 | - 'button_text' => esc_html__( 'Add Item', 'elementor' ), | |
| 149 | + 'button_text' => 'Add Item', | |
| 171 | 150 | ] |
| 172 | 151 | ); |
| 173 | 152 | |
| 174 | 153 | $this->add_responsive_control( |
| @@ -325,9 +304,9 @@ | ||
| 325 | 304 | 'faq_schema_message', |
| 326 | 305 | [ |
| 327 | 306 | 'type' => Controls_Manager::ALERT, |
| 328 | 307 | 'alert_type' => 'info', |
| 329 | - 'content' => esc_html__( 'Google no longer supports the FAQ schema; however, it may still hold secondary value for AI and LLMs.', 'elementor' ), | |
| 308 | + 'content' => esc_html__( 'Let Google know that this section contains an FAQ. Make sure to only use it only once per page', 'elementor' ), | |
| 330 | 309 | 'condition' => [ |
| 331 | 310 | 'faq_schema[value]' => 'yes', |
| 332 | 311 | ], |
| 333 | 312 | ] |
| @@ -492,10 +471,11 @@ | ||
| 492 | 471 | $this->end_controls_section(); |
| 493 | 472 | } |
| 494 | 473 | |
| 495 | 474 | private function add_content_style_section() { |
| 496 | - $low_specificity_accordion_item_selector = ":where( {{WRAPPER}}{$this->widget_container_selector} > .e-n-accordion > .e-n-accordion-item ) > .e-con"; | |
| 497 | 475 | |
| 476 | + $low_specificity_accordion_item_selector = ':where( {{WRAPPER}} > .elementor-widget-container > .e-n-accordion > .e-n-accordion-item ) > .e-con'; | |
| 477 | + | |
| 498 | 478 | $this->start_controls_section( |
| 499 | 479 | 'section_content_style', |
| 500 | 480 | [ |
| 501 | 481 | 'label' => esc_html__( 'Content', 'elementor' ), |
| @@ -577,9 +557,9 @@ | ||
| 577 | 557 | $this->add_group_control( |
| 578 | 558 | Group_Control_Typography::get_type(), |
| 579 | 559 | [ |
| 580 | 560 | 'name' => 'title_typography', |
| 581 | - 'selector' => ":where( {{WRAPPER}}{$this->widget_container_selector} > .e-n-accordion > .e-n-accordion-item > .e-n-accordion-item-title > .e-n-accordion-item-title-header ) > .e-n-accordion-item-title-text", | |
| 561 | + 'selector' => ':where( {{WRAPPER}} > .elementor-widget-container > .e-n-accordion > .e-n-accordion-item > .e-n-accordion-item-title > .e-n-accordion-item-title-header ) > .e-n-accordion-item-title-text', | |
| 582 | 562 | 'fields_options' => [ |
| 583 | 563 | 'font_size' => [ |
| 584 | 564 | 'selectors' => [ |
| 585 | 565 | '{{WRAPPER}}' => '--n-accordion-title-font-size: {{SIZE}}{{UNIT}}', |
| @@ -669,17 +649,17 @@ | ||
| 669 | 649 | |
| 670 | 650 | switch ( $state ) { |
| 671 | 651 | case 'hover': |
| 672 | 652 | $translated_tab_text = esc_html__( 'Hover', 'elementor' ); |
| 673 | - $translated_tab_css_selector = ":where( {{WRAPPER}}{$this->widget_container_selector} > .e-n-accordion > .e-n-accordion-item:not([open]) > .e-n-accordion-item-title:hover > .e-n-accordion-item-title-header ) > .e-n-accordion-item-title-text"; | |
| 653 | + $translated_tab_css_selector = ':where( {{WRAPPER}} > .elementor-widget-container > .e-n-accordion > .e-n-accordion-item:not([open]) > .e-n-accordion-item-title:hover > .e-n-accordion-item-title-header ) > .e-n-accordion-item-title-text'; | |
| 674 | 654 | break; |
| 675 | 655 | case 'active': |
| 676 | 656 | $translated_tab_text = esc_html__( 'Active', 'elementor' ); |
| 677 | - $translated_tab_css_selector = ":where( {{WRAPPER}}{$this->widget_container_selector} > .e-n-accordion > .e-n-accordion-item[open] > .e-n-accordion-item-title > .e-n-accordion-item-title-header ) > .e-n-accordion-item-title-text"; | |
| 657 | + $translated_tab_css_selector = ':where( {{WRAPPER}} > .elementor-widget-container > .e-n-accordion > .e-n-accordion-item[open] > .e-n-accordion-item-title > .e-n-accordion-item-title-header ) > .e-n-accordion-item-title-text'; | |
| 678 | 658 | break; |
| 679 | 659 | default: |
| 680 | 660 | $translated_tab_text = esc_html__( 'Normal', 'elementor' ); |
| 681 | - $translated_tab_css_selector = ":where( {{WRAPPER}}{$this->widget_container_selector} > .e-n-accordion > .e-n-accordion-item:not([open]) > .e-n-accordion-item-title:not(hover) > .e-n-accordion-item-title-header ) > .e-n-accordion-item-title-text"; | |
| 661 | + $translated_tab_css_selector = ':where( {{WRAPPER}} > .elementor-widget-container > .e-n-accordion > .e-n-accordion-item:not([open]) > .e-n-accordion-item-title:not(hover) > .e-n-accordion-item-title-header ) > .e-n-accordion-item-title-text'; | |
| 682 | 662 | break; |
| 683 | 663 | } |
| 684 | 664 | |
| 685 | 665 | $this->start_controls_tab( |
| @@ -705,8 +685,13 @@ | ||
| 705 | 685 | Group_Control_Text_Shadow::get_type(), |
| 706 | 686 | [ |
| 707 | 687 | 'name' => $context . '_' . $state . '_text_shadow', |
| 708 | 688 | 'selector' => '{{WRAPPER}} ' . $translated_tab_css_selector, |
| 689 | + 'fields_options' => [ | |
| 690 | + 'text_shadow_type' => [ | |
| 691 | + 'label' => esc_html__( 'Shadow', 'elementor' ), | |
| 692 | + ], | |
| 693 | + ], | |
| 709 | 694 | ] |
| 710 | 695 | ); |
| 711 | 696 | |
| 712 | 697 | $this->add_group_control( |
| @@ -724,10 +709,9 @@ | ||
| 724 | 709 | /** |
| 725 | 710 | * @string $state |
| 726 | 711 | */ |
| 727 | 712 | private function add_border_and_radius_style( $state ) { |
| 728 | - $selector = "{{WRAPPER}}{$this->widget_container_selector} > .e-n-accordion > .e-n-accordion-item > .e-n-accordion-item-title"; | |
| 729 | - | |
| 713 | + $selector = '{{WRAPPER}} > .elementor-widget-container > .e-n-accordion > .e-n-accordion-item > .e-n-accordion-item-title'; | |
| 730 | 714 | $translated_tab_text = esc_html__( 'Normal', 'elementor' ); |
| 731 | 715 | |
| 732 | 716 | switch ( $state ) { |
| 733 | 717 | case 'hover': |
| @@ -734,9 +718,9 @@ | ||
| 734 | 718 | $selector .= ':hover'; |
| 735 | 719 | $translated_tab_text = esc_html__( 'Hover', 'elementor' ); |
| 736 | 720 | break; |
| 737 | 721 | case 'active': |
| 738 | - $selector = "{{WRAPPER}}{$this->widget_container_selector} > .e-n-accordion > .e-n-accordion-item[open] > .e-n-accordion-item-title"; | |
| 722 | + $selector = '{{WRAPPER}} > .elementor-widget-container > .e-n-accordion > .e-n-accordion-item[open] > .e-n-accordion-item-title'; | |
| 739 | 723 | $translated_tab_text = esc_html__( 'Active', 'elementor' ); |
| 740 | 724 | break; |
| 741 | 725 | } |
| 742 | 726 | |
| @@ -772,9 +756,9 @@ | ||
| 772 | 756 | |
| 773 | 757 | $this->end_controls_tab(); |
| 774 | 758 | } |
| 775 | 759 | |
| 776 | - private function is_active_icon_exist( $settings ): bool { | |
| 760 | + private function is_active_icon_exist( $settings ):bool { | |
| 777 | 761 | return array_key_exists( 'accordion_item_title_icon_active', $settings ) && ! empty( $settings['accordion_item_title_icon_active'] ) && ! empty( $settings['accordion_item_title_icon_active']['value'] ); |
| 778 | 762 | } |
| 779 | 763 | |
| 780 | 764 | private function render_accordion_icons( $settings ) { |
| @@ -909,14 +893,18 @@ | ||
| 909 | 893 | ] ); |
| 910 | 894 | } |
| 911 | 895 | |
| 912 | 896 | protected function get_initial_config(): array { |
| 913 | - return array_merge( parent::get_initial_config(), [ | |
| 914 | - 'support_improved_repeaters' => true, | |
| 915 | - 'target_container' => [ '.e-n-accordion' ], | |
| 916 | - 'node' => 'details', | |
| 917 | - 'is_interlaced' => true, | |
| 918 | - ] ); | |
| 897 | + if ( Plugin::$instance->experiments->is_feature_active( 'e_nested_atomic_repeaters' ) ) { | |
| 898 | + return array_merge( parent::get_initial_config(), [ | |
| 899 | + 'support_improved_repeaters' => true, | |
| 900 | + 'target_container' => [ '.e-n-accordion' ], | |
| 901 | + 'node' => 'details', | |
| 902 | + 'is_interlaced' => true, | |
| 903 | + ] ); | |
| 904 | + } | |
| 905 | + | |
| 906 | + return parent::get_initial_config(); | |
| 919 | 907 | } |
| 920 | 908 | |
| 921 | 909 | protected function content_template_single_repeater_item() { |
| 922 | 910 | ?> |
| @@ -937,22 +925,13 @@ | ||
| 937 | 925 | }; |
| 938 | 926 | |
| 939 | 927 | const itemTitleTextAttributes = { |
| 940 | 928 | 'class': [ 'e-n-accordion-item-title-text' ], |
| 941 | - 'data-binding-index': view.collection.length + 1, | |
| 942 | 929 | 'data-binding-type': 'repeater-item', |
| 943 | 930 | 'data-binding-repeater-name': 'items', |
| 944 | - 'data-binding-setting': ['item_title', 'element_css_id'], | |
| 945 | - 'data-binding-config': JSON.stringify({ | |
| 946 | - 'element_css_id': { | |
| 947 | - editType: 'attribute', | |
| 948 | - attr: 'id', | |
| 949 | - selector: 'details' | |
| 950 | - }, | |
| 951 | - 'item_title': { | |
| 952 | - editType: 'text' | |
| 953 | - } | |
| 954 | - }), | |
| 931 | + 'data-binding-setting': ['item_title'], | |
| 932 | + 'data-binding-index': view.collection.length + 1, | |
| 933 | + 'data-binding-dynamic': 'true', | |
| 955 | 934 | }; |
| 956 | 935 | |
| 957 | 936 | view.addRenderAttribute( 'details-container', itemWrapperAttributes, null, true ); |
| 958 | 937 | view.addRenderAttribute( 'summary-container', itemTitleAttributes, null, true ); |
| @@ -1020,22 +999,13 @@ | ||
| 1020 | 999 | }); |
| 1021 | 1000 | |
| 1022 | 1001 | view.addRenderAttribute( itemTitleTextKey, { |
| 1023 | 1002 | 'class': ['e-n-accordion-item-title-text'], |
| 1024 | - 'data-binding-index': itemCount, | |
| 1025 | 1003 | 'data-binding-type': 'repeater-item', |
| 1026 | 1004 | 'data-binding-repeater-name': 'items', |
| 1027 | - 'data-binding-setting': ['item_title', 'element_css_id'], | |
| 1028 | - 'data-binding-config': JSON.stringify({ | |
| 1029 | - 'element_css_id': { | |
| 1030 | - editType: 'attribute', | |
| 1031 | - attr: 'id', | |
| 1032 | - selector: 'details' | |
| 1033 | - }, | |
| 1034 | - 'item_title': { | |
| 1035 | - editType: 'text' | |
| 1036 | - } | |
| 1037 | - }), | |
| 1005 | + 'data-binding-setting': ['item_title'], | |
| 1006 | + 'data-binding-index': itemCount, | |
| 1007 | + 'data-binding-dynamic': 'true', | |
| 1038 | 1008 | }); |
| 1039 | 1009 | #> |
| 1040 | 1010 | |
| 1041 | 1011 | <details {{{ view.getRenderAttributeString( itemWrapperKey ) }}}> |