PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.18
UiCore Elements – Free widgets and templates for Elementor v1.3.18
1.3.18 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 All 42 releases
← All changes | includes/widgets/testimonial-carousel.php +209 -208 1.0.0 → 1.3.18 View file →
@@ -1,208 +1,209 @@
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 -
9 -defined('ABSPATH') || exit();
10 -
11 -/**
12 - * Testimonial Carousel
13 - *
14 - * @author Lucas Marini Falbo <[email protected]>
15 - * @since 1.0.1
16 - */
17 -
18 -class TestimonialCarousel extends UiCoreWidget
19 -{
20 -
21 - public $is_slider;
22 -
23 - use Carousel_Trait;
24 - use Testimonial_Trait;
25 - use Animation_Trait;
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', 'features', 'testimonial', 'client', 'carousel', 'slide'];
46 - }
47 - public function get_styles()
48 - {
49 - return [
50 - 'testimonial-carousel',
51 - 'animation', // hover animations
52 - 'entrance', // entrance basic style
53 - 'e-animations' => [ // entrance animations
54 - 'condition' => [
55 - 'animation_assets' => 'false'
56 - ],
57 - 'external' => true,
58 - ]
59 - ];
60 - }
61 - public function get_scripts()
62 - {
63 - return [
64 - 'carousel',
65 - 'testimonial' => [
66 - 'condition' => [
67 - 'layout' => 'layout_5'
68 - ],
69 - ],
70 - 'entrance' => [
71 - 'condition' => [
72 - 'animate_items' => 'ui-e-grid-animate'
73 - ],
74 - ]
75 - ];
76 - }
77 - protected function register_controls()
78 - {
79 -
80 - $this->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_entrace_asset_helper(); // Animation asset condition
92 - $this->register_specific_testimonial_controls('layout');
93 - if(!$this->is_slider){
94 - $this->register_carousel_additional_controls(); // Carousel Additionals
95 - }
96 - $this->register_testimonial_additional_controls(); // Testimonial Additionals
97 -
98 - $this->end_controls_section();
99 -
100 - $this->start_controls_section(
101 - 'section_carousel_settings',
102 - [
103 - 'label' => __('Carousel Settings', 'uicore-elements'),
104 - ]
105 - );
106 -
107 - $this->register_carousel_settings_controls($this->is_slider); // Carousel settings
108 -
109 - $this->end_controls_section();
110 -
111 - $this->register_navigation_controls(); // Navigation settings
112 -
113 - $this->start_controls_section(
114 - 'section_style_review_items',
115 - [
116 - 'label' => esc_html__( 'Items', 'uicore-elements' ),
117 - 'tab' => Controls_Manager::TAB_STYLE,
118 - ]
119 - );
120 -
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,
133 - ],
134 - '%' => [
135 - 'min' => 0,
136 - 'max' => 100,
137 - ],
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',
153 - ],
154 - [
155 - 'name' => 'layout',
156 - 'operator' => 'in',
157 - 'value' => ['layout_2'],
158 - ],
159 - ],
160 - ],
161 - ]
162 - );
163 - $this->register_all_carousel_item_style_controls();
164 -
165 - $this->end_controls_section();
166 -
167 - $this->register_style_controls(); // All Testimonial components styles
168 - $this->register_navigation_style_controls(); // Carousel Navigation Styles
169 -
170 - $this->start_controls_section(
171 - 'section_style_animations',
172 - [
173 - 'label' => __('Animations', 'uicore-elements'),
174 - 'tab' => Controls_Manager::TAB_STYLE,
175 - ]
176 - );
177 -
178 - $this->register_testimonial_animation_controls();
179 -
180 - $this->end_controls_section();
181 - }
182 - public function render()
183 - {
184 - $ID = $this->get_ID();
185 - $settings = $this->get_settings_for_display();
186 -
187 - $this->add_render_attribute('review-carousel', 'class', ['ui-e-carousel', "carousel-$ID"]);
188 - ?>
189 - <div <?php $this->print_render_attribute_string('review-carousel'); ?>>
190 - <?php
191 -
192 - foreach ( $settings['review_items'] as $index => $item ) :
193 - $this->render_review_item($item, $settings['layout'], false);
194 - endforeach;
195 -
196 - if(in_array('arrows', $settings['navigation'])) {
197 - $this->render_carousel_arrows();
198 - }
199 -
200 - if(in_array('fraction', $settings['navigation'])) {
201 - $this->render_carousel_fraction();
202 - }
203 - ?>
204 - </div>
205 - <?php
206 - }
207 -}
208 -\Elementor\Plugin::instance()->widgets_manager->register(new TestimonialCarousel());
1 +<?php
2 +
3 +namespace UiCoreElements;
4 +
5 +use Elementor\Controls_Manager;
6 +use UiCoreElements\UiCoreWidget;
7 +use UiCoreElements\Utils\Carousel_Trait;
8 +use UiCoreElements\Utils\Testimonial_Trait;
9 +use UiCoreElements\Utils\Animation_Trait;
10 +use UiCoreElements\Utils\Item_Style_Component;
11 +
12 +defined('ABSPATH') || exit();
13 +
14 +/**
15 + * Testimonial Carousel
16 + *
17 + * @author Lucas Marini Falbo <[email protected]>
18 + * @since 1.0.1
19 + */
20 +
21 +class TestimonialCarousel extends UiCoreWidget
22 +{
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 + 'carousel',
54 + 'animation', // hover animations
55 + 'entrance', // entrance basic style
56 + ];
57 + if (!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')) {
58 + $styles['e-animations'] = [ // entrance animations
59 + 'external' => true,
60 + ];
61 + }
62 + return $styles;
63 + }
64 + public function get_scripts()
65 + {
66 + $scripts = [
67 + 'testimonial' => [
68 + 'condition' => [
69 + 'layout' => 'layout_5'
70 + ]
71 + ]
72 + ];
73 + return array_merge($scripts, $this->TRAIT_get_carousel_scripts());
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 + }
80 + protected function register_controls()
81 + {
82 +
83 + $this->TRAIT_register_testimonial_repeater_controls('Testimonial Carousel Items'); // Repeater Controls
84 +
85 + // Additional Carousel Controls
86 + $this->start_controls_section(
87 + 'section_review_additional_settings',
88 + [
89 + 'label' => __('Additional Settings', 'uicore-elements'),
90 + 'tab' => Controls_Manager::TAB_CONTENT,
91 + ]
92 + );
93 +
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
97 +
98 + $this->end_controls_section();
99 +
100 + $this->start_controls_section(
101 + 'section_carousel_settings',
102 + [
103 + 'label' => __('Carousel Settings', 'uicore-elements'),
104 + ]
105 + );
106 +
107 + $this->TRAIT_register_carousel_settings_controls(); // Carousel settings
108 +
109 + $this->end_controls_section();
110 +
111 + $this->TRAIT_register_navigation_controls(); // Navigation settings
112 +
113 + $this->start_controls_section(
114 + 'section_style_review_items',
115 + [
116 + 'label' => esc_html__('Items', 'uicore-elements'),
117 + 'tab' => Controls_Manager::TAB_STYLE,
118 + ]
119 + );
120 +
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,
133 + ],
134 + '%' => [
135 + 'min' => 0,
136 + 'max' => 100,
137 + ],
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',
153 + ],
154 + [
155 + 'name' => 'layout',
156 + 'operator' => 'in',
157 + 'value' => ['layout_2'],
158 + ],
159 + ],
160 + ],
161 + ]
162 + );
163 + $this->TRAIT_register_all_item_style_controls();
164 +
165 + $this->end_controls_section();
166 +
167 + $this->TRAIT_register_style_controls(); // All Testimonial components styles
168 + $this->TRAIT_register_navigation_style_controls(); // Carousel Navigation Styles
169 +
170 + $this->start_controls_section(
171 + 'section_style_animations',
172 + [
173 + 'label' => __('Animations', 'uicore-elements'),
174 + 'tab' => Controls_Manager::TAB_STYLE,
175 + ]
176 + );
177 +
178 + $this->TRAIT_register_testimonial_animation_controls();
179 +
180 + $this->end_controls_section();
181 +
182 + // We need to set border radius as variable to use item radius on other components on swiper elements
183 + $this->update_control('item_border_radius', [
184 + 'selectors' => [
185 + '{{WRAPPER}} .ui-e-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
186 + '{{WRAPPER}}' => '--ui-e-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
187 + ],
188 + ]);
189 + }
190 + public function render()
191 + {
192 + $settings = $this->get_settings_for_display();
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 + ?>
203 + </div>
204 + </div>
205 + <?php $this->TRAIT_render_carousel_navigations($total_slides); ?>
206 +<?php
207 + }
208 +}
209 +\Elementor\Plugin::instance()->widgets_manager->register(new TestimonialCarousel());