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
← All changes | modules/sub-category/widgets/sub-category.php +181 -51 2.0.13.1.4 View file →
@@ -7,11 +7,14 @@
7 7 use Elementor\Group_Control_Border;
8 8 use Elementor\Group_Control_Box_Shadow;
9 9 use Elementor\Group_Control_Image_Size;
10 10 use Elementor\Group_Control_Typography;
11 -use Elementor\Utils;
11 +// 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.
12 +
13 +// use Elementor\Utils;
12 14 use UltimateStoreKit\Base\Module_Base;
13 15 use UltimateStoreKit\Traits\Global_Terms_Query_Controls;
16 +use UltimateStoreKit\Classes\Utils;
14 17
15 18 use WP_Query;
16 19
17 20
@@ -43,19 +46,19 @@
43 46 }
44 47
45 48 public function get_style_depends() {
46 49 if ($this->usk_is_edit_mode()) {
47 - return ['usk-all-styles'];
50 + return ['swiper', 'usk-all-styles'];
48 51 } else {
49 - return ['usk-sub-category'];
52 + return ['swiper', 'usk-sub-category'];
50 53 }
51 54 }
52 55
53 56 public function get_script_depends() {
54 57 if ($this->usk_is_edit_mode()) {
55 - return ['usk-all-styles'];
58 + return ['swiper', 'usk-all-styles'];
56 59 } else {
57 - return ['usk-sub-category'];
60 + return ['swiper', 'usk-sub-category'];
58 61 }
59 62 }
60 63 // public function get_custom_help_url() {
61 64 // return 'https://youtu.be/ksy2uZ5Hg3M';
@@ -60,8 +63,11 @@
60 63 // public function get_custom_help_url() {
61 64 // return 'https://youtu.be/ksy2uZ5Hg3M';
62 65 // }
63 66
67 + public function has_widget_inner_wrapper(): bool {
68 + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');
69 + }
64 70 protected function register_controls() {
65 71 $this->start_controls_section(
66 72 'section_content_layout',
67 73 [
@@ -125,25 +131,25 @@
125 131
126 132 $this->add_responsive_control(
127 133 'item_flex_direction',
128 134 [
129 - 'label' => esc_html__( 'Direction', 'ultimate-store-kit' ),
135 + 'label' => esc_html__('Direction', 'ultimate-store-kit'),
130 136 'type' => Controls_Manager::CHOOSE,
131 137 'options' => [
132 138 'row' => [
133 - 'title' => esc_html__( 'Row - horizontal', 'ultimate-store-kit' ),
139 + 'title' => esc_html__('Row - horizontal', 'ultimate-store-kit'),
134 140 'icon' => 'eicon-arrow-right',
135 141 ],
136 142 'column' => [
137 - 'title' => esc_html__( 'Column - vertical', 'ultimate-store-kit' ),
143 + 'title' => esc_html__('Column - vertical', 'ultimate-store-kit'),
138 144 'icon' => 'eicon-arrow-down',
139 145 ],
140 146 'row-reverse' => [
141 - 'title' => esc_html__( 'Row - reversed', 'ultimate-store-kit' ),
147 + 'title' => esc_html__('Row - reversed', 'ultimate-store-kit'),
142 148 'icon' => 'eicon-arrow-left',
143 149 ],
144 150 'column-reverse' => [
145 - 'title' => esc_html__( 'Column - reversed', 'ultimate-store-kit' ),
151 + 'title' => esc_html__('Column - reversed', 'ultimate-store-kit'),
146 152 'icon' => 'eicon-arrow-up',
147 153 ],
148 154 ],
149 155 'selectors' => [
@@ -154,25 +160,25 @@
154 160
155 161 $this->add_responsive_control(
156 162 'text_align',
157 163 [
158 - 'label' => esc_html__( 'Text Align', 'ultimate-store-kit' ),
164 + 'label' => esc_html__('Text Align', 'ultimate-store-kit'),
159 165 'type' => Controls_Manager::CHOOSE,
160 166 'options' => [
161 167 'left' => [
162 - 'title' => esc_html__( 'Left', 'ultimate-store-kit' ),
168 + 'title' => esc_html__('Left', 'ultimate-store-kit'),
163 169 'icon' => 'eicon-text-align-left',
164 170 ],
165 171 'center' => [
166 - 'title' => esc_html__( 'Center', 'ultimate-store-kit' ),
172 + 'title' => esc_html__('Center', 'ultimate-store-kit'),
167 173 'icon' => 'eicon-text-align-center',
168 174 ],
169 175 'right' => [
170 - 'title' => esc_html__( 'Right', 'ultimate-store-kit' ),
176 + 'title' => esc_html__('Right', 'ultimate-store-kit'),
171 177 'icon' => 'eicon-text-align-right',
172 178 ],
173 179 'justify' => [
174 - 'title' => esc_html__( 'Justify', 'ultimate-store-kit' ),
180 + 'title' => esc_html__('Justify', 'ultimate-store-kit'),
175 181 'icon' => 'eicon-text-align-justify',
176 182 ],
177 183 ],
178 184 'selectors' => [
@@ -254,10 +260,10 @@
254 260 'label' => __('Order', 'ultimate-store-kit'),
255 261 'type' => Controls_Manager::SELECT,
256 262 'default' => 'desc',
257 263 'options' => [
258 - 'desc' => __('Descending', 'ultimate-store-kit'),
259 - 'asc' => __('Ascending', 'ultimate-store-kit'),
264 + 'desc' => __('DESC', 'ultimate-store-kit'),
265 + 'asc' => __('ASC', 'ultimate-store-kit'),
260 266 ],
261 267 ]
262 268 );
263 269 $this->add_control(
@@ -264,8 +270,9 @@
264 270 'hide_empty',
265 271 [
266 272 'label' => __('Hide Empty', 'ultimate-store-kit'),
267 273 'type' => Controls_Manager::SWITCHER,
274 + 'default' => 'yes',
268 275 ]
269 276 );
270 277
271 278 $this->end_controls_section();
@@ -295,9 +302,9 @@
295 302 'name' => 'item_background',
296 303 'selector' => '{{WRAPPER}} .usk-sub-category .usk-item',
297 304 ]
298 305 );
299 -
306 +
300 307 $this->add_group_control(
301 308 Group_Control_Border::get_type(),
302 309 [
303 310 'name' => 'item_border',
@@ -341,11 +348,11 @@
341 348 );
342 349 $this->add_responsive_control(
343 350 'space_between',
344 351 [
345 - 'label' => esc_html__( 'Space Between', 'ultimate-store-kit' ),
352 + 'label' => esc_html__('Space Between', 'ultimate-store-kit'),
346 353 'type' => Controls_Manager::SLIDER,
347 - 'size_units' => [ 'px', 'em', '%' ],
354 + 'size_units' => ['px', 'em', '%'],
348 355 'selectors' => [
349 356 '{{WRAPPER}} .usk-sub-category .usk-item' => 'gap: {{SIZE}}{{UNIT}};',
350 357 ],
351 358 ]
@@ -392,8 +399,108 @@
392 399 'label' => esc_html__('Image', 'ultimate-store-kit'),
393 400 'tab' => Controls_Manager::TAB_STYLE,
394 401 ]
395 402 );
403 + $this->add_responsive_control(
404 + 'image_height',
405 + [
406 + 'label' => esc_html__('Height', 'ultimate-store-kit'),
407 + 'type' => Controls_Manager::SLIDER,
408 + 'size_units' => ['px', '%'],
409 + 'range' => [
410 + 'px' => [
411 + 'min' => 50,
412 + 'max' => 500,
413 + 'step' => 1,
414 + ],
415 + '%' => [
416 + 'min' => 10,
417 + 'max' => 100,
418 + 'step' => 1,
419 + ],
420 + ],
421 + 'selectors' => [
422 + '{{WRAPPER}} .usk-sub-category .usk-image-slider .swiper-slide' => 'height: {{SIZE}}{{UNIT}};',
423 + ],
424 + ]
425 + );
426 + $this->add_responsive_control(
427 + 'image_width',
428 + [
429 + 'label' => esc_html__('Width', 'ultimate-store-kit'),
430 + 'type' => Controls_Manager::SLIDER,
431 + 'size_units' => ['px', '%'],
432 + 'range' => [
433 + 'px' => [
434 + 'min' => 50,
435 + 'max' => 500,
436 + 'step' => 1,
437 + ],
438 + '%' => [
439 + 'min' => 10,
440 + 'max' => 100,
441 + 'step' => 1,
442 + ],
443 + ],
444 + 'selectors' => [
445 + '{{WRAPPER}} .usk-sub-category .usk-image-slider' => 'width: {{SIZE}}{{UNIT}};',
446 + ],
447 + ]
448 + );
449 + $this->add_responsive_control(
450 + 'image_alignment',
451 + [
452 + 'label' => esc_html__('Alignment', 'ultimate-store-kit'),
453 + 'type' => Controls_Manager::CHOOSE,
454 + 'options' => [
455 + 'left' => [
456 + 'title' => esc_html__('Left', 'ultimate-store-kit'),
457 + 'icon' => 'eicon-h-align-left',
458 + ],
459 + 'center' => [
460 + 'title' => esc_html__('Center', 'ultimate-store-kit'),
461 + 'icon' => 'eicon-h-align-center',
462 + ],
463 + 'right' => [
464 + 'title' => esc_html__('Right', 'ultimate-store-kit'),
465 + 'icon' => 'eicon-h-align-right',
466 + ],
467 + ],
468 + 'selectors_dictionary' => [
469 + 'left' => 'margin-left: inherit;',
470 + 'center' => 'margin-left: auto; margin-right: auto;',
471 + 'right' => 'margin-right: inherit;',
472 + ],
473 + 'selectors' => [
474 + '{{WRAPPER}} .usk-sub-category .usk-image-slider' => '{{VALUE}}',
475 + ],
476 + 'conditions' => [
477 + 'relation' => 'and',
478 + 'terms' => [
479 + [
480 + 'name' => 'image_width[size]',
481 + 'operator' => '>',
482 + 'value' => 0,
483 + ],
484 + [
485 + 'relation' => 'or',
486 + 'terms' => [
487 + [
488 + 'name' => 'item_flex_direction',
489 + 'operator' => '==',
490 + 'value' => 'column',
491 + ],
492 + [
493 + 'name' => 'item_flex_direction',
494 + 'operator' => '==',
495 + 'value' => 'column-reverse',
496 + ],
497 + ],
498 + ],
499 + ],
500 + ],
501 + ]
502 + );
396 503
397 504 $this->add_group_control(
398 505 Group_Control_Border::get_type(),
399 506 [
@@ -399,8 +506,9 @@
399 506 [
400 507 'name' => 'image_border',
401 508 'label' => esc_html__('Image Border', 'ultimate-store-kit'),
402 509 'selector' => '{{WRAPPER}} .usk-sub-category .usk-image-slider .swiper-slide',
510 + 'separator' => 'before',
403 511 ]
404 512 );
405 513
406 514 $this->add_responsive_control(
@@ -489,9 +597,9 @@
489 597 'label' => esc_html__('Margin', 'ultimate-store-kit'),
490 598 'type' => Controls_Manager::DIMENSIONS,
491 599 'size_units' => ['px', '%'],
492 600 'selectors' => [
493 - '{{WRAPPER}} .usk-sub-category .usk-list li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
601 + '{{WRAPPER}} .usk-sub-category .usk-list' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
494 602 ],
495 603 ]
496 604 );
497 605 $this->add_group_control(
@@ -575,9 +683,9 @@
575 683 'return_value' => 'yes',
576 684 'default' => 'yes',
577 685 ]
578 686 );
579 -
687 +
580 688 $this->add_control(
581 689 'thumbs_loop',
582 690 [
583 691 'label' => __('Loop', 'ultimate-store-kit'),
@@ -587,9 +695,9 @@
587 695 'return_value' => 'yes',
588 696 'default' => 'yes',
589 697 ]
590 698 );
591 -
699 +
592 700 $this->add_control(
593 701 'thumbs_autoplay_speed',
594 702 [
595 703 'label' => __('Delay', 'ultimate-store-kit'),
@@ -639,26 +747,26 @@
639 747 'dynamic' => ['active' => true],
640 748 ]
641 749 );
642 750 //creative effect control
643 - $this->add_control(
644 - 'creative_effect',
645 - [
646 - 'label' => esc_html__( 'Creative Effect', 'bdthemes-prime-slider' ),
647 - 'type' => Controls_Manager::SELECT,
648 - 'default' => 'creative-1',
649 - 'options' => [
650 - 'creative-1' => esc_html__( 'Creative 1', 'bdthemes-prime-slider' ),
651 - 'creative-2' => esc_html__( 'Creative 2', 'bdthemes-prime-slider' ),
652 - 'creative-3' => esc_html__( 'Creative 3', 'bdthemes-prime-slider' ),
653 - 'creative-4' => esc_html__( 'Creative 4', 'bdthemes-prime-slider' ),
654 - 'creative-5' => esc_html__( 'Creative 5', 'bdthemes-prime-slider' ),
655 - ],
656 - 'condition' => [
657 - 'thumbs_effect' => 'creative',
658 - ],
659 - ]
660 - );
751 + $this->add_control(
752 + 'creative_effect',
753 + [
754 + 'label' => esc_html__('Creative Effect', 'ultimate-store-kit'),
755 + 'type' => Controls_Manager::SELECT,
756 + 'default' => 'creative-1',
757 + 'options' => [
758 + 'creative-1' => esc_html__('Creative 1', 'ultimate-store-kit'),
759 + 'creative-2' => esc_html__('Creative 2', 'ultimate-store-kit'),
760 + 'creative-3' => esc_html__('Creative 3', 'ultimate-store-kit'),
761 + 'creative-4' => esc_html__('Creative 4', 'ultimate-store-kit'),
762 + 'creative-5' => esc_html__('Creative 5', 'ultimate-store-kit'),
763 + ],
764 + 'condition' => [
765 + 'thumbs_effect' => 'creative',
766 + ],
767 + ]
768 + );
661 769
662 770 $this->end_controls_section();
663 771 }
664 772
@@ -664,12 +772,12 @@
664 772
665 773 public function render_items() {
666 774 $settings = $this->get_settings_for_display();
667 775 $args = [
668 - 'taxonomy' => 'product_cat',
776 + 'taxonomy' => 'product_cat',
669 777 'orderby' => isset($settings['orderby']) ? $settings['orderby'] : 'name',
670 778 'order' => isset($settings['order']) ? $settings['order'] : 'ASC',
671 - 'hide_empty' => isset($settings['hide_empty']) && ($settings['hide_empty'] == 'yes') ? 0 : 1,
779 + 'hide_empty' => isset($settings['hide_empty']) && ($settings['hide_empty'] == 'yes') ? 1 : 0,
672 780 ];
673 781 if (isset($settings['cats_include_by_id']) && !empty($settings['cats_include_by_id'])) {
674 782 $args['include'] = $settings['cats_include_by_id'];
675 783 }
@@ -680,9 +788,8 @@
680 788 $taxonomies = get_terms($args);
681 789 if (!(empty($taxonomies))) :
682 790 $index = 50;
683 791 foreach ($taxonomies as $category) :
684 - // $index
685 792 if ($category->parent == 0 && get_term_children($category->term_id, 'product_cat')) :
686 793 $this->add_render_attribute('sub-category-item', [
687 794 'class' => [
688 795 'usk-item'
@@ -688,11 +795,12 @@
688 795 'usk-item'
689 796 ],
690 797 'data-settings' => [
691 798 wp_json_encode(array_filter([
692 - "autoplay" => ("yes" == $settings["thumbs_autoplay"]) ? ["delay" => $settings["thumbs_autoplay_speed"] + $index += rand(500, 1500)] : false,
799 + "autoplay" => ("yes" == $settings["thumbs_autoplay"]) ? ["delay" => $settings["thumbs_autoplay_speed"] + $index += wp_rand(500, 1500)] : false,
693 800 "loop" => ($settings["thumbs_loop"] == "yes") ? true : false,
694 801 "speed" => $settings["thumbs_slide_speed"]["size"],
802 + "fadeEffect" => ['crossFade' => true],
695 803 "effect" => $settings["thumbs_effect"],
696 804 "creativeEffect" => isset($settings["creative_effect"]) ? $settings["creative_effect"] : false,
697 805 ]))
698 806 ]
@@ -704,9 +812,20 @@
704 812 <?php
705 813 $parentcategory_thumb_id = get_term_meta($category->term_id, 'thumbnail_id', true);
706 814 $images = [$parentcategory_thumb_id];
707 815
708 - foreach ($taxonomies as $subcategory) :
816 + // Get subcategories for the specified parent category
817 + $args = array(
818 + 'taxonomy' => 'product_cat',
819 + 'orderby' => isset($settings['orderby']) ? $settings['orderby'] : 'name',
820 + 'order' => isset($settings['order']) ? $settings['order'] : 'ASC',
821 + 'hide_empty' => isset($settings['hide_empty']) && ($settings['hide_empty'] == 'yes') ? 1 : 0,
822 + 'parent' => $category->term_id,
823 + );
824 +
825 + $subcategories = get_terms($args);
826 +
827 + foreach ($subcategories as $subcategory) :
709 828 if ($subcategory->parent == $category->term_id) {
710 829 $subcategory_thumb_id = get_term_meta($subcategory->term_id, 'thumbnail_id', true);
711 830 $images[] = $subcategory_thumb_id;
712 831 }
@@ -727,13 +846,18 @@
727 846 </div>
728 847 </div>
729 848 <div class="usk-content">
730 849
731 - <?php printf('<%1$s class="usk-name">%2$s</%1$s>', esc_attr($settings['title_tags']), esc_html($category->name)); ?>
850 + <?php printf(
851 + '<%1$s class="usk-name">%2$s</%1$s>',
852 + esc_attr( Utils::get_valid_html_tag($settings['title_tags']) ),
853 + esc_html($category->name)
854 + );
855 + ?>
732 856 <div class="usk-list">
733 857 <?php
734 - foreach ($taxonomies as $key => $subcategory) :
735 - if (($subcategory->parent == $category->term_id) && ($subcategory->count > 0)) {
858 + foreach ($subcategories as $key => $subcategory) :
859 + if ($subcategory->parent == $category->term_id) {
736 860 printf('<a href="%1$s">%2$s</a>', esc_url(get_term_link($subcategory->term_id, 'product_cat')), esc_html($subcategory->name));
737 861 }
738 862 endforeach;
739 863 ?>
@@ -739,10 +863,16 @@
739 863 ?>
740 864 </div>
741 865
742 866 <div class="usk-link-btn">
743 - <?php printf('<a href="%2$s"><span>%1$s</span><i class="usk-icon-arrow-right-8"></i>', esc_html__('All ' . $category->name . '', 'ultimate-store-kit'), esc_url(get_term_link($category->term_id, 'product_cat'))); ?>
744 - </a>
867 + <?php
868 + printf(
869 + '<a href="%2$s"><span>%1$s</span><i class="usk-icon-arrow-right-8"></i></a>',
870 + /* translators: %s: Category name */
871 + sprintf(esc_html__('All %s', 'ultimate-store-kit'), esc_html($category->name)),
872 + esc_url(get_term_link($category->term_id, 'product_cat'))
873 + );
874 + ?>
745 875 </div>
746 876 </div>
747 877 </div>
748 878 <?php