PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 3.0.2
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v3.0.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 / shiny-grid / widgets / shiny-grid.php

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

379 lines 12.6 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\ShinyGrid\Widgets;
4
5 use Elementor\Controls_Manager;
6 use UltimateStoreKit\Base\Module_Base;
7 use UltimateStoreKit\Traits\Global_Widget_Template;
8 use UltimateStoreKit\Includes\Controls\GroupQuery\Group_Control_Query;
9 use UltimateStoreKit\Traits\Global_Widget_Controls;
10 use WP_Query;
11 use UltimateStoreKit\Templates\USK_Shiny_Grid_Template;
12
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 class Shiny_Grid extends Module_Base
18 {
19 use Global_Widget_Controls;
20 use Global_Widget_Template;
21 use Group_Control_Query;
22 // use Global_Widget_Template;
23
24 /**
25 * @var \WP_Query
26 */
27 private $_query = null;
28
29 public function get_name()
30 {
31 return 'usk-shiny-grid';
32 }
33
34 public function get_title()
35 {
36 return esc_html__('Shiny Grid', 'ultimate-store-kit');
37 }
38
39 public function get_icon()
40 {
41 return 'usk-widget-icon usk-icon-shiny-grid';
42 }
43
44 public function get_categories()
45 {
46 return ['ultimate-store-kit'];
47 }
48
49 public function get_keywords()
50 {
51 return ['product', 'product-grid', 'table', 'wc'];
52 }
53 public function get_script_depends()
54 {
55 if ($this->usk_is_edit_mode()) {
56 return ['usk-site'];
57 } else {
58 return ['usk-shiny-grid', 'usk-grid-variations'];
59 }
60 }
61
62 public function get_style_depends()
63 {
64 if ($this->usk_is_edit_mode()) {
65 return ['usk-all-styles'];
66 } else {
67 return ['usk-font', 'usk-shiny-grid', 'slick-modal'];
68 }
69 }
70
71 // public function get_custom_help_url() {
72 // return 'https://youtu.be/3VkvEpVaNAM';
73 // }
74
75 public function get_query()
76 {
77 return $this->_query;
78 }
79 public function has_widget_inner_wrapper(): bool
80 {
81 return !\Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');
82 }
83 protected function register_controls()
84 {
85 $this->start_controls_section(
86 'section_woocommerce_layout',
87 [
88 'label' => esc_html__('Layout', 'ultimate-store-kit'),
89 ]
90 );
91
92 $this->add_control(
93 'layout_style',
94 [
95 'label' => esc_html__('Style', 'ultimate-store-kit'),
96 'type' => Controls_Manager::SELECT,
97 'default' => 'grid',
98 'options' => [
99 'grid' => esc_html__('Grid', 'ultimate-store-kit'),
100 'list' => esc_html__('List', 'ultimate-store-kit'),
101 ],
102 'condition' => [
103 'show_tab!' => 'yes'
104 ]
105 ]
106 );
107 $this->add_responsive_control(
108 'columns',
109 [
110 'label' => esc_html__('Columns', 'ultimate-store-kit'),
111 'type' => Controls_Manager::SELECT,
112 'default' => '3',
113 'tablet_default' => '2',
114 'mobile_default' => '1',
115 'options' => [
116 '1' => esc_html__('1', 'ultimate-store-kit'),
117 '2' => esc_html__('2', 'ultimate-store-kit'),
118 '3' => esc_html__('3', 'ultimate-store-kit'),
119 '4' => esc_html__('4', 'ultimate-store-kit'),
120 '5' => esc_html__('5', 'ultimate-store-kit'),
121 '6' => esc_html__('6', 'ultimate-store-kit'),
122 ],
123 'condition' => [
124 'layout_style' => 'grid',
125 'show_tab!' => 'yes'
126 ],
127 'selectors' => [
128 '{{WRAPPER}} .usk-shiny-grid .usk-grid.usk-grid-layout' => 'grid-template-columns: repeat({{VALUE}}, 1fr);',
129
130 ],
131 'render_type' => 'template'
132 ]
133 );
134
135 $this->add_responsive_control(
136 'columns_list',
137 [
138 'label' => esc_html__('Columns', 'ultimate-store-kit'),
139 'type' => Controls_Manager::SELECT,
140 'default' => '2',
141 'tablet_default' => '2',
142 'mobile_default' => '1',
143 'options' => [
144 '1' => esc_html__('1', 'ultimate-store-kit'),
145 '2' => esc_html__('2', 'ultimate-store-kit'),
146 '3' => esc_html__('3', 'ultimate-store-kit'),
147 '4' => esc_html__('4', 'ultimate-store-kit'),
148 '5' => esc_html__('5', 'ultimate-store-kit'),
149 '6' => esc_html__('6', 'ultimate-store-kit'),
150 ],
151 'condition' => [
152 'layout_style' => 'list'
153 ],
154 'selectors' => [
155 '{{WRAPPER}} .usk-shiny-grid .usk-grid.usk-list-layout' => 'grid-template-columns: repeat({{VALUE}}, 1fr);',
156
157 ],
158 'render_type' => 'template'
159 ]
160 );
161
162 $this->add_responsive_control(
163 'items_columns_gap',
164 [
165 'label' => esc_html__('Columns Gap', 'ultimate-store-kit'),
166 'type' => Controls_Manager::SLIDER,
167 'default' => [
168 'size' => 30,
169 ],
170 'selectors' => [
171 '{{WRAPPER}} .usk-shiny-grid .usk-grid' => 'grid-column-gap: {{SIZE}}px;',
172 ],
173 ]
174 );
175
176 $this->add_responsive_control(
177 'items_row_gap',
178 [
179 'label' => esc_html__('Row Gap', 'ultimate-store-kit'),
180 'type' => Controls_Manager::SLIDER,
181 'default' => [
182 'size' => 30,
183 ],
184 'selectors' => [
185 '{{WRAPPER}} .usk-shiny-grid .usk-grid' => 'grid-row-gap: {{SIZE}}px;',
186 ],
187 ]
188 );
189
190 $this->register_global_controls_grid_layout();
191
192 $this->add_control(
193 'show_tab',
194 [
195 'label' => esc_html__('Columns Filter', 'ultimate-store-kit'),
196 'type' => Controls_Manager::SWITCHER,
197 'separator' => 'before',
198 'condition' => [
199 'layout_style' => 'grid'
200 ],
201 ]
202 );
203
204 $this->add_control(
205 'filter_column_lists',
206 [
207 'label' => __('Select Column Type', 'ultimate-store-kit'),
208 'type' => Controls_Manager::SELECT2,
209 'label_block' => true,
210 'multiple' => true,
211 'options' => [
212 'list-2' => __('List', 'ultimate-store-kit'),
213 'grid-2' => __('Column 2', 'ultimate-store-kit'),
214 'grid-3' => __('Column 3', 'ultimate-store-kit'),
215 'grid-4' => __('Column 4', 'ultimate-store-kit'),
216 'grid-5' => __('Column 5', 'ultimate-store-kit'),
217 'grid-6' => __('Column 6', 'ultimate-store-kit'),
218
219 ],
220 'condition' => [
221 'show_tab' => 'yes',
222 'layout_style' => 'grid'
223 ],
224 'default' => ['list-2', 'grid-2', 'grid-3', 'grid-4'],
225 ]
226 );
227
228 $this->add_control(
229 'show_result_count',
230 [
231 'label' => esc_html__('Result Count', 'ultimate-store-kit'),
232 'type' => Controls_Manager::SWITCHER,
233 'label_on' => esc_html__('Show', 'ultimate-store-kit'),
234 'label_off' => esc_html__('Hide', 'ultimate-store-kit'),
235 'return_value' => 'yes',
236 'default' => 'yes',
237 'separator' => 'before',
238 'condition' => [
239 'show_tab' => 'yes'
240 ]
241 ]
242 );
243 $this->add_control(
244 'show_pagination',
245 [
246 'label' => esc_html__('Pagination', 'ultimate-store-kit'),
247 'type' => Controls_Manager::SWITCHER,
248 'separator' => 'before'
249 ]
250 );
251
252 $this->end_controls_section();
253 $this->start_controls_section(
254 'section_post_query_builder',
255 [
256 'label' => __('Query', 'ultimate-store-kit'),
257 'tab' => Controls_Manager::TAB_CONTENT,
258 ]
259 );
260 $this->register_query_builder_controls();
261 $this->register_controls_wc_additional();
262 $this->end_controls_section();
263 $this->register_global_controls_additional();
264 $this->register_global_controls_grid_columns();
265 $this->register_global_controls_result_count();
266 $this->register_global_controls_grid_items();
267 $this->register_global_controls_grid_image();
268 $this->register_global_controls_content();
269 $this->register_global_controls_title();
270 $this->register_global_controls_category();
271 $this->register_global_controls_excerpt();
272 $this->register_global_controls_price();
273 $this->register_global_controls_rating();
274 $this->register_global_controls_badge();
275 $this->register_global_controls_add_to_cart();
276 $this->register_global_controls_action_btn();
277 $this->register_global_controls_variation();
278
279 $this->register_global_controls_grid_pagination();
280 }
281 public function render_header()
282 {
283 $settings = $this->get_settings_for_display();
284 $this->add_render_attribute('usk-shiny-grid', 'class', 'usk-shiny-grid usk-grid-carousel usk-css-grid', true);
285 $this->add_render_attribute('usk-shiny-grid', 'data-filter', [$settings['show_tab']]);
286
287 ?>
288 <div class="ultimate-store-kit">
289 <div <?php $this->print_render_attribute_string('usk-shiny-grid'); ?>>
290 <?php $this->template_grid_columns(); ?>
291 <?php
292 }
293 public function render_footer()
294 { ?>
295 </div>
296 </div>
297 <?php
298 }
299 public function render_loop_item()
300 {
301 $settings = $this->get_settings_for_display();
302 $this->query_product();
303 $wp_query = $this->get_query();
304
305
306 if ($settings['layout_style'] === 'grid') {
307 $this->add_render_attribute('usk-grid', 'class', ['usk-grid', 'usk-grid-layout']);
308 } else {
309 $this->add_render_attribute('usk-grid', 'class', ['usk-grid', 'usk-list-layout']);
310 }
311
312 if ($wp_query->have_posts()) { ?>
313 <div <?php $this->print_render_attribute_string('usk-grid'); ?>">
314 <?php while ($wp_query->have_posts()):
315 $wp_query->the_post();
316 global $product;
317 if (empty($product)) {
318 continue;
319 }
320 ?>
321 <?php $shiny_grid_template = new USK_Shiny_Grid_Template($settings, 'shiny-grid');
322 $shiny_grid_template->render_shiny_grid_item($product, $settings);
323 ?>
324 <?php endwhile; ?>
325 </div>
326 <?php if ($settings['show_pagination']):
327 ultimate_store_kit_post_pagination($wp_query);
328 endif;
329 wp_reset_postdata();
330 } else { ?>
331 <div class="usk-warning">
332 <span><?php echo esc_html__('Ops! There no product to display', 'ultimate-store-kit'); ?></span>
333 </div>
334 <?php
335 }
336 }
337 public function render()
338 {
339 $this->render_header();
340 $this->render_loop_item();
341 $this->render_footer();
342 }
343
344 public function query_product()
345 {
346 $default = $this->getGroupControlQueryArgs();
347 $this->_query = $this->build_query_from_args($default);
348 }
349 protected function template_grid_columns()
350 {
351 $settings = $this->get_settings_for_display();
352 $this->query_product();
353 $wp_query = $this->get_query();
354 if (get_query_var('paged')) {
355 $paged = get_query_var('paged');
356 } elseif (get_query_var('page')) {
357 $paged = get_query_var('page');
358 } else {
359 $paged = 1;
360 }
361
362 $args = array(
363 'total' => $wp_query->found_posts,
364 'per_page' => $settings['product_limit'],
365 'current' => $paged,
366 'orderedby' => $wp_query->get('orderby'),
367 );
368 if ($settings['show_tab'] == 'yes'): ?>
369 <div class="usk-grid-header usk-visible@l">
370 <?php if (($settings['show_result_count'] == 'yes')):
371 wc_get_template('loop/result-count.php', $args);
372 endif;
373 ?>
374 <?php $this->register_templates_grid_columns_markup($settings); ?>
375 </div>
376 <?php endif;
377 }
378 }
379