PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 3.1.4
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v3.1.4
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 / edd-category-carousel / widgets / edd-category-carousel.php

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

856 lines 25.7 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\EddCategoryCarousel\Widgets;
4
5 use UltimateStoreKit\Base\Module_Base;
6 use Elementor\Controls_Manager;
7 use Elementor\Utils;
8 use Elementor\Group_Control_Border;
9 use Elementor\Group_Control_Box_Shadow;
10 use Elementor\Group_Control_Image_Size;
11 use Elementor\Group_Control_Background;
12 use Elementor\Group_Control_Typography;
13
14 use UltimateStoreKit\Traits\Global_Terms_Query_Controls;
15 use UltimateStoreKit\traits\Global_Widget_Controls;
16 use UltimateStoreKit\traits\Global_Widget_Template;
17
18 if (!defined('ABSPATH')) {
19 exit; // Exit if accessed directly.
20 }
21
22 // phpcs:disable WordPressVIPMinimum.Performance.WPQueryParams -- WordPressVIPMinimum targets the VIP platform, not the plugin directory. These exclusionary parameters come from a widget's own "exclude" control: the list is whatever the site owner picked in Elementor, applied to a bounded result set, not an unbounded catalogue scan.
23
24 class EDD_Category_Carousel extends Module_Base {
25 use Global_Widget_Controls;
26 use Global_Terms_Query_Controls;
27 use Global_Widget_Template;
28 public function get_name() {
29 return 'usk-edd-category-carousel';
30 }
31
32 public function get_title() {
33 return esc_html__('EDD Category Carousel', 'ultimate-store-kit');
34 }
35
36 public function get_icon() {
37 return 'usk-widget-icon usk-icon-edd-category-carousel';
38 }
39
40 public function get_categories() {
41 return ['ultimate-store-kit'];
42 }
43
44 public function get_keywords() {
45 return ['easy', 'digital', 'category', 'downloads', 'eshop', 'estore', 'profile', 'editor'];
46 }
47
48 public function get_style_depends() {
49 if ($this->usk_is_edit_mode()) {
50 return ['swiper', 'usk-all-styles'];
51 } else {
52 return ['swiper', 'usk-font', 'usk-edd-category-carousel'];
53 }
54 }
55
56 public function get_script_depends() {
57 if ($this->usk_is_edit_mode()) {
58 return ['swiper', 'usk-site'];
59 } else {
60 return ['swiper', 'usk-edd-category-carousel'];
61 }
62 }
63
64 public function get_custom_help_url() {
65 return 'https://youtu.be/z6MSJtvbxPQ';
66 }
67
68 public function has_widget_inner_wrapper(): bool {
69 return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');
70 }
71 protected function register_controls() {
72
73 $this->start_controls_section(
74 'section_content_layout',
75 [
76 'label' => esc_html__('Layout', 'ultimate-store-kit'),
77 ]
78 );
79
80 $this->add_control(
81 'skin_layout',
82 [
83 'label' => __('Skin', 'ultimate-store-kit'),
84 'type' => Controls_Manager::SELECT,
85 'default' => 'style-1',
86 'options' => [
87 'style-1' => __('Style 1', 'ultimate-store-kit'),
88 'style-2' => __('Style 2', 'ultimate-store-kit'),
89 'style-3' => __('Style 3', 'ultimate-store-kit'),
90 'style-4' => __('Style 4', 'ultimate-store-kit'),
91 'style-5' => __('Style 5', 'ultimate-store-kit'),
92
93 // 'style-6' => __('Style 6', 'ultimate-store-kit'),
94 ],
95 ]
96 );
97 $this->add_responsive_control(
98 'columns',
99 [
100 'label' => __('Columns', 'ultimate-store-kit'),
101 'type' => Controls_Manager::SELECT,
102 'default' => 3,
103 'tablet_default' => 2,
104 'mobile_default' => 1,
105 'options' => [
106 1 => esc_html__('1', 'ultimate-store-kit'),
107 2 => esc_html__('2', 'ultimate-store-kit'),
108 3 => esc_html__('3', 'ultimate-store-kit'),
109 4 => esc_html__('4', 'ultimate-store-kit'),
110 5 => esc_html__('5', 'ultimate-store-kit'),
111 6 => esc_html__('6', 'ultimate-store-kit'),
112 ],
113 ]
114 );
115 $this->add_control(
116 'alignment',
117 [
118 'label' => __('Title', 'ultimate-store-kit'),
119 'type' => Controls_Manager::HIDDEN,
120 'default' => 'traditional',
121 ]
122 );
123
124 $this->add_responsive_control(
125 'items_gap',
126 [
127 'label' => __('Item Gap', 'ultimate-store-kit'),
128 'type' => Controls_Manager::SLIDER,
129 'default' => [
130 'size' => 20,
131 ],
132 ]
133 );
134
135 $this->add_responsive_control(
136 'item_height',
137 [
138 'label' => esc_html__('Item Height(px)', 'ultimate-store-kit'),
139 'type' => Controls_Manager::SLIDER,
140 'range' => [
141 'px' => [
142 'min' => 0,
143 'max' => 1000,
144 ],
145 ],
146 'selectors' => [
147 '{{WRAPPER}} .usk-edd-category-carousel .edd-item' => 'height: {{SIZE}}{{UNIT}};',
148 '{{WRAPPER}} .usk-edd-category-carousel .usk-edd-category-carousel-image' => 'height: {{SIZE}}{{UNIT}};'
149 ],
150 'condition' => [
151 'skin_layout!' => 'style-3'
152 ]
153 ]
154 );
155 $this->add_responsive_control(
156 'item_height_skin_3',
157 [
158 'label' => esc_html__('Item Height(px)', 'ultimate-store-kit'),
159 'type' => Controls_Manager::SLIDER,
160 'range' => [
161 'px' => [
162 'min' => 0,
163 'max' => 1000,
164 ],
165 ],
166 'selectors' => [
167 '{{WRAPPER}} .usk-edd-category-carousel .usk-edd-category-carousel-image' => 'height: {{SIZE}}{{UNIT}};'
168 ],
169 'condition' => [
170 'skin_layout' => 'style-3'
171 ]
172 ]
173 );
174 $this->add_control(
175 'is_use_image',
176 [
177 'label' => esc_html__('Use Static Image', 'ultimate-store-kit'),
178 'type' => Controls_Manager::SWITCHER,
179 'default' => 'yes',
180 'suskarator' => 'before'
181 ]
182 );
183 $this->add_control(
184 'category_image',
185 [
186 'label' => __('Select Image', 'ultimate-store-kit'),
187 'type' => Controls_Manager::MEDIA,
188 'dynamic' => [ 'active' => true ],
189 'default' => [
190 'url' => Utils::get_placeholder_image_src(),
191 ],
192 'condition' => [
193 'is_use_image' => 'yes'
194 ]
195 ]
196 );
197
198 $this->add_group_control(
199 Group_Control_Image_Size::get_type(),
200 [
201 'name' => 'category_thumbnail',
202 'exclude' => ['custom'],
203 'default' => 'medium',
204 'condition' => [
205 'is_use_image' => 'yes'
206 ]
207 ]
208 );
209 $this->add_control(
210 'show_count',
211 [
212 'label' => esc_html__('Show Count', 'ultimate-store-kit'),
213 'type' => Controls_Manager::SWITCHER,
214 'default' => 'yes',
215 // 'suskarator' => 'before'
216 ]
217 );
218 $this->end_controls_section();
219 $this->render_terms_query_controls('download_category');
220 // $this->register_global_controls_additional();
221 $this->register_global_controls_carousel_navigation();
222 $this->register_global_controls_carousel_settings();
223
224 $this->start_controls_section(
225 'section_style_item',
226 [
227 'label' => esc_html__('Item', 'ultimate-store-kit'),
228 'tab' => Controls_Manager::TAB_STYLE,
229 ]
230 );
231 $this->start_controls_tabs(
232 'item_tabs'
233 );
234 $this->start_controls_tab(
235 'item_tab_normal',
236 [
237 'label' => esc_html__('Normal', 'ultimate-store-kit'),
238 ]
239 );
240 $this->add_group_control(
241 Group_Control_Background::get_type(),
242 [
243 'name' => 'items_background',
244 'label' => esc_html__('Backgrund', 'ultimate-store-kit'),
245 'types' => ['classic', 'gradient'],
246 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item',
247 ]
248 );
249 $this->add_control(
250 'item_overlay',
251 [
252 'label' => esc_html__('Overlay Color', 'ultimate-store-kit'),
253 'type' => Controls_Manager::COLOR,
254 'selectors' => [
255 '{{WRAPPER}} .usk-edd-category-carousel .edd-item-overlay' => 'background: {{VALUE}}',
256 ],
257 'condition' => [
258 'skin_layout!' => ['style-3']
259 ]
260 ]
261 );
262 $this->add_control(
263 'item_overlay_blur_effect',
264 [
265 'label' => esc_html__('Glassmorphism', 'ultimate-store-kit'),
266 'type' => Controls_Manager::SWITCHER,
267 // 'description' => sprintf(__('This feature will not work in the Firefox browser untill you enable browser compatibility so please %1s look here %2s', 'ultimate-store-kit'), '<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility" target="_blank">', '</a>'),
268 'description' => sprintf(
269 /* translators: 1: opening anchor tag, 2: closing anchor tag */
270 __('This feature will not work in the Firefox browser until you enable browser compatibility, so please %1$s look here %2$s.', 'ultimate-store-kit'),
271 '<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility" target="_blank">',
272 '</a>'
273 ),
274 'default' => 'yes',
275 'condition' => [
276 'skin_layout' => [
277 'style-5',
278 ]
279 ]
280 ]
281 );
282
283 $this->add_control(
284 'item_overlay_blur_level',
285 [
286 'label' => __('Blur Level', 'ultimate-store-kit'),
287 'type' => Controls_Manager::SLIDER,
288 'range' => [
289 'px' => [
290 'min' => 0,
291 'step' => 1,
292 'max' => 50,
293 ]
294 ],
295 'default' => [
296 'size' => 10
297 ],
298 'selectors' => [
299 '{{WRAPPER}} .usk-edd-category-grid.style-5 .usk-edd-category-grid-image:before' => 'backdrop-filter: blur({{SIZE}}px); -webkit-backdrop-filter: blur({{SIZE}}px);'
300 ],
301 'condition' => [
302 'item_overlay_blur_effect' => 'yes',
303 'skin_layout' => [
304 'style-5'
305 ]
306 ]
307 ]
308 );
309
310 $this->add_group_control(
311 Group_Control_Background::get_type(),
312 [
313 'name' => 'item_background',
314 'selector' => '{{WRAPPER}} .usk-edd-category-grid.style-5 .usk-edd-category-grid-image:before',
315 'condition' => [
316 'skin_layout' => [
317 'style-5'
318 ]
319 ]
320 ]
321 );
322 $this->add_responsive_control(
323 'item_padding',
324 [
325 'label' => esc_html__('Padding', 'ultimate-store-kit'),
326 'type' => Controls_Manager::DIMENSIONS,
327 'size_units' => ['px', '%', 'em'],
328 'selectors' => [
329 '{{WRAPPER}} .usk-edd-category-carousel .edd-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
330 ],
331 ]
332 );
333 $this->add_responsive_control(
334 'item_margin',
335 [
336 'label' => esc_html__('Margin', 'ultimate-store-kit'),
337 'type' => Controls_Manager::DIMENSIONS,
338 'size_units' => ['px', '%', 'em'],
339 'selectors' => [
340 '{{WRAPPER}} .usk-edd-category-carousel .edd-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
341 ],
342 ]
343 );
344 $this->add_group_control(
345 Group_Control_Border::get_type(),
346 [
347 'name' => 'item_border',
348 'label' => esc_html__('Border', 'ultimate-store-kit'),
349 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item',
350 ]
351 );
352 $this->add_responsive_control(
353 'item_radius',
354 [
355 'label' => esc_html__('Radius', 'ultimate-store-kit'),
356 'type' => Controls_Manager::DIMENSIONS,
357 'size_units' => ['px', '%', 'em'],
358 'selectors' => [
359 '{{WRAPPER}} .usk-edd-category-carousel .edd-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
360 ],
361 ]
362 );
363
364 // $this->add_group_control(
365 // Group_Control_Box_Shadow::get_type(),
366 // [
367 // 'name' => 'item_shadow',
368 // 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item',
369 // ]
370 // );
371 $this->end_controls_tab();
372 $this->start_controls_tab(
373 'item_tab_hover',
374 [
375 'label' => esc_html__('Hover', 'ultimate-store-kit'),
376 ]
377 );
378 $this->add_group_control(
379 Group_Control_Background::get_type(),
380 [
381 'name' => 'items_hover_background',
382 'label' => esc_html__('Backgrund', 'ultimate-store-kit'),
383 'types' => ['classic', 'gradient'],
384 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item:hover',
385 'condition' => [
386 'skin_layout!' => 'style-5'
387 ]
388 ]
389 );
390 $this->add_control(
391 'item_overlay_hover',
392 [
393 'label' => esc_html__('Overlay Color', 'ultimate-store-kit'),
394 'type' => Controls_Manager::COLOR,
395 'selectors' => [
396 '{{WRAPPER}} .usk-edd-category-carousel .edd-item:hover .edd-item-overlay' => 'background: {{VALUE}}',
397 ],
398 'condition' => [
399 'skin_layout!' => ['style-3']
400 ]
401 ]
402 );
403 $this->add_control(
404 'item_hover_border_color',
405 [
406 'label' => esc_html__('Border Color', 'ultimate-store-kit'),
407 'type' => Controls_Manager::COLOR,
408 'selectors' => [
409 '{{WRAPPER}} .usk-edd-category-carousel .edd-item:hover' => 'border-color: {{VALUE}}',
410 ],
411 ]
412 );
413 $this->end_controls_tab();
414 $this->end_controls_tabs();
415 $this->end_controls_section();
416 $this->start_controls_section(
417 'section_style_content',
418 [
419 'label' => esc_html__('Content', 'ultimate-store-kit'),
420 'tab' => Controls_Manager::TAB_STYLE,
421 'condition' => [
422 'skin_layout' => [
423 'style-1'
424 ]
425 ]
426 ]
427 );
428 $this->start_controls_tabs(
429 'content_tabs'
430 );
431 $this->start_controls_tab(
432 'content_tab_normal',
433 [
434 'label' => esc_html__('Normal', 'ultimate-store-kit'),
435 ]
436 );
437
438 $this->add_group_control(
439 Group_Control_Background::get_type(),
440 [
441 'name' => 'content_background',
442 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content',
443 'condition' => [
444 'skin_layout' => 'style-1'
445 ]
446 ]
447 );
448
449 $this->add_responsive_control(
450 'content_padding',
451 [
452 'label' => esc_html__('Padding', 'ultimate-store-kit'),
453 'type' => Controls_Manager::DIMENSIONS,
454 'size_units' => ['px', '%', 'em'],
455 'selectors' => [
456 '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
457 ],
458 ]
459 );
460 $this->add_responsive_control(
461 'content_margin',
462 [
463 'label' => esc_html__('Margin', 'ultimate-store-kit'),
464 'type' => Controls_Manager::DIMENSIONS,
465 'size_units' => ['px', '%', 'em'],
466 'selectors' => [
467 '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
468 ],
469 ]
470 );
471 $this->add_group_control(
472 Group_Control_Border::get_type(),
473 [
474 'name' => 'content_border',
475 'label' => esc_html__('Border', 'ultimate-store-kit'),
476 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content',
477 ]
478 );
479 $this->add_responsive_control(
480 'content_radius',
481 [
482 'label' => esc_html__('Radius', 'ultimate-store-kit'),
483 'type' => Controls_Manager::DIMENSIONS,
484 'size_units' => ['px', '%', 'em'],
485 'selectors' => [
486 '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
487 ],
488 ]
489 );
490
491 $this->add_group_control(
492 Group_Control_Box_Shadow::get_type(),
493 [
494 'name' => 'content_shadow',
495 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content',
496 ]
497 );
498 $this->end_controls_tab();
499 $this->start_controls_tab(
500 'content_tab_hover',
501 [
502 'label' => esc_html__('Hover', 'ultimate-store-kit'),
503 ]
504 );
505 $this->add_control(
506 'content_hover_border_color',
507 [
508 'label' => esc_html__('Border Color', 'ultimate-store-kit'),
509 'type' => Controls_Manager::COLOR,
510 'selectors' => [
511 '{{WRAPPER}} .usk-edd-category-carousel .edd-item:hover .edd-content' => 'border-color: {{VALUE}}',
512 ],
513 ]
514 );
515 $this->add_group_control(
516 Group_Control_Box_Shadow::get_type(),
517 [
518 'name' => 'content_hover_shadow',
519 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item:hover .edd-content',
520 ]
521 );
522 $this->end_controls_tab();
523 $this->end_controls_tabs();
524 $this->end_controls_section();
525 $this->start_controls_section(
526 'section_style_category',
527 [
528 'label' => esc_html__('Category', 'ultimate-store-kit'),
529 'tab' => Controls_Manager::TAB_STYLE,
530 ]
531 );
532 $this->start_controls_tabs(
533 'category_tabs'
534 );
535 $this->start_controls_tab(
536 'category_tab_normal',
537 [
538 'label' => esc_html__('Normal', 'ultimate-store-kit'),
539 ]
540 );
541 $this->add_control(
542 'category_color',
543 [
544 'label' => esc_html__('Color', 'ultimate-store-kit'),
545 'type' => Controls_Manager::COLOR,
546 'selectors' => [
547 '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content .title' => 'color: {{VALUE}}',
548 ],
549 ]
550 );
551 $this->add_group_control(
552 Group_Control_Background::get_type(),
553 [
554 'name' => 'style_5_category_bg',
555 'label' => esc_html__('Backgorund', 'ultimate-store-kit'),
556 'types' => ['classic', 'gradient'],
557 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content .title',
558 'condition' => [
559 'skin_layout' => [
560 'style-5'
561 ]
562 ]
563 ]
564 );
565 $this->add_group_control(
566 Group_Control_Background::get_type(),
567 [
568 'name' => 'style_6_category_bg',
569 'label' => esc_html__('Background', 'ultimate-store-kit'),
570 'types' => ['classic', 'gradient'],
571 'selector' => '{{WRAPPER}} .usk-edd-category-carousel.style-5 .usk-edd-category-carousel-image:before',
572 'condition' => [
573 'skin_layout' => [
574 'style-6'
575 ]
576 ]
577 ]
578 );
579 $this->add_responsive_control(
580 'category_margin',
581 [
582 'label' => esc_html__('Margin', 'ultimate-store-kit'),
583 'type' => Controls_Manager::DIMENSIONS,
584 'size_units' => ['px', '%'],
585 'selectors' => [
586 '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content .title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
587 ],
588 ]
589 );
590 $this->add_responsive_control(
591 'category_padding',
592 [
593 'label' => esc_html__('Padding', 'ultimate-store-kit'),
594 'type' => Controls_Manager::DIMENSIONS,
595 'size_units' => ['px', '%'],
596 'selectors' => [
597 '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content .title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
598 ],
599 'condition' => [
600 'skin_layout' => [
601 'style-4'
602 ]
603 ]
604 ]
605 );
606
607 $this->add_group_control(
608 Group_Control_Typography::get_type(),
609 [
610 'name' => 'category_typography',
611 'label' => esc_html__('Typography', 'ultimate-store-kit'),
612 'exclude' => ['line_height'],
613 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content .title',
614 ]
615 );
616 $this->end_controls_tab();
617 $this->start_controls_tab(
618 'category_tab_hover',
619 [
620 'label' => esc_html__('Hover', 'ultimate-store-kit'),
621 'condition' => [
622 'skin_layout!' => 'style-5'
623 ]
624 ]
625 );
626 $this->add_control(
627 'hover_category_color',
628 [
629 'label' => esc_html__('Hover Color', 'ultimate-store-kit'),
630 'type' => Controls_Manager::COLOR,
631 'selectors' => [
632 '{{WRAPPER}} .usk-edd-category-carousel .edd-item:hover .edd-content .title' => 'color: {{VALUE}};',
633 ],
634 ]
635 );
636 $this->end_controls_tab();
637 $this->end_controls_tabs();
638 $this->end_controls_section();
639 $this->start_controls_section(
640 'section_style_count',
641 [
642 'label' => esc_html__('Count', 'ultimate-store-kit'),
643 'tab' => Controls_Manager::TAB_STYLE,
644 ]
645 );
646 $this->start_controls_tabs(
647 'count_tabs'
648 );
649 $this->start_controls_tab(
650 'count_tab_normal',
651 [
652 'label' => esc_html__('Normal', 'ultimate-store-kit'),
653 'condition' => [
654 'skin_layout!' => [
655 'style-5'
656 ]
657 ]
658 ]
659 );
660 $this->add_control(
661 'count_color',
662 [
663 'label' => esc_html__('Color', 'ultimate-store-kit'),
664 'type' => Controls_Manager::COLOR,
665 'selectors' => [
666 '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content .edd-category-count > *' => 'color: {{VALUE}};',
667 ],
668 ]
669 );
670 $this->add_group_control(
671 Group_Control_Background::get_type(),
672 [
673 'name' => 'count_background',
674 'label' => esc_html__('Background', 'ultimate-store-kit'),
675 'types' => ['classic', 'gradient'],
676 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content .edd-category-count > *',
677 'condition' => [
678 'skin_layout' => [
679 'style-2'
680 ]
681 ]
682 ]
683 );
684 $this->add_responsive_control(
685 'count_number_size',
686 [
687 'label' => esc_html__('Size', 'ultimate-store-kit'),
688 'type' => Controls_Manager::SLIDER,
689 'size_units' => ['px'],
690 'default' => [
691 'unit' => 'px',
692 'size' => 30,
693 ],
694 'selectors' => [
695 '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content .edd-category-count > *' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};',
696 ],
697 'condition' => [
698 'skin_layout' => [
699 'style-2'
700 ]
701 ]
702 ]
703 );
704 // $this->add_responsive_control(
705 // 'count_padding',
706 // [
707 // 'label' => __('Padding', 'ultimate-store-kit'),
708 // 'type' => Controls_Manager::DIMENSIONS,
709 // 'size_units' => ['px', 'em', '%'],
710 // 'selectors' => [
711 // '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content .edd-category-count > *' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
712 // ],
713 // ]
714 // );
715 $this->add_group_control(
716 Group_Control_Typography::get_type(),
717 [
718 'name' => 'count_typography',
719 'label' => esc_html__('Typography', 'ultimate-store-kit'),
720 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item .edd-content .edd-category-count > *',
721 ]
722 );
723 $this->end_controls_tab();
724 $this->start_controls_tab(
725 'count_tab_hover',
726 [
727 'label' => esc_html__('Hover', 'ultimate-store-kit'),
728 ]
729 );
730 $this->add_control(
731 'count_color_hover',
732 [
733 'label' => esc_html__('Color', 'ultimate-store-kit'),
734 'type' => Controls_Manager::COLOR,
735 'selectors' => [
736 '{{WRAPPER}} .usk-edd-category-carousel .edd-item:hover .edd-content .edd-category-count > *' => 'color: {{VALUE}};',
737 ],
738 ]
739 );
740 $this->add_group_control(
741 Group_Control_Background::get_type(),
742 [
743 'name' => 'count_hover_background',
744 'label' => esc_html__('Background', 'ultimate-store-kit'),
745 'types' => ['classic', 'gradient'],
746 'selector' => '{{WRAPPER}} .usk-edd-category-carousel .edd-item:hover .edd-content .edd-category-count > *',
747 'condition' => [
748 'skin_layout' => [
749 'style-2'
750 ]
751 ]
752 ]
753 );
754 $this->end_controls_tab();
755 $this->end_controls_tabs();
756 $this->end_controls_section();
757 $this->register_global_controls_navigation_style();
758 }
759 public function render_query() {
760 $settings = $this->get_settings_for_display();
761 $args = [
762 'orderby' => isset($settings['orderby']) ? $settings['orderby'] : 'name',
763 'order' => isset($settings['order']) ? $settings['order'] : 'ASC',
764 'hide_empty' => isset($settings['hide_empty']) && ($settings['hide_empty'] == 'yes') ? 0 : 1,
765 ];
766
767
768 switch ($settings['display_category']) {
769 case 'all':
770 if (isset($settings['cats_include_by_id']) && !empty($settings['cats_include_by_id'])) {
771 $args['include'] = $settings['cats_include_by_id'];
772 }
773 if (isset($settings['cats_exclude_by_id']) && !empty($settings['cats_exclude_by_id'])) {
774 $args['exclude'] = $settings['cats_exclude_by_id'];
775 }
776 break;
777 case 'child':
778 if ($settings['parent_cats'] != 'none' && !empty($settings['parent_cats'])) {
779 $args['child_of'] = $settings['parent_cats'];
780 }
781 break;
782 case 'parents':
783 $args['parent'] = 0;
784 break;
785 }
786 $args['taxonomy'] = 'download_category';
787 $categories = get_terms($args);
788 return $categories;
789 }
790 public function render_image() {
791 $settings = $this->get_settings_for_display();
792 $image_src = Utils::get_placeholder_image_src();
793 ?>
794 <div class="usk-edd-category-carousel-image">
795 <?php if ($settings['is_use_image']) :
796 $thumb_url = Group_Control_Image_Size::get_attachment_image_src($settings['category_image']['id'], 'category_thumbnail', $settings);
797 if (!empty($thumb_url)) {
798 $image_src = $settings['category_image']['url'];
799 }
800 $path_parts = pathinfo( $image_src );
801 $image_alt_text = isset( $path_parts['filename'] ) ? $path_parts['filename'] : '';
802 ?>
803 <img src="<?php echo esc_url($image_src); ?>" alt="<?php echo esc_attr( $image_alt_text ); ?>">
804 <?php endif; ?>
805 </div><?php
806 }
807 public function render_loop_item() {
808 $settings = $this->get_settings_for_display();
809 $categories = $this->render_query();
810 ?>
811 <?php
812 if (!empty($categories)) {
813 foreach ($categories as $index => $category) :
814 $category_thumb_id = get_term_meta($category->term_id, 'download_term_image', true);
815 $img_url = wp_get_attachment_image_url($category_thumb_id, $settings['category_thumbnail_size']);
816 $category_image = $img_url ? $img_url : Utils::get_placeholder_image_src();
817 $image_alt_text = pathinfo( $category_image, PATHINFO_FILENAME );
818
819 $this->add_render_attribute('edd-category-item', 'class', ['edd-item swiper-slide', 'category-link'], true);
820 $this->add_render_attribute('edd-category-item', 'href', get_term_link($category->term_id, 'download_category'), true); ?>
821 <a <?php $this->print_render_attribute_string('edd-category-item'); ?>>
822 <?php if (!$category_thumb_id) {
823 $this->render_image();
824 } else { ?>
825 <div class="usk-edd-category-carousel-image">
826 <img src="<?php echo esc_url($category_image); ?>" alt="<?php echo esc_attr( $image_alt_text ); ?>">
827 </div>
828 <?php } ?>
829 <div class="edd-content">
830 <?php printf('<h3 class="title">%s</h3>', esc_html($category->name)); ?>
831 <?php if ($settings['show_count']) :
832 printf('<p class="edd-category-count"><span class="edd-count-number">%s</span><span class="edd-count-text">products</span></p>', esc_html($category->count));
833 endif;
834 ?>
835 </div>
836 <div class="edd-item-overlay"></div>
837 </a>
838 <?php
839 // if (!empty($settings['item_limit']['size'])) {
840 // if ($index == ($settings['item_limit']['size'] - 1)) break;
841 // }
842 endforeach;
843 } else {
844 printf('<span class="bdt-warning">%s</span>', esc_html__('Opps, Nothing found to display', 'ultimate-store-kit'));
845 }
846 }
847
848 public function render() {
849 $settings = $this->get_settings_for_display();
850 $this->add_render_attribute('usk-carousel-wrapper', 'class', [$settings['skin_layout']]);
851 $this->register_global_template_carousel_header();
852 $this->render_loop_item();
853 $this->usk_register_global_template_carousel_footer();
854 }
855 }
856