PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.3
ShopBuilder – WooCommerce Builder For Elementor v3.2.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 3.2.3, at app/Elementor/Widgets/Controls/LayoutFields.php

1,070 lines 34.6 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 ],
418 'condition' => [ 'layout' => [ 'list-layout1', 'list-layout2', 'list-layout3', 'list-layout4','list-layout5','list-layout6','list-layout7' ] ],
419 ];
420
421 $fields['image_gap'] = [
422 'type' => 'slider',
423 'mode' => 'responsive',
424 'label' => esc_html__( 'Image Gap (px)', 'shopbuilder' ),
425 'size_units' => [ 'px' ],
426 'range' => [
427 'px' => [
428 'min' => 0,
429 'max' => 100,
430 'step' => 1,
431 ],
432 ],
433 'default' => [
434 'unit' => 'px',
435 'size' => 30,
436 ],
437 'description' => esc_html__( 'Please select the image gap in px.', 'shopbuilder' ),
438 'selectors' => [
439 $obj->selectors['columns']['image_gap'] => 'gap: {{SIZE}}{{UNIT}};',
440 ],
441 'condition' => [ 'layout' => [ 'list-layout1', 'list-layout2', 'list-layout3', 'list-layout4','list-layout5','list-layout6','list-layout7' ] ],
442 ];
443
444 $fields['v_action_btn_width'] = [
445 'type' => 'slider',
446 'mode' => 'responsive',
447 'label' => esc_html__( 'Vertical Action Buttons Width (px)', 'shopbuilder' ),
448 'size_units' => [ 'px' ],
449 'range' => [
450 'px' => [
451 'min' => 0,
452 'max' => 500,
453 'step' => 1,
454 ],
455 ],
456 'description' => esc_html__( 'Please select the vertical action buttons width in px.', 'shopbuilder' ),
457 'selectors' => [
458 $obj->selectors['columns']['v_action_btn_width'] => 'flex-basis: {{SIZE}}{{UNIT}};',
459 ],
460 'condition' => [ 'layout' => [ 'list-layout3' ] ],
461 ];
462
463 return apply_filters( 'rtsb/elements/elementor/columns_control', $fields, $obj );
464 }
465
466 /**
467 * Columns section
468 *
469 * @param object $obj Reference object.
470 *
471 * @return array
472 */
473 public static function structure_slider( $obj ) {
474 $fields['cols'] = [
475 'type' => 'select2',
476 'mode' => 'responsive',
477 'label' => esc_html__( 'Number of Slides (Columns) Per View', 'shopbuilder' ),
478 'description' => esc_html__( 'Please select the number of slides to show per view.', 'shopbuilder' ),
479 'options' => ControlHelper::layout_columns(),
480 'label_block' => true,
481 'default' => '0',
482 'tablet_default' => '2',
483 'mobile_default' => '1',
484 'required' => true,
485 'separator' => 'default elementor-control-separator-after',
486 ];
487
488 $fields['rows'] = [
489 'type' => 'select2',
490 'label' => esc_html__( 'Number of Product Rows', 'shopbuilder' ),
491 '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' ),
492 'options' => [
493 1 => esc_html__( 'Layout Default (1 Row)', 'shopbuilder' ),
494 2 => esc_html__( '2 Rows', 'shopbuilder' ),
495 3 => esc_html__( '3 Rows', 'shopbuilder' ),
496 4 => esc_html__( '4 Rows', 'shopbuilder' ),
497 5 => esc_html__( '5 Rows', 'shopbuilder' ),
498 ],
499 'label_block' => true,
500 'default' => '1',
501 'tablet_default' => '1',
502 'mobile_default' => '1',
503 'required' => true,
504 'classes' => $obj->pro_class(),
505 ];
506
507 $fields['cols_group'] = [
508 'type' => 'select2',
509 'mode' => 'responsive',
510 'label' => esc_html__( 'Number of Slides Per Group', 'shopbuilder' ),
511 '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' ),
512 'options' => ControlHelper::layout_columns(),
513 'label_block' => true,
514 'default' => '0',
515 'tablet_default' => '2',
516 'mobile_default' => '1',
517 'required' => true,
518 'classes' => $obj->pro_class(),
519 ];
520
521 $fields['grid_style'] = [
522 'type' => 'select',
523 'label' => esc_html__( 'Layout Grid Style', 'shopbuilder' ),
524 'options' => [
525 'even' => esc_html__( 'Default', 'shopbuilder' ),
526 ],
527 'label_block' => true,
528 'default' => 'even',
529 'description' => esc_html__( 'Please select the layout grid style.', 'shopbuilder' ),
530 ];
531
532 $fields['image_width'] = [
533 'type' => 'slider',
534 'mode' => 'responsive',
535 'label' => esc_html__( 'Image Width', 'shopbuilder' ),
536 'size_units' => [ 'px','%' ],
537 'range' => [
538 '%' => [
539 'min' => 0,
540 'max' => 100,
541 'step' => 1,
542 ],
543 ],
544 'default' => [
545 'unit' => '%',
546 'size' => 32,
547 ],
548 'description' => esc_html__( 'Please select the image width in %.', 'shopbuilder' ),
549 'selectors' => [
550 $obj->selectors['columns']['image_width']['image'] => 'flex-basis: {{SIZE}}{{UNIT}}; max-width: {{SIZE}}{{UNIT}} !important;',
551 ],
552 'condition' => [ 'layout' => [ 'slider-layout5' ] ],
553 ];
554
555 $fields['image_gap'] = [
556 'type' => 'slider',
557 'mode' => 'responsive',
558 'label' => esc_html__( 'Image Gap (px)', 'shopbuilder' ),
559 'size_units' => [ 'px' ],
560 'range' => [
561 'px' => [
562 'min' => 0,
563 'max' => 100,
564 'step' => 1,
565 ],
566 ],
567 'default' => [
568 'unit' => 'px',
569 'size' => 30,
570 ],
571 'description' => esc_html__( 'Please select the image gap in px.', 'shopbuilder' ),
572 'selectors' => [
573 $obj->selectors['columns']['image_gap'] => 'gap: {{SIZE}}{{UNIT}};',
574 ],
575 'condition' => [ 'layout' => [ 'slider-layout5' ] ],
576 ];
577
578 return apply_filters( 'rtsb/elements/elementor/columns_control', $fields, $obj );
579 }
580
581 /**
582 * Query section
583 *
584 * @param object $obj Reference object.
585 *
586 * @return array
587 */
588 public static function query( $obj ) {
589 $fields['query_section'] = $obj->start_section(
590 esc_html__( 'Query', 'shopbuilder' ),
591 self::$tab
592 );
593
594 $fields['query_note'] = $obj->el_heading( esc_html__( 'Common Filters', 'shopbuilder' ) );
595
596 $fields['include_posts'] = [
597 'type' => 'rt-select2',
598 'label' => esc_html__( 'Include Products', 'shopbuilder' ),
599 'description' => esc_html__( 'Please select the products to show. Leave it blank to include all products.', 'shopbuilder' ),
600 'source_name' => 'post_type',
601 'source_type' => 'product',
602 'multiple' => true,
603 'label_block' => true,
604 ];
605
606 $fields['exclude_posts'] = [
607 'type' => 'rt-select2',
608 'label' => esc_html__( 'Exclude Products', 'shopbuilder' ),
609 'description' => esc_html__( 'Please select the products to show. Leave it blank to exclude none.', 'shopbuilder' ),
610 'source_name' => 'post_type',
611 'source_type' => 'product',
612 'multiple' => true,
613 'label_block' => true,
614 ];
615
616 $fields['posts_limit'] = [
617 'type' => 'number',
618 'label' => esc_html__( 'Products Limit', 'shopbuilder' ),
619 'description' => esc_html__( 'The number of products to show. Set empty to show all products.', 'shopbuilder' ),
620 'default' => 12,
621 ];
622
623 $fields['posts_offset'] = [
624 'type' => 'number',
625 'label' => esc_html__( 'Products Offset', 'shopbuilder' ),
626 'description' => esc_html__( 'Number of products to skip.', 'shopbuilder' ),
627 ];
628
629 $fields['category_note'] = $obj->el_heading( esc_html__( 'Taxonomy Filters', 'shopbuilder' ), 'before' );
630
631 $fields['filter_categories'] = [
632 'type' => 'rt-select2',
633 'label' => esc_html__( 'Filter By Categories', 'shopbuilder' ),
634 'description' => esc_html__( 'Select the categories you want to filter, Leave it blank for all categories.', 'shopbuilder' ),
635 'source_name' => 'taxonomy',
636 'source_type' => 'product_cat',
637 'multiple' => true,
638 'label_block' => true,
639 'minimum_input_length' => 1,
640 ];
641
642 $fields['filter_tags'] = [
643 'type' => 'rt-select2',
644 'label' => esc_html__( 'Filter By Tags', 'shopbuilder' ),
645 'description' => esc_html__( 'Select the tags you want to filter, Leave it blank for all tags.', 'shopbuilder' ),
646 'source_name' => 'taxonomy',
647 'source_type' => 'product_tag',
648 'multiple' => true,
649 'label_block' => true,
650 'minimum_input_length' => 1,
651 ];
652 $fields['filter_brands'] = [
653 'type' => 'rt-select2',
654 'label' => esc_html__( 'Filter By Brand', 'shopbuilder' ),
655 'description' => esc_html__( 'Select the tags you want to filter, Leave it blank for all brands.', 'shopbuilder' ),
656 'source_name' => 'taxonomy',
657 'source_type' => 'product_brand',
658 'multiple' => true,
659 'label_block' => true,
660 'minimum_input_length' => 1,
661 ];
662
663 $fields['filter_attributes'] = [
664 'type' => 'select2',
665 'label' => esc_html__( 'Filter By Attributes', 'shopbuilder' ),
666 'description' => esc_html__( 'Select the attributes you want to filter, Leave it blank for all attributes.', 'shopbuilder' ),
667 'options' => Fns::get_all_attributes(),
668 'multiple' => true,
669 'label_block' => true,
670 ];
671
672 $fields['tax_relation'] = [
673 'type' => 'select2',
674 'label' => esc_html__( 'Taxonomy relation', 'shopbuilder' ),
675 'options' => [
676 'OR' => 'Show All Products (OR)',
677 'AND' => 'Show Common Products (AND)',
678 ],
679 'default' => 'AND',
680 'label_block' => true,
681 ];
682
683 $fields['advanced_note'] = $obj->el_heading( esc_html__( 'Advanced Filters', 'shopbuilder' ), 'before' );
684
685 $fields['filter_author'] = [
686 'type' => 'rt-select2',
687 'label' => esc_html__( 'Filter By Author', 'shopbuilder' ),
688 'description' => esc_html__( 'Select the author you want to filter, Leave it blank for all author.', 'shopbuilder' ),
689 'source_name' => 'user',
690 'multiple' => true,
691 'label_block' => true,
692 'minimum_input_length' => 1,
693 'separator' => rtsb()->has_pro() ? 'default' : 'default elementor-control-separator-after',
694 ];
695
696 $fields['products_filter'] = [
697 'type' => 'select2',
698 'label' => esc_html__( 'Display Products By:', 'shopbuilder' ),
699 'options' => ControlHelper::filter_products(),
700 'default' => rtsb()->has_pro() ? 'recent' : 'best-selling',
701 'description' => esc_html__( 'Please select the conditional display of products.', 'shopbuilder' ),
702 'label_block' => true,
703 'classes' => $obj->pro_class(),
704 ];
705
706 $fields['sorting_note'] = $obj->el_heading( esc_html__( 'Sorting', 'shopbuilder' ), 'before' );
707
708 $fields['posts_order_by'] = [
709 'type' => 'select2',
710 'label' => esc_html__( 'Order By', 'shopbuilder' ),
711 'options' => ControlHelper::posts_order_by(),
712 'default' => 'date',
713 ];
714
715 if ( rtsb()->has_pro() ) {
716 $fields['products_filter']['condition'] = [ 'ajax_filter_type' => [ 'taxonomy' ] ];
717 $fields['posts_order_by']['condition'] = [
718 'ajax_filter_type' => [ 'taxonomy' ],
719 'products_filter' => 'recent',
720 ];
721 }
722
723 $fields['posts_order'] = [
724 'type' => 'select2',
725 'label' => esc_html__( 'Order', 'shopbuilder' ),
726 'options' => ControlHelper::posts_order(),
727 'default' => 'DESC',
728 ];
729
730 $fields['query_section_end'] = $obj->end_section();
731
732 return apply_filters( 'rtsb/elements/elementor/query_control', $fields, $obj );
733 }
734
735 /**
736 * Query section
737 *
738 * @param object $obj Reference object.
739 *
740 * @return array
741 */
742 public static function additional_query( $obj ) {
743 $fields['query_section'] = $obj->start_section(
744 esc_html__( 'Query', 'shopbuilder' ),
745 self::$tab
746 );
747
748 $fields['query_note'] = $obj->el_heading( esc_html__( 'Common Filters', 'shopbuilder' ) );
749
750 $fields['posts_limit'] = [
751 'type' => 'number',
752 'label' => esc_html__( 'Products Limit', 'shopbuilder' ),
753 'description' => esc_html__( 'The number of products to show. Set empty to show all products.', 'shopbuilder' ),
754 'default' => 12,
755 ];
756
757 $fields['sorting_note'] = $obj->el_heading( esc_html__( 'Sorting', 'shopbuilder' ), 'before' );
758
759 $fields['posts_order_by'] = [
760 'type' => 'select2',
761 'label' => esc_html__( 'Order By', 'shopbuilder' ),
762 'description' => esc_html__( 'Please choose to reorder products.', 'shopbuilder' ),
763 'options' => ControlHelper::posts_order_by(),
764 'default' => 'date',
765 ];
766
767 $fields['posts_order'] = [
768 'type' => 'select2',
769 'label' => esc_html__( 'Order', 'shopbuilder' ),
770 'description' => esc_html__( 'Please choose to reorder products.', 'shopbuilder' ),
771 'options' => ControlHelper::posts_order(),
772 'default' => 'DESC',
773 ];
774
775 $fields['query_section_end'] = $obj->end_section();
776
777 return apply_filters( 'rtsb/elements/elementor/query_control', $fields, $obj );
778 }
779
780 /**
781 * Category Query section
782 *
783 * @param object $obj Reference object.
784 *
785 * @return array
786 */
787 public static function cat_single_query( $obj ) {
788 $all_tag_list = Fns::get_tax_list();
789 unset( $all_tag_list['product_attr'] );
790 $fields['query_section'] = $obj->start_section(
791 esc_html__( 'Query', 'shopbuilder' ),
792 self::$tab
793 );
794
795 $fields['select_source'] = [
796 'type' => 'select2',
797 'label' => esc_html__( 'Select Taxonomy', 'shopbuilder' ),
798 'options' => $all_tag_list,
799 'description' => esc_html__( 'Please select the taxonomy.', 'shopbuilder' ),
800 'label_block' => true,
801 'default' => 'product_cat',
802 ];
803
804 $fields['select_cat'] = [
805 'type' => 'rt-select2',
806 'label' => esc_html__( 'Choose Category', 'shopbuilder' ),
807 'source_name' => 'taxonomy',
808 'source_type' => 'product_cat',
809 'description' => esc_html__( 'Please select the category to show.', 'shopbuilder' ),
810 'label_block' => true,
811 'minimum_input_length' => 1,
812 'condition' => [
813 'select_source' => [ 'product_cat' ],
814 ],
815 ];
816
817 $fields['select_tag'] = [
818 'type' => 'rt-select2',
819 'label' => esc_html__( 'Choose Tag', 'shopbuilder' ),
820 'source_name' => 'taxonomy',
821 'source_type' => 'product_tag',
822 'description' => esc_html__( 'Please select the tag to show.', 'shopbuilder' ),
823 'label_block' => true,
824 'minimum_input_length' => 1,
825 'condition' => [
826 'select_source' => [ 'product_tag' ],
827 ],
828 ];
829 $fields['select_brand'] = [
830 'type' => 'rt-select2',
831 'label' => esc_html__( 'Choose Brand', 'shopbuilder' ),
832 'source_name' => 'taxonomy',
833 'source_type' => 'product_brand',
834 'description' => esc_html__( 'Please select the brand to show.', 'shopbuilder' ),
835 'label_block' => true,
836 'minimum_input_length' => 1,
837 'condition' => [
838 'select_source' => [ 'product_brand' ],
839 ],
840 ];
841
842 $fields['query_section_end'] = $obj->end_section();
843
844 return apply_filters( 'rtsb/elements/elementor/cat_single_query_control', $fields, $obj );
845 }
846
847 /**
848 * Category Query section
849 *
850 * @param object $obj Reference object.
851 *
852 * @return array
853 */
854 public static function cat_query( $obj ) {
855 $fields['query_section'] = $obj->start_section(
856 esc_html__( 'Query', 'shopbuilder' ),
857 self::$tab
858 );
859
860 $fields['query_note'] = $obj->el_heading( esc_html__( 'Filter', 'shopbuilder' ) );
861
862 $fields['display_cat_by'] = [
863 'type' => 'select2',
864 'label' => esc_html__( 'Display Categories By:', 'shopbuilder' ),
865 'options' => Fns::get_cat_list(),
866 'description' => esc_html__( 'Please select what categories will be displayed.', 'shopbuilder' ),
867 'label_block' => true,
868 'default' => 'all',
869 ];
870
871 $fields['select_parent_cat'] = [
872 'type' => 'rt-select2',
873 'label' => esc_html__( 'Select Parent Category', 'shopbuilder' ),
874 'source_name' => 'taxonomy',
875 'source_type' => 'product_cat',
876 'minimum_input_length' => 1,
877 'description' => esc_html__( 'Please select the parent category to show.', 'shopbuilder' ),
878 'label_block' => true,
879 'default' => Fns::get_terms( 'product_cat', true, true ),
880 'condition' => [ 'display_cat_by' => [ 'specific_parent' ] ],
881 ];
882
883 $fields['include_cats'] = [
884 'type' => 'rt-select2',
885 'label' => esc_html__( 'Select Categories', 'shopbuilder' ),
886 'source_name' => 'taxonomy',
887 'source_type' => 'product_cat',
888 'description' => esc_html__( 'Please select the categories to show.', 'shopbuilder' ),
889 'label_block' => true,
890 'multiple' => true,
891 'minimum_input_length' => 1,
892 'condition' => [ 'display_cat_by' => [ 'selection' ] ],
893 ];
894
895 $fields['include_cat_ids'] = [
896 'type' => 'text',
897 'label' => esc_html__( 'Enter Category IDs', 'shopbuilder' ),
898 'description' => esc_html__( 'Please enter the category IDs separated by comma.', 'shopbuilder' ),
899 'label_block' => true,
900 'condition' => [ 'display_cat_by' => [ 'cat_ids' ] ],
901 ];
902
903 $fields['exclude_cats'] = [
904 'type' => 'rt-select2',
905 'label' => esc_html__( 'Exclude Categories', 'shopbuilder' ),
906 'source_name' => 'taxonomy',
907 'source_type' => 'product_cat',
908 'description' => esc_html__( 'Please select the categories to exclude. Leave it blank to exclude none.', 'shopbuilder' ),
909 'multiple' => true,
910 'minimum_input_length' => 1,
911 'label_block' => true,
912 'condition' => [ 'display_cat_by' => [ 'all' ] ],
913 ];
914
915 $fields['cats_limit'] = [
916 'type' => 'number',
917 'label' => esc_html__( 'Categories Limit', 'shopbuilder' ),
918 'description' => esc_html__( 'The number of categories to show. Set empty to show all categories.', 'shopbuilder' ),
919 'condition' => [ 'display_cat_by!' => [ 'selection' ] ],
920 ];
921
922 $fields['show_top_level_cats'] = [
923 'type' => 'switch',
924 'label' => __( 'Show only Top Level <br /> Sub-Categories?', 'shopbuilder' ),
925 'description' => esc_html__( 'Switch on to display only first level sub-categories.', 'shopbuilder' ),
926 'label_on' => esc_html__( 'On', 'shopbuilder' ),
927 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
928 'condition' => [ 'display_cat_by' => [ 'specific_parent' ] ],
929 ];
930
931 $fields['show_empty'] = [
932 'type' => 'switch',
933 'label' => esc_html__( 'Show Empty Categories?', 'shopbuilder' ),
934 'description' => esc_html__( 'Switch on to display empty categories.', 'shopbuilder' ),
935 'label_on' => esc_html__( 'On', 'shopbuilder' ),
936 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
937 'default' => 'yes',
938 ];
939
940 $fields['show_uncategorized'] = [
941 'type' => 'switch',
942 'label' => __( 'Show Uncategorized <br />(Or Default Category)?', 'shopbuilder' ),
943 'description' => esc_html__( 'Switch on to display uncategorized.', 'shopbuilder' ),
944 'label_on' => esc_html__( 'On', 'shopbuilder' ),
945 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
946 'default' => 'yes',
947 'condition' => [ 'display_cat_by' => [ 'all' ] ],
948 ];
949
950 $fields['show_subcats'] = [
951 'type' => 'switch',
952 'label' => esc_html__( 'Show Sub-Categories?', 'shopbuilder' ),
953 'description' => esc_html__( 'Switch on to display subcategories.', 'shopbuilder' ),
954 'label_on' => esc_html__( 'On', 'shopbuilder' ),
955 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
956 'default' => 'yes',
957 'condition' => [ 'display_cat_by' => [ 'all' ] ],
958 ];
959
960 $fields['sorting_note'] = $obj->el_heading( esc_html__( 'Sorting', 'shopbuilder' ), 'before' );
961
962 $fields['cats_order_by'] = [
963 'type' => 'select2',
964 'label' => esc_html__( 'Order By', 'shopbuilder' ),
965 'description' => esc_html__( 'Please choose to reorder categories.', 'shopbuilder' ),
966 'options' => ControlHelper::cats_order_by(),
967 'default' => 'name',
968 ];
969
970 $fields['cats_order'] = [
971 'type' => 'select2',
972 'label' => esc_html__( 'Order', 'shopbuilder' ),
973 'description' => esc_html__( 'Please choose to reorder categories.', 'shopbuilder' ),
974 'options' => ControlHelper::posts_order(),
975 'default' => 'ASC',
976 ];
977
978 $fields['query_section_end'] = $obj->end_section();
979
980 return apply_filters( 'rtsb/elements/elementor/cat_query_control', $fields, $obj );
981 }
982
983 /**
984 * Pagination section
985 *
986 * @param object $obj Reference object.
987 *
988 * @return array
989 */
990 public static function pagination( $obj ) {
991 $fields['pagination_section'] = $obj->start_section(
992 esc_html__( 'Pagination', 'shopbuilder' ),
993 self::$tab,
994 [],
995 rtsb()->has_pro() ? [ 'tax_filter!' => [ 'yes' ] ] : []
996 );
997
998 $fields['show_pagination'] = [
999 'type' => 'switch',
1000 'label' => esc_html__( 'Enable Pagination?', 'shopbuilder' ),
1001 'description' => esc_html__( 'Switch on to enable pagination.', 'shopbuilder' ),
1002 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1003 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1004 ];
1005
1006 $fields['pagination_per_page'] = [
1007 'type' => 'number',
1008 'label' => esc_html__( 'Number of Posts Per Page', 'shopbuilder' ),
1009 'default' => 8,
1010 'description' => esc_html__( 'Please enter the number of products per page to show.', 'shopbuilder' ),
1011 'condition' => [ 'show_pagination' => [ 'yes' ] ],
1012 ];
1013
1014 $pagination_description = esc_html__( 'Please choose the pagination type', 'shopbuilder' );
1015
1016 if ( ! rtsb()->has_pro() ) {
1017 $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>';
1018 $pagination_description .= $upgrade_link;
1019 }
1020
1021 $fields['pagination_type'] = [
1022 'type' => 'select',
1023 'label' => esc_html__( 'Pagination Type', 'shopbuilder' ),
1024 'description' => $pagination_description,
1025 'options' => ControlHelper::pagination_options(),
1026 'default' => 'pagination',
1027 'label_block' => true,
1028 'condition' => [ 'show_pagination' => [ 'yes' ] ],
1029 ];
1030
1031 $fields['pagination_section_end'] = $obj->end_section();
1032
1033 return apply_filters( 'rtsb/elementor/pagination_control', $fields, $obj );
1034 }
1035
1036 /**
1037 * Filter section
1038 *
1039 * @param object $obj Reference object.
1040 *
1041 * @return array
1042 */
1043 public static function filter( $obj ) {
1044 $fields['filter_section'] = $obj->start_section(
1045 esc_html__( 'Ajax Tab Filters', 'shopbuilder' ),
1046 self::$tab,
1047 );
1048
1049 $fields['filter_note'] = [
1050 'type' => 'html',
1051 'raw' => '',
1052 'content_classes' => 'elementor-panel-heading-title',
1053 ];
1054
1055 $fields['tax_filter'] = [
1056 'type' => 'switch',
1057 'label' => esc_html__( 'Enable Ajax Tab Filter Buttons?', 'shopbuilder' ),
1058 'description' => esc_html__( 'Switch on to enable Ajax tab filter buttons.', 'shopbuilder' ),
1059 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1060 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1061 'separator' => $obj->pro_class(),
1062 'classes' => $obj->pro_class(),
1063 ];
1064
1065 $fields['filter_section_end'] = $obj->end_section();
1066
1067 return apply_filters( 'rtsb/elementor/filter_control', $fields, $obj );
1068 }
1069 }
1070