| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace UiCoreElements; |
| 4 | + | |
| 3 | 5 | use Elementor\Controls_Manager; |
| 4 | 6 | use UiCoreElements\UiCoreWidget; |
| 5 | 7 | use UiCoreElements\Utils\Carousel_Trait; |
| 6 | 8 | use UiCoreElements\Utils\Testimonial_Trait; |
| @@ -51,9 +53,9 @@ | ||
| 51 | 53 | 'carousel', |
| 52 | 54 | 'animation', // hover animations |
| 53 | 55 | 'entrance', // entrance basic style |
| 54 | 56 | ]; |
| 55 | - if(!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')){ | |
| 57 | + if (!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')) { | |
| 56 | 58 | $styles['e-animations'] = [ // entrance animations |
| 57 | 59 | 'external' => true, |
| 58 | 60 | ]; |
| 59 | 61 | } |
| @@ -69,8 +71,13 @@ | ||
| 69 | 71 | ] |
| 70 | 72 | ]; |
| 71 | 73 | return array_merge($scripts, $this->TRAIT_get_carousel_scripts()); |
| 72 | 74 | } |
| 75 | + public function has_widget_inner_wrapper(): bool | |
| 76 | + { | |
| 77 | + // TODO: remove after Optmized Markup experiment is merged to the core | |
| 78 | + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup'); | |
| 79 | + } | |
| 73 | 80 | protected function register_controls() |
| 74 | 81 | { |
| 75 | 82 | |
| 76 | 83 | $this->TRAIT_register_testimonial_repeater_controls('Testimonial Carousel Items'); // Repeater Controls |
| @@ -83,22 +90,22 @@ | ||
| 83 | 90 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 84 | 91 | ] |
| 85 | 92 | ); |
| 86 | 93 | |
| 87 | - $this->TRAIT_register_specific_testimonial_controls('layout'); | |
| 88 | - $this->TRAIT_register_carousel_additional_controls(); // Carousel Additionals | |
| 89 | - $this->TRAIT_register_testimonial_additional_controls(); // Testimonial Additionals | |
| 94 | + $this->TRAIT_register_specific_testimonial_controls('layout'); | |
| 95 | + $this->TRAIT_register_carousel_additional_controls(); // Carousel Additionals | |
| 96 | + $this->TRAIT_register_testimonial_additional_controls(); // Testimonial Additionals | |
| 90 | 97 | |
| 91 | 98 | $this->end_controls_section(); |
| 92 | 99 | |
| 93 | 100 | $this->start_controls_section( |
| 94 | - 'section_carousel_settings', | |
| 95 | - [ | |
| 96 | - 'label' => __('Carousel Settings', 'uicore-elements'), | |
| 97 | - ] | |
| 98 | - ); | |
| 101 | + 'section_carousel_settings', | |
| 102 | + [ | |
| 103 | + 'label' => __('Carousel Settings', 'uicore-elements'), | |
| 104 | + ] | |
| 105 | + ); | |
| 99 | 106 | |
| 100 | - $this->TRAIT_register_carousel_settings_controls(); // Carousel settings | |
| 107 | + $this->TRAIT_register_carousel_settings_controls(); // Carousel settings | |
| 101 | 108 | |
| 102 | 109 | $this->end_controls_section(); |
| 103 | 110 | |
| 104 | 111 | $this->TRAIT_register_navigation_controls(); // Navigation settings |
| @@ -103,58 +110,58 @@ | ||
| 103 | 110 | |
| 104 | 111 | $this->TRAIT_register_navigation_controls(); // Navigation settings |
| 105 | 112 | |
| 106 | 113 | $this->start_controls_section( |
| 107 | - 'section_style_review_items', | |
| 108 | - [ | |
| 109 | - 'label' => esc_html__( 'Items', 'uicore-elements' ), | |
| 110 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 111 | - ] | |
| 112 | - ); | |
| 114 | + 'section_style_review_items', | |
| 115 | + [ | |
| 116 | + 'label' => esc_html__('Items', 'uicore-elements'), | |
| 117 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 118 | + ] | |
| 119 | + ); | |
| 113 | 120 | |
| 114 | - // move it to specific controls | |
| 115 | - $this->add_control( | |
| 116 | - 'item_gap', | |
| 117 | - [ | |
| 118 | - 'label' => esc_html__( 'Inner Content Spacing', 'uicore-elements' ), | |
| 119 | - 'type' => Controls_Manager::SLIDER, | |
| 120 | - 'size_units' => [ 'px', '%', 'em' ], | |
| 121 | - 'range' => [ | |
| 122 | - 'px' => [ | |
| 123 | - 'min' => 0, | |
| 124 | - 'max' => 50, | |
| 125 | - 'step' => 1, | |
| 126 | - ], | |
| 127 | - '%' => [ | |
| 128 | - 'min' => 0, | |
| 129 | - 'max' => 100, | |
| 130 | - ], | |
| 121 | + // move it to specific controls | |
| 122 | + $this->add_control( | |
| 123 | + 'item_gap', | |
| 124 | + [ | |
| 125 | + 'label' => esc_html__('Inner Content Spacing', 'uicore-elements'), | |
| 126 | + 'type' => Controls_Manager::SLIDER, | |
| 127 | + 'size_units' => ['px', '%', 'em'], | |
| 128 | + 'range' => [ | |
| 129 | + 'px' => [ | |
| 130 | + 'min' => 0, | |
| 131 | + 'max' => 50, | |
| 132 | + 'step' => 1, | |
| 131 | 133 | ], |
| 132 | - 'default' => [ | |
| 133 | - 'unit' => 'px', | |
| 134 | - 'size' => 15, | |
| 134 | + '%' => [ | |
| 135 | + 'min' => 0, | |
| 136 | + 'max' => 100, | |
| 135 | 137 | ], |
| 136 | - 'selectors' => [ | |
| 137 | - '{{WRAPPER}} .ui-e-testimonial-flex' => 'margin-bottom: {{SIZE}}{{UNIT}};', | |
| 138 | - ], | |
| 139 | - 'conditions' => [ | |
| 140 | - 'relation' => 'and', | |
| 141 | - 'terms' => [ | |
| 142 | - [ | |
| 143 | - 'name' => 'image_inline', | |
| 144 | - 'operator' => '===', | |
| 145 | - 'value' => 'yes', | |
| 146 | - ], | |
| 147 | - [ | |
| 148 | - 'name' => 'layout', | |
| 149 | - 'operator' => 'in', | |
| 150 | - 'value' => ['layout_2'], | |
| 151 | - ], | |
| 138 | + ], | |
| 139 | + 'default' => [ | |
| 140 | + 'unit' => 'px', | |
| 141 | + 'size' => 15, | |
| 142 | + ], | |
| 143 | + 'selectors' => [ | |
| 144 | + '{{WRAPPER}} .ui-e-testimonial-flex' => 'margin-bottom: {{SIZE}}{{UNIT}};', | |
| 145 | + ], | |
| 146 | + 'conditions' => [ | |
| 147 | + 'relation' => 'and', | |
| 148 | + 'terms' => [ | |
| 149 | + [ | |
| 150 | + 'name' => 'image_inline', | |
| 151 | + 'operator' => '===', | |
| 152 | + 'value' => 'yes', | |
| 152 | 153 | ], |
| 154 | + [ | |
| 155 | + 'name' => 'layout', | |
| 156 | + 'operator' => 'in', | |
| 157 | + 'value' => ['layout_2'], | |
| 158 | + ], | |
| 153 | 159 | ], |
| 154 | - ] | |
| 155 | - ); | |
| 156 | - $this->TRAIT_register_all_item_style_controls(); | |
| 160 | + ], | |
| 161 | + ] | |
| 162 | + ); | |
| 163 | + $this->TRAIT_register_all_item_style_controls(); | |
| 157 | 164 | |
| 158 | 165 | $this->end_controls_section(); |
| 159 | 166 | |
| 160 | 167 | $this->TRAIT_register_style_controls(); // All Testimonial components styles |
| @@ -167,9 +174,9 @@ | ||
| 167 | 174 | 'tab' => Controls_Manager::TAB_STYLE, |
| 168 | 175 | ] |
| 169 | 176 | ); |
| 170 | 177 | |
| 171 | - $this->TRAIT_register_testimonial_animation_controls(); | |
| 178 | + $this->TRAIT_register_testimonial_animation_controls(); | |
| 172 | 179 | |
| 173 | 180 | $this->end_controls_section(); |
| 174 | 181 | |
| 175 | 182 | // We need to set border radius as variable to use item radius on other components on swiper elements |
| @@ -182,19 +189,21 @@ | ||
| 182 | 189 | } |
| 183 | 190 | public function render() |
| 184 | 191 | { |
| 185 | 192 | $settings = $this->get_settings_for_display(); |
| 186 | - ?> | |
| 187 | - <div class="ui-e-carousel swiper"> | |
| 188 | - <div class='swiper-wrapper'> | |
| 189 | - <?php | |
| 190 | - foreach ( $settings['review_items'] as $index => $item ) : | |
| 191 | - $this->TRAIT_render_review_item($item, $settings['layout']); | |
| 192 | - endforeach; | |
| 193 | - ?> | |
| 194 | - </div> | |
| 195 | - <?php $this->TRAIT_render_carousel_navigations(); ?> | |
| 193 | + $total_slides = count($settings['review_items']); | |
| 194 | + $this->TRAIT_render_center_loop_warning($total_slides); | |
| 195 | +?> | |
| 196 | + <div class="ui-e-carousel swiper"> | |
| 197 | + <div class='swiper-wrapper'> | |
| 198 | + <?php | |
| 199 | + foreach ($settings['review_items'] as $index => $item) : | |
| 200 | + $this->TRAIT_render_review_item($item, $settings['layout']); | |
| 201 | + endforeach; | |
| 202 | + ?> | |
| 196 | 203 | </div> |
| 197 | - <?php | |
| 204 | + </div> | |
| 205 | + <?php $this->TRAIT_render_carousel_navigations($total_slides); ?> | |
| 206 | +<?php | |
| 198 | 207 | } |
| 199 | 208 | } |
| 200 | -\Elementor\Plugin::instance()->widgets_manager->register(new TestimonialCarousel()); | |
| 209 | +\Elementor\Plugin::instance()->widgets_manager->register(new TestimonialCarousel()); | |