PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.1.3
ShopBuilder – WooCommerce Builder For Elementor v2.1.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 / ProductImagesSettings.php

ProductImagesSettings.php in ShopBuilder – WooCommerce Builder For Elementor 2.1.3, at app/Elementor/Widgets/Controls/ProductImagesSettings.php

576 lines 15.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main ProductImagesSettings class.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Elementor\Widgets\Controls;
9
10 use Elementor\Controls_Manager;
11 use RadiusTheme\SB\Helpers\Fns;
12
13 // Do not allow directly accessing this file.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit( 'This script cannot be accessed directly.' );
16 }
17
18
19 /**
20 * Product Image Settings class
21 */
22 class ProductImagesSettings {
23
24 /**
25 * Widget Control Selectors
26 *
27 * @var array
28 */
29 private static $selectors = [];
30 /**
31 * Widget Field
32 *
33 * @return array
34 */
35 public static function widget_fields( $widget ) {
36 self::$selectors = $widget->selectors;
37 return self::general_section() +
38 self::image() +
39 self::flash_sale( $widget ) +
40 self::zoom_icon();
41 }
42
43 /**
44 * Widget Field
45 *
46 * @return array
47 */
48 public static function general_section() {
49 $fields = [
50 'image_general_section_start' => [
51 'mode' => 'section_start',
52 'label' => esc_html__( 'General', 'shopbuilder' ),
53 ],
54
55 'sale_flash_badge' => [
56 'label' => esc_html__( 'Show Flash Sale?', 'shopbuilder' ),
57 'type' => 'switch',
58 'description' => esc_html__( 'Switch on to show Flash Sale.', 'shopbuilder' ),
59 'default' => 'yes',
60 ],
61 'show_zoom' => [
62 'label' => esc_html__( 'Show Zoom Icon?', 'shopbuilder' ),
63 'type' => 'switch',
64 'description' => esc_html__( 'Switch on to show Zoom Icon.', 'shopbuilder' ),
65 'default' => 'yes',
66 ],
67 'show_thumbnails' => [
68 'label' => esc_html__( 'Show Thumbnails?', 'shopbuilder' ),
69 'type' => 'switch',
70 'description' => esc_html__( 'Switch on to show Thumbnails.', 'shopbuilder' ),
71 'default' => 'yes',
72 ],
73 'lightbox_icon' => [
74 'label' => esc_html__( 'Icon', 'shopbuilder' ),
75 'type' => 'icons',
76 'fa4compatibility' => 'icon',
77 'default' => [
78 'value' => 'fas fa-expand-alt',
79 'library' => 'fa-solid',
80 ],
81 'condition' => [
82 'show_zoom' => 'yes',
83 ],
84 ],
85 'image_general_section_end' => [
86 'mode' => 'section_end',
87 ],
88 ];
89
90 if ( function_exists( 'rtwpvg' ) && rtwpvg()->active_pro() ) {
91 $image_layout = [
92 'image_layout' => [
93 'type' => 'rtsb-image-selector',
94 'label' => esc_html__( 'Image Layout', 'shopbuilder' ),
95 'description' => esc_html__( 'Please choose image layout. The layout display the change after reload.', 'shopbuilder' ),
96 'options' => [
97 'bottom' => [
98 'title' => esc_html__( 'Gallery Bottom', 'shopbuilder' ),
99 'url' => esc_url( rtsb()->get_assets_uri( 'images/layout/image-layout-gallery-bottom-2.png' ) ),
100 ],
101 'left' => [
102 'title' => esc_html__( 'Gallery left', 'shopbuilder' ),
103 'url' => esc_url( rtsb()->get_assets_uri( 'images/layout/image-layout-gallery-left-2.png' ) ),
104 ],
105 'right' => [
106 'title' => esc_html__( 'Gallery Right', 'shopbuilder' ),
107 'url' => esc_url( rtsb()->get_assets_uri( 'images/layout/image-layout-gallery-right-2.png' ) ),
108 ],
109 'grid' => [
110 'title' => esc_html__( 'Gallery Grid', 'shopbuilder' ),
111 'url' => esc_url( rtsb()->get_assets_uri( 'images/layout/image-layout-gallery-grid-2.png' ) ),
112 ],
113 ],
114 'default' => 'bottom',
115 ],
116 ];
117 $fields = Fns::insert_controls( 'image_general_section_start', $fields, $image_layout, true );
118
119 }
120
121 return $fields;
122 }
123
124 /**
125 * Widget Field
126 *
127 * @return array
128 */
129 public static function image() {
130 $fields = [
131 'image_section_start' => [
132 'mode' => 'section_start',
133 'label' => esc_html__( 'Product Image', 'shopbuilder' )
134 ],
135 'image_width' => [
136 'label' => esc_html__( 'Image Width', 'shopbuilder' ),
137 'type' => 'slider',
138 'size_units' => [ '%', 'px' ],
139 'range' => [
140 '%' => [
141 'min' => 0,
142 'max' => 100,
143 'step' => 1,
144 ],
145 'px' => [
146 'min' => 0,
147 'max' => 2000,
148 'step' => 1,
149 ],
150 ],
151 'default' => [
152 'unit' => '%',
153 ],
154 'separator' => 'default',
155 'selectors' => [
156 self::$selectors['image_width'] => 'width: {{SIZE}}{{UNIT}} !important;',
157 ],
158 ],
159 'image_border_radius' => [
160 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
161 'type' => 'slider',
162 'size_units' => [ 'px', '%' ],
163 'range' => [
164 'px' => [
165 'min' => 0,
166 'max' => 100,
167 'step' => 1,
168 ],
169 '%' => [
170 'min' => 0,
171 'max' => 100,
172 'step' => 1,
173 ],
174 ],
175 'selectors' => [
176 self::$selectors['image_border_radius'] => 'border-radius: {{SIZE}}{{UNIT}} !important;',
177 ],
178 ],
179 'gallery_thumbs_style' => [
180 'type' => 'html',
181 'raw' => sprintf(
182 '<h3 class="rtsb-elementor-group-heading">%s</h3>',
183 esc_html__( 'Gallery Thumbnails', 'shopbuilder' )
184 ),
185 'content_classes' => 'elementor-panel-heading-title',
186 ],
187
188 'gallery_thumbs_column_gap' => [
189 'mode' => 'responsive',
190 'label' => esc_html__( 'Thumbnail Gap', 'shopbuilder' ),
191 'description' => esc_html__( 'Gallery Thumbnails Gap Is required.', 'shopbuilder' ),
192 'render_type' => 'template',
193 'type' => 'slider',
194 'range' => [
195 'px' => [
196 'min' => 0,
197 'max' => 100,
198 'step' => 1,
199 ],
200 ],
201 'default' => [
202 'unit' => 'px',
203 'size' => 10,
204 ],
205 'desktop_default' => [
206 'size' => 10,
207 'unit' => 'px',
208 ],
209 'tablet_default' => [
210 'size' => 10,
211 'unit' => 'px',
212 ],
213 'mobile_default' => [
214 'size' => 10,
215 'unit' => 'px',
216 ],
217 'selectors' => [
218 ':root' => '--rtwpvg-thumbnail-gap:{{SIZE}}{{UNIT}};',
219 ],
220 ],
221 'gallery_thumbs_column' => [
222 'mode' => 'responsive',
223 'label' => esc_html__( 'Column', 'shopbuilder' ),
224 'description' => esc_html__( 'Above Control the Gallery Thumbnails Gap is required.', 'shopbuilder' ),
225 'type' => 'slider',
226 'range' => [
227 'px' => [
228 'min' => 2,
229 'max' => 8,
230 'step' => 1,
231 ],
232 ],
233 'default' => [
234 'unit' => 'px',
235 'size' => 6,
236 ],
237 'desktop_default' => [
238 'size' => 5,
239 'unit' => 'px',
240 ],
241 'tablet_default' => [
242 'size' => 4,
243 'unit' => 'px',
244 ],
245 'mobile_default' => [
246 'size' => 3,
247 'unit' => 'px',
248 ],
249 'selectors' => [
250 self::$selectors['gallery_thumbs_column'] => 'width: calc(100%/{{SIZE}} - ( {{gallery_thumbs_column_gap.size}}{{gallery_thumbs_column_gap.unit}} / {{SIZE}} ) * ({{SIZE}} - 1 ) );flex: 0 0 auto;max-width: initial;',
251 ],
252 ],
253 'gallery_image_gap_with_main' => [
254 'mode' => 'responsive',
255 'label' => esc_html__( 'Gap with main image', 'shopbuilder' ),
256 'type' => 'slider',
257 'range' => [
258 'px' => [
259 'min' => 0,
260 'max' => 200,
261 'step' => 1,
262 ],
263 ],
264 'default' => [
265 'unit' => 'px',
266 'size' => 10,
267 ],
268 'selectors' => [
269 ':root' => '--rtwpvg-thumbnail-gap-with-main:{{SIZE}}{{UNIT}};',
270 //self::$selectors['gallery_image_gap_with_main']['margin-top'] => 'margin-top: {{SIZE}}{{UNIT}};',
271 // self::$selectors['gallery_image_gap_with_main']['rtwpvg-thumb-mb'] => 'margin-bottom: {{SIZE}}{{UNIT}};',
272 // self::$selectors['gallery_image_gap_with_main']['rtwpvg-thumb-ml'] => 'margin-left: {{SIZE}}{{UNIT}};',
273 // self::$selectors['gallery_image_gap_with_main']['rtwpvg-thumb-mr'] => 'margin-right: {{SIZE}}{{UNIT}};',
274 ],
275 ],
276 'thumb_border' => [
277 'mode' => 'group',
278 'type' => 'border',
279 'selector' => self::$selectors['thumb_border'],
280 'size_units' => [ 'px' ],
281 ],
282 'thumbs_border_radius' => [
283 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
284 'type' => 'slider',
285 'size_units' => [ 'px', '%' ],
286 'range' => [
287 'px' => [
288 'min' => 0,
289 'max' => 100,
290 'step' => 1,
291 ],
292 '%' => [
293 'min' => 0,
294 'max' => 100,
295 'step' => 1,
296 ],
297 ],
298 'selectors' => [
299 self::$selectors['thumbs_border_radius'] => 'border-radius: {{SIZE}}{{UNIT}}',
300 ],
301 ],
302 'image_section_end' => [
303 'mode' => 'section_end',
304 ],
305 ];
306 if ( function_exists( 'rtwpvg' ) ) {
307 unset( $fields['gallery_thumbs_column']['selectors'] );
308 //unset( $fields['gallery_thumbs_column_gap'] );
309 }
310 return $fields;
311 }
312 /**
313 * Widget Field
314 *
315 * @return array
316 */
317 public static function flash_sale( $widget ) {
318 $fields = ProductFlashSale::flash_sale( $widget );
319
320 $fields['flash_sale_section_start']['condition'] = [
321 'sale_flash_badge' => 'yes',
322 ];
323
324 $extra_controls = [];
325
326 $extra_controls['flash_sale_position'] = [
327 'label' => esc_html__( 'Position', 'shopbuilder' ),
328 'type' => 'choose',
329 'options' => [
330 'left' => [
331 'title' => esc_html__( 'Left', 'shopbuilder' ),
332 'icon' => 'eicon-h-align-left',
333 ],
334 'right' => [
335 'title' => esc_html__( 'Right', 'shopbuilder' ),
336 'icon' => 'eicon-h-align-right',
337 ],
338 ],
339 'default' => 'left',
340 'separator' => 'before',
341 ];
342
343 $extra_controls['flash_sale_position_horizontal'] = [
344 'label' => esc_html__( 'Horizontal', 'shopbuilder' ),
345 'type' => 'slider',
346 'size_units' => [ 'px', '%' ],
347 'range' => [
348 'px' => [
349 'min' => -100,
350 'max' => 100,
351 'step' => 5,
352 ],
353 '%' => [
354 'min' => 0,
355 'max' => 100,
356 ],
357 ],
358 'default' => [
359 'unit' => 'px',
360 'size' => 0,
361 ],
362 'selectors' => [
363 $widget->selectors['flash_sale_position_horizontal'] => '{{flash_sale_position.VALUE}}: {{SIZE}}{{UNIT}};position: absolute;z-index: 2;',
364 ],
365 ];
366 $extra_controls['flash_sale_position_vertical'] = [
367 'label' => esc_html__( 'Vertical', 'shopbuilder' ),
368 'type' => 'slider',
369 'size_units' => [ 'px', '%' ],
370 'range' => [
371 'px' => [
372 'min' => -100,
373 'max' => 100,
374 'step' => 5,
375 ],
376 '%' => [
377 'min' => 0,
378 'max' => 100,
379 ],
380 ],
381 'default' => [
382 'unit' => 'px',
383 'size' => 0,
384 ],
385 'selectors' => [
386 $widget->selectors['flash_sale_position_vertical'] => 'top: {{SIZE}}{{UNIT}};position: absolute;z-index: 2;',
387 ],
388 ];
389
390 $fields = Fns::insert_controls( 'flash_sale_badge_border_radius', $fields, $extra_controls );
391
392 return $fields;
393 }
394 /**
395 * Widget Field
396 *
397 * @return array
398 */
399 public static function zoom_icon() {
400 $fields = [
401 'zoom_section_start' => [
402 'mode' => 'section_start',
403 'label' => esc_html__( 'Image Zoom', 'shopbuilder' ),
404 'tab' => 'style',
405 'condition' => [
406 'show_zoom' => 'yes',
407 ],
408 ],
409 'zoom_color' => [
410 'label' => esc_html__( 'Color', 'shopbuilder' ),
411 'type' => 'color',
412
413 'separator' => 'default',
414 'selectors' => [
415 self::$selectors['zoom_color'] => 'color: {{VALUE}};',
416 ],
417 ],
418 'zoom_bg_color' => [
419 'label' => esc_html__( 'Background Color', 'shopbuilder' ),
420 'type' => 'color',
421 'selectors' => [
422 self::$selectors['zoom_bg_color'] => 'background-color: {{VALUE}};',
423 ],
424 ],
425 'zoom_icon_size' => [
426 'label' => esc_html__( 'Icon Size (px)', 'shopbuilder' ),
427 'type' => 'slider',
428 'size_units' => [ 'px' ],
429 'range' => [
430 'px' => [
431 'min' => 0,
432 'max' => 50,
433 'step' => 1,
434 ],
435 ],
436 'selectors' => [
437 self::$selectors['zoom_icon_size'] => 'font-size: {{SIZE}}{{UNIT}};',
438 ],
439 'separator' => 'before',
440 ],
441 'zoom_badge_width' => [
442 'label' => esc_html__( 'Badge Width (px)', 'shopbuilder' ),
443 'type' => 'slider',
444 'size_units' => [ 'px' ],
445 'range' => [
446 'px' => [
447 'min' => 15,
448 'max' => 100,
449 'step' => 1,
450 ],
451 ],
452 'selectors' => [
453 self::$selectors['zoom_badge_width'] => 'width: {{SIZE}}{{UNIT}};min-width: initial;',
454 ],
455 ],
456 'zoom_badge_height' => [
457 'label' => esc_html__( 'Badge Height (px)', 'shopbuilder' ),
458 'type' => 'slider',
459 'size_units' => [ 'px' ],
460 'range' => [
461 'px' => [
462 'min' => 15,
463 'max' => 100,
464 'step' => 1,
465 ],
466 ],
467 'selectors' => [
468 self::$selectors['zoom_badge_height'] => 'height: {{SIZE}}{{UNIT}};min-height: initial;',
469 ],
470 ],
471 'zoom_badge_border_radius' => [
472 'label' => esc_html__( 'Badge Border Radius (px)', 'shopbuilder' ),
473 'type' => 'slider',
474 'size_units' => [ 'px', '%' ],
475 'range' => [
476 'px' => [
477 'min' => 0,
478 'max' => 100,
479 'step' => 1,
480 ],
481 '%' => [
482 'min' => 0,
483 'max' => 100,
484 'step' => 1,
485 ],
486 ],
487 'selectors' => [
488 self::$selectors['zoom_badge_border_radius'] => 'border-radius: {{SIZE}}{{UNIT}};',
489 ],
490 ],
491 'zoom_padding' => [
492 'label' => esc_html__( 'Padding (px)', 'shopbuilder' ),
493 'type' => 'dimensions',
494 'mode' => 'responsive',
495 'size_units' => [ 'px' ],
496 'default' => [
497 'top' => '0',
498 'right' => '0',
499 'bottom' => '0',
500 'left' => '0',
501 'unit' => 'px',
502 'isLinked' => true,
503 ],
504 'selectors' => [
505 self::$selectors['zoom_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
506 ],
507 ],
508 'zoom_position' => [
509 'label' => esc_html__( 'Position', 'shopbuilder' ),
510 'type' => 'choose',
511 'options' => [
512 'left' => [
513 'title' => esc_html__( 'Left', 'shopbuilder' ),
514 'icon' => 'eicon-h-align-left',
515 ],
516 'right' => [
517 'title' => esc_html__( 'Right', 'shopbuilder' ),
518 'icon' => 'eicon-h-align-right',
519 ],
520 ],
521 'default' => 'right',
522 'separator' => 'before',
523 ],
524 'zoom_position_horizontal' => [
525 'label' => esc_html__( 'Horizontal', 'shopbuilder' ),
526 'type' => 'slider',
527 'size_units' => [ 'px', '%' ],
528 'range' => [
529 'px' => [
530 'min' => -200,
531 'max' => 200,
532 'step' => 5,
533 ],
534 '%' => [
535 'min' => 0,
536 'max' => 100,
537 ],
538 ],
539
540 'selectors' => [
541 self::$selectors['zoom_position_horizontal']['zoom_position'] => '{{zoom_position.VALUE}}: {{SIZE}}{{UNIT}};',
542 self::$selectors['zoom_position_horizontal']['rtwpvg-tr-br'] => 'right: {{SIZE}}{{UNIT}};',
543 self::$selectors['zoom_position_horizontal']['rtwpvg-tl-bl'] => 'left: {{SIZE}}{{UNIT}};',
544 ],
545 ],
546 'zoom_position_vertical' => [
547 'label' => esc_html__( 'Vertical', 'shopbuilder' ),
548 'type' => 'slider',
549 'size_units' => [ 'px', '%' ],
550 'range' => [
551 'px' => [
552 'min' => -200,
553 'max' => 200,
554 'step' => 5,
555 ],
556 '%' => [
557 'min' => 0,
558 'max' => 100,
559 ],
560 ],
561 'selectors' => [
562 self::$selectors['zoom_position_vertical']['zoom-icon-top'] => 'top: {{SIZE}}{{UNIT}};',
563 self::$selectors['zoom_position_vertical']['zoom-icon-bottom'] . ':is(.rtwpvg-trigger-position-bottom-right, .rtwpvg-trigger-position-bottom-left)' => 'bottom: {{SIZE}}{{UNIT}};',
564 ],
565 ],
566 'zoom_section_end' => [
567 'mode' => 'section_end',
568 ],
569 ];
570 if ( function_exists( 'rtwpvg' ) ) {
571 unset( $fields['zoom_position'] );
572 }
573 return $fields;
574 }
575 }
576