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 / glossy-grid / widgets / glossy-grid.php

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

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