PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 1.6.3
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v1.6.3
3.1.4 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.0.7 3.0.5 3.0.4 3.0.3 3.0.2 trunk 1.5.0 1.5.1 1.5.2 1.6.1 1.6.2 1.6.3 1.6.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 All 93 releases
ultimate-store-kit / modules / glossy-carousel / widgets / glossy-carousel.php

glossy-carousel.php in Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder 1.6.3, at modules/glossy-carousel/widgets/glossy-carousel.php

400 lines 14.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UltimateStoreKit\Modules\GlossyCarousel\Widgets;
4
5 use Elementor\Controls_Manager;
6
7 use Elementor\Group_Control_Border;
8 use Elementor\Group_Control_Box_Shadow;
9 use UltimateStoreKit\Base\Module_Base;
10 use UltimateStoreKit\traits\Global_Widget_Controls;
11 use UltimateStoreKit\traits\Global_Widget_Template;
12 // use UltimateStoreKit\traits\Global_Swiper_Template;
13 use UltimateStoreKit\Includes\Controls\GroupQuery\Group_Control_Query;
14 use WP_Query;
15
16 if (!defined('ABSPATH')) {
17 exit;
18 }
19
20 // Exit if accessed directly
21
22 class Glossy_Carousel extends Module_Base {
23 use Global_Widget_Controls;
24 use Global_Widget_Template;
25 // use Global_Swiper_Template;
26 use Group_Control_Query;
27
28 /**
29 * @var \WP_Query
30 */
31 private $_query = null;
32 public function get_name() {
33 return 'usk-glossy-carousel';
34 }
35
36 public function get_title() {
37 return esc_html__('Glossy Carousel', 'ultimate-store-kit');
38 }
39
40 public function get_icon() {
41 return 'usk-widget-icon usk-icon-glossy-carousel';
42 }
43
44 public function get_categories() {
45 return ['ultimate-store-kit'];
46 }
47
48 public function get_keywords() {
49 return ['product', 'product-grid', 'table', 'wc'];
50 }
51
52 public function get_script_depends() {
53 return ['micromodal'];
54 }
55
56 public function get_style_depends() {
57 if ($this->usk_is_edit_mode()) {
58 return ['usk-all-styles'];
59 } else {
60 return ['ultimate-store-kit-font', 'usk-glossy-carousel'];
61 }
62 }
63
64 public function get_custom_help_url() {
65 return 'https://youtu.be/P9proLYapgQ';
66 }
67
68 public function get_query() {
69 return $this->_query;
70 }
71 protected function register_controls() {
72
73 $this->start_controls_section(
74 'section_woocommerce_layout',
75 [
76 'label' => esc_html__('Layout', 'ultimate-store-kit'),
77 ]
78 );
79
80 $this->add_responsive_control(
81 'columns',
82 [
83 'label' => esc_html__('Columns', 'ultimate-store-kit'),
84 'type' => Controls_Manager::SELECT,
85 'default' => 3,
86 'tablet_default' => 2,
87 'mobile_default' => 1,
88 'options' => [
89 1 => '1',
90 2 => '2',
91 3 => '3',
92 4 => '4',
93 5 => '5',
94 6 => '6',
95 ],
96 ]
97 );
98 $this->add_responsive_control(
99 'items_gap',
100 [
101 'label' => esc_html__('Item Gap', 'bdthemes-prime-slider'),
102 'type' => Controls_Manager::SLIDER,
103 'default' => [
104 'size' => 30,
105 ],
106 'range' => [
107 'px' => [
108 'min' => 0,
109 'max' => 100,
110 ],
111 ],
112 'tablet_default' => [
113 'size' => 20,
114 ],
115 'mobile_default' => [
116 'size' => 20,
117 ],
118 ]
119 );
120 $this->register_global_controls_grid_layout();
121
122 $this->end_controls_section();
123 $this->start_controls_section(
124 'section_post_query_builder',
125 [
126 'label' => __('Query', 'ultimate-store-kit'),
127 'tab' => Controls_Manager::TAB_CONTENT,
128 ]
129 );
130 $this->register_query_builder_controls();
131 $this->register_controls_wc_additional();
132 $this->end_controls_section();
133
134
135 $this->register_global_controls_additional();
136 $this->register_global_controls_carousel_navigation();
137 $this->register_global_controls_carousel_settings();
138 $this->start_controls_section(
139 'section_style_item',
140 [
141 'label' => esc_html__('Items', 'ultimate-store-kit'),
142 'tab' => Controls_Manager::TAB_STYLE,
143 ]
144 );
145
146 $this->start_controls_tabs('item_tabs');
147
148 $this->start_controls_tab(
149 'item_tab_normal',
150 [
151 'label' => esc_html__('Normal', 'ultimate-store-kit'),
152 ]
153 );
154
155 $this->add_group_control(
156 Group_Control_Border::get_type(),
157 [
158 'name' => 'item_border',
159 'selector' => '{{WRAPPER}} .usk-glossy-carousel .usk-item',
160 ]
161 );
162
163 $this->add_responsive_control(
164 'item_border_radius',
165 [
166 'label' => esc_html__('Border Radius', 'ultimate-store-kit'),
167 'type' => Controls_Manager::DIMENSIONS,
168 'size_units' => ['px', '%', 'em'],
169 'selectors' => [
170 '{{WRAPPER}} .usk-glossy-carousel .usk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
171 ],
172 ]
173 );
174
175 $this->add_responsive_control(
176 'item_padding',
177 [
178 'label' => esc_html__('Padding', 'ultimate-store-kit'),
179 'type' => Controls_Manager::DIMENSIONS,
180 'size_units' => ['px', '%', 'em'],
181 'selectors' => [
182 '{{WRAPPER}} .usk-glossy-carousel .usk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
183 ],
184 ]
185 );
186
187 $this->end_controls_tab();
188
189 $this->start_controls_tab(
190 'item_tab_hover',
191 [
192 'label' => esc_html__('Hover', 'ultimate-store-kit'),
193 ]
194 );
195
196 $this->add_control(
197 'item_hover_border_color',
198 [
199 'label' => esc_html__('Border Color', 'ultimate-store-kit'),
200 'type' => Controls_Manager::COLOR,
201 'selectors' => [
202 '{{WRAPPER}} .usk-glossy-carousel .usk-item:hover' => 'border-color: {{VALUE}}',
203 ],
204 ]
205 );
206
207 $this->end_controls_tab();
208
209 $this->end_controls_tabs();
210
211 $this->end_controls_section();
212 $this->register_global_controls_grid_image();
213 $this->register_global_controls_content();
214 $this->register_global_controls_title();
215 $this->register_global_controls_price();
216
217 $this->start_controls_section(
218 'section_style_rating',
219 [
220 'label' => esc_html__('Rating', 'ultimate-store-kit'),
221 'tab' => Controls_Manager::TAB_STYLE,
222 'condition' => [
223 'show_rating' => 'yes',
224 ],
225 ]
226 );
227 $this->start_controls_tabs(
228 'tab_rating_star'
229 );
230 $this->start_controls_tab(
231 'rating_star',
232 [
233 'label' => esc_html__('Star', 'ultimate-store-kit'),
234 ]
235 );
236 $this->add_control(
237 'rating_color',
238 [
239 'label' => esc_html__('Color', 'ultimate-store-kit'),
240 'type' => Controls_Manager::COLOR,
241 'default' => '#e7e7e7',
242 'selectors' => [
243 '{{WRAPPER}} .usk-glossy-carousel .usk-rating .star-rating::before' => 'color: {{VALUE}};',
244 ],
245 ]
246 );
247
248 $this->add_control(
249 'active_rating_color',
250 [
251 'label' => esc_html__('Active Color', 'ultimate-store-kit'),
252 'type' => Controls_Manager::COLOR,
253 'default' => '#FFCC00',
254 'selectors' => [
255 '{{WRAPPER}} .usk-glossy-carousel .usk-rating .star-rating span::before' => 'color: {{VALUE}};',
256 ],
257 ]
258 );
259 $this->end_controls_tab();
260 $this->start_controls_tab(
261 'tab_rating_review',
262 [
263 'label' => esc_html__('Review', 'ultimate-store-kit'),
264 'condition' => [
265 'hide_customer_review!' => 'yes',
266 ],
267 ]
268 );
269 $this->add_control(
270 'rating_review_color',
271 [
272 'label' => esc_html__('Color', 'ultimate-store-kit'),
273 'type' => Controls_Manager::COLOR,
274 'selectors' => [
275 '{{WRAPPER}} .usk-glossy-carousel .usk-rating .woocommerce-product-rating .woocommerce-review-link' => 'color: {{VALUE}}',
276 '{{WRAPPER}} .usk-glossy-carousel .usk-rating .woocommerce-product-rating .woocommerce-review-link span' => 'color: {{VALUE}}',
277 ],
278 ]
279 );
280 $this->add_control(
281 'rating_review_hover_color',
282 [
283 'label' => esc_html__('Hover color', 'ultimate-store-kit'),
284 'type' => Controls_Manager::COLOR,
285 'selectors' => [
286 '{{WRAPPER}} .usk-glossy-carousel .usk-rating .woocommerce-product-rating .woocommerce-review-link:hover' => 'color: {{VALUE}}',
287 '{{WRAPPER}} .usk-glossy-carousel .usk-rating .woocommerce-product-rating .woocommerce-review-link:hover span' => 'color: {{VALUE}}',
288 ],
289 ]
290 );
291 $this->end_controls_tab();
292 $this->end_controls_tabs();
293 $this->end_controls_section();
294 $this->register_global_controls_badge();
295 $this->register_global_controls_action_btn();
296
297 //Navigation Style Global Controls
298 $this->register_global_controls_navigation_style();
299 }
300
301 public function render_image() {
302 global $product;
303 $settings = $this->get_settings_for_display();
304 $gallery_thumbs = $product->get_gallery_image_ids();
305 $product_image = wp_get_attachment_image_url(get_post_thumbnail_id(), $settings['image_size']);
306 if ($gallery_thumbs) {
307 foreach ($gallery_thumbs as $key => $gallery_thumb) {
308 if ($key == 0) :
309 $gallery_image_link = wp_get_attachment_image_url($gallery_thumb, $settings['image_size']);
310 endif;
311 }
312 } else {
313 $gallery_image_link = wp_get_attachment_image_url(get_post_thumbnail_id(), $settings['image_size']);
314 }
315 ?>
316 <div class="usk-image">
317 <a href="<?php echo esc_url(get_permalink()); ?>">
318 <img class="img default-image" src="<?php echo esc_url($product_image); ?>" alt="<?php echo esc_html(get_the_title()); ?>">
319 <img class="img hover-image" src="<?php echo esc_url($gallery_image_link); ?>" alt="<?php echo esc_html(get_the_title()); ?>">
320 </a>
321 <div class="usk-badge-label-wrapper">
322 <div class="usk-badge-label-content">
323 <?php $this->register_global_template_badge_label(); ?>
324 </div>
325 </div>
326
327 </div>
328 <?php
329 }
330
331 public function print_price_output($output) {
332 $tags = [
333 'del' => ['aria-hidden' => []],
334 'span' => ['class' => []],
335 'bdi' => [],
336 'ins' => [],
337 ];
338
339 if (isset($output)) {
340 echo wp_kses($output, $tags);
341 }
342 }
343 public function render_loop_item() {
344 $settings = $this->get_settings_for_display();
345 $this->query_product();
346 $wp_query = $this->get_query();
347 if ($wp_query->have_posts()) { ?>
348 <?php while ($wp_query->have_posts()) : $wp_query->the_post();
349 global $product;
350 $tooltip_position = 'right';
351 $rating_count = $product->get_rating_count();
352 $average = $product->get_average_rating();
353 $have_rating = ('yes' == $settings['show_rating']) ? 'usk-have-rating' : ''; ?>
354
355 <div class="swiper-slide usk-item <?php esc_attr_e($have_rating, 'utlimate-woo-kit'); ?>">
356 <div class=" usk-item-box">
357 <?php $this->render_image(); ?>
358 <div class="usk-content">
359 <?php if ('yes' == $settings['show_title']) :
360 printf('<a href="%2$s" class="usk-title"><%1$s class="title">%3$s</%1$s></a>', esc_attr($settings['title_tags']), esc_url($product->get_permalink()), esc_html($product->get_title()));
361 endif; ?>
362 <?php if ('yes' == $settings['show_price']) : ?>
363 <div class="usk-price">
364 <?php $this->print_price_output($product->get_price_html()); ?>
365 </div>
366 <?php endif; ?>
367 <?php if ('yes' == $settings['show_rating']) : ?>
368 <div class="usk-rating">
369 <?php echo wp_kses_post($this->register_global_template_wc_rating($average, $rating_count)); ?></span>
370 </div>
371 <?php endif; ?>
372 </div>
373 <div class="usk-shoping">
374 <?php
375 $this->register_global_template_add_to_wishlist($tooltip_position);
376 $this->register_global_template_quick_view($product->get_id(), $tooltip_position);
377 $this->register_global_template_add_to_cart($tooltip_position);
378
379 ?>
380 </div>
381 </div>
382 </div>
383 <?php endwhile;
384 wp_reset_postdata();
385 } else {
386 echo '<div class="usk-alert-warning" usk-alert>' . esc_html__('Ops! There no product to display.', 'ultimate-store-kit') . '</div>';
387 }
388 }
389
390 public function render() {
391 $this->register_global_template_carousel_header();
392 $this->render_loop_item();
393 $this->usk_register_global_template_carousel_footer();
394 }
395 public function query_product() {
396 $default = $this->getGroupControlQueryArgs();
397 $this->_query = new WP_Query($default);
398 }
399 }
400