PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 1.1.4
ShopBuilder – WooCommerce Builder For Elementor v1.1.4
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 1.1.4, at app/Elementor/Widgets/Controls/ProductImagesSettings.php

517 lines 14.8 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 'sale_flash_badge' => [
55 'label' => esc_html__( 'Show Flash Sale?', 'shopbuilder' ),
56 'type' => 'switch',
57 'description' => esc_html__( 'Switch on to show Flash Sale.', 'shopbuilder' ),
58 'default' => 'yes',
59 'separator' => 'default',
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 return $fields;
90 }
91 /**
92 * Widget Field
93 *
94 * @return array
95 */
96 public static function image() {
97 $fields = [
98 'image_section_start' => [
99 'mode' => 'section_start',
100 'label' => esc_html__( 'Product Image', 'shopbuilder' ),
101 'tab' => 'style',
102 ],
103 'image_width' => [
104 'label' => esc_html__( 'Image Width', 'shopbuilder' ),
105 'type' => 'slider',
106 'size_units' => [ '%', 'px' ],
107 'range' => [
108 '%' => [
109 'min' => 0,
110 'max' => 100,
111 'step' => 1,
112 ],
113 'px' => [
114 'min' => 0,
115 'max' => 2000,
116 'step' => 1,
117 ],
118 ],
119 'default' => [
120 'unit' => '%',
121 ],
122 'separator' => 'default',
123 'selectors' => [
124 self::$selectors['image_width'] => 'width: {{SIZE}}{{UNIT}} !important;',
125 ],
126 ],
127 'image_border_radius' => [
128 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
129 'type' => 'slider',
130 'size_units' => [ 'px', '%' ],
131 'range' => [
132 'px' => [
133 'min' => 0,
134 'max' => 100,
135 'step' => 1,
136 ],
137 '%' => [
138 'min' => 0,
139 'max' => 100,
140 'step' => 1,
141 ],
142 ],
143 'selectors' => [
144 self::$selectors['image_border_radius'] => 'border-radius: {{SIZE}}{{UNIT}} !important;',
145 ],
146 ],
147 'gallery_thumbs_style' => [
148 'type' => 'html',
149 'raw' => sprintf(
150 '<h3 class="rtsb-elementor-group-heading">%s</h3>',
151 esc_html__( 'Gallery Thumbnails', 'shopbuilder' )
152 ),
153 'content_classes' => 'elementor-panel-heading-title',
154 ],
155
156 'gallery_thumbs_column_gap' => [
157 'mode' => 'responsive',
158 'label' => esc_html__( 'Thumbnail Gap', 'shopbuilder' ),
159 'type' => 'slider',
160 'range' => [
161 'px' => [
162 'min' => 0,
163 'max' => 20,
164 'step' => 1,
165 ],
166 ],
167 'default' => [
168 'unit' => 'px',
169 'size' => 5,
170 ],
171 'selectors' => [
172 self::$selectors['gallery_thumbs_column_gap'] => 'gap: {{SIZE}}{{UNIT}};',
173 ],
174 ],
175 'gallery_thumbs_column' => [
176 'mode' => 'responsive',
177 'label' => esc_html__( 'Column', 'shopbuilder' ),
178 'type' => 'slider',
179 'range' => [
180 'px' => [
181 'min' => 2,
182 'max' => 20,
183 'step' => 1,
184 ],
185 ],
186 'default' => [
187 'unit' => 'px',
188 'size' => 4,
189 ],
190 'separator' => 'default',
191 'selectors' => [
192 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;',
193 ],
194 ],
195 'gallery_image_gap_with_main' => [
196 'mode' => 'responsive',
197 'label' => esc_html__( 'Gap with main image', 'shopbuilder' ),
198 'type' => 'slider',
199 'range' => [
200 'px' => [
201 'min' => 0,
202 'max' => 200,
203 'step' => 1,
204 ],
205 ],
206 'default' => [
207 'unit' => 'px',
208 'size' => 10,
209 ],
210 'selectors' => [
211 self::$selectors['gallery_image_gap_with_main']['margin-top'] => 'margin-top: {{SIZE}}{{UNIT}};',
212 self::$selectors['gallery_image_gap_with_main']['rtwpvg-thumb-mb'] => 'margin-bottom: {{SIZE}}{{UNIT}};',
213 self::$selectors['gallery_image_gap_with_main']['rtwpvg-thumb-ml'] => 'margin-left: {{SIZE}}{{UNIT}};',
214 self::$selectors['gallery_image_gap_with_main']['rtwpvg-thumb-mr'] => 'margin-right: {{SIZE}}{{UNIT}};',
215 ],
216 ],
217 'thumb_border' => [
218 'mode' => 'group',
219 'type' => 'border',
220 'selector' => self::$selectors['thumb_border'],
221 'size_units' => [ 'px' ],
222 ],
223 'thumbs_border_radius' => [
224 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
225 'type' => 'slider',
226 'size_units' => [ 'px', '%' ],
227 'range' => [
228 'px' => [
229 'min' => 0,
230 'max' => 100,
231 'step' => 1,
232 ],
233 '%' => [
234 'min' => 0,
235 'max' => 100,
236 'step' => 1,
237 ],
238 ],
239 'selectors' => [
240 self::$selectors['thumbs_border_radius'] => 'border-radius: {{SIZE}}{{UNIT}}',
241 ],
242 ],
243 'image_section_end' => [
244 'mode' => 'section_end',
245 ],
246 ];
247 if ( function_exists( 'rtwpvg' ) ) {
248 unset( $fields['gallery_thumbs_column'] );
249 unset( $fields['gallery_thumbs_column_gap'] );
250 }
251 return $fields;
252 }
253 /**
254 * Widget Field
255 *
256 * @return array
257 */
258 public static function flash_sale( $widget ) {
259 $fields = ProductFlashSale::flash_sale( $widget );
260
261 $fields['flash_sale_section_start']['condition'] = [
262 'sale_flash_badge' => 'yes',
263 ];
264
265 $extra_controls = [];
266
267 $extra_controls['flash_sale_position'] = [
268 'label' => esc_html__( 'Position', 'shopbuilder' ),
269 'type' => 'choose',
270 'options' => [
271 'left' => [
272 'title' => esc_html__( 'Left', 'shopbuilder' ),
273 'icon' => 'eicon-h-align-left',
274 ],
275 'right' => [
276 'title' => esc_html__( 'Right', 'shopbuilder' ),
277 'icon' => 'eicon-h-align-right',
278 ],
279 ],
280 'default' => 'left',
281 'separator' => 'before',
282 ];
283
284 $extra_controls['flash_sale_position_horizontal'] = [
285 'label' => esc_html__( 'Horizontal', 'shopbuilder' ),
286 'type' => 'slider',
287 'size_units' => [ 'px', '%' ],
288 'range' => [
289 'px' => [
290 'min' => -100,
291 'max' => 100,
292 'step' => 5,
293 ],
294 '%' => [
295 'min' => 0,
296 'max' => 100,
297 ],
298 ],
299 'default' => [
300 'unit' => 'px',
301 'size' => 0,
302 ],
303 'selectors' => [
304 $widget->selectors['flash_sale_position_horizontal'] => '{{flash_sale_position.VALUE}}: {{SIZE}}{{UNIT}};position: absolute;z-index: 2;',
305 ],
306 ];
307 $extra_controls['flash_sale_position_vertical'] = [
308 'label' => esc_html__( 'Vertical', 'shopbuilder' ),
309 'type' => 'slider',
310 'size_units' => [ 'px', '%' ],
311 'range' => [
312 'px' => [
313 'min' => -100,
314 'max' => 100,
315 'step' => 5,
316 ],
317 '%' => [
318 'min' => 0,
319 'max' => 100,
320 ],
321 ],
322 'default' => [
323 'unit' => 'px',
324 'size' => 0,
325 ],
326 'selectors' => [
327 $widget->selectors['flash_sale_position_vertical'] => 'top: {{SIZE}}{{UNIT}};position: absolute;z-index: 2;',
328 ],
329 ];
330
331 $fields = Fns::insert_controls( 'flash_sale_badge_border_radius', $fields, $extra_controls );
332
333
334 return $fields;
335 }
336 /**
337 * Widget Field
338 *
339 * @return array
340 */
341 public static function zoom_icon() {
342 $fields = [
343 'zoom_section_start' => [
344 'mode' => 'section_start',
345 'label' => esc_html__( 'Image Zoom', 'shopbuilder' ),
346 'tab' => 'style',
347 'condition' => [
348 'show_zoom' => 'yes',
349 ],
350 ],
351 'zoom_color' => [
352 'label' => esc_html__( 'Color', 'shopbuilder' ),
353 'type' => 'color',
354
355 'separator' => 'default',
356 'selectors' => [
357 self::$selectors['zoom_color'] => 'color: {{VALUE}};',
358 ],
359 ],
360 'zoom_bg_color' => [
361 'label' => esc_html__( 'Background Color', 'shopbuilder' ),
362 'type' => 'color',
363 'selectors' => [
364 self::$selectors['zoom_bg_color'] => 'background-color: {{VALUE}};',
365 ],
366 ],
367 'zoom_icon_size' => [
368 'label' => esc_html__( 'Icon Size (px)', 'shopbuilder' ),
369 'type' => 'slider',
370 'size_units' => [ 'px' ],
371 'range' => [
372 'px' => [
373 'min' => 0,
374 'max' => 50,
375 'step' => 1,
376 ],
377 ],
378 'selectors' => [
379 self::$selectors['zoom_icon_size'] => 'font-size: {{SIZE}}{{UNIT}};',
380 ],
381 'separator' => 'before',
382 ],
383 'zoom_badge_width' => [
384 'label' => esc_html__( 'Badge Width (px)', 'shopbuilder' ),
385 'type' => 'slider',
386 'size_units' => [ 'px' ],
387 'range' => [
388 'px' => [
389 'min' => 15,
390 'max' => 100,
391 'step' => 1,
392 ],
393 ],
394 'selectors' => [
395 self::$selectors['zoom_badge_width'] => 'width: {{SIZE}}{{UNIT}};min-width: initial;',
396 ],
397 ],
398 'zoom_badge_height' => [
399 'label' => esc_html__( 'Badge Height (px)', 'shopbuilder' ),
400 'type' => 'slider',
401 'size_units' => [ 'px' ],
402 'range' => [
403 'px' => [
404 'min' => 15,
405 'max' => 100,
406 'step' => 1,
407 ],
408 ],
409 'selectors' => [
410 self::$selectors['zoom_badge_height'] => 'height: {{SIZE}}{{UNIT}};min-height: initial;',
411 ],
412 ],
413 'zoom_badge_border_radius' => [
414 'label' => esc_html__( 'Badge Border Radius (px)', 'shopbuilder' ),
415 'type' => 'slider',
416 'size_units' => [ 'px', '%' ],
417 'range' => [
418 'px' => [
419 'min' => 0,
420 'max' => 100,
421 'step' => 1,
422 ],
423 '%' => [
424 'min' => 0,
425 'max' => 100,
426 'step' => 1,
427 ],
428 ],
429 'selectors' => [
430 self::$selectors['zoom_badge_border_radius'] => 'border-radius: {{SIZE}}{{UNIT}};',
431 ],
432 ],
433 'zoom_padding' => [
434 'label' => esc_html__( 'Padding (px)', 'shopbuilder' ),
435 'type' => 'dimensions',
436 'size_units' => [ 'px' ],
437 'default' => [
438 'top' => '0',
439 'right' => '0',
440 'bottom' => '0',
441 'left' => '0',
442 'unit' => 'px',
443 'isLinked' => true,
444 ],
445 'selectors' => [
446 self::$selectors['zoom_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
447 ],
448 ],
449 'zoom_position' => [
450 'label' => esc_html__( 'Position', 'shopbuilder' ),
451 'type' => 'choose',
452 'options' => [
453 'left' => [
454 'title' => esc_html__( 'Left', 'shopbuilder' ),
455 'icon' => 'eicon-h-align-left',
456 ],
457 'right' => [
458 'title' => esc_html__( 'Right', 'shopbuilder' ),
459 'icon' => 'eicon-h-align-right',
460 ],
461 ],
462 'default' => 'right',
463 'separator' => 'before',
464 ],
465 'zoom_position_horizontal' => [
466 'label' => esc_html__( 'Horizontal', 'shopbuilder' ),
467 'type' => 'slider',
468 'size_units' => [ 'px', '%' ],
469 'range' => [
470 'px' => [
471 'min' => -200,
472 'max' => 200,
473 'step' => 5,
474 ],
475 '%' => [
476 'min' => 0,
477 'max' => 100,
478 ],
479 ],
480
481 'selectors' => [
482 self::$selectors['zoom_position_horizontal']['zoom_position'] => '{{zoom_position.VALUE}}: {{SIZE}}{{UNIT}};',
483 self::$selectors['zoom_position_horizontal']['rtwpvg-tr-br'] => 'right: {{SIZE}}{{UNIT}};',
484 self::$selectors['zoom_position_horizontal']['rtwpvg-tl-bl'] => 'left: {{SIZE}}{{UNIT}};',
485 ],
486 ],
487 'zoom_position_vertical' => [
488 'label' => esc_html__( 'Vertical', 'shopbuilder' ),
489 'type' => 'slider',
490 'size_units' => [ 'px', '%' ],
491 'range' => [
492 'px' => [
493 'min' => -200,
494 'max' => 200,
495 'step' => 5,
496 ],
497 '%' => [
498 'min' => 0,
499 'max' => 100,
500 ],
501 ],
502 'selectors' => [
503 self::$selectors['zoom_position_vertical']['zoom-icon-top'] => 'top: {{SIZE}}{{UNIT}};',
504 self::$selectors['zoom_position_vertical']['zoom-icon-bottom'] . ':is(.rtwpvg-trigger-position-bottom-right, .rtwpvg-trigger-position-bottom-left)' => 'bottom: {{SIZE}}{{UNIT}};',
505 ],
506 ],
507 'zoom_section_end' => [
508 'mode' => 'section_end',
509 ],
510 ];
511 if ( function_exists( 'rtwpvg' ) ) {
512 unset( $fields['zoom_position'] );
513 }
514 return $fields;
515 }
516 }
517