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

209 lines 6.6 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 public $is_slider;
23
24 use Carousel_Trait;
25 use Testimonial_Trait;
26 use Animation_Trait;
27 use Item_Style_Component;
28
29 public function get_name()
30 {
31 return 'uicore-testimonial-carousel';
32 }
33 public function get_title()
34 {
35 return esc_html__('Testimonial Carousel', 'uicore-elements');
36 }
37 public function get_icon()
38 {
39 return 'eicon-testimonial ui-e-widget';
40 }
41 public function get_categories()
42 {
43 return ['uicore'];
44 }
45 public function get_keywords()
46 {
47 return ['testimonial', 'review', 'services', 'cards', 'box', 'client', 'carousel'];
48 }
49 public function get_styles()
50 {
51 $styles = [
52 'testimonial-carousel',
53 'animation', // hover animations
54 'entrance', // entrance basic style
55 ];
56 if(!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')){
57 $styles['e-animations'] = [ // entrance animations
58 'external' => true,
59 ];
60 }
61 return $styles;
62 }
63 public function get_scripts()
64 {
65 return [
66 'carousel',
67 'testimonial' => [
68 'condition' => [
69 'layout' => 'layout_5'
70 ],
71 ],
72 'entrance' => [
73 'condition' => [
74 'animate_items' => 'ui-e-grid-animate'
75 ],
76 ]
77 ];
78 }
79 protected function register_controls()
80 {
81
82 $this->TRAIT_register_testimonial_repeater_controls('Testimonial Carousel Items'); // Repeater Controls
83
84 // Additional Carousel Controls
85 $this->start_controls_section(
86 'section_review_additional_settings',
87 [
88 'label' => __('Additional Settings', 'uicore-elements'),
89 'tab' => Controls_Manager::TAB_CONTENT,
90 ]
91 );
92
93 $this->TRAIT_register_specific_testimonial_controls('layout');
94 $this->TRAIT_register_carousel_additional_controls(); // Carousel Additionals
95 $this->TRAIT_register_testimonial_additional_controls(); // Testimonial Additionals
96
97 $this->end_controls_section();
98
99 $this->start_controls_section(
100 'section_carousel_settings',
101 [
102 'label' => __('Carousel Settings', 'uicore-elements'),
103 ]
104 );
105
106 $this->TRAIT_register_carousel_settings_controls(); // Carousel settings
107
108 $this->end_controls_section();
109
110 $this->TRAIT_register_navigation_controls(); // Navigation settings
111
112 $this->start_controls_section(
113 'section_style_review_items',
114 [
115 'label' => esc_html__( 'Items', 'uicore-elements' ),
116 'tab' => Controls_Manager::TAB_STYLE,
117 ]
118 );
119
120 // move it to specific controls
121 $this->add_control(
122 'item_gap',
123 [
124 'label' => esc_html__( 'Inner Content Spacing', 'uicore-elements' ),
125 'type' => Controls_Manager::SLIDER,
126 'size_units' => [ 'px', '%', 'em' ],
127 'range' => [
128 'px' => [
129 'min' => 0,
130 'max' => 50,
131 'step' => 1,
132 ],
133 '%' => [
134 'min' => 0,
135 'max' => 100,
136 ],
137 ],
138 'default' => [
139 'unit' => 'px',
140 'size' => 15,
141 ],
142 'selectors' => [
143 '{{WRAPPER}} .ui-e-testimonial-flex' => 'margin-bottom: {{SIZE}}{{UNIT}};',
144 ],
145 'conditions' => [
146 'relation' => 'and',
147 'terms' => [
148 [
149 'name' => 'image_inline',
150 'operator' => '===',
151 'value' => 'yes',
152 ],
153 [
154 'name' => 'layout',
155 'operator' => 'in',
156 'value' => ['layout_2'],
157 ],
158 ],
159 ],
160 ]
161 );
162 $this->TRAIT_register_all_item_style_controls();
163
164 $this->end_controls_section();
165
166 $this->TRAIT_register_style_controls(); // All Testimonial components styles
167 $this->TRAIT_register_navigation_style_controls(); // Carousel Navigation Styles
168
169 $this->start_controls_section(
170 'section_style_animations',
171 [
172 'label' => __('Animations', 'uicore-elements'),
173 'tab' => Controls_Manager::TAB_STYLE,
174 ]
175 );
176
177 $this->TRAIT_register_testimonial_animation_controls();
178
179 $this->end_controls_section();
180
181 // We need to set border radius as variable to use item radius on other components on swiper elements
182 $this->update_control('item_border_radius', [
183 'selectors' => [
184 '{{WRAPPER}} .ui-e-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
185 '{{WRAPPER}}' => '--ui-e-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
186 ],
187 ]);
188 }
189 public function render()
190 {
191 $ID = $this->get_ID();
192 $settings = $this->get_settings_for_display();
193
194 $this->add_render_attribute('review-carousel', 'class', ['swiper-wrapper', "carousel-$ID"]);
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 ?>
203 </div>
204 <?php $this->TRAIT_render_carousel_navigations(); ?>
205 </div>
206 <?php
207 }
208 }
209 \Elementor\Plugin::instance()->widgets_manager->register(new TestimonialCarousel());