PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 2.0.0
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v2.0.0
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 2.0.0, at modules/edd-category-grid/widgets/edd-category-grid.php

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