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

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