| @@ -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; |
| @@ -18,10 +20,8 @@ | ||
| 18 | 20 | |
| 19 | 21 | class TestimonialCarousel extends UiCoreWidget |
| 20 | 22 | { |
| 21 | 23 | |
| 22 | - public $is_slider; | |
| 23 | - | |
| 24 | 24 | use Carousel_Trait; |
| 25 | 25 | use Testimonial_Trait; |
| 26 | 26 | use Animation_Trait; |
| 27 | 27 | use Item_Style_Component; |
| @@ -49,12 +49,13 @@ | ||
| 49 | 49 | public function get_styles() |
| 50 | 50 | { |
| 51 | 51 | $styles = [ |
| 52 | 52 | 'testimonial-carousel', |
| 53 | + 'carousel', | |
| 53 | 54 | 'animation', // hover animations |
| 54 | 55 | 'entrance', // entrance basic style |
| 55 | 56 | ]; |
| 56 | - if(!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')){ | |
| 57 | + if (!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')) { | |
| 57 | 58 | $styles['e-animations'] = [ // entrance animations |
| 58 | 59 | 'external' => true, |
| 59 | 60 | ]; |
| 60 | 61 | } |
| @@ -61,40 +62,22 @@ | ||
| 61 | 62 | return $styles; |
| 62 | 63 | } |
| 63 | 64 | public function get_scripts() |
| 64 | 65 | { |
| 65 | - $scripts = [ | |
| 66 | - 'carousel', | |
| 67 | - 'utils/global-testimonial' => [ | |
| 66 | + $scripts = [ | |
| 67 | + 'testimonial' => [ | |
| 68 | 68 | 'condition' => [ |
| 69 | 69 | 'layout' => 'layout_5' |
| 70 | - ], | |
| 71 | - ], | |
| 72 | - 'utils/carousel-effects/circular' => [ | |
| 73 | - 'condition' => [ | |
| 74 | - 'animation_style' => 'circular', | |
| 75 | - ] | |
| 76 | - ], | |
| 77 | - 'utils/carousel-effects/fade-and-blur' => [ | |
| 78 | - 'condition' => [ | |
| 79 | - 'animation_style' => 'fade_blur', | |
| 80 | - ] | |
| 81 | - ], | |
| 82 | - 'entrance' => [ | |
| 83 | - 'condition' => [ | |
| 84 | - 'animate_items' => 'ui-e-grid-animate' | |
| 85 | - ], | |
| 70 | + ] | |
| 86 | 71 | ] |
| 87 | - ]; | |
| 88 | - if($this->get_name() === 'uicore-testimonial-slider'){ | |
| 89 | - $scripts['utils/carousel-effects/stacked'] = [ | |
| 90 | - 'condition' => [ | |
| 91 | - 'animation_style' => 'stacked', | |
| 92 | - ] | |
| 93 | - ]; | |
| 94 | - } | |
| 95 | - return $scripts; | |
| 72 | + ]; | |
| 73 | + return array_merge($scripts, $this->TRAIT_get_carousel_scripts()); | |
| 96 | 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 | + } | |
| 97 | 80 | protected function register_controls() |
| 98 | 81 | { |
| 99 | 82 | |
| 100 | 83 | $this->TRAIT_register_testimonial_repeater_controls('Testimonial Carousel Items'); // Repeater Controls |
| @@ -107,22 +90,22 @@ | ||
| 107 | 90 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 108 | 91 | ] |
| 109 | 92 | ); |
| 110 | 93 | |
| 111 | - $this->TRAIT_register_specific_testimonial_controls('layout'); | |
| 112 | - $this->TRAIT_register_carousel_additional_controls(); // Carousel Additionals | |
| 113 | - $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 | |
| 114 | 97 | |
| 115 | 98 | $this->end_controls_section(); |
| 116 | 99 | |
| 117 | 100 | $this->start_controls_section( |
| 118 | - 'section_carousel_settings', | |
| 119 | - [ | |
| 120 | - 'label' => __('Carousel Settings', 'uicore-elements'), | |
| 121 | - ] | |
| 122 | - ); | |
| 101 | + 'section_carousel_settings', | |
| 102 | + [ | |
| 103 | + 'label' => __('Carousel Settings', 'uicore-elements'), | |
| 104 | + ] | |
| 105 | + ); | |
| 123 | 106 | |
| 124 | - $this->TRAIT_register_carousel_settings_controls(); // Carousel settings | |
| 107 | + $this->TRAIT_register_carousel_settings_controls(); // Carousel settings | |
| 125 | 108 | |
| 126 | 109 | $this->end_controls_section(); |
| 127 | 110 | |
| 128 | 111 | $this->TRAIT_register_navigation_controls(); // Navigation settings |
| @@ -127,58 +110,58 @@ | ||
| 127 | 110 | |
| 128 | 111 | $this->TRAIT_register_navigation_controls(); // Navigation settings |
| 129 | 112 | |
| 130 | 113 | $this->start_controls_section( |
| 131 | - 'section_style_review_items', | |
| 132 | - [ | |
| 133 | - 'label' => esc_html__( 'Items', 'uicore-elements' ), | |
| 134 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 135 | - ] | |
| 136 | - ); | |
| 114 | + 'section_style_review_items', | |
| 115 | + [ | |
| 116 | + 'label' => esc_html__('Items', 'uicore-elements'), | |
| 117 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 118 | + ] | |
| 119 | + ); | |
| 137 | 120 | |
| 138 | - // move it to specific controls | |
| 139 | - $this->add_control( | |
| 140 | - 'item_gap', | |
| 141 | - [ | |
| 142 | - 'label' => esc_html__( 'Inner Content Spacing', 'uicore-elements' ), | |
| 143 | - 'type' => Controls_Manager::SLIDER, | |
| 144 | - 'size_units' => [ 'px', '%', 'em' ], | |
| 145 | - 'range' => [ | |
| 146 | - 'px' => [ | |
| 147 | - 'min' => 0, | |
| 148 | - 'max' => 50, | |
| 149 | - 'step' => 1, | |
| 150 | - ], | |
| 151 | - '%' => [ | |
| 152 | - 'min' => 0, | |
| 153 | - 'max' => 100, | |
| 154 | - ], | |
| 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, | |
| 155 | 133 | ], |
| 156 | - 'default' => [ | |
| 157 | - 'unit' => 'px', | |
| 158 | - 'size' => 15, | |
| 134 | + '%' => [ | |
| 135 | + 'min' => 0, | |
| 136 | + 'max' => 100, | |
| 159 | 137 | ], |
| 160 | - 'selectors' => [ | |
| 161 | - '{{WRAPPER}} .ui-e-testimonial-flex' => 'margin-bottom: {{SIZE}}{{UNIT}};', | |
| 162 | - ], | |
| 163 | - 'conditions' => [ | |
| 164 | - 'relation' => 'and', | |
| 165 | - 'terms' => [ | |
| 166 | - [ | |
| 167 | - 'name' => 'image_inline', | |
| 168 | - 'operator' => '===', | |
| 169 | - 'value' => 'yes', | |
| 170 | - ], | |
| 171 | - [ | |
| 172 | - 'name' => 'layout', | |
| 173 | - 'operator' => 'in', | |
| 174 | - 'value' => ['layout_2'], | |
| 175 | - ], | |
| 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', | |
| 176 | 153 | ], |
| 154 | + [ | |
| 155 | + 'name' => 'layout', | |
| 156 | + 'operator' => 'in', | |
| 157 | + 'value' => ['layout_2'], | |
| 158 | + ], | |
| 177 | 159 | ], |
| 178 | - ] | |
| 179 | - ); | |
| 180 | - $this->TRAIT_register_all_item_style_controls(); | |
| 160 | + ], | |
| 161 | + ] | |
| 162 | + ); | |
| 163 | + $this->TRAIT_register_all_item_style_controls(); | |
| 181 | 164 | |
| 182 | 165 | $this->end_controls_section(); |
| 183 | 166 | |
| 184 | 167 | $this->TRAIT_register_style_controls(); // All Testimonial components styles |
| @@ -191,9 +174,9 @@ | ||
| 191 | 174 | 'tab' => Controls_Manager::TAB_STYLE, |
| 192 | 175 | ] |
| 193 | 176 | ); |
| 194 | 177 | |
| 195 | - $this->TRAIT_register_testimonial_animation_controls(); | |
| 178 | + $this->TRAIT_register_testimonial_animation_controls(); | |
| 196 | 179 | |
| 197 | 180 | $this->end_controls_section(); |
| 198 | 181 | |
| 199 | 182 | // We need to set border radius as variable to use item radius on other components on swiper elements |
| @@ -205,23 +188,22 @@ | ||
| 205 | 188 | ]); |
| 206 | 189 | } |
| 207 | 190 | public function render() |
| 208 | 191 | { |
| 209 | - $ID = $this->get_ID(); | |
| 210 | 192 | $settings = $this->get_settings_for_display(); |
| 211 | - | |
| 212 | - $this->add_render_attribute('review-carousel', 'class', ['swiper-wrapper', "carousel-$ID"]); | |
| 213 | - ?> | |
| 214 | - <div class="ui-e-carousel swiper"> | |
| 215 | - <div class='swiper-wrapper'> | |
| 216 | - <?php | |
| 217 | - foreach ( $settings['review_items'] as $index => $item ) : | |
| 218 | - $this->TRAIT_render_review_item($item, $settings['layout']); | |
| 219 | - endforeach; | |
| 220 | - ?> | |
| 221 | - </div> | |
| 222 | - <?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 | + ?> | |
| 223 | 203 | </div> |
| 224 | - <?php | |
| 204 | + </div> | |
| 205 | + <?php $this->TRAIT_render_carousel_navigations($total_slides); ?> | |
| 206 | +<?php | |
| 225 | 207 | } |
| 226 | 208 | } |
| 227 | -\Elementor\Plugin::instance()->widgets_manager->register(new TestimonialCarousel()); | |
| 209 | +\Elementor\Plugin::instance()->widgets_manager->register(new TestimonialCarousel()); | |