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-grid / widgets / edd-category-grid.php

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

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