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

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

1,225 lines 38.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' ] ],
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' ] ],
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}};',
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' => 'OR',
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' => '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 $fields['posts_order'] = [
694 'type' => 'select2',
695 'label' => esc_html__( 'Order', 'shopbuilder' ),
696 'options' => ControlHelper::posts_order(),
697 'default' => 'DESC',
698 ];
699
700 $fields['query_section_end'] = $obj->end_section();
701
702 return apply_filters( 'rtsb/elements/elementor/query_control', $fields, $obj );
703 }
704
705 /**
706 * Query section
707 *
708 * @param object $obj Reference object.
709 *
710 * @return array
711 */
712 public static function additional_query( $obj ) {
713 $fields['query_section'] = $obj->start_section(
714 esc_html__( 'Query', 'shopbuilder' ),
715 self::$tab
716 );
717
718 $fields['query_note'] = $obj->el_heading( esc_html__( 'Common Filters', 'shopbuilder' ) );
719
720 $fields['posts_limit'] = [
721 'type' => 'number',
722 'label' => esc_html__( 'Products Limit', 'shopbuilder' ),
723 'description' => esc_html__( 'The number of products to show. Set empty to show all products.', 'shopbuilder' ),
724 'default' => 12,
725 ];
726
727 $fields['sorting_note'] = $obj->el_heading( esc_html__( 'Sorting', 'shopbuilder' ), 'before' );
728
729 $fields['posts_order_by'] = [
730 'type' => 'select2',
731 'label' => esc_html__( 'Order By', 'shopbuilder' ),
732 'description' => esc_html__( 'Please choose to reorder products.', 'shopbuilder' ),
733 'options' => ControlHelper::posts_order_by(),
734 'default' => 'date',
735 ];
736
737 $fields['posts_order'] = [
738 'type' => 'select2',
739 'label' => esc_html__( 'Order', 'shopbuilder' ),
740 'description' => esc_html__( 'Please choose to reorder products.', 'shopbuilder' ),
741 'options' => ControlHelper::posts_order(),
742 'default' => 'DESC',
743 ];
744
745 $fields['query_section_end'] = $obj->end_section();
746
747 return apply_filters( 'rtsb/elements/elementor/query_control', $fields, $obj );
748 }
749
750 /**
751 * Category Query section
752 *
753 * @param object $obj Reference object.
754 *
755 * @return array
756 */
757 public static function cat_single_query( $obj ) {
758 $fields['query_section'] = $obj->start_section(
759 esc_html__( 'Query', 'shopbuilder' ),
760 self::$tab
761 );
762
763 $fields['select_source'] = [
764 'type' => 'select2',
765 'label' => esc_html__( 'Select Taxonomy', 'shopbuilder' ),
766 'options' => Fns::get_tax_list(),
767 'description' => esc_html__( 'Please select the taxonomy.', 'shopbuilder' ),
768 'label_block' => true,
769 'default' => 'product_cat',
770 ];
771
772 $fields['select_cat'] = [
773 'type' => 'rt-select2',
774 'label' => esc_html__( 'Choose Category', 'shopbuilder' ),
775 'source_name' => 'taxonomy',
776 'source_type' => 'product_cat',
777 'description' => esc_html__( 'Please select the category to show.', 'shopbuilder' ),
778 'label_block' => true,
779 'minimum_input_length' => 1,
780 'condition' => [
781 'select_source' => [ 'product_cat' ],
782 ],
783 ];
784
785 $fields['select_tag'] = [
786 'type' => 'rt-select2',
787 'label' => esc_html__( 'Choose Tag', 'shopbuilder' ),
788 'source_name' => 'taxonomy',
789 'source_type' => 'product_tag',
790 'description' => esc_html__( 'Please select the tag to show.', 'shopbuilder' ),
791 'label_block' => true,
792 'minimum_input_length' => 1,
793 'condition' => [
794 'select_source' => [ 'product_tag' ],
795 ],
796 ];
797
798 $fields['query_section_end'] = $obj->end_section();
799
800 return apply_filters( 'rtsb/elements/elementor/cat_single_query_control', $fields, $obj );
801 }
802
803 /**
804 * Category Query section
805 *
806 * @param object $obj Reference object.
807 *
808 * @return array
809 */
810 public static function cat_query( $obj ) {
811 $fields['query_section'] = $obj->start_section(
812 esc_html__( 'Query', 'shopbuilder' ),
813 self::$tab
814 );
815
816 $fields['query_note'] = $obj->el_heading( esc_html__( 'Filter', 'shopbuilder' ) );
817
818 $fields['display_cat_by'] = [
819 'type' => 'select2',
820 'label' => esc_html__( 'Display Categories By:', 'shopbuilder' ),
821 'options' => Fns::get_cat_list(),
822 'description' => esc_html__( 'Please select what categories will be displayed.', 'shopbuilder' ),
823 'label_block' => true,
824 'default' => 'all',
825 ];
826
827 $fields['select_parent_cat'] = [
828 'type' => 'rt-select2',
829 'label' => esc_html__( 'Select Parent Category', 'shopbuilder' ),
830 'source_name' => 'taxonomy',
831 'source_type' => 'product_cat',
832 'minimum_input_length' => 1,
833 'description' => esc_html__( 'Please select the parent category to show.', 'shopbuilder' ),
834 'label_block' => true,
835 'default' => Fns::get_terms( 'product_cat', true, true ),
836 'condition' => [ 'display_cat_by' => [ 'specific_parent' ] ],
837 ];
838
839 $fields['include_cats'] = [
840 'type' => 'rt-select2',
841 'label' => esc_html__( 'Select Categories', 'shopbuilder' ),
842 'source_name' => 'taxonomy',
843 'source_type' => 'product_cat',
844 'description' => esc_html__( 'Please select the categories to show.', 'shopbuilder' ),
845 'label_block' => true,
846 'multiple' => true,
847 'minimum_input_length' => 1,
848 'condition' => [ 'display_cat_by' => [ 'selection' ] ],
849 ];
850
851 $fields['include_cat_ids'] = [
852 'type' => 'text',
853 'label' => esc_html__( 'Enter Category IDs', 'shopbuilder' ),
854 'description' => esc_html__( 'Please enter the category IDs separated by comma.', 'shopbuilder' ),
855 'label_block' => true,
856 'condition' => [ 'display_cat_by' => [ 'cat_ids' ] ],
857 ];
858
859 $fields['exclude_cats'] = [
860 'type' => 'rt-select2',
861 'label' => esc_html__( 'Exclude Categories', 'shopbuilder' ),
862 'source_name' => 'taxonomy',
863 'source_type' => 'product_cat',
864 'description' => esc_html__( 'Please select the categories to exclude. Leave it blank to exclude none.', 'shopbuilder' ),
865 'multiple' => true,
866 'minimum_input_length' => 1,
867 'label_block' => true,
868 'condition' => [ 'display_cat_by' => [ 'all' ] ],
869 ];
870
871 $fields['cats_limit'] = [
872 'type' => 'number',
873 'label' => esc_html__( 'Categories Limit', 'shopbuilder' ),
874 'description' => esc_html__( 'The number of categories to show. Set empty to show all categories.', 'shopbuilder' ),
875 'condition' => [ 'display_cat_by!' => [ 'selection' ] ],
876 ];
877
878 $fields['show_top_level_cats'] = [
879 'type' => 'switch',
880 'label' => __( 'Show only Top Level <br /> Sub-Categories?', 'shopbuilder' ),
881 'description' => esc_html__( 'Switch on to display only first level sub-categories.', 'shopbuilder' ),
882 'label_on' => esc_html__( 'On', 'shopbuilder' ),
883 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
884 'condition' => [ 'display_cat_by' => [ 'specific_parent' ] ],
885 ];
886
887 $fields['show_empty'] = [
888 'type' => 'switch',
889 'label' => esc_html__( 'Show Empty Categories?', 'shopbuilder' ),
890 'description' => esc_html__( 'Switch on to display empty categories.', 'shopbuilder' ),
891 'label_on' => esc_html__( 'On', 'shopbuilder' ),
892 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
893 'default' => 'yes',
894 ];
895
896 $fields['show_uncategorized'] = [
897 'type' => 'switch',
898 'label' => __( 'Show Uncategorized <br />(Or Default Category)?', 'shopbuilder' ),
899 'description' => esc_html__( 'Switch on to display uncategorized.', 'shopbuilder' ),
900 'label_on' => esc_html__( 'On', 'shopbuilder' ),
901 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
902 'default' => 'yes',
903 'condition' => [ 'display_cat_by' => [ 'all' ] ],
904 ];
905
906 $fields['show_subcats'] = [
907 'type' => 'switch',
908 'label' => esc_html__( 'Show Sub-Categories?', 'shopbuilder' ),
909 'description' => esc_html__( 'Switch on to display subcategories.', 'shopbuilder' ),
910 'label_on' => esc_html__( 'On', 'shopbuilder' ),
911 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
912 'default' => 'yes',
913 'condition' => [ 'display_cat_by' => [ 'all' ] ],
914 ];
915
916 $fields['sorting_note'] = $obj->el_heading( esc_html__( 'Sorting', 'shopbuilder' ), 'before' );
917
918 $fields['cats_order_by'] = [
919 'type' => 'select2',
920 'label' => esc_html__( 'Order By', 'shopbuilder' ),
921 'description' => esc_html__( 'Please choose to reorder categories.', 'shopbuilder' ),
922 'options' => ControlHelper::cats_order_by(),
923 'default' => 'name',
924 ];
925
926 $fields['cats_order'] = [
927 'type' => 'select2',
928 'label' => esc_html__( 'Order', 'shopbuilder' ),
929 'description' => esc_html__( 'Please choose to reorder categories.', 'shopbuilder' ),
930 'options' => ControlHelper::posts_order(),
931 'default' => 'ASC',
932 ];
933
934 $fields['query_section_end'] = $obj->end_section();
935
936 return apply_filters( 'rtsb/elements/elementor/cat_query_control', $fields, $obj );
937 }
938
939 /**
940 * Pagination section
941 *
942 * @param object $obj Reference object.
943 *
944 * @return array
945 */
946 public static function pagination( $obj ) {
947 $fields['pagination_section'] = $obj->start_section(
948 esc_html__( 'Pagination', 'shopbuilder' ),
949 self::$tab,
950 [],
951 rtsb()->has_pro() ? [ 'tax_filter!' => [ 'yes' ] ] : []
952 );
953
954 $fields['show_pagination'] = [
955 'type' => 'switch',
956 'label' => esc_html__( 'Enable Pagination?', 'shopbuilder' ),
957 'description' => esc_html__( 'Switch on to enable pagination.', 'shopbuilder' ),
958 'label_on' => esc_html__( 'On', 'shopbuilder' ),
959 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
960 ];
961
962 $fields['pagination_per_page'] = [
963 'type' => 'number',
964 'label' => esc_html__( 'Number of Posts Per Page', 'shopbuilder' ),
965 'default' => 8,
966 'description' => esc_html__( 'Please enter the number of team members per page to show.', 'shopbuilder' ),
967 'condition' => [ 'show_pagination' => [ 'yes' ] ],
968 ];
969
970 $pagination_description = esc_html__( 'Please choose the pagination type', 'shopbuilder' );
971
972 if ( ! rtsb()->has_pro() ) {
973 $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' );
974 }
975
976 $fields['pagination_type'] = [
977 'type' => 'select',
978 'label' => esc_html__( 'Pagination Type', 'shopbuilder' ),
979 'description' => $pagination_description,
980 'options' => ControlHelper::pagination_options(),
981 'default' => 'pagination',
982 'label_block' => true,
983 'condition' => [ 'show_pagination' => [ 'yes' ] ],
984 ];
985
986 $fields['pagination_section_end'] = $obj->end_section();
987
988 return apply_filters( 'rtsb/elementor/pagination_control', $fields, $obj );
989 }
990
991 /**
992 * Filter section
993 *
994 * @param object $obj Reference object.
995 *
996 * @return array
997 */
998 public static function filter( $obj ) {
999 $fields['filter_section'] = $obj->start_section(
1000 esc_html__( 'Ajax Tab Filters', 'shopbuilder' ),
1001 self::$tab,
1002 );
1003
1004 $fields['filter_note'] = [
1005 'type' => 'html',
1006 'raw' => '',
1007 'content_classes' => 'elementor-panel-heading-title',
1008 ];
1009
1010 $fields['tax_filter'] = [
1011 'type' => 'switch',
1012 'label' => esc_html__( 'Enable Taxonomy Filter Button?', 'shopbuilder' ),
1013 'description' => esc_html__( 'Switch on to enable taxonomy filter button.', 'shopbuilder' ),
1014 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1015 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1016 'separator' => $obj->pro_class(),
1017 'classes' => $obj->pro_class(),
1018 ];
1019
1020 $fields['filter_section_end'] = $obj->end_section();
1021
1022 return apply_filters( 'rtsb/elementor/filter_control', $fields, $obj );
1023 }
1024
1025 /**
1026 * Category Image section
1027 *
1028 * @param object $obj Reference object.
1029 *
1030 * @return array
1031 */
1032 public static function cat_image( $obj ) {
1033 $fields['cat_image_section'] = $obj->start_section(
1034 esc_html__( 'Image', 'shopbuilder' ),
1035 self::$tab
1036 );
1037
1038 $fields['show_cat_image'] = [
1039 'type' => 'switch',
1040 'label' => esc_html__( 'Display Category Image?', 'shopbuilder' ),
1041 'description' => esc_html__( 'Switch on to display category image.', 'shopbuilder' ),
1042 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1043 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1044 'default' => 'yes',
1045 ];
1046
1047 $fields['show_custom_image'] = [
1048 'type' => 'switch',
1049 'label' => esc_html__( 'Add Custom Image?', 'shopbuilder' ),
1050 'description' => esc_html__( 'Switch on to select a custom category image. Setting a custom image will override the category image.', 'shopbuilder' ),
1051 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1052 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1053 'classes' => $obj->pro_class(),
1054 'separator' => rtsb()->has_pro() ? 'before-short' : 'default',
1055 'condition' => [ 'layout' => [ 'category-single-layout1' ] ],
1056 ];
1057
1058 $fields['custom_image'] = [
1059 'type' => 'media',
1060 'label' => esc_html__( 'Upload Custom Image', 'shopbuilder' ),
1061 'description' => esc_html__( 'Please choose the custom category image.', 'shopbuilder' ),
1062 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1063 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1064 'condition' => [ 'show_custom_image' => [ 'yes' ] ],
1065 'default' => [
1066 'url' => \Elementor\Utils::get_placeholder_image_src(),
1067 ],
1068 ];
1069
1070 $fields['show_overlay'] = [
1071 'type' => 'switch',
1072 'label' => esc_html__( 'Enable Image Overlay?', 'shopbuilder' ),
1073 'description' => esc_html__( 'Switch on to enable image overlay.', 'shopbuilder' ),
1074 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1075 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1076 'separator' => rtsb()->has_pro() ? 'default' : 'before',
1077 'condition' => [
1078 'layout' => [ 'category-single-layout1' ],
1079 ],
1080 ];
1081
1082 // TODO:: Will be implemented later.
1083 // $fields['show_custom_icon'] = [
1084 // 'type' => 'switch',
1085 // 'label' => esc_html__( 'Enable Custom Icons?', 'shopbuilder' ),
1086 // 'description' => esc_html__( 'Switch on to enable custom icons instead of category images.', 'shopbuilder' ),
1087 // 'label_on' => esc_html__( 'On', 'shopbuilder' ),
1088 // 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
1089 // 'condition' => [ 'layout!' => [ 'category-single-layout1' ] ],
1090 // 'classes' => $obj->pro_class(),
1091 // 'separator' => rtsb()->has_pro() ? 'before-short' : 'default',
1092 // ];
1093 //
1094 // $all_categories = Fns::get_terms( 'product_cat', false, false, true );
1095 //
1096 // foreach ( $all_categories as $cat_id => $category ) {
1097 // $fields[ 'custom_icon_' . $cat_id ] = [
1098 // 'type' => 'icons',
1099 // 'label' => sprintf(
1100 // * translators: Category name */
1101 // __( 'Choose Icon for Category: %s', 'shopbuilder' ),
1102 // esc_html( $category )
1103 // ),
1104 // 'condition' => [
1105 // 'show_custom_icon' => [ 'yes' ],
1106 // 'layout!' => [ 'category-single-layout1' ],
1107 // ],
1108 // ];
1109 // }
1110
1111 $fields['cat_image_size_note'] = $obj->el_heading(
1112 esc_html__( 'Image Size', 'shopbuilder' ),
1113 'before',
1114 [],
1115 [ 'show_cat_image' => [ 'yes' ] ]
1116 );
1117
1118 $fields = array_merge( $fields, self::image_size_controls( 'catgory' ) );
1119
1120 $fields['cat_image_section_end'] = $obj->end_section();
1121
1122 return apply_filters( 'rtsb/elements/elementor/cat_image_control', $fields, $obj );
1123 }
1124
1125 /**
1126 * Image Size Controls.
1127 *
1128 * @param string $type Type.
1129 *
1130 * @return array
1131 */
1132 public static function image_size_controls( $type ) {
1133 $conditions = [
1134 'relation' => 'and',
1135 'terms' => [],
1136 ];
1137
1138 if ( 'grid' === $type ) {
1139 $conditions['terms'][] = [
1140 'relation' => 'or',
1141 'terms' => [
1142 [
1143 'name' => 'show_featured_image',
1144 'operator' => '==',
1145 'value' => 'yes',
1146 ],
1147 ],
1148 ];
1149 } else {
1150 $conditions['terms'][] = [
1151 'relation' => 'or',
1152 'terms' => [
1153 [
1154 'name' => 'show_cat_image',
1155 'operator' => '==',
1156 'value' => 'yes',
1157 ],
1158 [
1159 'name' => 'show_custom_image',
1160 'operator' => '==',
1161 'value' => 'yes',
1162 ],
1163 ],
1164 ];
1165 }
1166
1167 $fields['image'] = [
1168 'type' => 'select2',
1169 'label' => esc_html__( 'Select Image Size', 'shopbuilder' ),
1170 'description' => esc_html__( 'Please select the image size.', 'shopbuilder' ),
1171 'options' => Fns::get_image_sizes(),
1172 'default' => 'woocommerce_thumbnail',
1173 'label_block' => true,
1174 'content_classes' => 'elementor-descriptor',
1175 'conditions' => $conditions,
1176 ];
1177
1178 $conditions['terms'][] = [
1179 'relation' => 'or',
1180 'terms' => [
1181 [
1182 'name' => 'image',
1183 'operator' => '==',
1184 'value' => 'rtsb_custom',
1185 ],
1186 ],
1187 ];
1188
1189 $fields['image_custom_dimension'] = [
1190 'type' => 'image-dimensions',
1191 'label' => esc_html__( 'Enter Custom Image Size', 'shopbuilder' ),
1192 'label_block' => true,
1193 'show_label' => true,
1194 'default' => [
1195 'width' => 400,
1196 'height' => 400,
1197 ],
1198 'conditions' => $conditions,
1199 ];
1200
1201 $fields['image_crop'] = [
1202 'type' => 'select2',
1203 'label' => esc_html__( 'Image Crop', 'shopbuilder' ),
1204 'description' => esc_html__( 'Please click on "Apply" to update the image.', 'shopbuilder' ),
1205 'options' => [
1206 'soft' => esc_html__( 'Soft Crop', 'shopbuilder' ),
1207 'hard' => esc_html__( 'Hard Crop', 'shopbuilder' ),
1208 ],
1209 'default' => 'hard',
1210 'conditions' => $conditions,
1211 ];
1212
1213 $fields['image_custom_dimension_note'] = [
1214 'type' => 'html',
1215 'raw' => sprintf(
1216 '<span style="display: block; background: #fffbf1; padding: 10px; font-weight: 500; line-height: 1.4; color: #bd3a3a;border: 1px solid #bd3a3a;">%s</span>',
1217 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' )
1218 ),
1219 'conditions' => $conditions,
1220 ];
1221
1222 return $fields;
1223 }
1224 }
1225