PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.2.0
UiCore Elements – Free widgets and templates for Elementor v1.2.0
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.0, at includes/widgets/testimonial-carousel.php

210 lines 7.0 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 protected function register_controls()
74 {
75
76 $this->TRAIT_register_testimonial_repeater_controls('Testimonial Carousel Items'); // Repeater Controls
77
78 // Additional Carousel Controls
79 $this->start_controls_section(
80 'section_review_additional_settings',
81 [
82 'label' => __('Additional Settings', 'uicore-elements'),
83 'tab' => Controls_Manager::TAB_CONTENT,
84 ]
85 );
86
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
90
91 $this->end_controls_section();
92
93 $this->start_controls_section(
94 'section_carousel_settings',
95 [
96 'label' => __('Carousel Settings', 'uicore-elements'),
97 ]
98 );
99
100 $this->TRAIT_register_carousel_settings_controls(); // Carousel settings
101
102 $this->end_controls_section();
103
104 $this->TRAIT_register_navigation_controls(); // Navigation settings
105
106 $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 );
113
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 ],
131 ],
132 'default' => [
133 'unit' => 'px',
134 'size' => 15,
135 ],
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 ],
152 ],
153 ],
154 ]
155 );
156 $this->TRAIT_register_all_item_style_controls();
157
158 $this->end_controls_section();
159
160 $this->TRAIT_register_style_controls(); // All Testimonial components styles
161 $this->TRAIT_register_navigation_style_controls(); // Carousel Navigation Styles
162
163 $this->start_controls_section(
164 'section_style_animations',
165 [
166 'label' => __('Animations', 'uicore-elements'),
167 'tab' => Controls_Manager::TAB_STYLE,
168 ]
169 );
170
171 $this->TRAIT_register_testimonial_animation_controls();
172
173 $this->end_controls_section();
174
175 // We need to set border radius as variable to use item radius on other components on swiper elements
176 $this->update_control('item_border_radius', [
177 'selectors' => [
178 '{{WRAPPER}} .ui-e-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
179 '{{WRAPPER}}' => '--ui-e-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
180 ],
181 ]);
182 }
183 public function render()
184 {
185 $settings = $this->get_settings_for_display();
186 $total_slides = count($settings['review_items']);
187
188 ?>
189 <div class="ui-e-carousel swiper">
190 <div class='swiper-wrapper'>
191 <?php
192 foreach ( $settings['review_items'] as $index => $item ) :
193 $this->TRAIT_render_review_item($item, $settings['layout']);
194 endforeach;
195
196 // Most recent swiper versions requires, if loop, at least one extra slide compared to visible slides
197 if( $this->TRAIT_should_duplicate_slides($total_slides)) {
198 $diff = $this->TRAIT_get_duplication_diff($total_slides);
199 for($i = 0; $i <= $diff; $i++){
200 $this->TRAIT_render_review_item($settings['review_items'][$i], $settings['layout']);
201 }
202 }
203 ?>
204 </div>
205 </div>
206 <?php $this->TRAIT_render_carousel_navigations(); ?>
207 <?php
208 }
209 }
210 \Elementor\Plugin::instance()->widgets_manager->register(new TestimonialCarousel());