PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 2.0.5
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v2.0.5
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 2.0.5, at modules/glossy-carousel/widgets/glossy-carousel.php

349 lines 12.4 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 ['usk-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', 'ultimate-store-kit'),
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 'condition' => [
205 'item_border_border!' => '',
206 ],
207 ]
208 );
209 $this->add_control(
210 'item_box_shadow_color',
211 [
212 'label' => esc_html__('Shadow Color', 'ultimate-store-kit'),
213 'type' => Controls_Manager::COLOR,
214 'selectors' => [
215 '{{WRAPPER}} .usk-glossy-carousel .usk-product-hover:before' => 'box-shadow: 0 8px 55px {{VALUE}}',
216 ],
217 ]
218 );
219
220 $this->add_control(
221 'item_shape_color',
222 [
223 'label' => esc_html__('Shape Color', 'ultimate-store-kit'),
224 'type' => Controls_Manager::COLOR,
225 'selectors' => [
226 '{{WRAPPER}} .usk-glossy-carousel .usk-product-hover:before' => 'background-color: {{VALUE}}',
227 ],
228 ]
229 );
230
231 $this->end_controls_tab();
232 $this->end_controls_tabs();
233 $this->end_controls_section();
234 $this->register_global_controls_grid_image();
235 $this->register_global_controls_content();
236 $this->register_global_controls_title();
237 $this->register_global_controls_price();
238 $this->register_global_controls_rating();
239 $this->register_global_controls_badge();
240 $this->register_global_controls_action_btn();
241
242 //Navigation Style Global Controls
243 $this->register_global_controls_navigation_style();
244 }
245
246 public function render_image() {
247 global $product;
248 $settings = $this->get_settings_for_display();
249 $gallery_thumbs = $product->get_gallery_image_ids();
250 $product_image = wp_get_attachment_image_url(get_post_thumbnail_id(), $settings['image_size']);
251 if ($gallery_thumbs) {
252 foreach ($gallery_thumbs as $key => $gallery_thumb) {
253 if ($key == 0) :
254 $gallery_image_link = wp_get_attachment_image_url($gallery_thumb, $settings['image_size']);
255 endif;
256 }
257 } else {
258 $gallery_image_link = wp_get_attachment_image_url(get_post_thumbnail_id(), $settings['image_size']);
259 }
260 ?>
261 <div class="usk-image">
262 <a href="<?php echo esc_url(get_permalink()); ?>">
263 <img class="img image-default" src="<?php echo esc_url($product_image); ?>" alt="<?php echo esc_html(get_the_title()); ?>">
264 <img class="img image-hover" src="<?php echo esc_url($gallery_image_link); ?>" alt="<?php echo esc_html(get_the_title()); ?>">
265 </a>
266 <div class="usk-badge-label-wrapper">
267 <div class="usk-badge-label-content usk-flex usk-flex-column usk-flex-bottom">
268 <?php $this->register_global_template_badge_label(); ?>
269 </div>
270 </div>
271
272 </div>
273 <?php
274 }
275
276 public function print_price_output($output) {
277 $tags = [
278 'del' => ['aria-hidden' => []],
279 'span' => ['class' => []],
280 'bdi' => [],
281 'ins' => [],
282 ];
283
284 if (isset($output)) {
285 echo wp_kses($output, $tags);
286 }
287 }
288 public function render_loop_item() {
289 $settings = $this->get_settings_for_display();
290 $this->query_product();
291 $wp_query = $this->get_query();
292 if ($wp_query->have_posts()) { ?>
293 <?php while ($wp_query->have_posts()) : $wp_query->the_post();
294 global $product;
295 $tooltip_position = 'right';
296 $rating_count = $product->get_rating_count();
297 $average = $product->get_average_rating();
298 $have_rating = ('yes' == $settings['show_rating']) ? 'usk-have-rating' : ''; ?>
299
300 <div class="swiper-slide usk-item <?php esc_attr_e($have_rating, 'utlimate-woo-kit'); ?>">
301 <div class="usk-item-box">
302 <?php $this->render_image(); ?>
303 <div class="usk-content">
304 <div class="usk-content-inner">
305 <?php if ('yes' == $settings['show_title']) :
306 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()));
307 endif; ?>
308 <?php if ('yes' == $settings['show_price']) : ?>
309 <div class="usk-price">
310 <?php $this->print_price_output($product->get_price_html()); ?>
311 </div>
312 <?php endif; ?>
313 <?php if ('yes' == $settings['show_rating']) : ?>
314 <div class="usk-rating">
315 <?php echo wp_kses_post($this->register_global_template_wc_rating($average, $rating_count)); ?></span>
316 </div>
317 <?php endif; ?>
318 </div>
319 </div>
320 <div class="usk-shoping">
321 <?php
322 $this->register_global_template_add_to_wishlist($tooltip_position);
323 $this->register_global_template_add_to_compare($tooltip_position);
324 $this->register_global_template_quick_view($product->get_id(), $tooltip_position);
325 $this->register_global_template_add_to_cart($tooltip_position);
326
327 ?>
328 </div>
329 </div>
330 <div class="usk-product-hover"></div>
331 </div>
332 <?php endwhile;
333 wp_reset_postdata();
334 } else {
335 echo '<div class="usk-alert-warning" usk-alert>' . esc_html__('Ops! There no product to display.', 'ultimate-store-kit') . '</div>';
336 }
337 }
338
339 public function render() {
340 $this->register_global_template_carousel_header();
341 $this->render_loop_item();
342 $this->usk_register_global_template_carousel_footer();
343 }
344 public function query_product() {
345 $default = $this->getGroupControlQueryArgs();
346 $this->_query = new WP_Query($default);
347 }
348 }
349