PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.2.4
UiCore Elements – Free widgets and templates for Elementor v1.2.4
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
uicore-elements / includes / widgets / testimonial-carousel.php

testimonial-carousel.php in UiCore Elements – Free widgets and templates for Elementor 1.2.4, at includes/widgets/testimonial-carousel.php

215 lines 7.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace UiCoreElements;
3 use Elementor\Controls_Manager;
4 use UiCoreElements\UiCoreWidget;
5 use UiCoreElements\Utils\Carousel_Trait;
6 use UiCoreElements\Utils\Testimonial_Trait;
7 use UiCoreElements\Utils\Animation_Trait;
8 use UiCoreElements\Utils\Item_Style_Component;
9
10 defined('ABSPATH') || exit();
11
12 /**
13 * Testimonial Carousel
14 *
15 * @author Lucas Marini Falbo <lucas@uicore.co>
16 * @since 1.0.1
17 */
18
19 class TestimonialCarousel extends UiCoreWidget
20 {
21
22 use Carousel_Trait;
23 use Testimonial_Trait;
24 use Animation_Trait;
25 use Item_Style_Component;
26
27 public function get_name()
28 {
29 return 'uicore-testimonial-carousel';
30 }
31 public function get_title()
32 {
33 return esc_html__('Testimonial Carousel', 'uicore-elements');
34 }
35 public function get_icon()
36 {
37 return 'eicon-testimonial ui-e-widget';
38 }
39 public function get_categories()
40 {
41 return ['uicore'];
42 }
43 public function get_keywords()
44 {
45 return ['testimonial', 'review', 'services', 'cards', 'box', 'client', 'carousel'];
46 }
47 public function get_styles()
48 {
49 $styles = [
50 'testimonial-carousel',
51 'carousel',
52 'animation', // hover animations
53 'entrance', // entrance basic style
54 ];
55 if(!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')){
56 $styles['e-animations'] = [ // entrance animations
57 'external' => true,
58 ];
59 }
60 return $styles;
61 }
62 public function get_scripts()
63 {
64 $scripts = [
65 'testimonial' => [
66 'condition' => [
67 'layout' => 'layout_5'
68 ]
69 ]
70 ];
71 return array_merge($scripts, $this->TRAIT_get_carousel_scripts());
72 }
73 public function has_widget_inner_wrapper(): bool {
74 // TODO: remove after 3.30, when the full deprecation of widget innet wrapper is ready
75 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
76 }
77 protected function register_controls()
78 {
79
80 $this->TRAIT_register_testimonial_repeater_controls('Testimonial Carousel Items'); // Repeater Controls
81
82 // Additional Carousel Controls
83 $this->start_controls_section(
84 'section_review_additional_settings',
85 [
86 'label' => __('Additional Settings', 'uicore-elements'),
87 'tab' => Controls_Manager::TAB_CONTENT,
88 ]
89 );
90
91 $this->TRAIT_register_specific_testimonial_controls('layout');
92 $this->TRAIT_register_carousel_additional_controls(); // Carousel Additionals
93 $this->TRAIT_register_testimonial_additional_controls(); // Testimonial Additionals
94
95 $this->end_controls_section();
96
97 $this->start_controls_section(
98 'section_carousel_settings',
99 [
100 'label' => __('Carousel Settings', 'uicore-elements'),
101 ]
102 );
103
104 $this->TRAIT_register_carousel_settings_controls(); // Carousel settings
105
106 $this->end_controls_section();
107
108 $this->TRAIT_register_navigation_controls(); // Navigation settings
109
110 $this->start_controls_section(
111 'section_style_review_items',
112 [
113 'label' => esc_html__( 'Items', 'uicore-elements' ),
114 'tab' => Controls_Manager::TAB_STYLE,
115 ]
116 );
117
118 // move it to specific controls
119 $this->add_control(
120 'item_gap',
121 [
122 'label' => esc_html__( 'Inner Content Spacing', 'uicore-elements' ),
123 'type' => Controls_Manager::SLIDER,
124 'size_units' => [ 'px', '%', 'em' ],
125 'range' => [
126 'px' => [
127 'min' => 0,
128 'max' => 50,
129 'step' => 1,
130 ],
131 '%' => [
132 'min' => 0,
133 'max' => 100,
134 ],
135 ],
136 'default' => [
137 'unit' => 'px',
138 'size' => 15,
139 ],
140 'selectors' => [
141 '{{WRAPPER}} .ui-e-testimonial-flex' => 'margin-bottom: {{SIZE}}{{UNIT}};',
142 ],
143 'conditions' => [
144 'relation' => 'and',
145 'terms' => [
146 [
147 'name' => 'image_inline',
148 'operator' => '===',
149 'value' => 'yes',
150 ],
151 [
152 'name' => 'layout',
153 'operator' => 'in',
154 'value' => ['layout_2'],
155 ],
156 ],
157 ],
158 ]
159 );
160 $this->TRAIT_register_all_item_style_controls();
161
162 $this->end_controls_section();
163
164 $this->TRAIT_register_style_controls(); // All Testimonial components styles
165 $this->TRAIT_register_navigation_style_controls(); // Carousel Navigation Styles
166
167 $this->start_controls_section(
168 'section_style_animations',
169 [
170 'label' => __('Animations', 'uicore-elements'),
171 'tab' => Controls_Manager::TAB_STYLE,
172 ]
173 );
174
175 $this->TRAIT_register_testimonial_animation_controls();
176
177 $this->end_controls_section();
178
179 // We need to set border radius as variable to use item radius on other components on swiper elements
180 $this->update_control('item_border_radius', [
181 'selectors' => [
182 '{{WRAPPER}} .ui-e-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
183 '{{WRAPPER}}' => '--ui-e-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
184 ],
185 ]);
186 }
187 public function render()
188 {
189 $settings = $this->get_settings_for_display();
190 $total_slides = count($settings['review_items']);
191
192 ?>
193 <div class="ui-e-carousel swiper">
194 <div class='swiper-wrapper'>
195 <?php
196 foreach ( $settings['review_items'] as $index => $item ) :
197 $this->TRAIT_render_review_item($item, $settings['layout']);
198 endforeach;
199
200 // Most recent swiper versions requires, if loop, at least one extra slide compared to visible slides
201 if( $this->TRAIT_should_duplicate_slides($total_slides)) {
202 $diff = $this->TRAIT_get_duplication_diff($total_slides);
203 for($i = 0; $i <= $diff; $i++){
204 $index = $i % $total_slides; // Ensure the index does not surpass the maximum index
205 $this->TRAIT_render_review_item($settings['review_items'][$index], $settings['layout']);
206 }
207 }
208 ?>
209 </div>
210 </div>
211 <?php $this->TRAIT_render_carousel_navigations(); ?>
212 <?php
213 }
214 }
215 \Elementor\Plugin::instance()->widgets_manager->register(new TestimonialCarousel());