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

1,229 lines 38.9 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 /**
463 * Columns section
464 *
465 * @param object $obj Reference object.
466 *
467 * @return array
468 */
469 public static function structure_slider( $obj ) {
470 $fields['cols'] = [
471 'type' => 'select2',
472 'mode' => 'responsive',
473 'label' => esc_html__( 'Number of Slides Per View', 'shopbuilder' ),
474 'description' => esc_html__( 'Please select the number of slides to show per view.', 'shopbuilder' ),
475 'options' => ControlHelper::layout_columns(),
476 'label_block' => true,
477 'default' => '0',
478 'tablet_default' => '2',
479 'mobile_default' => '1',
480 'required' => true,
481 'separator' => 'default elementor-control-separator-after',
482 ];
483
484 $fields['rows'] = [
485 'type' => 'select2',
486 'label' => esc_html__( 'Number of Product Rows', 'shopbuilder' ),
487 'description' => esc_html__( 'Please select the number of product rows.', 'shopbuilder' ),
488 'options' => [
489 1 => esc_html__( 'Layout Default (1 Row)', 'shopbuilder' ),
490 2 => esc_html__( '2 Rows', 'shopbuilder' ),
491 3 => esc_html__( '3 Rows', 'shopbuilder' ),
492 4 => esc_html__( '4 Rows', 'shopbuilder' ),
493 5 => esc_html__( '5 Rows', 'shopbuilder' ),
494 ],
495 'label_block' => true,
496 'default' => '1',
497 'tablet_default' => '1',
498 'mobile_default' => '1',
499 'required' => true,
500 'classes' => $obj->pro_class(),
501 ];
502
503 $fields['cols_group'] = [
504 'type' => 'select2',
505 'mode' => 'responsive',
506 'label' => esc_html__( 'Number of Slides Per Group', 'shopbuilder' ),
507 'description' => esc_html__( 'Please select the number of slides to show per group.', 'shopbuilder' ),
508 'options' => ControlHelper::layout_columns(),
509 'label_block' => true,
510 'default' => '0',
511 'tablet_default' => '2',
512 'mobile_default' => '1',
513 'required' => true,
514 'classes' => $obj->pro_class(),
515 ];
516
517 $fields['image_width'] = [
518 'type' => 'slider',
519 'mode' => 'responsive',
520 'label' => esc_html__( 'Image Width', 'shopbuilder' ),
521 'size_units' => [ 'px','%' ],
522 'range' => [
523 '%' => [
524 'min' => 0,
525 'max' => 100,
526 'step' => 1,
527 ],
528 ],
529 'default' => [
530 'unit' => '%',
531 'size' => 32,
532 ],
533 'description' => esc_html__( 'Please select the image width in %.', 'shopbuilder' ),
534 'selectors' => [
535 $obj->selectors['columns']['image_width']['image'] => 'flex-basis: {{SIZE}}{{UNIT}}; max-width: {{SIZE}}{{UNIT}} !important;',
536 // $obj->selectors['columns']['image_width']['content'] => 'flex-basis: calc(100% - {{SIZE}}{{UNIT}}); max-width: calc(100% - {{SIZE}}{{UNIT}});',
537 ],
538 'condition' => [ 'layout' => [ 'slider-layout5' ] ],
539 ];
540
541 $fields['image_gap'] = [
542 'type' => 'slider',
543 'mode' => 'responsive',
544 'label' => esc_html__( 'Image Gap (px)', 'shopbuilder' ),
545 'size_units' => [ 'px' ],
546 'range' => [
547 'px' => [
548 'min' => 0,
549 'max' => 100,
550 'step' => 1,
551 ],
552 ],
553 'default' => [
554 'unit' => 'px',
555 'size' => 30,
556 ],
557 'description' => esc_html__( 'Please select the image gap in px.', 'shopbuilder' ),
558 'selectors' => [
559 $obj->selectors['columns']['image_gap'] => 'gap: {{SIZE}}{{UNIT}};',
560 ],
561 'condition' => [ 'layout' => [ 'slider-layout5' ] ],
562 ];
563
564 return apply_filters( 'rtsb/elements/elementor/columns_control', $fields, $obj );
565 }
566
567 /**
568 * Query section
569 *
570 * @param object $obj Reference object.
571 *
572 * @return array
573 */
574 public static function query( $obj ) {
575 $fields['query_section'] = $obj->start_section(
576 esc_html__( 'Query', 'shopbuilder' ),
577 self::$tab
578 );
579
580 $fields['query_note'] = $obj->el_heading( esc_html__( 'Common Filters', 'shopbuilder' ) );
581
582 $fields['include_posts'] = [
583 'type' => 'rt-select2',
584 'label' => esc_html__( 'Include Products', 'shopbuilder' ),
585 'description' => esc_html__( 'Please select the products to show. Leave it blank to include all products.', 'shopbuilder' ),
586 'source_name' => 'post_type',
587 'source_type' => 'product',
588 'multiple' => true,
589 'label_block' => true,
590 ];
591
592 $fields['exclude_posts'] = [
593 'type' => 'rt-select2',
594 'label' => esc_html__( 'Exclude Products', 'shopbuilder' ),
595 'description' => esc_html__( 'Please select the products to show. Leave it blank to exclude none.', 'shopbuilder' ),
596 'source_name' => 'post_type',
597 'source_type' => 'product',
598 'multiple' => true,
599 'label_block' => true,
600 ];
601
602 $fields['posts_limit'] = [
603 'type' => 'number',
604 'label' => esc_html__( 'Products Limit', 'shopbuilder' ),
605 'description' => esc_html__( 'The number of products to show. Set empty to show all products.', 'shopbuilder' ),
606 'default' => 12,
607 ];
608
609 $fields['posts_offset'] = [
610 'type' => 'number',
611 'label' => esc_html__( 'Products Offset', 'shopbuilder' ),
612 'description' => esc_html__( 'Number of products to skip.', 'shopbuilder' ),
613 ];
614
615 $fields['category_note'] = $obj->el_heading( esc_html__( 'Taxonomy Filters', 'shopbuilder' ), 'before' );
616
617 $fields['filter_categories'] = [
618 'type' => 'rt-select2',
619 'label' => esc_html__( 'Filter By Categories', 'shopbuilder' ),
620 'description' => esc_html__( 'Select the categories you want to filter, Leave it blank for all categories.', 'shopbuilder' ),
621 'source_name' => 'taxonomy',
622 'source_type' => 'product_cat',
623 'multiple' => true,
624 'label_block' => true,
625 'minimum_input_length' => 1,
626 ];
627
628 $fields['filter_tags'] = [
629 'type' => 'rt-select2',
630 'label' => esc_html__( 'Filter By Tags', 'shopbuilder' ),
631 'description' => esc_html__( 'Select the tags you want to filter, Leave it blank for all tags.', 'shopbuilder' ),
632 'source_name' => 'taxonomy',
633 'source_type' => 'product_tag',
634 'multiple' => true,
635 'label_block' => true,
636 'minimum_input_length' => 1,
637 ];
638
639 $fields['filter_attributes'] = [
640 'type' => 'select2',
641 'label' => esc_html__( 'Filter By Attributes', 'shopbuilder' ),
642 'description' => esc_html__( 'Select the attributes you want to filter, Leave it blank for all attributes.', 'shopbuilder' ),
643 'options' => Fns::get_all_attributes(),
644 'multiple' => true,
645 'label_block' => true,
646 'condition' => [ 'tax_filter!' => [ 'yes' ] ],
647 ];
648
649 $fields['tax_relation'] = [
650 'type' => 'select2',
651 'label' => esc_html__( 'Taxonomy relation', 'shopbuilder' ),
652 'options' => [
653 'OR' => 'Show All Products (OR)',
654 'AND' => 'Show Common Products (AND)',
655 ],
656 'default' => 'AND',
657 'description' => esc_html__( 'Select the taxonomies relationship. It is applicable if you select more than one taxonomy.', 'shopbuilder' ),
658 'label_block' => true,
659 ];
660
661 $fields['advanced_note'] = $obj->el_heading( esc_html__( 'Advanced Filters', 'shopbuilder' ), 'before' );
662
663 $fields['filter_author'] = [
664 'type' => 'rt-select2',
665 'label' => esc_html__( 'Filter By Author', 'shopbuilder' ),
666 'description' => esc_html__( 'Select the author you want to filter, Leave it blank for all author.', 'shopbuilder' ),
667 'source_name' => 'user',
668 'multiple' => true,
669 'label_block' => true,
670 'minimum_input_length' => 1,
671 'separator' => rtsb()->has_pro() ? 'default' : 'default elementor-control-separator-after',
672 ];
673
674 $fields['products_filter'] = [
675 'type' => 'select2',
676 'label' => esc_html__( 'Display Products By:', 'shopbuilder' ),
677 'options' => ControlHelper::filter_products(),
678 'default' => rtsb()->has_pro() ? 'recent' : 'best-selling',
679 'description' => esc_html__( 'Please select the conditional display of products.', 'shopbuilder' ),
680 'label_block' => true,
681 'classes' => $obj->pro_class(),
682 ];
683
684 $fields['sorting_note'] = $obj->el_heading( esc_html__( 'Sorting', 'shopbuilder' ), 'before' );
685
686 $fields['posts_order_by'] = [
687 'type' => 'select2',
688 'label' => esc_html__( 'Order By', 'shopbuilder' ),
689 'options' => ControlHelper::posts_order_by(),
690 'default' => 'date',
691 ];
692
693 if ( rtsb()->has_pro() ) {
694 $fields['posts_order_by']['condition'] = [ 'products_filter' => 'recent' ];
695 }
696
697 $fields['posts_order'] = [
698 'type' => 'select2',
699 'label' => esc_html__( 'Order', 'shopbuilder' ),
700 'options' => ControlHelper::posts_order(),
701 'default' => 'DESC',
702 ];
703
704 $fields['query_section_end'] = $obj->end_section();
705
706 return apply_filters( 'rtsb/elements/elementor/query_control', $fields, $obj );
707 }
708
709 /**
710 * Query section
711 *
712 * @param object $obj Reference object.
713 *
714 * @return array
715 */
716 public static function additional_query( $obj ) {
717 $fields['query_section'] = $obj->start_section(
718 esc_html__( 'Query', 'shopbuilder' ),
719 self::$tab
720 );
721
722 $fields['query_note'] = $obj->el_heading( esc_html__( 'Common Filters', 'shopbuilder' ) );
723
724 $fields['posts_limit'] = [
725 'type' => 'number',
726 'label' => esc_html__( 'Products Limit', 'shopbuilder' ),
727 'description' => esc_html__( 'The number of products to show. Set empty to show all products.', 'shopbuilder' ),
728 'default' => 12,
729 ];
730
731 $fields['sorting_note'] = $obj->el_heading( esc_html__( 'Sorting', 'shopbuilder' ), 'before' );
732
733 $fields['posts_order_by'] = [
734 'type' => 'select2',
735 'label' => esc_html__( 'Order By', 'shopbuilder' ),
736 'description' => esc_html__( 'Please choose to reorder products.', 'shopbuilder' ),
737 'options' => ControlHelper::posts_order_by(),
738 'default' => 'date',
739 ];
740
741 $fields['posts_order'] = [
742 'type' => 'select2',
743 'label' => esc_html__( 'Order', 'shopbuilder' ),
744 'description' => esc_html__( 'Please choose to reorder products.', 'shopbuilder' ),
745 'options' => ControlHelper::posts_order(),
746 'default' => 'DESC',
747 ];
748
749 $fields['query_section_end'] = $obj->end_section();
750
751 return apply_filters( 'rtsb/elements/elementor/query_control', $fields, $obj );
752 }
753
754 /**
755 * Category Query section
756 *
757 * @param object $obj Reference object.
758 *
759 * @return array
760 */
761 public static function cat_single_query( $obj ) {
762 $fields['query_section'] = $obj->start_section(
763 esc_html__( 'Query', 'shopbuilder' ),
764 self::$tab
765 );
766
767 $fields['select_source'] = [
768 'type' => 'select2',
769 'label' => esc_html__( 'Select Taxonomy', 'shopbuilder' ),
770 'options' => Fns::get_tax_list(),
771 'description' => esc_html__( 'Please select the taxonomy.', 'shopbuilder' ),
772 'label_block' => true,
773 'default' => 'product_cat',
774 ];
775
776 $fields['select_cat'] = [
777 'type' => 'rt-select2',
778 'label' => esc_html__( 'Choose Category', 'shopbuilder' ),
779 'source_name' => 'taxonomy',
780 'source_type' => 'product_cat',
781 'description' => esc_html__( 'Please select the category to show.', 'shopbuilder' ),
782 'label_block' => true,
783 'minimum_input_length' => 1,
784 'condition' => [
785 'select_source' => [ 'product_cat' ],
786 ],
787 ];
788
789 $fields['select_tag'] = [
790 'type' => 'rt-select2',
791 'label' => esc_html__( 'Choose Tag', 'shopbuilder' ),
792 'source_name' => 'taxonomy',
793 'source_type' => 'product_tag',
794 'description' => esc_html__( 'Please select the tag to show.', 'shopbuilder' ),
795 'label_block' => true,
796 'minimum_input_length' => 1,
797 'condition' => [
798 'select_source' => [ 'product_tag' ],
799 ],
800 ];
801
802 $fields['query_section_end'] = $obj->end_section();
803
804 return apply_filters( 'rtsb/elements/elementor/cat_single_query_control', $fields, $obj );
805 }
806
807 /**
808 * Category Query section
809 *
810 * @param object $obj Reference object.
811 *
812 * @return array
813 */
814 public static function cat_query( $obj ) {
815 $fields['query_section'] = $obj->start_section(
816 esc_html__( 'Query', 'shopbuilder' ),
817 self::$tab
818 );
819
820 $fields['query_note'] = $obj->el_heading( esc_html__( 'Filter', 'shopbuilder' ) );
821
822 $fields['display_cat_by'] = [
823 'type' => 'select2',
824 'label' => esc_html__( 'Display Categories By:', 'shopbuilder' ),
825 'options' => Fns::get_cat_list(),
826 'description' => esc_html__( 'Please select what categories will be displayed.', 'shopbuilder' ),
827 'label_block' => true,
828 'default' => 'all',
829 ];
830
831 $fields['select_parent_cat'] = [
832 'type' => 'rt-select2',
833 'label' => esc_html__( 'Select Parent Category', 'shopbuilder' ),
834 'source_name' => 'taxonomy',
835 'source_type' => 'product_cat',
836 'minimum_input_length' => 1,
837 'description' => esc_html__( 'Please select the parent category to show.', 'shopbuilder' ),
838 'label_block' => true,
839 'default' => Fns::get_terms( 'product_cat', true, true ),
840 'condition' => [ 'display_cat_by' => [ 'specific_parent' ] ],
841 ];
842
843 $fields['include_cats'] = [
844 'type' => 'rt-select2',
845 'label' => esc_html__( 'Select Categories', 'shopbuilder' ),
846 'source_name' => 'taxonomy',
847 'source_type' => 'product_cat',
848 'description' => esc_html__( 'Please select the categories to show.', 'shopbuilder' ),
849 'label_block' => true,
850 'multiple' => true,
851 'minimum_input_length' => 1,
852 'condition' => [ 'display_cat_by' => [ 'selection' ] ],
853 ];
854
855 $fields['include_cat_ids'] = [
856 'type' => 'text',
857 'label' => esc_html__( 'Enter Category IDs', 'shopbuilder' ),
858 'description' => esc_html__( 'Please enter the category IDs separated by comma.', 'shopbuilder' ),
859 'label_block' => true,
860 'condition' => [ 'display_cat_by' => [ 'cat_ids' ] ],
861 ];
862
863 $fields['exclude_cats'] = [
864 'type' => 'rt-select2',
865 'label' => esc_html__( 'Exclude Categories', 'shopbuilder' ),
866 'source_name' => 'taxonomy',
867 'source_type' => 'product_cat',
868 'description' => esc_html__( 'Please select the categories to exclude. Leave it blank to exclude none.', 'shopbuilder' ),
869 'multiple' => true,
870 'minimum_input_length' => 1,
871 'label_block' => true,
872 'condition' => [ 'display_cat_by' => [ 'all' ] ],
873 ];
874
875 $fields['cats_limit'] = [
876 'type' => 'number',
877 'label' => esc_html__( 'Categories Limit', 'shopbuilder' ),
878 'description' => esc_html__( 'The number of categories to show. Set empty to show all categories.', 'shopbuilder' ),
879 'condition' => [ 'display_cat_by!' => [ 'selection' ] ],
880 ];
881
882 $fields['show_top_level_cats'] = [
883 'type' => 'switch',
884 'label' => __( 'Show only Top Level <br /> Sub-Categories?', 'shopbuilder' ),
885 'description' => esc_html__( 'Switch on to display only first level sub-categories.', 'shopbuilder' ),
886 'label_on' => esc_html__( 'On', 'shopbuilder' ),
887 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
888 'condition' => [ 'display_cat_by' => [ 'specific_parent' ] ],
889 ];
890
891 $fields['show_empty'] = [
892 'type' => 'switch',
893 'label' => esc_html__( 'Show Empty Categories?', 'shopbuilder' ),
894 'description' => esc_html__( 'Switch on to display empty categories.', 'shopbuilder' ),
895 'label_on' => esc_html__( 'On', 'shopbuilder' ),
896 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
897 'default' => 'yes',
898 ];
899
900 $fields['show_uncategorized'] = [
901 'type' => 'switch',
902 'label' => __( 'Show Uncategorized <br />(Or Default Category)?', 'shopbuilder' ),
903 'description' => esc_html__( 'Switch on to display uncategorized.', 'shopbuilder' ),
904 'label_on' => esc_html__( 'On', 'shopbuilder' ),
905 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
906 'default' => 'yes',
907 'condition' => [ 'display_cat_by' => [ 'all' ] ],
908 ];
909
910 $fields['show_subcats'] = [
911 'type' => 'switch',
912 'label' => esc_html__( 'Show Sub-Categories?', 'shopbuilder' ),
913 'description' => esc_html__( 'Switch on to display subcategories.', 'shopbuilder' ),
914 'label_on' => esc_html__( 'On', 'shopbuilder' ),
915 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
916 'default' => 'yes',
917 'condition' => [ 'display_cat_by' => [ 'all' ] ],
918 ];
919
920 $fields['sorting_note'] = $obj->el_heading( esc_html__( 'Sorting', 'shopbuilder' ), 'before' );
921
922 $fields['cats_order_by'] = [
923 'type' => 'select2',
924 'label' => esc_html__( 'Order By', 'shopbuilder' ),
925 'description' => esc_html__( 'Please choose to reorder categories.', 'shopbuilder' ),
926 'options' => ControlHelper::cats_order_by(),
927 'default' => 'name',
928 ];
929
930 $fields['cats_order'] = [
931 'type' => 'select2',
932 'label' => esc_html__( 'Order', 'shopbuilder' ),
933 'description' => esc_html__( 'Please choose to reorder categories.', 'shopbuilder' ),
934 'options' => ControlHelper::posts_order(),
935 'default' => 'ASC',
936 ];
937
938 $fields['query_section_end'] = $obj->end_section();
939
940 return apply_filters( 'rtsb/elements/elementor/cat_query_control', $fields, $obj );
941 }
942
943 /**
944 * Pagination section
945 *
946 * @param object $obj Reference object.
947 *
948 * @return array
949 */
950 public static function pagination( $obj ) {
951 $fields['pagination_section'] = $obj->start_section(
952 esc_html__( 'Pagination', 'shopbuilder' ),
953 self::$tab,
954 [],
955 rtsb()->has_pro() ? [ 'tax_filter!' => [ 'yes' ] ] : []
956 );
957
958 $fields['show_pagination'] = [
959 'type' => 'switch',
960 'label' => esc_html__( 'Enable Pagination?', 'shopbuilder' ),
961 'description' => esc_html__( 'Switch on to enable pagination.', 'shopbuilder' ),
962 'label_on' => esc_html__( 'On', 'shopbuilder' ),
963 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
964 ];
965
966 $fields['pagination_per_page'] = [
967 'type' => 'number',
968 'label' => esc_html__( 'Number of Posts Per Page', 'shopbuilder' ),
969 'default' => 8,
970 'description' => esc_html__( 'Please enter the number of team members per page to show.', 'shopbuilder' ),
971 'condition' => [ 'show_pagination' => [ 'yes' ] ],
972 ];
973
974 $pagination_description = esc_html__( 'Please choose the pagination type', 'shopbuilder' );
975
976 if ( ! rtsb()->has_pro() ) {
977 $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' );
978 }
979
980 $fields['pagination_type'] = [
981 'type' => 'select',
982 'label' => esc_html__( 'Pagination Type', 'shopbuilder' ),
983 'description' => $pagination_description,
984 'options' => ControlHelper::pagination_options(),
985 'default' => 'pagination',
986 'label_block' => true,
987 'condition' => [ 'show_pagination' => [ 'yes' ] ],
988 ];
989
990 $fields['pagination_section_end'] = $obj->end_section();
991
992 return apply_filters( 'rtsb/elementor/pagination_control', $fields, $obj );
993 }
994
995 /**
996 * Filter section
997 *
998 * @param object $obj Reference object.
999 *
1000 * @return array
1001 */
1002 public static function filter( $obj ) {
1003 $fields['filter_section'] = $obj->start_section(
1004 esc_html__( 'Ajax Tab Filters', 'shopbuilder' ),
1005 self::$tab,
1006 );
1007
1008 $fields['filter_note'] = [
1009 'type' => 'html',
1010 'raw' => '',
1011 'content_classes' => 'elementor-panel-heading-title',
1012 ];
1013
1014 $fields['tax_filter'] = [
1015 'type' => 'switch',
1016 'label' => esc_html__( 'Enable Taxonomy Filter Button?', 'shopbuilder' ),
1017 'description' => esc_html__( 'Switch on to enable taxonomy filter button.', 'shopbuilder' ),
1018 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1019 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1020 'separator' => $obj->pro_class(),
1021 'classes' => $obj->pro_class(),
1022 ];
1023
1024 $fields['filter_section_end'] = $obj->end_section();
1025
1026 return apply_filters( 'rtsb/elementor/filter_control', $fields, $obj );
1027 }
1028
1029 /**
1030 * Category Image section
1031 *
1032 * @param object $obj Reference object.
1033 *
1034 * @return array
1035 */
1036 public static function cat_image( $obj ) {
1037 $fields['cat_image_section'] = $obj->start_section(
1038 esc_html__( 'Image', 'shopbuilder' ),
1039 self::$tab
1040 );
1041
1042 $fields['show_cat_image'] = [
1043 'type' => 'switch',
1044 'label' => esc_html__( 'Display Category Image?', 'shopbuilder' ),
1045 'description' => esc_html__( 'Switch on to display category image.', 'shopbuilder' ),
1046 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1047 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1048 'default' => 'yes',
1049 ];
1050
1051 $fields['show_custom_image'] = [
1052 'type' => 'switch',
1053 'label' => esc_html__( 'Add Custom Image?', 'shopbuilder' ),
1054 'description' => esc_html__( 'Switch on to select a custom category image. Setting a custom image will override the category image.', 'shopbuilder' ),
1055 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1056 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1057 'classes' => $obj->pro_class(),
1058 'separator' => rtsb()->has_pro() ? 'before-short' : 'default',
1059 'condition' => [ 'layout' => [ 'category-single-layout1' ] ],
1060 ];
1061
1062 $fields['custom_image'] = [
1063 'type' => 'media',
1064 'label' => esc_html__( 'Upload Custom Image', 'shopbuilder' ),
1065 'description' => esc_html__( 'Please choose the custom category image.', 'shopbuilder' ),
1066 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1067 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1068 'condition' => [ 'show_custom_image' => [ 'yes' ] ],
1069 'default' => [
1070 'url' => \Elementor\Utils::get_placeholder_image_src(),
1071 ],
1072 ];
1073
1074 $fields['show_overlay'] = [
1075 'type' => 'switch',
1076 'label' => esc_html__( 'Enable Image Overlay?', 'shopbuilder' ),
1077 'description' => esc_html__( 'Switch on to enable image overlay.', 'shopbuilder' ),
1078 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1079 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1080 'separator' => rtsb()->has_pro() ? 'default' : 'before',
1081 'condition' => [
1082 'layout' => [ 'category-single-layout1' ],
1083 ],
1084 ];
1085
1086 // TODO:: Will be implemented later.
1087 // $fields['show_custom_icon'] = [
1088 // 'type' => 'switch',
1089 // 'label' => esc_html__( 'Enable Custom Icons?', 'shopbuilder' ),
1090 // 'description' => esc_html__( 'Switch on to enable custom icons instead of category images.', 'shopbuilder' ),
1091 // 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1092 // 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1093 // 'condition' => [ 'layout!' => [ 'category-single-layout1' ] ],
1094 // 'classes' => $obj->pro_class(),
1095 // 'separator' => rtsb()->has_pro() ? 'before-short' : 'default',
1096 // ];
1097 //
1098 // $all_categories = Fns::get_terms( 'product_cat', false, false, true );
1099 //
1100 // foreach ( $all_categories as $cat_id => $category ) {
1101 // $fields[ 'custom_icon_' . $cat_id ] = [
1102 // 'type' => 'icons',
1103 // 'label' => sprintf(
1104 // * translators: Category name */
1105 // __( 'Choose Icon for Category: %s', 'shopbuilder' ),
1106 // esc_html( $category )
1107 // ),
1108 // 'condition' => [
1109 // 'show_custom_icon' => [ 'yes' ],
1110 // 'layout!' => [ 'category-single-layout1' ],
1111 // ],
1112 // ];
1113 // }
1114
1115 $fields['cat_image_size_note'] = $obj->el_heading(
1116 esc_html__( 'Image Size', 'shopbuilder' ),
1117 'before',
1118 [],
1119 [ 'show_cat_image' => [ 'yes' ] ]
1120 );
1121
1122 $fields = array_merge( $fields, self::image_size_controls( 'catgory' ) );
1123
1124 $fields['cat_image_section_end'] = $obj->end_section();
1125
1126 return apply_filters( 'rtsb/elements/elementor/cat_image_control', $fields, $obj );
1127 }
1128
1129 /**
1130 * Image Size Controls.
1131 *
1132 * @param string $type Type.
1133 *
1134 * @return array
1135 */
1136 public static function image_size_controls( $type ) {
1137 $conditions = [
1138 'relation' => 'and',
1139 'terms' => [],
1140 ];
1141
1142 if ( 'grid' === $type ) {
1143 $conditions['terms'][] = [
1144 'relation' => 'or',
1145 'terms' => [
1146 [
1147 'name' => 'show_featured_image',
1148 'operator' => '==',
1149 'value' => 'yes',
1150 ],
1151 ],
1152 ];
1153 } else {
1154 $conditions['terms'][] = [
1155 'relation' => 'or',
1156 'terms' => [
1157 [
1158 'name' => 'show_cat_image',
1159 'operator' => '==',
1160 'value' => 'yes',
1161 ],
1162 [
1163 'name' => 'show_custom_image',
1164 'operator' => '==',
1165 'value' => 'yes',
1166 ],
1167 ],
1168 ];
1169 }
1170
1171 $fields['image'] = [
1172 'type' => 'select2',
1173 'label' => esc_html__( 'Select Image Size', 'shopbuilder' ),
1174 'description' => esc_html__( 'Please select the image size.', 'shopbuilder' ),
1175 'options' => Fns::get_image_sizes(),
1176 'default' => 'woocommerce_thumbnail',
1177 'label_block' => true,
1178 'content_classes' => 'elementor-descriptor',
1179 'conditions' => $conditions,
1180 ];
1181
1182 $conditions['terms'][] = [
1183 'relation' => 'or',
1184 'terms' => [
1185 [
1186 'name' => 'image',
1187 'operator' => '==',
1188 'value' => 'rtsb_custom',
1189 ],
1190 ],
1191 ];
1192
1193 $fields['image_custom_dimension'] = [
1194 'type' => 'image-dimensions',
1195 'label' => esc_html__( 'Enter Custom Image Size', 'shopbuilder' ),
1196 'label_block' => true,
1197 'show_label' => true,
1198 'default' => [
1199 'width' => 400,
1200 'height' => 400,
1201 ],
1202 'conditions' => $conditions,
1203 ];
1204
1205 $fields['image_crop'] = [
1206 'type' => 'select2',
1207 'label' => esc_html__( 'Image Crop', 'shopbuilder' ),
1208 'description' => esc_html__( 'Please click on "Apply" to update the image.', 'shopbuilder' ),
1209 'options' => [
1210 'soft' => esc_html__( 'Soft Crop', 'shopbuilder' ),
1211 'hard' => esc_html__( 'Hard Crop', 'shopbuilder' ),
1212 ],
1213 'default' => 'hard',
1214 'conditions' => $conditions,
1215 ];
1216
1217 $fields['image_custom_dimension_note'] = [
1218 'type' => 'html',
1219 'raw' => sprintf(
1220 '<span style="display: block; background: #fffbf1; padding: 10px; font-weight: 500; line-height: 1.4; color: #bd3a3a;border: 1px solid #bd3a3a;">%s</span>',
1221 esc_html__( 'Please note that, if you enter image size larger than the actual image iteself, the image sizes will fallback to the full image dimension.', 'shopbuilder' )
1222 ),
1223 'conditions' => $conditions,
1224 ];
1225
1226 return $fields;
1227 }
1228 }
1229