PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
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 / gallery-carousel.php

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

327 lines 9.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UiCoreElements;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Background;
7
8 use UiCoreElements\UiCoreWidget;
9 use UiCoreElements\Utils\Animation_Trait;
10 use UiCoreElements\Utils\Gallery_Trait;
11 use UiCoreElements\Utils\Carousel_Trait;
12 use UicoreElements\Utils\Item_Style_Component;
13
14 defined('ABSPATH') || exit();
15
16 /**
17 * Gallery Carousel
18 *
19 * @author Lucas Marini Falbo <lucas95@uicore.co>
20 * @since 1.0.14
21 */
22
23 class GalleryCarousel extends UiCoreWidget
24 {
25 use Animation_Trait;
26 use Gallery_Trait;
27 use Carousel_Trait;
28 use Item_Style_Component;
29
30 public function get_name()
31 {
32 return 'uicore-gallery-carousel';
33 }
34 public function get_title()
35 {
36 return esc_html__('Gallery Carousel', 'uicore-elements');
37 }
38 public function get_icon()
39 {
40 return 'eicon-carousel-loop ui-e-widget';
41 }
42 public function get_categories()
43 {
44 return ['uicore'];
45 }
46 public function get_keywords()
47 {
48 return ['gallery', 'carousel', 'slides', 'content', 'box'];
49 }
50 public function get_styles()
51 {
52 $styles = [
53 'gallery-carousel',
54 'carousel',
55 'animation', // hover animations
56 'entrance', // entrance basic style
57 ];
58 if (!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')) {
59 $styles['e-animations'] = [ // entrance animations
60 'external' => true,
61 ];
62 }
63 return $styles;
64 }
65 public function get_scripts()
66 {
67 return $this->TRAIT_get_carousel_scripts();
68 }
69 public function has_widget_inner_wrapper(): bool
70 {
71 // TODO: remove after Optmized Markup experiment is merged to the core
72 return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');
73 }
74 protected function register_controls()
75 {
76 $this->TRAIT_register_gallery_repeater_controls('Content');
77 $this->TRAIT_register_additional_controls(true);
78
79 $this->start_controls_section(
80 'carousel_section',
81 [
82 'label' => esc_html__('Carousel Settings', 'uicore-elements'),
83 'tab' => Controls_Manager::TAB_CONTENT,
84 ]
85 );
86 $this->TRAIT_register_carousel_additional_controls();
87 $this->add_control(
88 'divider',
89 [
90 'type' => Controls_Manager::DIVIDER,
91 ]
92 );
93 $this->TRAIT_register_carousel_settings_controls();
94
95 $this->end_controls_section();
96
97 $this->TRAIT_register_navigation_controls();
98
99 $this->start_controls_section(
100 'items_style_section',
101 [
102 'label' => esc_html__('Item', 'uicore-elements'),
103 'tab' => Controls_Manager::TAB_STYLE,
104 ]
105 );
106
107 $this->TRAIT_register_all_item_style_controls();
108
109 $this->end_controls_section();
110
111 $this->TRAIT_register_filters_style_controls();
112 $this->TRAIT_register_image_style_controls(true);
113 $this->TRAIT_register_title_style_controls();
114 $this->TRAIT_register_description_style_controls();
115 $this->TRAIT_register_tags_style_controls();
116 $this->TRAIT_register_badge_style_controls();
117 $this->TRAIT_register_navigation_style_controls();
118 $this->TRAIT_register_gallery_animations();
119
120 // Update some component controls
121 $this->update_control(
122 'item_border_border',
123 [
124 'default' => 'none'
125 ]
126 );
127 $this->update_responsive_control(
128 'item_padding',
129 [
130 'default' => [
131 'top' => 10,
132 'right' => 10,
133 'bottom' => 10,
134 'left' => 10,
135 ],
136 'selectors' => [
137 '{{WRAPPER}} .ui-e-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
138 ],
139 ]
140 );
141 $this->update_control(
142 'item_border_radius',
143 [
144 'default' => [
145 'top' => 0,
146 'right' => 0,
147 'bottom' => 0,
148 'left' => 0,
149 'unit' => 'px',
150 ]
151 ]
152 );
153 $this->update_control(
154 'match_height',
155 [
156 'render_type' => 'template',
157 ]
158 );
159
160 $image_conditions = [
161 'relation' => 'or',
162 'terms' => [
163 [
164 'relation' => 'and',
165 'terms' => [
166 [
167 'name' => 'layout',
168 'operator' => '==',
169 'value' => '',
170 ],
171 [
172 'name' => 'vertical',
173 'operator' => '!=',
174 'value' => 'true',
175 ],
176 ]
177 ],
178 [
179 'relation' => 'and',
180 'terms' => [
181 [
182 'name' => 'layout',
183 'operator' => '==',
184 'value' => 'ui-e-overlay',
185 ],
186 [
187 'name' => 'match_height',
188 'operator' => '==',
189 'value' => 'yes',
190 ],
191 [
192 'name' => 'vertical',
193 'operator' => '!=',
194 'value' => 'true',
195 ],
196 ],
197 ]
198 ],
199 ];
200
201 $this->update_control(
202 'style_image_section',
203 [
204 'conditions' => $image_conditions
205 ]
206 );
207 $this->update_responsive_control(
208 'image_height',
209 [
210 'conditions' => $image_conditions
211 ]
212 );
213
214
215 // Remove some useless component controls or group controls that can't be properly updated
216 $this->remove_control('item_background_background');
217 $this->remove_control('item_hover_background_background');
218 $this->remove_control('item_background_color');
219 $this->remove_control('item_background_image');
220 $this->remove_control('item_background_gradient');
221
222 // Inject new controls
223 $this->start_injection([
224 'of' => 'animation_style',
225 'at' => 'after',
226 ]);
227
228 $this->add_control(
229 'main_image',
230 [
231 'label' => __('Main image', 'uicore-elements'),
232 'type' => Controls_Manager::SELECT,
233 'default' => '',
234 'options' => [
235 '' => esc_html__('Default', 'uicore-elements'),
236 'ui-e-main-image-scale' => esc_html__('Scale', 'uicore-elements'),
237 'ui-e-main-image-show' => esc_html__('Show Info', 'uicore-elements'),
238 'ui-e-main-image-show_scale' => esc_html__('Show Info & Scale', 'uicore-elements'),
239 ],
240 'description' => __('Works best with centered slides.', 'uicore-elements'),
241 'prefix_class' => '',
242 'render_type' => 'template',
243 'frontend_available' => true,
244 'condition' => [
245 'animation_style!' => 'marquee',
246 ]
247 ]
248 );
249
250 $this->end_injection();
251
252 $this->start_injection([
253 'of' => 'item_border_border',
254 'at' => 'before',
255 ]);
256
257 // normal background controls
258 $this->add_group_control(
259 Group_Control_Background::get_type(),
260 [
261 'name' => 'item_gallery_background',
262 'selector' => '{{WRAPPER}} .ui-e-item',
263 'condition' => [
264 'layout' => '',
265 ]
266 ]
267 );
268 $this->add_group_control(
269 Group_Control_Background::get_type(),
270 [
271 'name' => 'item_content_background',
272 'selector' => '{{WRAPPER}} .ui-e-content',
273 'condition' => [
274 'layout' => 'ui-e-overlay',
275 ]
276 ]
277 );
278
279 $this->end_injection();
280
281 $this->start_injection([
282 'of' => 'item_hover_border_color',
283 'at' => 'before',
284 ]);
285
286 // hover background controls
287 $this->add_group_control(
288 Group_Control_Background::get_type(),
289 [
290 'name' => 'item_gallery_hover_background',
291 'selector' => '{{WRAPPER}} .ui-e-item:hover',
292 'condition' => [
293 'layout' => '',
294 ]
295 ]
296 );
297 $this->add_group_control(
298 Group_Control_Background::get_type(),
299 [
300 'name' => 'item_content_hover_background',
301 'selector' => '{{WRAPPER}} .ui-e-item:hover .ui-e-content',
302 'condition' => [
303 'layout' => 'ui-e-overlay',
304 ]
305 ]
306 );
307
308 $this->end_injection();
309 }
310
311 public function render()
312 {
313 $settings = $this->get_settings_for_display();
314 $total_slides = count($settings['gallery_items']);
315 $this->TRAIT_render_center_loop_warning($total_slides);
316 ?>
317 <div class="ui-e-carousel swiper">
318 <div class='swiper-wrapper'>
319 <?php $this->TRAIT_render_gallery($settings, true); ?>
320 </div>
321 </div>
322 <?php $this->TRAIT_render_carousel_navigations($total_slides); ?>
323 <?php
324 }
325 }
326 \Elementor\Plugin::instance()->widgets_manager->register(new GalleryCarousel());
327