PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 1.5.2
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v1.5.2
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 / sub-category / widgets / sub-category.php

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

990 lines 38.0 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\SubCategory\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 use WP_Query;
16
17
18 if (!defined('ABSPATH')) {
19 exit;
20 }
21 // Exit if accessed directly
22
23 class Sub_Category extends Module_Base {
24 use Global_Terms_Query_Controls;
25 public function get_name() {
26 return 'usk-sub-category';
27 }
28
29 public function get_title() {
30 return BDTUSK . esc_html__('Sub Category', 'ultimate-store-kit');
31 }
32
33 public function get_icon() {
34 return 'usk-widget-icon usk-icon-sub-category';
35 }
36
37 public function get_categories() {
38 return ['ultimate-store-kit'];
39 }
40
41 public function get_keywords() {
42 return ['ultimate-store-kit', 'shop', 'store', 'sub', 'heading', 'product'];
43 }
44
45 public function get_style_depends() {
46 if ($this->usk_is_edit_mode()) {
47 return ['usk-all-styles'];
48 } else {
49 return ['usk-sub-category'];
50 }
51 }
52
53 public function get_script_depends() {
54 if ($this->usk_is_edit_mode()) {
55 return ['usk-all-styles'];
56 } else {
57 return ['usk-sub-category'];
58 }
59 }
60 // public function get_custom_help_url() {
61 // return 'https://youtu.be/ksy2uZ5Hg3M';
62 // }
63
64 protected function register_controls() {
65 $this->start_controls_section(
66 'section_content_layout',
67 [
68 'label' => esc_html__('Layout', 'ultimate-store-kit'),
69 ]
70 );
71 $this->add_responsive_control(
72 'columns',
73 [
74 'label' => __('Columns', 'ultimate-store-kit-pro'),
75 'type' => Controls_Manager::SELECT,
76 'default' => 3,
77 'tablet_default' => 2,
78 'mobile_default' => 1,
79 'options' => [
80 1 => '1',
81 2 => '2',
82 3 => '3',
83 4 => '4',
84 5 => '5',
85 6 => '6',
86 ],
87 'selectors' => [
88 '{{WRAPPER}} .usk-sub-category' => 'grid-template-columns:repeat({{VALUE}}, 1fr)'
89 ]
90 ]
91 );
92
93 $this->add_responsive_control(
94 'item_gap',
95 [
96 'label' => __('Item Gap', 'ultimate-store-kit'),
97 'type' => Controls_Manager::SLIDER,
98 'default' => [
99 'size' => 20,
100 ],
101 'selectors' => [
102 '{{WRAPPER}} .usk-sub-category' => 'grid-gap: {{SIZE}}{{UNIT}};',
103 ],
104 ]
105 );
106
107 $this->add_control(
108 'title_tags',
109 [
110 'label' => esc_html__('Title HTML Tag', 'ultimate-store-kit'),
111 'type' => Controls_Manager::SELECT,
112 'default' => 'h3',
113 'options' => ultimate_store_kit_title_tags(),
114 ]
115 );
116
117 $this->add_group_control(
118 Group_Control_Image_Size::get_type(),
119 [
120 'name' => 'category_thumbnail',
121 'exclude' => ['custom'],
122 'default' => 'medium',
123 ]
124 );
125 $this->end_controls_section();
126 $this->start_controls_section(
127 'section_term_query',
128 [
129 'label' => __('Query', 'ultimate-store-kit'),
130 'tab' => Controls_Manager::TAB_CONTENT,
131 ]
132 );
133
134
135 // $this->add_control(
136 // 'item_limit',
137 // [
138 // 'label' => esc_html__('Item Limit', 'ultimate-store-kit'),
139 // 'type' => Controls_Manager::SLIDER,
140 // 'range' => [
141 // 'px' => [
142 // 'min' => 1,
143 // 'max' => 20,
144 // ],
145 // ],
146 // 'default' => [
147 // 'size' => 6,
148 // ],
149 // ]
150 // );
151
152 $this->start_controls_tabs(
153 'tabs_terms_include_exclude',
154 []
155 );
156 $this->start_controls_tab(
157 'tab_term_include',
158 [
159 'label' => __('Include', 'ultimate-store-kit'),
160 ]
161 );
162
163 $this->add_control(
164 'cats_include_by_id',
165 [
166 'label' => __('Categories', 'ultimate-store-kit'),
167 'type' => Controls_Manager::SELECT2,
168 'multiple' => true,
169 'label_block' => true,
170 'options' => ultimate_store_kit_get_only_parent_cats('product_cat'),
171 ]
172 );
173
174 $this->end_controls_tab();
175
176 $this->start_controls_tab(
177 'tab_term_exclude',
178 [
179 'label' => __('Exclude', 'ultimate-store-kit'),
180 ]
181 );
182
183 $this->add_control(
184 'cats_exclude_by_id',
185 [
186 'label' => __('Categories', 'ultimate-store-kit'),
187 'type' => Controls_Manager::SELECT2,
188 'multiple' => true,
189 'label_block' => true,
190 'options' => ultimate_store_kit_get_only_parent_cats('product_cat'),
191 ]
192 );
193
194 $this->end_controls_tab();
195 $this->end_controls_tabs();
196 $this->add_control(
197 'orderby',
198 [
199 'label' => __('Order By', 'ultimate-store-kit'),
200 'type' => Controls_Manager::SELECT,
201 'default' => 'name',
202 'options' => [
203 'name' => esc_html__('Name', 'ultimate-store-kit'),
204 'count' => esc_html__('Count', 'ultimate-store-kit'),
205 'slug' => esc_html__('Slug', 'ultimate-store-kit'),
206 ],
207 ]
208 );
209
210 $this->add_control(
211 'order',
212 [
213 'label' => __('Order', 'ultimate-store-kit'),
214 'type' => Controls_Manager::SELECT,
215 'default' => 'desc',
216 'options' => [
217 'desc' => __('Descending', 'ultimate-store-kit'),
218 'asc' => __('Ascending', 'ultimate-store-kit'),
219 ],
220 ]
221 );
222 $this->add_control(
223 'hide_empty',
224 [
225 'label' => __('Hide Empty', 'ultimate-store-kit'),
226 'type' => Controls_Manager::SWITCHER,
227 ]
228 );
229
230 $this->end_controls_section();
231
232 $this->start_controls_section(
233 'section_style_item',
234 [
235 'label' => esc_html__('Item', 'ultimate-store-kit'),
236 'tab' => Controls_Manager::TAB_STYLE,
237 ]
238 );
239 $this->start_controls_tabs(
240 'item_tabs'
241 );
242 $this->start_controls_tab(
243 'item_tab_normal',
244 [
245 'label' => esc_html__('Normal', 'ultimate-store-kit'),
246 ]
247 );
248 $this->add_group_control(
249 Group_Control_Background::get_type(),
250 [
251 'name' => 'item_background',
252 'selector' => '{{WRAPPER}} .usk-sub-category-item',
253 ]
254 );
255 $this->add_responsive_control(
256 'item_padding',
257 [
258 'label' => esc_html__('Padding', 'ultimate-store-kit'),
259 'type' => Controls_Manager::DIMENSIONS,
260 'size_units' => ['px', '%', 'em'],
261 'selectors' => [
262 '{{WRAPPER}} .usk-sub-category-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
263 ],
264 ]
265 );
266 $this->add_responsive_control(
267 'item_margin',
268 [
269 'label' => esc_html__('Margin', 'ultimate-store-kit'),
270 'type' => Controls_Manager::DIMENSIONS,
271 'size_units' => ['px', '%', 'em'],
272 'selectors' => [
273 '{{WRAPPER}} .usk-sub-category-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
274 ],
275 ]
276 );
277 $this->add_group_control(
278 Group_Control_Border::get_type(),
279 [
280 'name' => 'item_border',
281 'label' => esc_html__('Border', 'ultimate-store-kit'),
282 'selector' => '{{WRAPPER}} .usk-sub-category-item',
283 ]
284 );
285 $this->add_responsive_control(
286 'item_radius',
287 [
288 'label' => esc_html__('Radius', 'ultimate-store-kit'),
289 'type' => Controls_Manager::DIMENSIONS,
290 'size_units' => ['px', '%', 'em'],
291 'selectors' => [
292 '{{WRAPPER}} .usk-sub-category-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
293 ],
294 ]
295 );
296
297 $this->add_group_control(
298 Group_Control_Box_Shadow::get_type(),
299 [
300 'name' => 'item_shadow',
301 'selector' => '{{WRAPPER}} .usk-sub-category-item',
302 ]
303 );
304 $this->end_controls_tab();
305 $this->start_controls_tab(
306 'item_tab_hover',
307 [
308 'label' => esc_html__('Hover', 'ultimate-store-kit'),
309 ]
310 );
311 $this->add_control(
312 'item_hover_border_color',
313 [
314 'label' => esc_html__('Border Color', 'ultimate-store-kit'),
315 'type' => Controls_Manager::COLOR,
316 'selectors' => [
317 '{{WRAPPER}} .usk-sub-category-item:hover' => 'border-color: {{VALUE}}',
318 ],
319 ]
320 );
321 $this->add_group_control(
322 Group_Control_Box_Shadow::get_type(),
323 [
324 'name' => 'item_hover_shadow',
325 'selector' => '{{WRAPPER}} .usk-sub-category-item:hover',
326 ]
327 );
328 $this->end_controls_tab();
329 $this->end_controls_tabs();
330 $this->end_controls_section();
331 $this->start_controls_section(
332 'section_style_image',
333 [
334 'label' => esc_html__('Image', 'ultimate-store-kit'),
335 'tab' => Controls_Manager::TAB_STYLE,
336 ]
337 );
338
339 $this->add_group_control(
340 Group_Control_Border::get_type(),
341 [
342 'name' => 'image_border',
343 'label' => esc_html__('Image Border', 'ultimate-store-kit'),
344 'selector' => '{{WRAPPER}} .usk-sub-category .usk-image-slider .usk-image-wrap .usk-img',
345 ]
346 );
347
348 $this->add_responsive_control(
349 'image_border_radius',
350 [
351 'label' => esc_html__('Border Radius', 'ultimate-store-kit'),
352 'type' => Controls_Manager::DIMENSIONS,
353 'size_units' => ['px', '%'],
354 'selectors' => [
355 '{{WRAPPER}} .usk-sub-category .usk-image-slider .usk-image-wrap .usk-img ' => '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' => 'image_shadow',
364 // 'exclude' => [
365 // 'shadow_position',
366 // ],
367 // 'selector' => '{{WRAPPER}} .usk-sub-category .usk-image-slider .usk-image-wrap .usk-img',
368 // ]
369 // );
370
371 $this->end_controls_section();
372 $this->start_controls_section(
373 'section_style_title',
374 [
375 'label' => esc_html__('Title', 'ultimate-store-kit'),
376 'tab' => Controls_Manager::TAB_STYLE,
377 ]
378 );
379
380 $this->add_control(
381 'title_color',
382 [
383 'label' => esc_html__('Color', 'ultimate-store-kit'),
384 'type' => Controls_Manager::COLOR,
385 'selectors' => [
386 '{{WRAPPER}} .usk-sub-category .usk-category-name' => 'color: {{VALUE}}',
387 ],
388 ]
389 );
390
391 $this->add_control(
392 'hover_title_color',
393 [
394 'label' => esc_html__('Hover Color', 'ultimate-store-kit'),
395 'type' => Controls_Manager::COLOR,
396 'selectors' => [
397 '{{WRAPPER}} .usk-sub-category .usk-category-name:hover' => 'color: {{VALUE}};',
398 ],
399 ]
400 );
401
402 $this->add_responsive_control(
403 'title_margin',
404 [
405 'label' => esc_html__('Margin', 'ultimate-store-kit'),
406 'type' => Controls_Manager::DIMENSIONS,
407 'size_units' => ['px', '%'],
408 'selectors' => [
409 '{{WRAPPER}} .usk-sub-category .usk-category-name' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
410 ],
411 ]
412 );
413 $this->add_group_control(
414 Group_Control_Typography::get_type(),
415 [
416 'name' => 'title_typography',
417 'label' => esc_html__('Typography', 'ultimate-store-kit'),
418 'selector' => '{{WRAPPER}} .usk-sub-category .usk-category-name',
419 ]
420 );
421 $this->end_controls_section();
422 $this->start_controls_section(
423 'section_style_sub_category',
424 [
425 'label' => esc_html__('Sub Category', 'ultimate-store-kit'),
426 'tab' => Controls_Manager::TAB_STYLE,
427 ]
428 );
429
430 $this->add_control(
431 'sub_category_color',
432 [
433 'label' => esc_html__('Color', 'ultimate-store-kit'),
434 'type' => Controls_Manager::COLOR,
435 'selectors' => [
436 '{{WRAPPER}} .usk-sub-category .usk-category-list li a' => 'color: {{VALUE}}',
437 ],
438 ]
439 );
440
441 $this->add_control(
442 'hover_sub_category_color',
443 [
444 'label' => esc_html__('Hover Color', 'ultimate-store-kit'),
445 'type' => Controls_Manager::COLOR,
446 'selectors' => [
447 '{{WRAPPER}} .usk-sub-category .usk-category-list li a:hover' => 'color: {{VALUE}};',
448 ],
449 ]
450 );
451
452 $this->add_responsive_control(
453 'sub_category_margin',
454 [
455 'label' => esc_html__('Margin', 'ultimate-store-kit'),
456 'type' => Controls_Manager::DIMENSIONS,
457 'size_units' => ['px', '%'],
458 'selectors' => [
459 '{{WRAPPER}} .usk-sub-category .usk-category-list li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
460 ],
461 ]
462 );
463 $this->add_group_control(
464 Group_Control_Typography::get_type(),
465 [
466 'name' => 'sub_category_typography',
467 'label' => esc_html__('Typography', 'ultimate-store-kit'),
468 'selector' => '{{WRAPPER}} .usk-sub-category .usk-category-list li a',
469 ]
470 );
471 $this->end_controls_section();
472 $this->start_controls_section(
473 'section_style_all_category',
474 [
475 'label' => esc_html__('All Category', 'ultimate-store-kit'),
476 'tab' => Controls_Manager::TAB_STYLE,
477 ]
478 );
479
480 $this->add_control(
481 'all_category_color',
482 [
483 'label' => esc_html__('Color', 'ultimate-store-kit'),
484 'type' => Controls_Manager::COLOR,
485 'selectors' => [
486 '{{WRAPPER}} .usk-sub-category .usk-link-btn a' => 'color: {{VALUE}}',
487 ],
488 ]
489 );
490
491 $this->add_control(
492 'hover_all_category_color',
493 [
494 'label' => esc_html__('Hover Color', 'ultimate-store-kit'),
495 'type' => Controls_Manager::COLOR,
496 'selectors' => [
497 '{{WRAPPER}} .usk-sub-category .usk-link-btn a:hover' => 'color: {{VALUE}};',
498 ],
499 ]
500 );
501
502 $this->add_responsive_control(
503 'all_category_margin',
504 [
505 'label' => esc_html__('Margin', 'ultimate-store-kit'),
506 'type' => Controls_Manager::DIMENSIONS,
507 'size_units' => ['px', '%'],
508 'selectors' => [
509 '{{WRAPPER}} .usk-sub-category .usk-link-btn a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
510 ],
511 ]
512 );
513 $this->add_group_control(
514 Group_Control_Typography::get_type(),
515 [
516 'name' => 'all_category_typography',
517 'label' => esc_html__('Typography', 'ultimate-store-kit'),
518 'selector' => '{{WRAPPER}} .usk-sub-category .usk-link-btn a',
519 ]
520 );
521 $this->end_controls_section();
522 // $this->start_controls_section(
523 // 'section_style_content',
524 // [
525 // 'label' => esc_html__('Content', 'ultimate-store-kit'),
526 // 'tab' => Controls_Manager::TAB_STYLE,
527 // ]
528 // );
529
530 // $this->add_control(
531 // 'content_color',
532 // [
533 // 'label' => esc_html__('Color', 'ultimate-store-kit'),
534 // 'type' => Controls_Manager::COLOR,
535 // 'selectors' => [
536 // '{{WRAPPER}} .usk-sub-category-item .usk-review-text' => 'color: {{VALUE}}',
537 // ],
538 // ]
539 // );
540
541 // $this->add_control(
542 // 'hover_content_color',
543 // [
544 // 'label' => esc_html__('Hover Color', 'ultimate-store-kit'),
545 // 'type' => Controls_Manager::COLOR,
546 // 'selectors' => [
547 // '{{WRAPPER}} .usk-sub-category-item .usk-review-text:hover' => 'color: {{VALUE}};',
548 // ],
549 // ]
550 // );
551 // $this->add_group_control(
552 // Group_Control_Typography::get_type(),
553 // [
554 // 'name' => 'content_typography',
555 // 'label' => esc_html__('Typography', 'ultimate-store-kit'),
556 // 'selector' => '{{WRAPPER}} .usk-sub-category-item .usk-review-text',
557 // ]
558 // );
559
560 // $this->end_controls_section();
561 // $this->start_controls_section(
562 // 'section_style_rating',
563 // [
564 // 'label' => esc_html__('Rating', 'ultimate-store-kit'),
565 // 'tab' => Controls_Manager::TAB_STYLE,
566 // // 'condition' => [
567 // // 'show_rating' => 'yes',
568 // // ],
569 // ]
570 // );
571 // $this->add_control(
572 // 'rating_color',
573 // [
574 // 'label' => esc_html__('Color', 'ultimate-store-kit'),
575 // 'type' => Controls_Manager::COLOR,
576 // 'default' => '#e7e7e7',
577 // 'selectors' => [
578 // '{{WRAPPER}} .ultimate-store-kit-review-wrapper .usk-review-info-wrap .usk-review-rating .usk-rating-text' => 'color: {{VALUE}};',
579 // ],
580 // ]
581 // );
582
583 // $this->add_control(
584 // 'rating_bg_color',
585 // [
586 // 'label' => esc_html__('Background', 'ultimate-store-kit'),
587 // 'type' => Controls_Manager::COLOR,
588 // 'default' => '#FFCC00',
589 // 'selectors' => [
590 // '{{WRAPPER}} .ultimate-store-kit-review-wrapper .usk-review-info-wrap .usk-review-rating span .usk-rating-icon' => 'color: {{VALUE}};',
591 // ],
592 // ]
593 // );
594 // $this->add_group_control(
595 // Group_Control_Typography::get_type(),
596 // [
597 // 'name' => 'rating_typography',
598 // 'label' => esc_html__('Typography', 'ultimate-store-kit'),
599 // 'selector' => '{{WRAPPER}} .ultimate-store-kit-review-wrapper .usk-review-info-wrap .usk-review-rating .usk-rating-text',
600 // ]
601 // );
602
603 // $this->end_controls_section();
604 // $this->start_controls_section(
605 // 'badge',
606 // [
607 // 'label' => esc_html__('Badge', 'ultimate-store-kit'),
608 // 'tab' => Controls_Manager::TAB_STYLE,
609 // ]
610 // );
611 // $this->start_controls_tabs(
612 // 'label_badge_tabs'
613 // );
614 // $this->start_controls_tab(
615 // 'sale_badge_tab',
616 // [
617 // 'label' => esc_html__(
618 // 'Sale',
619 // 'ultimate-store-kit'
620 // ),
621 // 'condition' => [
622 // 'show_sale_badge' => 'yes',
623 // ],
624 // ]
625 // );
626 // $this->add_control(
627 // 'sale_badge_color',
628 // [
629 // 'label' => esc_html__(
630 // 'Color',
631 // 'ultimate-store-kit'
632 // ),
633 // 'type' => Controls_Manager::COLOR,
634 // 'selectors' => [
635 // '{{WRAPPER}} .usk-list-wrap .usk-sub-category-item .usk-sub-category-item-box .usk-badge-label-wrapper .usk-sale-badge .usk-badge' => 'color: {{VALUE}}',
636 // ],
637 // ]
638 // );
639 // $this->add_control(
640 // 'sale_badge_bg',
641 // [
642 // 'label' => esc_html__('Background', 'ultimae-woo-kit'),
643 // 'type' => Controls_Manager::COLOR,
644 // 'selectors' => [
645 // '{{WRAPPER}} .usk-list-wrap .usk-sub-category-item .usk-sub-category-item-box .usk-badge-label-wrapper .usk-sale-badge .usk-badge' => 'background: {{VALUE}}',
646 // ],
647 // ]
648 // );
649 // $this->end_controls_tab();
650 // $this->start_controls_tab(
651 // 'percentage_badge_tab',
652 // [
653 // 'label' => esc_html__('Percentage', 'ultimate-store-kit'),
654 // 'condition' => [
655 // 'show_percentage_badge' => 'yes',
656 // ],
657 // ]
658 // );
659 // $this->add_control(
660 // 'percentage_badge_color',
661 // [
662 // 'label' => esc_html__('Color', 'ultimate-store-kit'),
663 // 'type' => Controls_Manager::COLOR,
664 // 'selectors' => [
665 // '{{WRAPPER}} .usk-list-wrap .usk-badge-label-wrapper .usk-percantage-badge .usk-badge' => 'color: {{VALUE}}',
666 // ],
667 // ]
668 // );
669 // $this->add_control(
670 // 'percentage_badge_bg',
671 // [
672 // 'label' => esc_html__('Background', 'ultimae-woo-kit'),
673 // 'type' => Controls_Manager::COLOR,
674 // 'selectors' => [
675 // '{{WRAPPER}} .usk-list-wrap .usk-badge-label-wrapper .usk-percantage-badge .usk-badge' => 'background: {{VALUE}}',
676 // ],
677 // ]
678 // );
679 // $this->end_controls_tab();
680 // $this->start_controls_tab(
681 // 'stock_badge_tab',
682 // [
683 // 'label' => esc_html__('Stock', 'ultimate-store-kit'),
684 // 'condition' => [
685 // 'show_stock_status' => 'yes',
686 // ],
687 // ]
688 // );
689 // $this->add_control(
690 // 'stock_badge_color',
691 // [
692 // 'label' => esc_html__('Color', 'ultimate-store-kit'),
693 // 'type' => Controls_Manager::COLOR,
694 // 'selectors' => [
695 // '{{WRAPPER}} .usk-list-wrap .usk-badge-label-wrapper .usk-stock-status-badge .usk-badge' => 'color: {{VALUE}}',
696 // ],
697 // ]
698 // );
699 // $this->add_control(
700 // 'stock_badge_bg',
701 // [
702 // 'label' => esc_html__('Background', 'ultimae-woo-kit'),
703 // 'type' => Controls_Manager::COLOR,
704 // 'selectors' => [
705 // '{{WRAPPER}} .usk-list-wrap .usk-badge-label-wrapper .usk-stock-status-badge .usk-badge' => 'background: {{VALUE}}',
706 // ],
707 // ]
708 // );
709 // $this->end_controls_tab();
710 // $this->start_controls_tab(
711 // 'trending_badge_tab',
712 // [
713 // 'label' => esc_html__('Trending', 'ultimate-store-kit'),
714 // 'condition' => [
715 // 'show_trending_badge' => 'yes',
716 // ],
717 // ]
718 // );
719 // $this->add_control(
720 // 'trending_badge_color',
721 // [
722 // 'label' => esc_html__('Color', 'ultimate-store-kit'),
723 // 'type' => Controls_Manager::COLOR,
724 // 'selectors' => [
725 // '{{WRAPPER}} .usk-list-wrap .usk-badge-label-wrapper .usk-trending-badge .usk-badge' => 'color: {{VALUE}}',
726 // ],
727 // ]
728 // );
729 // $this->add_control(
730 // 'trending_badge_bg',
731 // [
732 // 'label' => esc_html__('Background', 'ultimae-woo-kit'),
733 // 'type' => Controls_Manager::COLOR,
734 // 'selectors' => [
735 // '{{WRAPPER}} .usk-list-wrap .usk-badge-label-wrapper .usk-trending-badge .usk-badge' => 'background: {{VALUE}}',
736 // ],
737 // ]
738 // );
739
740 // $this->end_controls_tab();
741 // $this->start_controls_tab(
742 // 'new_badge_tab',
743 // [
744 // 'label' => esc_html__('new', 'ultimate-store-kit'),
745 // 'condition' => [
746 // 'show_new_badge' => 'yes',
747 // ],
748 // ]
749 // );
750 // $this->add_control(
751 // 'new_badge_color',
752 // [
753 // 'label' => esc_html__('Color', 'ultimate-store-kit'),
754 // 'type' => Controls_Manager::COLOR,
755 // 'selectors' => [
756 // '{{WRAPPER}} .usk-list-wrap .usk-badge-label-wrapper .usk-new-badge .usk-badge' => 'color: {{VALUE}}',
757 // ],
758 // ]
759 // );
760 // $this->add_control(
761 // 'new_badge_bg',
762 // [
763 // 'label' => esc_html__('Background', 'ultimae-woo-kit'),
764 // 'type' => Controls_Manager::COLOR,
765 // 'selectors' => [
766 // '{{WRAPPER}} .usk-list-wrap .usk-badge-label-wrapper .usk-new-badge .usk-badge' => 'background: {{VALUE}}',
767 // ],
768 // ]
769 // );
770
771 // $this->end_controls_tab();
772 // $this->end_controls_tabs();
773 // $this->add_control(
774 // 'badge_padding',
775 // [
776 // 'label' => esc_html__('Padding', 'ultimate-store-kit'),
777 // 'type' => Controls_Manager::DIMENSIONS,
778 // 'size_units' => ['px', '%', 'em'],
779 // 'selectors' => [
780 // '{{WRAPPER}} .usk-list-wrap .usk-badge-label-wrapper .usk-badge-wrap .usk-badge' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
781 // ],
782 // 'separator' => 'before'
783 // ]
784 // );
785 // $this->add_control(
786 // 'badge_margin',
787 // [
788 // 'label' => esc_html__('Margin', 'ultimate-store-kit'),
789 // 'type' => Controls_Manager::DIMENSIONS,
790 // 'size_units' => ['px', '%', 'em'],
791 // 'selectors' => [
792 // 'menu_order' => esc_html__('Menu Order', 'ultimate-store-kit'),
793 // '{{WRAPPER}} .usk-list-wrap .usk-badge-label-wrapper .usk-badge-wrap .usk-badge' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
794 // ],
795 // ]
796 // );
797 // $this->add_group_control(
798 // Group_Control_Typography::get_type(),
799 // [
800 // 'name' => 'badge_typography',
801 // 'label' => esc_html__(
802 // 'Typography',
803 // 'ultimate-store-kit'
804 // ),
805 // 'selector' => '{{WRAPPER}} .usk-list-wrap .usk-badge-label-wrapper .usk-badge-wrap .usk-badge',
806 // ]
807 // );
808 // $this->end_controls_section();
809 $this->render_thumbs_settings();
810 }
811
812 public function render_thumbs_settings() {
813 $this->start_controls_section(
814 'section_content_thumbs_settings',
815 [
816 'label' => __('Settings', 'ultimate-store-kit'),
817 'tab' => Controls_Manager::TAB_CONTENT,
818 ]
819 );
820 $this->add_control(
821 'thumbs_effect',
822 [
823 'label' => __('Effect', 'ultimate-store-kit'),
824 'type' => Controls_Manager::SELECT,
825 'options' => [
826 'fade' => __('Fade', 'ultimate-store-kit'),
827 'slide' => __('Slide', 'ultimate-store-kit'),
828 ],
829 'default' => 'fade',
830 'dynamic' => ['active' => true],
831 ]
832 );
833 $this->add_control(
834 'thumbs_loop',
835 [
836 'label' => __('Loop', 'ultimate-store-kit'),
837 'type' => Controls_Manager::SWITCHER,
838 'label_on' => __('Yes', 'ultimate-store-kit'),
839 'label_off' => __('No', 'ultimate-store-kit'),
840 'return_value' => 'yes',
841 'default' => 'yes',
842 ]
843 );
844 $this->add_control(
845 'thumbs_autoplay',
846 [
847 'label' => __('Auto Play', 'ultimate-store-kit'),
848 'type' => Controls_Manager::SWITCHER,
849 'label_on' => __('Yes', 'ultimate-store-kit'),
850 'label_off' => __('No', 'ultimate-store-kit'),
851 'return_value' => 'yes',
852 'default' => 'yes',
853 ]
854 );
855 $this->add_control(
856 'thumbs_autoplay_speed',
857 [
858 'label' => __('Delay', 'ultimate-store-kit'),
859 'type' => Controls_Manager::NUMBER,
860 'min' => 0,
861 'max' => 10000,
862 'step' => 5,
863 'default' => 1500,
864 'dynamic' => ['active' => true],
865 'condition' => [
866 'thumbs_autoplay' => 'yes'
867 ]
868 ]
869 );
870
871 $this->add_responsive_control(
872 'thumbs_slide_speed',
873 [
874 'label' => __('Speed', 'ultimate-store-kit'),
875 'type' => Controls_Manager::SLIDER,
876 'size_units' => ['px'],
877 'range' => [
878 'px' => [
879 'min' => 0,
880 'max' => 5000,
881 'step' => 1,
882 ]
883 ],
884 'default' => [
885 'unit' => 'px',
886 'size' => 1500,
887 ]
888 ]
889 );
890
891 $this->end_controls_section();
892 }
893
894 public function render_items() {
895 $settings = $this->get_settings_for_display();
896 $args = [
897 'taxonomy' => 'product_cat',
898 'orderby' => isset($settings['orderby']) ? $settings['orderby'] : 'name',
899 'order' => isset($settings['order']) ? $settings['order'] : 'ASC',
900 'hide_empty' => isset($settings['hide_empty']) && ($settings['hide_empty'] == 'yes') ? 0 : 1,
901 ];
902 if (isset($settings['cats_include_by_id']) && !empty($settings['cats_include_by_id'])) {
903 $args['include'] = $settings['cats_include_by_id'];
904 }
905 if (isset($settings['cats_exclude_by_id']) && !empty($settings['cats_exclude_by_id'])) {
906 $args['exclude'] = $settings['cats_exclude_by_id'];
907 }
908 // print_r($args);
909 $taxonomies = get_terms($args);
910 if (!(empty($taxonomies))) :
911 $index = 50;
912 foreach ($taxonomies as $category) :
913 // $index
914 if ($category->parent == 0 && get_term_children($category->term_id, 'product_cat')) :
915 $this->add_render_attribute('sub-category-item', [
916 'class' => [
917 'usk-sub-category-item'
918 ],
919 'data-settings' => [
920 wp_json_encode(array_filter([
921 "autoplay" => ("yes" == $settings["thumbs_autoplay"]) ? ["delay" => $settings["thumbs_autoplay_speed"] + $index += rand(500, 1500)] : false,
922 "loop" => ($settings["thumbs_loop"] == "yes") ? true : false,
923 "speed" => $settings["thumbs_slide_speed"]["size"],
924 "effect" => $settings["thumbs_effect"],
925 ]))
926 ]
927 ], null, true);
928 ?>
929 <div <?php $this->print_render_attribute_string('sub-category-item'); ?>>
930 <div class="swiper usk-image-slider">
931 <div class="swiper-wrapper">
932 <?php
933 $parentcategory_thumb_id = get_term_meta($category->term_id, 'thumbnail_id', true);
934 $images = [$parentcategory_thumb_id];
935
936 foreach ($taxonomies as $subcategory) :
937 if ($subcategory->parent == $category->term_id) {
938 $subcategory_thumb_id = get_term_meta($subcategory->term_id, 'thumbnail_id', true);
939 $images[] = $subcategory_thumb_id;
940 }
941 endforeach;
942
943 foreach ($images as $image_id) :
944 $img_url = wp_get_attachment_image_url($image_id, $settings['category_thumbnail_size']);
945 if (!(empty($img_url))) : ?>
946 <div class="usk-item swiper-slide">
947 <a href="#" class="usk-image-wrap">
948 <img class="usk-img" src="<?php echo $img_url; ?>" />
949 </a>
950 </div>
951 <?php
952 endif;
953 endforeach;
954 ?>
955 </div>
956 </div>
957 <div class="usk-category-content">
958
959 <?php printf('<%1$s class="usk-category-name">%2$s</%1$s>', $settings['title_tags'], esc_html($category->name)); ?>
960 <ul class="usk-category-list">
961 <?php
962 foreach ($taxonomies as $key => $subcategory) :
963 if (($subcategory->parent == $category->term_id) && ($subcategory->count > 0)) {
964 printf('<li><a href="%1$s">%2$s</a></li>', get_term_link($subcategory->term_id, 'product_cat'), $subcategory->name);
965 }
966 endforeach;
967 ?>
968 </ul>
969
970 <div class="usk-link-btn">
971 <?php printf('<a href="%2$s"><span>%1$s</span><i class="eicon-arrow-right"></i>', esc_html('All ' . $category->name . ''), get_term_link($category->term_id, 'product_cat')); ?>
972 </a>
973 </div>
974 </div>
975 </div>
976 <?php
977 endif;
978 $index++;
979 endforeach;
980 endif;
981 }
982 public function render() {
983 ?>
984 <div class="usk-sub-category usk-sub-category-style-1">
985 <?php $this->render_items(); ?>
986 </div>
987 <?php
988 }
989 }
990