PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.6.3
ShopBuilder – WooCommerce Builder For Elementor v2.6.3
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Elementor / Widgets / Controls / LayoutFields.php

LayoutFields.php in ShopBuilder – WooCommerce Builder For Elementor 2.6.3, at app/Elementor/Widgets/Controls/LayoutFields.php

1,050 lines 34.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elementor Layout Fields Class.
4 *
5 * This class contains all the common fields for Layout tab.
6 *
7 * @package RadiusTheme\SB
8 */
9
10 namespace RadiusTheme\SB\Elementor\Widgets\Controls;
11
12 use RadiusTheme\SB\Helpers\Fns;
13 use RadiusTheme\SB\Elementor\Helper\ControlHelper;
14
15 // Do not allow directly accessing this file.
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit( 'This script cannot be accessed directly.' );
18 }
19
20 /**
21 * Elementor Layout Fields Class.
22 */
23 class LayoutFields {
24 /**
25 * Tab name.
26 *
27 * @access private
28 * @static
29 *
30 * @var array
31 */
32 private static $tab = 'layout';
33
34 /**
35 * Grid Layout section
36 *
37 * @param object $obj Reference object.
38 *
39 * @return array
40 */
41 public static function grid_layout( $obj ) {
42 $fields['layout_section'] = $obj->start_section(
43 esc_html__( 'Presentation', 'shopbuilder' ),
44 self::$tab
45 );
46
47 $fields['layout_note'] = $obj->el_heading( esc_html__( 'Predefined Layouts', 'shopbuilder' ) );
48
49 $fields['layout'] = [
50 'type' => 'rtsb-image-selector',
51 'options' => ControlHelper::grid_layouts(),
52 'default' => 'grid-layout1',
53 ];
54
55 $fields = array_merge( $fields, self::structure( $obj ) );
56 $fields = array_merge( $fields, self::action_btn_presets( $obj ) );
57
58 $fields['layout_section_end'] = $obj->end_section();
59
60 return apply_filters( 'rtsb/elements/elementor/grid_layout_control', $fields, $obj );
61 }
62
63 /**
64 * List Layout section
65 *
66 * @param object $obj Reference object.
67 *
68 * @return array
69 */
70 public static function list_layout( $obj ) {
71 $fields['layout_section'] = $obj->start_section(
72 esc_html__( 'Layouts', 'shopbuilder' ),
73 self::$tab
74 );
75
76 $fields['layout_note'] = $obj->el_heading( esc_html__( 'Predefined Layouts', 'shopbuilder' ) );
77
78 $fields['layout'] = [
79 'type' => 'rtsb-image-selector',
80 'options' => ControlHelper::list_layouts(),
81 'default' => 'list-layout1',
82 ];
83
84 $fields = array_merge( $fields, self::structure( $obj ) );
85 $fields = array_merge( $fields, self::action_btn_presets( $obj ) );
86
87 unset( $fields['action_btn_preset'] );
88 unset( $fields['action_btn_position'] );
89
90 $fields['layout_section_end'] = $obj->end_section();
91
92 return apply_filters( 'rtsb/elements/elementor/list_layout_control', $fields, $obj );
93 }
94
95 /**
96 * Slider Layout section
97 *
98 * @param object $obj Reference object.
99 *
100 * @return array
101 */
102 public static function slider_layout( $obj ) {
103 $fields['layout_section'] = $obj->start_section(
104 esc_html__( 'Slider Layouts', 'shopbuilder' ),
105 self::$tab
106 );
107
108 $fields['layout_note'] = $obj->el_heading( esc_html__( 'Predefined Layouts', 'shopbuilder' ) );
109
110 $fields['layout'] = [
111 'type' => 'rtsb-image-selector',
112 'options' => ControlHelper::slider_layouts(),
113 'default' => 'slider-layout1',
114 ];
115
116 $fields = array_merge( $fields, self::structure_slider( $obj ) );
117 $fields = array_merge( $fields, self::action_btn_presets( $obj ) );
118
119 $fields['layout_section_end'] = $obj->end_section();
120
121 return apply_filters( 'rtsb/elements/elementor/slider_layout_control', $fields, $obj );
122 }
123
124 /**
125 * Category Layout section
126 *
127 * @param object $obj Reference object.
128 *
129 * @return array
130 */
131 public static function category_layout( $obj ) {
132 $fields['layout_section'] = $obj->start_section(
133 esc_html__( 'Layouts', 'shopbuilder' ),
134 self::$tab
135 );
136
137 $fields['layout'] = [
138 'type' => 'rtsb-image-selector',
139 'options' => ControlHelper::category_layouts(),
140 'default' => 'category-layout1',
141 ];
142
143 $fields = array_merge( $fields, self::structure( $obj ) );
144
145 if ( 'rtsb-product-categories-general' === $obj->rtsb_base ) {
146 $fields['cols']['render_type'] = 'template';
147 }
148
149 $fields['cat_height'] = [
150 'type' => 'slider',
151 'mode' => 'responsive',
152 'label' => esc_html__( 'Element Height', 'shopbuilder' ),
153 'size_units' => [ 'px', '%' ],
154 'range' => [
155 'px' => [
156 'min' => 0,
157 'max' => 1500,
158 'step' => 1,
159 ],
160 '%' => [
161 'min' => 0,
162 'max' => 100,
163 'step' => 1,
164 ],
165 ],
166 'description' => esc_html__( 'Please select the element height.', 'shopbuilder' ),
167 'selectors' => [
168 $obj->selectors['category_multi_layout']['cat_height'] => 'height: {{SIZE}}{{UNIT}};',
169 ],
170 ];
171
172 $fields['layout_section_end'] = $obj->end_section();
173
174 return apply_filters( 'rtsb/elements/elementor/cat_layout_control', $fields, $obj );
175 }
176
177 /**
178 * Category Layout section
179 *
180 * @param object $obj Reference object.
181 *
182 * @return array
183 */
184 public static function category_single_layout( $obj ) {
185 $fields['layout_section'] = $obj->start_section(
186 esc_html__( 'Layouts', 'shopbuilder' ),
187 self::$tab
188 );
189
190 $fields['layout'] = [
191 'type' => 'rtsb-image-selector',
192 'options' => ControlHelper::single_category_layouts(),
193 'default' => 'category-single-layout1',
194 ];
195
196 $fields['cat_alignment'] = [
197 'mode' => 'responsive',
198 'type' => 'choose',
199 'label' => esc_html__( 'Element Alignment', 'shopbuilder' ),
200 'options' => [
201 'left' => [
202 'title' => esc_html__( 'Left', 'shopbuilder' ),
203 'icon' => 'eicon-text-align-left',
204 ],
205 'center' => [
206 'title' => esc_html__( 'Center', 'shopbuilder' ),
207 'icon' => 'eicon-text-align-center',
208 ],
209 'right' => [
210 'title' => esc_html__( 'Right', 'shopbuilder' ),
211 'icon' => 'eicon-text-align-right',
212 ],
213 ],
214 'selectors' => [
215 $obj->selectors['category_single_layout']['cat_alignment']['text_align'] => 'text-align: {{VALUE}};',
216 $obj->selectors['category_single_layout']['cat_alignment']['justify_content'] => 'justify-content: {{VALUE}};',
217 ],
218 ];
219
220 $fields['cat_height'] = [
221 'type' => 'slider',
222 'mode' => 'responsive',
223 'label' => esc_html__( 'Element Height', 'shopbuilder' ),
224 'size_units' => [ 'px', '%' ],
225 'range' => [
226 'px' => [
227 'min' => 0,
228 'max' => 1500,
229 'step' => 1,
230 ],
231 '%' => [
232 'min' => 0,
233 'max' => 100,
234 'step' => 1,
235 ],
236 ],
237 'description' => esc_html__( 'Please select the element height.', 'shopbuilder' ),
238 'selectors' => [
239 $obj->selectors['category_single_layout']['cat_height'] => 'height: {{SIZE}}{{UNIT}};',
240 ],
241 ];
242
243 $fields['layout_section_end'] = $obj->end_section();
244
245 return apply_filters( 'rtsb/elements/elementor/cat_layout_control', $fields, $obj );
246 }
247
248 /**
249 * Action button preset section
250 *
251 * @param object $obj Reference object.
252 *
253 * @return array
254 */
255 public static function action_btn_presets( $obj ) {
256 $fields['action_btn_note'] = $obj->el_heading( esc_html__( 'Action Button Layouts', 'shopbuilder' ), 'before' );
257
258 $fields['action_btn_preset'] = [
259 'type' => 'rtsb-image-selector',
260 'description' => esc_html__( 'Please choose your preferred action buttons preset.', 'shopbuilder' ),
261 'options' => ControlHelper::action_btn_presets(),
262 'default' => 'preset1',
263 ];
264
265 $fields['action_btn_position'] = [
266 'type' => 'select2',
267 'label' => esc_html__( 'Action Buttons Position', 'shopbuilder' ),
268 'description' => esc_html__( 'Please select the action buttons position.', 'shopbuilder' ),
269 'options' => [
270 'above' => esc_html__( 'Floating Above Image', 'shopbuilder' ),
271 'after' => esc_html__( 'After Content', 'shopbuilder' ),
272 ],
273 'default' => 'above',
274 'label_block' => true,
275 'condition' => [
276 'action_btn_preset' => [ 'preset1', 'preset5' ],
277 'layout!' => [ 'grid-layout2', 'slider-layout2' ],
278 ],
279 ];
280
281 $fields['action_btn_gap'] = [
282 'type' => 'slider',
283 'mode' => 'responsive',
284 'label' => esc_html__( 'Action Buttons Gap / Spacing (px)', 'shopbuilder' ),
285 'size_units' => [ 'px' ],
286 'range' => [
287 'px' => [
288 'min' => 0,
289 'max' => 100,
290 'step' => 1,
291 ],
292 ],
293 'description' => esc_html__( 'Please select the action buttons gap in px.', 'shopbuilder' ),
294 'selectors' => [
295 $obj->selectors['action_buttons']['action_btn_gap'] => 'gap: {{SIZE}}{{UNIT}} !important;',
296 ],
297 ];
298
299 $fields['action_btn_alignment'] = [
300 'type' => 'choose',
301 'label' => esc_html__( 'Action Buttons Alignment', 'shopbuilder' ),
302 'description' => esc_html__( 'Please select the action buttons alignment.', 'shopbuilder' ),
303 'options' => [
304 'flex-start' => [
305 'title' => esc_html__( 'Left', 'shopbuilder' ),
306 'icon' => 'eicon-text-align-left',
307 ],
308 'center' => [
309 'title' => esc_html__( 'Center', 'shopbuilder' ),
310 'icon' => 'eicon-text-align-center',
311 ],
312 'flex-end' => [
313 'title' => esc_html__( 'Right', 'shopbuilder' ),
314 'icon' => 'eicon-text-align-right',
315 ],
316 ],
317 'toggle' => true,
318 'condition' => [
319 'action_btn_position' => [ 'after' ],
320 'action_btn_preset' => [ 'preset1' ],
321 ],
322 'selectors' => [
323 $obj->selectors['action_buttons']['action_btn_alignment'] => 'justify-content: {{VALUE}};',
324 ],
325 ];
326
327 $fields['action_btn_tooltip_position'] = [
328 'label' => esc_html__( 'Tooltip Position', 'shopbuilder' ),
329 'type' => 'choose',
330 'description' => esc_html__( 'Please choose the tooltip position', 'shopbuilder' ),
331 'options' => [
332 'top' => [
333 'title' => esc_html__( 'Top', 'shopbuilder' ),
334 'icon' => ' eicon-arrow-up',
335 ],
336 'right' => [
337 'title' => esc_html__( 'Right', 'shopbuilder' ),
338 'icon' => ' eicon-arrow-right',
339 ],
340 'bottom' => [
341 'title' => esc_html__( 'Bottom', 'shopbuilder' ),
342 'icon' => ' eicon-arrow-down',
343 ],
344 'left' => [
345 'title' => esc_html__( 'Left', 'shopbuilder' ),
346 'icon' => ' eicon-arrow-left',
347 ],
348 ],
349 'default' => 'top',
350 ];
351
352 return $fields;
353 }
354
355 /**
356 * Columns section
357 *
358 * @param object $obj Reference object.
359 *
360 * @return array
361 */
362 public static function structure( $obj ) {
363 $fields['cols'] = [
364 'type' => 'select2',
365 'mode' => 'responsive',
366 'label' => esc_html__( 'Number of Columns', 'shopbuilder' ),
367 'description' => esc_html__( 'Please select the number of columns to show per row.', 'shopbuilder' ),
368 'options' => ControlHelper::layout_columns(),
369 'label_block' => true,
370 'render_type' => 'template',
371 'default' => '0',
372 'tablet_default' => '2',
373 'mobile_default' => '1',
374 'required' => true,
375 'separator' => rtsb()->has_pro() ? 'default' : 'default elementor-control-separator-after',
376 'selectors' => [
377 $obj->selectors['columns']['cols'] => 'grid-template-columns: repeat({{VALUE}}, minmax(0, 1fr));',
378 $obj->selectors['columns']['masonry'] => '--rtsb-masonry-columns: {{VALUE}};',
379 $obj->selectors['columns']['list_masonry'] => '--rtsb-masonry-list-columns: {{VALUE}};',
380 ],
381 ];
382
383 $fields['grid_style'] = [
384 'type' => 'select2',
385 'label' => esc_html__( 'Layout Grid Style', 'shopbuilder' ),
386 'options' => [
387 'even' => esc_html__( 'Default', 'shopbuilder' ),
388 'masonry' => esc_html__( 'Masonry', 'shopbuilder' ),
389 'equal' => esc_html__( 'Equal Height', 'shopbuilder' ),
390 ],
391 'label_block' => true,
392 'default' => 'even',
393 'description' => esc_html__( 'Please select the layout grid style.', 'shopbuilder' ),
394 'classes' => $obj->pro_class(),
395 ];
396
397 $fields['image_width'] = [
398 'type' => 'slider',
399 'mode' => 'responsive',
400 'label' => esc_html__( 'Image Width', 'shopbuilder' ),
401 'size_units' => [ 'px','%' ],
402 'range' => [
403 '%' => [
404 'min' => 0,
405 'max' => 100,
406 'step' => 1,
407 ],
408 ],
409 'default' => [
410 'unit' => '%',
411 'size' => 32,
412 ],
413 'description' => esc_html__( 'Please select the image width in %.', 'shopbuilder' ),
414 'separator' => rtsb()->has_pro() ? 'default' : 'before',
415 'selectors' => [
416 $obj->selectors['columns']['image_width']['image'] => 'flex-basis: {{SIZE}}{{UNIT}}; max-width: {{SIZE}}{{UNIT}};',
417 // $obj->selectors['columns']['image_width']['content'] => 'flex-basis: calc(100% - {{SIZE}}{{UNIT}}); max-width: calc(100% - {{SIZE}}{{UNIT}});',
418 ],
419 'condition' => [ 'layout' => [ 'list-layout1', 'list-layout2', 'list-layout3', 'list-layout4','list-layout5','list-layout6','list-layout7' ] ],
420 ];
421
422 $fields['image_gap'] = [
423 'type' => 'slider',
424 'mode' => 'responsive',
425 'label' => esc_html__( 'Image Gap (px)', 'shopbuilder' ),
426 'size_units' => [ 'px' ],
427 'range' => [
428 'px' => [
429 'min' => 0,
430 'max' => 100,
431 'step' => 1,
432 ],
433 ],
434 'default' => [
435 'unit' => 'px',
436 'size' => 30,
437 ],
438 'description' => esc_html__( 'Please select the image gap in px.', 'shopbuilder' ),
439 'selectors' => [
440 $obj->selectors['columns']['image_gap'] => 'gap: {{SIZE}}{{UNIT}};',
441 ],
442 'condition' => [ 'layout' => [ 'list-layout1', 'list-layout2', 'list-layout3', 'list-layout4','list-layout5','list-layout6','list-layout7' ] ],
443 ];
444
445 $fields['v_action_btn_width'] = [
446 'type' => 'slider',
447 'mode' => 'responsive',
448 'label' => esc_html__( 'Vertical Action Buttons Width (px)', 'shopbuilder' ),
449 'size_units' => [ 'px' ],
450 'range' => [
451 'px' => [
452 'min' => 0,
453 'max' => 500,
454 'step' => 1,
455 ],
456 ],
457 'description' => esc_html__( 'Please select the vertical action buttons width in px.', 'shopbuilder' ),
458 'selectors' => [
459 $obj->selectors['columns']['v_action_btn_width'] => 'flex-basis: {{SIZE}}{{UNIT}};',
460 ],
461 'condition' => [ 'layout' => [ 'list-layout3' ] ],
462 ];
463
464 return apply_filters( 'rtsb/elements/elementor/columns_control', $fields, $obj );
465 }
466
467 /**
468 * Columns section
469 *
470 * @param object $obj Reference object.
471 *
472 * @return array
473 */
474 public static function structure_slider( $obj ) {
475 $fields['cols'] = [
476 'type' => 'select2',
477 'mode' => 'responsive',
478 'label' => esc_html__( 'Number of Slides (Columns) Per View', 'shopbuilder' ),
479 'description' => esc_html__( 'Please select the number of slides to show per view.', 'shopbuilder' ),
480 'options' => ControlHelper::layout_columns(),
481 'label_block' => true,
482 'default' => '0',
483 'tablet_default' => '2',
484 'mobile_default' => '1',
485 'required' => true,
486 'separator' => 'default elementor-control-separator-after',
487 ];
488
489 $fields['rows'] = [
490 'type' => 'select2',
491 'label' => esc_html__( 'Number of Product Rows', 'shopbuilder' ),
492 'description' => rtsb()->has_pro() ? esc_html__( 'Please select the number of slide rows. Slide Rows represents how many rows of slides will be displayed at once.', 'shopbuilder' ) : esc_html__( 'Please select the number of slide rows.', 'shopbuilder' ),
493 'options' => [
494 1 => esc_html__( 'Layout Default (1 Row)', 'shopbuilder' ),
495 2 => esc_html__( '2 Rows', 'shopbuilder' ),
496 3 => esc_html__( '3 Rows', 'shopbuilder' ),
497 4 => esc_html__( '4 Rows', 'shopbuilder' ),
498 5 => esc_html__( '5 Rows', 'shopbuilder' ),
499 ],
500 'label_block' => true,
501 'default' => '1',
502 'tablet_default' => '1',
503 'mobile_default' => '1',
504 'required' => true,
505 'classes' => $obj->pro_class(),
506 ];
507
508 $fields['cols_group'] = [
509 'type' => 'select2',
510 'mode' => 'responsive',
511 'label' => esc_html__( 'Number of Slides Per Group', 'shopbuilder' ),
512 'description' => rtsb()->has_pro() ? esc_html__( 'Please select the number of slides to show per group. Slides Per Group indicates how many slides will be transitioned at a time.', 'shopbuilder' ) : esc_html__( 'Please select the number of slides to show per group.', 'shopbuilder' ),
513 'options' => ControlHelper::layout_columns(),
514 'label_block' => true,
515 'default' => '0',
516 'tablet_default' => '2',
517 'mobile_default' => '1',
518 'required' => true,
519 'classes' => $obj->pro_class(),
520 ];
521
522 $fields['grid_style'] = [
523 'type' => 'select',
524 'label' => esc_html__( 'Layout Grid Style', 'shopbuilder' ),
525 'options' => [
526 'even' => esc_html__( 'Default', 'shopbuilder' ),
527 ],
528 'label_block' => true,
529 'default' => 'even',
530 'description' => esc_html__( 'Please select the layout grid style.', 'shopbuilder' ),
531 ];
532
533 $fields['image_width'] = [
534 'type' => 'slider',
535 'mode' => 'responsive',
536 'label' => esc_html__( 'Image Width', 'shopbuilder' ),
537 'size_units' => [ 'px','%' ],
538 'range' => [
539 '%' => [
540 'min' => 0,
541 'max' => 100,
542 'step' => 1,
543 ],
544 ],
545 'default' => [
546 'unit' => '%',
547 'size' => 32,
548 ],
549 'description' => esc_html__( 'Please select the image width in %.', 'shopbuilder' ),
550 'selectors' => [
551 $obj->selectors['columns']['image_width']['image'] => 'flex-basis: {{SIZE}}{{UNIT}}; max-width: {{SIZE}}{{UNIT}} !important;',
552 // $obj->selectors['columns']['image_width']['content'] => 'flex-basis: calc(100% - {{SIZE}}{{UNIT}}); max-width: calc(100% - {{SIZE}}{{UNIT}});',
553 ],
554 'condition' => [ 'layout' => [ 'slider-layout5' ] ],
555 ];
556
557 $fields['image_gap'] = [
558 'type' => 'slider',
559 'mode' => 'responsive',
560 'label' => esc_html__( 'Image Gap (px)', 'shopbuilder' ),
561 'size_units' => [ 'px' ],
562 'range' => [
563 'px' => [
564 'min' => 0,
565 'max' => 100,
566 'step' => 1,
567 ],
568 ],
569 'default' => [
570 'unit' => 'px',
571 'size' => 30,
572 ],
573 'description' => esc_html__( 'Please select the image gap in px.', 'shopbuilder' ),
574 'selectors' => [
575 $obj->selectors['columns']['image_gap'] => 'gap: {{SIZE}}{{UNIT}};',
576 ],
577 'condition' => [ 'layout' => [ 'slider-layout5' ] ],
578 ];
579
580 return apply_filters( 'rtsb/elements/elementor/columns_control', $fields, $obj );
581 }
582
583 /**
584 * Query section
585 *
586 * @param object $obj Reference object.
587 *
588 * @return array
589 */
590 public static function query( $obj ) {
591 $fields['query_section'] = $obj->start_section(
592 esc_html__( 'Query', 'shopbuilder' ),
593 self::$tab
594 );
595
596 $fields['query_note'] = $obj->el_heading( esc_html__( 'Common Filters', 'shopbuilder' ) );
597
598 $fields['include_posts'] = [
599 'type' => 'rt-select2',
600 'label' => esc_html__( 'Include Products', 'shopbuilder' ),
601 'description' => esc_html__( 'Please select the products to show. Leave it blank to include all products.', 'shopbuilder' ),
602 'source_name' => 'post_type',
603 'source_type' => 'product',
604 'multiple' => true,
605 'label_block' => true,
606 ];
607
608 $fields['exclude_posts'] = [
609 'type' => 'rt-select2',
610 'label' => esc_html__( 'Exclude Products', 'shopbuilder' ),
611 'description' => esc_html__( 'Please select the products to show. Leave it blank to exclude none.', 'shopbuilder' ),
612 'source_name' => 'post_type',
613 'source_type' => 'product',
614 'multiple' => true,
615 'label_block' => true,
616 ];
617
618 $fields['posts_limit'] = [
619 'type' => 'number',
620 'label' => esc_html__( 'Products Limit', 'shopbuilder' ),
621 'description' => esc_html__( 'The number of products to show. Set empty to show all products.', 'shopbuilder' ),
622 'default' => 12,
623 ];
624
625 $fields['posts_offset'] = [
626 'type' => 'number',
627 'label' => esc_html__( 'Products Offset', 'shopbuilder' ),
628 'description' => esc_html__( 'Number of products to skip.', 'shopbuilder' ),
629 ];
630
631 $fields['category_note'] = $obj->el_heading( esc_html__( 'Taxonomy Filters', 'shopbuilder' ), 'before' );
632
633 $fields['filter_categories'] = [
634 'type' => 'rt-select2',
635 'label' => esc_html__( 'Filter By Categories', 'shopbuilder' ),
636 'description' => esc_html__( 'Select the categories you want to filter, Leave it blank for all categories.', 'shopbuilder' ),
637 'source_name' => 'taxonomy',
638 'source_type' => 'product_cat',
639 'multiple' => true,
640 'label_block' => true,
641 'minimum_input_length' => 1,
642 ];
643
644 $fields['filter_tags'] = [
645 'type' => 'rt-select2',
646 'label' => esc_html__( 'Filter By Tags', 'shopbuilder' ),
647 'description' => esc_html__( 'Select the tags you want to filter, Leave it blank for all tags.', 'shopbuilder' ),
648 'source_name' => 'taxonomy',
649 'source_type' => 'product_tag',
650 'multiple' => true,
651 'label_block' => true,
652 'minimum_input_length' => 1,
653 ];
654
655 $fields['filter_attributes'] = [
656 'type' => 'select2',
657 'label' => esc_html__( 'Filter By Attributes', 'shopbuilder' ),
658 'description' => esc_html__( 'Select the attributes you want to filter, Leave it blank for all attributes.', 'shopbuilder' ),
659 'options' => Fns::get_all_attributes(),
660 'multiple' => true,
661 'label_block' => true,
662 'condition' => [ 'tax_filter!' => [ 'yes' ] ],
663 ];
664
665 $fields['tax_relation'] = [
666 'type' => 'select2',
667 'label' => esc_html__( 'Taxonomy relation', 'shopbuilder' ),
668 'options' => [
669 'OR' => 'Show All Products (OR)',
670 'AND' => 'Show Common Products (AND)',
671 ],
672 'default' => 'AND',
673 'description' => esc_html__( 'Select the taxonomies relationship. It is applicable if you select more than one taxonomy.', 'shopbuilder' ),
674 'label_block' => true,
675 ];
676
677 $fields['advanced_note'] = $obj->el_heading( esc_html__( 'Advanced Filters', 'shopbuilder' ), 'before' );
678
679 $fields['filter_author'] = [
680 'type' => 'rt-select2',
681 'label' => esc_html__( 'Filter By Author', 'shopbuilder' ),
682 'description' => esc_html__( 'Select the author you want to filter, Leave it blank for all author.', 'shopbuilder' ),
683 'source_name' => 'user',
684 'multiple' => true,
685 'label_block' => true,
686 'minimum_input_length' => 1,
687 'separator' => rtsb()->has_pro() ? 'default' : 'default elementor-control-separator-after',
688 ];
689
690 $fields['products_filter'] = [
691 'type' => 'select2',
692 'label' => esc_html__( 'Display Products By:', 'shopbuilder' ),
693 'options' => ControlHelper::filter_products(),
694 'default' => rtsb()->has_pro() ? 'recent' : 'best-selling',
695 'description' => esc_html__( 'Please select the conditional display of products.', 'shopbuilder' ),
696 'label_block' => true,
697 'classes' => $obj->pro_class(),
698 ];
699
700 $fields['sorting_note'] = $obj->el_heading( esc_html__( 'Sorting', 'shopbuilder' ), 'before' );
701
702 $fields['posts_order_by'] = [
703 'type' => 'select2',
704 'label' => esc_html__( 'Order By', 'shopbuilder' ),
705 'options' => ControlHelper::posts_order_by(),
706 'default' => 'date',
707 ];
708
709 if ( rtsb()->has_pro() ) {
710 $fields['products_filter']['condition'] = [ 'ajax_filter_type' => [ 'taxonomy' ] ];
711 $fields['posts_order_by']['condition'] = [
712 'ajax_filter_type' => [ 'taxonomy' ],
713 'products_filter' => 'recent',
714 ];
715 }
716
717 $fields['posts_order'] = [
718 'type' => 'select2',
719 'label' => esc_html__( 'Order', 'shopbuilder' ),
720 'options' => ControlHelper::posts_order(),
721 'default' => 'DESC',
722 ];
723
724 $fields['query_section_end'] = $obj->end_section();
725
726 return apply_filters( 'rtsb/elements/elementor/query_control', $fields, $obj );
727 }
728
729 /**
730 * Query section
731 *
732 * @param object $obj Reference object.
733 *
734 * @return array
735 */
736 public static function additional_query( $obj ) {
737 $fields['query_section'] = $obj->start_section(
738 esc_html__( 'Query', 'shopbuilder' ),
739 self::$tab
740 );
741
742 $fields['query_note'] = $obj->el_heading( esc_html__( 'Common Filters', 'shopbuilder' ) );
743
744 $fields['posts_limit'] = [
745 'type' => 'number',
746 'label' => esc_html__( 'Products Limit', 'shopbuilder' ),
747 'description' => esc_html__( 'The number of products to show. Set empty to show all products.', 'shopbuilder' ),
748 'default' => 12,
749 ];
750
751 $fields['sorting_note'] = $obj->el_heading( esc_html__( 'Sorting', 'shopbuilder' ), 'before' );
752
753 $fields['posts_order_by'] = [
754 'type' => 'select2',
755 'label' => esc_html__( 'Order By', 'shopbuilder' ),
756 'description' => esc_html__( 'Please choose to reorder products.', 'shopbuilder' ),
757 'options' => ControlHelper::posts_order_by(),
758 'default' => 'date',
759 ];
760
761 $fields['posts_order'] = [
762 'type' => 'select2',
763 'label' => esc_html__( 'Order', 'shopbuilder' ),
764 'description' => esc_html__( 'Please choose to reorder products.', 'shopbuilder' ),
765 'options' => ControlHelper::posts_order(),
766 'default' => 'DESC',
767 ];
768
769 $fields['query_section_end'] = $obj->end_section();
770
771 return apply_filters( 'rtsb/elements/elementor/query_control', $fields, $obj );
772 }
773
774 /**
775 * Category Query section
776 *
777 * @param object $obj Reference object.
778 *
779 * @return array
780 */
781 public static function cat_single_query( $obj ) {
782 $fields['query_section'] = $obj->start_section(
783 esc_html__( 'Query', 'shopbuilder' ),
784 self::$tab
785 );
786
787 $fields['select_source'] = [
788 'type' => 'select2',
789 'label' => esc_html__( 'Select Taxonomy', 'shopbuilder' ),
790 'options' => Fns::get_tax_list(),
791 'description' => esc_html__( 'Please select the taxonomy.', 'shopbuilder' ),
792 'label_block' => true,
793 'default' => 'product_cat',
794 ];
795
796 $fields['select_cat'] = [
797 'type' => 'rt-select2',
798 'label' => esc_html__( 'Choose Category', 'shopbuilder' ),
799 'source_name' => 'taxonomy',
800 'source_type' => 'product_cat',
801 'description' => esc_html__( 'Please select the category to show.', 'shopbuilder' ),
802 'label_block' => true,
803 'minimum_input_length' => 1,
804 'condition' => [
805 'select_source' => [ 'product_cat' ],
806 ],
807 ];
808
809 $fields['select_tag'] = [
810 'type' => 'rt-select2',
811 'label' => esc_html__( 'Choose Tag', 'shopbuilder' ),
812 'source_name' => 'taxonomy',
813 'source_type' => 'product_tag',
814 'description' => esc_html__( 'Please select the tag to show.', 'shopbuilder' ),
815 'label_block' => true,
816 'minimum_input_length' => 1,
817 'condition' => [
818 'select_source' => [ 'product_tag' ],
819 ],
820 ];
821
822 $fields['query_section_end'] = $obj->end_section();
823
824 return apply_filters( 'rtsb/elements/elementor/cat_single_query_control', $fields, $obj );
825 }
826
827 /**
828 * Category Query section
829 *
830 * @param object $obj Reference object.
831 *
832 * @return array
833 */
834 public static function cat_query( $obj ) {
835 $fields['query_section'] = $obj->start_section(
836 esc_html__( 'Query', 'shopbuilder' ),
837 self::$tab
838 );
839
840 $fields['query_note'] = $obj->el_heading( esc_html__( 'Filter', 'shopbuilder' ) );
841
842 $fields['display_cat_by'] = [
843 'type' => 'select2',
844 'label' => esc_html__( 'Display Categories By:', 'shopbuilder' ),
845 'options' => Fns::get_cat_list(),
846 'description' => esc_html__( 'Please select what categories will be displayed.', 'shopbuilder' ),
847 'label_block' => true,
848 'default' => 'all',
849 ];
850
851 $fields['select_parent_cat'] = [
852 'type' => 'rt-select2',
853 'label' => esc_html__( 'Select Parent Category', 'shopbuilder' ),
854 'source_name' => 'taxonomy',
855 'source_type' => 'product_cat',
856 'minimum_input_length' => 1,
857 'description' => esc_html__( 'Please select the parent category to show.', 'shopbuilder' ),
858 'label_block' => true,
859 'default' => Fns::get_terms( 'product_cat', true, true ),
860 'condition' => [ 'display_cat_by' => [ 'specific_parent' ] ],
861 ];
862
863 $fields['include_cats'] = [
864 'type' => 'rt-select2',
865 'label' => esc_html__( 'Select Categories', 'shopbuilder' ),
866 'source_name' => 'taxonomy',
867 'source_type' => 'product_cat',
868 'description' => esc_html__( 'Please select the categories to show.', 'shopbuilder' ),
869 'label_block' => true,
870 'multiple' => true,
871 'minimum_input_length' => 1,
872 'condition' => [ 'display_cat_by' => [ 'selection' ] ],
873 ];
874
875 $fields['include_cat_ids'] = [
876 'type' => 'text',
877 'label' => esc_html__( 'Enter Category IDs', 'shopbuilder' ),
878 'description' => esc_html__( 'Please enter the category IDs separated by comma.', 'shopbuilder' ),
879 'label_block' => true,
880 'condition' => [ 'display_cat_by' => [ 'cat_ids' ] ],
881 ];
882
883 $fields['exclude_cats'] = [
884 'type' => 'rt-select2',
885 'label' => esc_html__( 'Exclude Categories', 'shopbuilder' ),
886 'source_name' => 'taxonomy',
887 'source_type' => 'product_cat',
888 'description' => esc_html__( 'Please select the categories to exclude. Leave it blank to exclude none.', 'shopbuilder' ),
889 'multiple' => true,
890 'minimum_input_length' => 1,
891 'label_block' => true,
892 'condition' => [ 'display_cat_by' => [ 'all' ] ],
893 ];
894
895 $fields['cats_limit'] = [
896 'type' => 'number',
897 'label' => esc_html__( 'Categories Limit', 'shopbuilder' ),
898 'description' => esc_html__( 'The number of categories to show. Set empty to show all categories.', 'shopbuilder' ),
899 'condition' => [ 'display_cat_by!' => [ 'selection' ] ],
900 ];
901
902 $fields['show_top_level_cats'] = [
903 'type' => 'switch',
904 'label' => __( 'Show only Top Level <br /> Sub-Categories?', 'shopbuilder' ),
905 'description' => esc_html__( 'Switch on to display only first level sub-categories.', 'shopbuilder' ),
906 'label_on' => esc_html__( 'On', 'shopbuilder' ),
907 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
908 'condition' => [ 'display_cat_by' => [ 'specific_parent' ] ],
909 ];
910
911 $fields['show_empty'] = [
912 'type' => 'switch',
913 'label' => esc_html__( 'Show Empty Categories?', 'shopbuilder' ),
914 'description' => esc_html__( 'Switch on to display empty categories.', 'shopbuilder' ),
915 'label_on' => esc_html__( 'On', 'shopbuilder' ),
916 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
917 'default' => 'yes',
918 ];
919
920 $fields['show_uncategorized'] = [
921 'type' => 'switch',
922 'label' => __( 'Show Uncategorized <br />(Or Default Category)?', 'shopbuilder' ),
923 'description' => esc_html__( 'Switch on to display uncategorized.', 'shopbuilder' ),
924 'label_on' => esc_html__( 'On', 'shopbuilder' ),
925 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
926 'default' => 'yes',
927 'condition' => [ 'display_cat_by' => [ 'all' ] ],
928 ];
929
930 $fields['show_subcats'] = [
931 'type' => 'switch',
932 'label' => esc_html__( 'Show Sub-Categories?', 'shopbuilder' ),
933 'description' => esc_html__( 'Switch on to display subcategories.', 'shopbuilder' ),
934 'label_on' => esc_html__( 'On', 'shopbuilder' ),
935 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
936 'default' => 'yes',
937 'condition' => [ 'display_cat_by' => [ 'all' ] ],
938 ];
939
940 $fields['sorting_note'] = $obj->el_heading( esc_html__( 'Sorting', 'shopbuilder' ), 'before' );
941
942 $fields['cats_order_by'] = [
943 'type' => 'select2',
944 'label' => esc_html__( 'Order By', 'shopbuilder' ),
945 'description' => esc_html__( 'Please choose to reorder categories.', 'shopbuilder' ),
946 'options' => ControlHelper::cats_order_by(),
947 'default' => 'name',
948 ];
949
950 $fields['cats_order'] = [
951 'type' => 'select2',
952 'label' => esc_html__( 'Order', 'shopbuilder' ),
953 'description' => esc_html__( 'Please choose to reorder categories.', 'shopbuilder' ),
954 'options' => ControlHelper::posts_order(),
955 'default' => 'ASC',
956 ];
957
958 $fields['query_section_end'] = $obj->end_section();
959
960 return apply_filters( 'rtsb/elements/elementor/cat_query_control', $fields, $obj );
961 }
962
963 /**
964 * Pagination section
965 *
966 * @param object $obj Reference object.
967 *
968 * @return array
969 */
970 public static function pagination( $obj ) {
971 $fields['pagination_section'] = $obj->start_section(
972 esc_html__( 'Pagination', 'shopbuilder' ),
973 self::$tab,
974 [],
975 rtsb()->has_pro() ? [ 'tax_filter!' => [ 'yes' ] ] : []
976 );
977
978 $fields['show_pagination'] = [
979 'type' => 'switch',
980 'label' => esc_html__( 'Enable Pagination?', 'shopbuilder' ),
981 'description' => esc_html__( 'Switch on to enable pagination.', 'shopbuilder' ),
982 'label_on' => esc_html__( 'On', 'shopbuilder' ),
983 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
984 ];
985
986 $fields['pagination_per_page'] = [
987 'type' => 'number',
988 'label' => esc_html__( 'Number of Posts Per Page', 'shopbuilder' ),
989 'default' => 8,
990 'description' => esc_html__( 'Please enter the number of products per page to show.', 'shopbuilder' ),
991 'condition' => [ 'show_pagination' => [ 'yes' ] ],
992 ];
993
994 $pagination_description = esc_html__( 'Please choose the pagination type', 'shopbuilder' );
995
996 if ( ! rtsb()->has_pro() ) {
997 $upgrade_link = '<span class="elementor-pro-notice"><a target="_blank" href="' . esc_url( rtsb()->pro_version_link() ) . '">Upgrade to PRO</a> to unlock Load More and Ajax Pagination.</span>';
998 $pagination_description .= $upgrade_link;
999 }
1000
1001 $fields['pagination_type'] = [
1002 'type' => 'select',
1003 'label' => esc_html__( 'Pagination Type', 'shopbuilder' ),
1004 'description' => $pagination_description,
1005 'options' => ControlHelper::pagination_options(),
1006 'default' => 'pagination',
1007 'label_block' => true,
1008 'condition' => [ 'show_pagination' => [ 'yes' ] ],
1009 ];
1010
1011 $fields['pagination_section_end'] = $obj->end_section();
1012
1013 return apply_filters( 'rtsb/elementor/pagination_control', $fields, $obj );
1014 }
1015
1016 /**
1017 * Filter section
1018 *
1019 * @param object $obj Reference object.
1020 *
1021 * @return array
1022 */
1023 public static function filter( $obj ) {
1024 $fields['filter_section'] = $obj->start_section(
1025 esc_html__( 'Ajax Tab Filters', 'shopbuilder' ),
1026 self::$tab,
1027 );
1028
1029 $fields['filter_note'] = [
1030 'type' => 'html',
1031 'raw' => '',
1032 'content_classes' => 'elementor-panel-heading-title',
1033 ];
1034
1035 $fields['tax_filter'] = [
1036 'type' => 'switch',
1037 'label' => esc_html__( 'Enable Ajax Tab Filter Buttons?', 'shopbuilder' ),
1038 'description' => esc_html__( 'Switch on to enable Ajax tab filter buttons.', 'shopbuilder' ),
1039 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1040 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1041 'separator' => $obj->pro_class(),
1042 'classes' => $obj->pro_class(),
1043 ];
1044
1045 $fields['filter_section_end'] = $obj->end_section();
1046
1047 return apply_filters( 'rtsb/elementor/filter_control', $fields, $obj );
1048 }
1049 }
1050