PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.6
ShopBuilder – WooCommerce Builder For Elementor v3.2.6
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 / General / LogoSliderAndGrid / Controls.php

Controls.php in ShopBuilder – WooCommerce Builder For Elementor 3.2.6, at app/Elementor/Widgets/General/LogoSliderAndGrid/Controls.php

538 lines 17.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Controls class.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Elementor\Widgets\General\LogoSliderAndGrid;
9
10 use Elementor\Utils;
11 use RadiusTheme\SB\Helpers\Fns;
12 use RadiusTheme\SB\Elementor\Helper\ControlHelper;
13 use RadiusTheme\SB\Elementor\Widgets\Controls\SettingsFields;
14 use RadiusTheme\SB\Elementor\Widgets\Controls\StyleFields as StyleFieldsFree;
15
16 // Do not allow directly accessing this file.
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit( 'This script cannot be accessed directly.' );
19 }
20
21 /**
22 * Settings class.
23 *
24 * @package RadiusTheme\SB
25 */
26 class Controls {
27 /**
28 * Content section
29 *
30 * @param object $obj Reference object.
31 *
32 * @return array
33 */
34 public static function content( $obj ) {
35 return array_merge(
36 self::preset( $obj ),
37 self::general_settings( $obj ),
38 self::slider_settings( $obj ),
39 self::logo_items( $obj ),
40 );
41 }
42
43 /**
44 * Style section
45 *
46 * @param object $obj Reference object.
47 *
48 * @return array
49 */
50 public static function style( $obj ) {
51 return array_merge(
52 self::logo_item_style( $obj ),
53 self::image_styles( $obj ),
54 self::title_style( $obj ),
55 self::logo_slider_buttons( $obj ),
56 );
57 }
58
59 /**
60 * Preset section
61 *
62 * @param object $obj Reference object.
63 *
64 * @return array
65 */
66 private static function preset( $obj ) {
67 $status = ! rtsb()->has_pro();
68 $fields['sb_accordion_preset'] = $obj->start_section(
69 esc_html__( 'Layout', 'shopbuilder' ),
70 'content'
71 );
72 $fields['layout_note'] = $obj->el_heading( esc_html__( 'Predefined Layouts', 'shopbuilder' ) );
73 $fields['layout_style'] = [
74 'type' => 'rtsb-image-selector',
75 'options' => ControlHelper::general_widgets_logo_slider_grid_layouts(),
76 'default' => 'rtsb-logo-layout1',
77 ];
78 $fields['cols'] = [
79 'type' => 'select2',
80 'mode' => 'responsive',
81 'label' => esc_html__( 'Number of Columns', 'shopbuilder' ),
82 'description' => esc_html__( 'Please select the number of columns to show per row.', 'shopbuilder' ),
83 'options' => ControlHelper::layout_columns(),
84 'label_block' => true,
85 'default' => '5',
86 'tablet_default' => '3',
87 'mobile_default' => '2',
88 'required' => true,
89 'render_type' => 'template',
90 'selectors' => [
91 $obj->selectors['columns']['cols'] => 'grid-template-columns: repeat({{VALUE}}, minmax(0, 1fr));',
92 ],
93 'separator' => 'before',
94 ];
95 $fields['rows'] = [
96 'type' => 'select2',
97 'label' => esc_html__( 'Number of Product Rows', 'shopbuilder' ),
98 'description' => esc_html__( 'Please select the number of slide rows. Slide Rows represents how many rows of slides will be displayed at once.', 'shopbuilder' ),
99 'options' => [
100 1 => esc_html__( 'Layout Default (1 Row)', 'shopbuilder' ),
101 2 => esc_html__( '2 Rows', 'shopbuilder' ),
102 3 => esc_html__( '3 Rows', 'shopbuilder' ),
103 4 => esc_html__( '4 Rows', 'shopbuilder' ),
104 5 => esc_html__( '5 Rows', 'shopbuilder' ),
105 ],
106 'label_block' => true,
107 'default' => '1',
108 'tablet_default' => '1',
109 'mobile_default' => '1',
110 'required' => true,
111 'classes' => $obj->pro_class(),
112 'is_pro' => $status,
113 'condition' => [ 'activate_slider_item' => 'yes' ],
114 ];
115
116 $fields['cols_group'] = [
117 'type' => 'select2',
118 'mode' => 'responsive',
119 'label' => esc_html__( 'Number of Slides Per Group', 'shopbuilder' ),
120 'description' => esc_html__( 'Please select the number of slides to show per group. Slides Per Group indicates how many slides will be transitioned at a time.', 'shopbuilder' ),
121 'options' => ControlHelper::layout_columns(),
122 'label_block' => true,
123 'default' => '0',
124 'tablet_default' => '2',
125 'mobile_default' => '1',
126 'required' => true,
127 'condition' => [ 'activate_slider_item' => 'yes' ],
128 ];
129 $fields['element_height'] = [
130 'type' => 'slider',
131 'mode' => 'responsive',
132 'label' => esc_html__( 'Element Height', 'shopbuilder' ),
133 'size_units' => [ 'px', '%' ],
134 'range' => [
135 'px' => [
136 'min' => 0,
137 'max' => 1000,
138 ],
139 '%' => [
140 'min' => 0,
141 'max' => 100,
142 ],
143 ],
144 'description' => esc_html__( 'Please select the element height.', 'shopbuilder' ),
145 'selectors' => [
146 $obj->selectors['element']['element_height'] => 'height: {{SIZE}}{{UNIT}};',
147 ],
148 ];
149 $fields['grid_gap'] = [
150 'type' => 'slider',
151 'mode' => 'responsive',
152 'label' => esc_html__( 'Grid Gap / Spacing (px)', 'shopbuilder' ),
153 'size_units' => [ 'px' ],
154 'range' => [
155 'px' => [
156 'min' => 0,
157 'max' => 100,
158 'step' => 1,
159 ],
160 ],
161 'default' => [
162 'unit' => 'px',
163 'size' => 30,
164 ],
165 'description' => esc_html__( 'Please select the grid gap in px.', 'shopbuilder' ),
166 'selectors' => [
167 $obj->selectors['columns']['grid_gap']['padding'] => 'padding-left: calc({{SIZE}}{{UNIT}} / 2); padding-right: calc({{SIZE}}{{UNIT}} / 2);',
168 $obj->selectors['columns']['grid_gap']['margin'] => 'margin-left: calc(-{{SIZE}}{{UNIT}} / 2); margin-right: calc(-{{SIZE}}{{UNIT}} / 2);',
169 $obj->selectors['columns']['grid_gap']['slider_layout'] => '--rtsb-logo-slider-spacing: {{SIZE}}{{UNIT}};',
170 $obj->selectors['columns']['grid_gap']['bottom'] => 'margin-bottom: {{SIZE}}{{UNIT}};',
171 ],
172 ];
173 $fields['sb_accordion_preset_end'] = $obj->end_section();
174 return $fields;
175 }
176
177
178 /**
179 * General section
180 *
181 * @param object $obj Reference object.
182 *
183 * @return array
184 */
185 private static function general_settings( $obj ) {
186 $fields['general_settings_sec_start'] = $obj->start_section(
187 esc_html__( 'General Settings', 'shopbuilder' ),
188 'content',
189 [],
190 );
191 $fields['logo_settings_note'] = $obj->el_heading( esc_html__( 'Logo Settings', 'shopbuilder' ) );
192 $fields['logo_gray_scale'] = [
193 'label' => esc_html__( 'Gray Scale Logo', 'shopbuilder' ),
194 'description' => esc_html__( 'Switch on to logo gray scale effect.', 'shopbuilder' ),
195 'label_on' => esc_html__( 'On', 'shopbuilder' ),
196 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
197 'type' => 'switch',
198 ];
199 $fields['display_logo_name'] = [
200 'label' => esc_html__( 'Show Logo Brand Name?', 'shopbuilder' ),
201 'description' => esc_html__( 'Switch on to show logo name.', 'shopbuilder' ),
202 'label_on' => esc_html__( 'On', 'shopbuilder' ),
203 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
204 'type' => 'switch',
205 'default' => 'yes',
206 ];
207 $fields['activate_slider_item'] = [
208 'label' => esc_html__( 'Activate Logo Slider?', 'shopbuilder' ),
209 'description' => esc_html__( 'Switch on to activate logo slider.', 'shopbuilder' ),
210 'label_on' => esc_html__( 'On', 'shopbuilder' ),
211 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
212 'type' => 'switch',
213 ];
214 $fields['logo_image_size_dimension_note'] = $obj->el_heading( esc_html__( 'Image Settings', 'shopbuilder' ), 'before' );
215 $fields['logo_image_size'] = [
216 'type' => 'select2',
217 'label' => esc_html__( 'Select Image Size', 'shopbuilder' ),
218 'description' => esc_html__( 'Please select the image size.', 'shopbuilder' ),
219 'options' => Fns::get_image_sizes(),
220 'default' => 'full',
221 'label_block' => true,
222 'content_classes' => 'elementor-descriptor',
223 ];
224 $fields['logo_img_dimension'] = [
225 'type' => 'image-dimensions',
226 'label' => esc_html__( 'Enter Custom Image Size', 'shopbuilder' ),
227 'label_block' => true,
228 'default' => [
229 'width' => 400,
230 'height' => 400,
231 ],
232 'condition' => [
233 'logo_image_size' => 'rtsb_custom',
234 ],
235 ];
236 $fields['logo_img_crop'] = [
237 'type' => 'select2',
238 'label' => esc_html__( 'Image Crop', 'shopbuilder' ),
239 'description' => esc_html__( 'Please click on "Apply" to update the image.', 'shopbuilder' ),
240 'options' => [
241 'soft' => esc_html__( 'Soft Crop', 'shopbuilder' ),
242 'hard' => esc_html__( 'Hard Crop', 'shopbuilder' ),
243 ],
244 'default' => 'hard',
245 'condition' => [
246 'logo_image_size' => 'rtsb_custom',
247 ],
248 ];
249 $fields['logo_img_custom_dimension_note'] = [
250 'type' => 'html',
251 'raw' => sprintf(
252 '<span style="display: block; background: #fffbf1; padding: 10px; font-weight: 500; line-height: 1.4; color: #bd3a3a;border: 1px solid #bd3a3a;">%s</span>',
253 esc_html__( 'Please note that, if you enter image size larger than the actual image itself, the image sizes will fallback to the full image dimension.', 'shopbuilder' )
254 ),
255 'condition' => [
256 'logo_image_size' => 'rtsb_custom',
257 ],
258
259 ];
260 $fields['general_settings_sec_end'] = $obj->end_section();
261
262 return $fields;
263 }
264 /**
265 * Logo Items
266 *
267 * @param object $obj Reference object.
268 *
269 * @return array
270 */
271 public static function logo_items( $obj ) {
272 $fields['logo_items_settings_sec_start'] = $obj->start_section(
273 esc_html__( 'Logo Items', 'shopbuilder' ),
274 'content',
275 [],
276 );
277 $fields['sb_logo_items'] = [
278 'type' => 'repeater',
279 'label' => esc_html__( 'Add Logo Items', 'shopbuilder' ),
280 'mode' => 'repeater',
281 'title_field' => '{{{ logo_name }}}',
282 'fields' => [
283 'logo_image' => [
284 'type' => 'media',
285 'label' => esc_html__( 'Upload Logo Image', 'shopbuilder' ),
286 'default' => [
287 'url' => Utils::get_placeholder_image_src(),
288 ],
289 ],
290 'logo_name' => [
291 'label' => esc_html__( 'Enter Logo Brand Name', 'shopbuilder' ),
292 'type' => 'text',
293 'label_block' => true,
294 'default' => esc_html__( 'ShopBuilder', 'shopbuilder' ),
295 'separator' => 'before-short',
296 ],
297 'enable_img_link' => [
298 'label' => esc_html__( 'Enable Image Link?', 'shopbuilder' ),
299 'description' => esc_html__( 'Switch on to enable image link.', 'shopbuilder' ),
300 'label_on' => esc_html__( 'On', 'shopbuilder' ),
301 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
302 'type' => 'switch',
303 'separator' => 'before-short',
304 ],
305 'img_link' => [
306 'label' => esc_html__( 'Enter URL', 'shopbuilder' ),
307 'type' => 'url',
308 'label_block' => true,
309 'condition' => [
310 'enable_img_link' => 'yes',
311 ],
312 ],
313
314 ],
315 ];
316 $fields['logo_items_settings_sec_end'] = $obj->end_section();
317 return $fields;
318 }
319
320 /**
321 * Slider section
322 *
323 * @param object $obj Reference object.
324 *
325 * @return array
326 */
327 public static function slider_settings( $obj ) {
328 $fields = SettingsFields::slider_settings( $obj );
329 unset( $fields['slider_nav_position'] );
330 $fields['slider_control_section']['condition'] = [
331 'activate_slider_item' => 'yes',
332 ];
333 $fields['slider_control_section']['tab'] = 'content';
334 return $fields;
335 }
336
337 /**
338 * Content Box style section
339 *
340 * @param object $obj Reference object.
341 *
342 * @return array
343 */
344 private static function logo_item_style( $obj ) {
345
346 $css_selectors = $obj->selectors['logo_item_style'];
347 $title = esc_html__( 'Logo Item', 'shopbuilder' );
348 $selectors = [
349 'box_shadow' => $css_selectors['box_shadow'],
350 'border' => $css_selectors['border'],
351 'bg_color' => [ $css_selectors['bg_color'] => 'background-color: {{VALUE}};' ],
352 'padding' => [ $css_selectors['padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
353 'border_radius' => [ $css_selectors['border_radius'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
354 ];
355
356 $fields = ControlHelper::general_elementor_style( 'logo_item_style', $title, $obj, [], $selectors );
357
358 unset(
359 $fields['logo_item_style_typo_note'],
360 $fields['rtsb_el_logo_item_style_typography'],
361 $fields['logo_item_style_color'],
362 $fields['logo_item_style_alignment'],
363 $fields['logo_item_style_color_tabs'],
364 $fields['logo_item_style_color_tab'],
365 $fields['logo_item_style_color_tab_end'],
366 $fields['logo_item_style_hover_color_tab'],
367 $fields['logo_item_style_hover_color'],
368 $fields['logo_item_style_hover_bg_color'],
369 $fields['logo_item_style_hover_color_tab_end'],
370 $fields['logo_item_style_color_tabs_end'],
371 $fields['logo_item_style_border_hover_color'],
372 $fields['logo_item_style_margin']
373 );
374 $fields['logo_item_style_border_note']['separator'] = 'default';
375 $fields['logo_item_style_color_note']['separator'] = 'default';
376 $extra_controls['logo_item_style_border_radius'] = [
377 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
378 'type' => 'dimensions',
379 'mode' => 'responsive',
380 'size_units' => [ 'px' ],
381 'selectors' => $selectors['border_radius'],
382 ];
383 $fields = Fns::insert_controls( 'logo_item_style_spacing_note', $fields, $extra_controls );
384
385 $extra_controls2['logo_item_style_box_shadow'] = [
386 'type' => 'box-shadow',
387 'mode' => 'group',
388 'label' => esc_html__( 'Box Shadow', 'shopbuilder' ),
389 'selector' => $selectors['box_shadow'],
390 ];
391 $fields = Fns::insert_controls( 'logo_item_style_border_note', $fields, $extra_controls2 );
392 return $fields;
393 }
394 /**
395 * Title style section
396 *
397 * @param object $obj Reference object.
398 *
399 * @return array
400 */
401 private static function title_style( $obj ) {
402 $css_selectors = $obj->selectors['title_style'];
403 $title = esc_html__( 'Title', 'shopbuilder' );
404 $selectors = [
405 'typography' => $css_selectors['typography'],
406 'color' => [ $css_selectors['color'] => 'color: {{VALUE}};' ],
407 'margin' => [ $css_selectors['margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;' ],
408 ];
409
410 $fields = ControlHelper::general_elementor_style( 'title_style', $title, $obj, [], $selectors );
411 unset(
412 $fields['title_style_alignment'],
413 $fields['rtsb_el_title_style_border'],
414 $fields['title_style_border_note'],
415 $fields['title_style_color_tabs'],
416 $fields['title_style_color_tab'],
417 $fields['title_style_color_tab_end'],
418 $fields['title_style_hover_color_tab'],
419 $fields['title_style_bg_color'],
420 $fields['title_style_hover_color'],
421 $fields['title_style_hover_bg_color'],
422 $fields['title_style_border_hover_color'],
423 $fields['title_style_padding'],
424 $fields['title_style_hover_color_tab_end'],
425 $fields['title_style_color_tabs_end'],
426 );
427 return $fields;
428 }
429 /**
430 * Image style section
431 *
432 * @param object $obj Reference object.
433 *
434 * @return array
435 */
436 public static function image_styles( $obj ) {
437 $alignment_options = ControlHelper::alignment();
438 unset( $alignment_options['justify'] );
439 $fields['image_style_sec_start'] = $obj->start_section(
440 esc_html__( 'Image', 'shopbuilder' ),
441 'style',
442 [],
443 );
444 $fields['image_styles_dimension_note'] = $obj->el_heading( esc_html__( 'Dimension', 'shopbuilder' ) );
445
446 $fields['image_styles_width'] = [
447 'type' => 'slider',
448 'label' => esc_html__( 'Image Width', 'shopbuilder' ),
449 'size_units' => [ '%', 'px' ],
450 'range' => [
451 '%' => [
452 'min' => 0,
453 'max' => 100,
454 'step' => 1,
455 ],
456 'px' => [
457 'min' => 0,
458 'max' => 600,
459 'step' => 1,
460 ],
461 ],
462 'selectors' => [
463 $obj->selectors['image_style']['width'] => 'width: {{SIZE}}{{UNIT}};',
464 ],
465 ];
466 $fields['image_styles_max_width'] = [
467 'type' => 'slider',
468 'label' => esc_html__( 'Image Max-Width', 'shopbuilder' ),
469 'size_units' => [ '%', 'px' ],
470 'range' => [
471 '%' => [
472 'min' => 0,
473 'max' => 100,
474 'step' => 1,
475 ],
476 'px' => [
477 'min' => 0,
478 'max' => 600,
479 'step' => 1,
480 ],
481
482 ],
483 'selectors' => [
484 $obj->selectors['image_style']['max_width'] => 'max-width: {{SIZE}}{{UNIT}};',
485 ],
486 ];
487 $fields['image_border_note'] = $obj->el_heading( esc_html__( 'Border', 'shopbuilder' ), 'before' );
488 $fields['image_border'] = [
489 'mode' => 'group',
490 'type' => 'border',
491 'label' => esc_html__( 'Border', 'shopbuilder' ),
492 'selector' => $obj->selectors['image_style']['border'],
493 'fields_options' => [
494 'color' => [
495 'label' => esc_html__( 'Border Color', 'shopbuilder' ),
496 ],
497 ],
498 'separator' => 'default',
499 ];
500 $fields['image_styles_radius'] = [
501 'mode' => 'responsive',
502 'type' => 'dimensions',
503 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
504 'size_units' => [ 'px', '%', 'em' ],
505 'selectors' => [
506 $obj->selectors['image_style']['border_radius'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
507 ],
508 ];
509 $fields['image_styles_spacing_note'] = $obj->el_heading( esc_html__( 'Spacing', 'shopbuilder' ) );
510 $fields['image_styles_margin'] = [
511 'mode' => 'responsive',
512 'type' => 'dimensions',
513 'label' => esc_html__( 'Margin', 'shopbuilder' ),
514 'size_units' => [ 'px', '%', 'em' ],
515 'selectors' => [
516 $obj->selectors['image_style']['margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
517 ],
518 ];
519 $fields['image_sec_end'] = $obj->end_section();
520
521 return $fields;
522 }
523 /**
524 * Slider Button section
525 *
526 * @param object $obj Reference object.
527 *
528 * @return array
529 */
530 public static function logo_slider_buttons( $obj ) {
531 $slider_btn_settings = StyleFieldsFree::slider_buttons( $obj );
532 $slider_btn_settings['slider_buttons_style_section']['condition'] = [
533 'activate_slider_item' => 'yes',
534 ];
535 return $slider_btn_settings;
536 }
537 }
538