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

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