PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 3.1.4
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v3.1.4
3.1.4 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.0.7 3.0.5 3.0.4 3.0.3 3.0.2 trunk 1.5.0 1.5.1 1.5.2 1.6.1 1.6.2 1.6.3 1.6.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 All 93 releases
ultimate-store-kit / modules / shiny-carousel / widgets / shiny-carousel.php

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

180 lines 5.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\ShinyCarousel\Widgets;
4
5 use Elementor\Controls_Manager;
6 use UltimateStoreKit\Base\Module_Base;
7 use UltimateStoreKit\traits\Global_Widget_Controls;
8 use UltimateStoreKit\traits\Global_Widget_Template;
9 use UltimateStoreKit\Includes\Controls\GroupQuery\Group_Control_Query;
10 use UltimateStoreKit\Templates\USK_Shiny_Grid_Template;
11
12 use WP_Query;
13
14 if (!defined('ABSPATH')) {
15 exit;
16 }
17
18 // Exit if accessed directly
19
20 class Shiny_Carousel extends Module_Base {
21 use Global_Widget_Controls;
22 use Global_Widget_Template;
23 use Group_Control_Query;
24
25 /**
26 * @var \WP_Query
27 */
28 private $_query = null;
29
30 public function get_name() {
31 return 'usk-shiny-carousel';
32 }
33
34 public function get_title() {
35 return esc_html__('Shiny Carousel', 'ultimate-store-kit');
36 }
37
38 public function get_icon() {
39 return 'usk-widget-icon usk-icon-shiny-carousel';
40 }
41
42 public function get_categories() {
43 return ['ultimate-store-kit'];
44 }
45
46 public function get_keywords() {
47 return ['product', 'product-grid', 'table', 'wc'];
48 }
49
50 public function get_script_depends() {
51 if ($this->usk_is_edit_mode()) {
52 return ['swiper', 'ultimate-store-kit-micromodal', 'usk-site'];
53 } else {
54 return ['swiper', 'ultimate-store-kit-micromodal', 'usk-shiny-carousel'];
55 }
56 }
57
58 public function get_style_depends() {
59 if ($this->usk_is_edit_mode()) {
60 return ['swiper', 'usk-all-styles'];
61 } else {
62 return ['swiper', 'usk-font', 'usk-shiny-carousel'];
63 }
64 }
65
66 // public function get_custom_help_url() {
67 // return 'https://youtu.be/3VkvEpVaNAM';
68 // }
69 public function get_query() {
70 return $this->_query;
71 }
72 public function has_widget_inner_wrapper(): bool {
73 return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');
74 }
75 protected function register_controls() {
76
77 $this->start_controls_section(
78 'section_woocommerce_layout',
79 [
80 'label' => esc_html__('Layout', 'ultimate-store-kit'),
81 ]
82 );
83
84 $this->add_responsive_control(
85 'columns',
86 [
87 'label' => esc_html__('Columns', 'ultimate-store-kit'),
88 'type' => Controls_Manager::SELECT,
89 'default' => 3,
90 'tablet_default' => 2,
91 'mobile_default' => 1,
92 'options' => [
93 1 => esc_html__( '1', 'ultimate-store-kit' ),
94 2 => esc_html__( '2', 'ultimate-store-kit' ),
95 3 => esc_html__( '3', 'ultimate-store-kit' ),
96 4 => esc_html__( '4', 'ultimate-store-kit' ),
97 5 => esc_html__( '5', 'ultimate-store-kit' ),
98 6 => esc_html__( '6', 'ultimate-store-kit' ),
99 ],
100 ]
101 );
102 $this->add_responsive_control(
103 'items_gap',
104 [
105 'label' => esc_html__('Item Gap', 'ultimate-store-kit'),
106 'type' => Controls_Manager::SLIDER,
107 'default' => [
108 'size' => 30,
109 ],
110 'range' => [
111 'px' => [
112 'min' => 0,
113 'max' => 100,
114 ],
115 ],
116 'tablet_default' => [
117 'size' => 20,
118 ],
119 'mobile_default' => [
120 'size' => 20,
121 ],
122 ]
123 );
124
125 $this->register_global_controls_grid_layout();
126
127 $this->end_controls_section();
128 $this->start_controls_section(
129 'section_post_query_builder',
130 [
131 'label' => __('Query', 'ultimate-store-kit'),
132 'tab' => Controls_Manager::TAB_CONTENT,
133 ]
134 );
135 $this->register_query_builder_controls();
136 $this->register_controls_wc_additional();
137 $this->end_controls_section();
138 $this->register_global_controls_additional();
139 $this->register_global_controls_carousel_navigation();
140 $this->register_global_controls_carousel_settings();
141 $this->register_global_controls_grid_items();
142 $this->register_global_controls_grid_image();
143 $this->register_global_controls_content();
144 $this->register_global_controls_title();
145 $this->register_global_controls_category();
146 $this->register_global_controls_price();
147 $this->register_global_controls_rating();
148 $this->register_global_controls_badge();
149 $this->register_global_controls_add_to_cart();
150 $this->register_global_controls_action_btn();
151 $this->register_global_controls_navigation_style();
152 }
153
154 public function render_loop_item() {
155 $settings = $this->get_settings_for_display();
156 $this->query_product();
157 $wp_query = $this->get_query();
158
159 if ($wp_query->have_posts()) :
160 while ($wp_query->have_posts()) : $wp_query->the_post();
161 global $product;
162 $shiny_grid_template = new USK_Shiny_Grid_Template($settings, 'shiny-carousel');
163 $shiny_grid_template->render_shiny_grid_item($product, $settings);
164 endwhile;
165 wp_reset_postdata();
166 else :
167 echo '<div class="usk-alert-warning" usk-alert>' . esc_html__('Ops! There no product to display.', 'ultimate-store-kit') . '</div>';
168 endif;
169 }
170 public function render() {
171 $this->register_global_template_carousel_header();
172 $this->render_loop_item();
173 $this->usk_register_global_template_carousel_footer();
174 }
175 public function query_product() {
176 $default = $this->getGroupControlQueryArgs();
177 $this->_query = $this->build_query_from_args($default);
178 }
179 }
180