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

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