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 / ShopBuilderButton / Controls.php

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

582 lines 19.0 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\ShopBuilderButton;
9
10 use RadiusTheme\SB\Helpers\Fns;
11 use RadiusTheme\SB\Elementor\Helper\ControlHelper;
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 * Settings class.
20 *
21 * @package RadiusTheme\SB
22 */
23 class Controls {
24 /**
25 * Content section
26 *
27 * @param object $obj Reference object.
28 *
29 * @return array
30 */
31 public static function content( $obj ) {
32 return array_merge(
33 self::preset( $obj ),
34 self::button_content( $obj ),
35 self::connector_content( $obj )
36 );
37 }
38 /**
39 * Preset section
40 *
41 * @param object $obj Reference object.
42 *
43 * @return array
44 */
45 private static function preset( $obj ) {
46 $fields['sb_button_preset'] = $obj->start_section(
47 esc_html__( 'Preset', 'shopbuilder' ),
48 'content'
49 );
50 $fields['layout_note'] = $obj->el_heading( esc_html__( 'Predefined Layouts', 'shopbuilder' ) );
51 $fields['layout_style'] = [
52 'type' => 'rtsb-image-selector',
53 'options' => ControlHelper::general_widgets_button_layouts(),
54 'default' => 'rtsb-sb-button-layout1',
55 ];
56 $fields['sb_button_hover_effect_note'] = $obj->el_heading( esc_html__( 'Hover Effect Preset', 'shopbuilder' ), 'before' );
57 $fields['button_hover_effects'] = [
58 'type' => 'rtsb-image-selector',
59 'options' => ControlHelper::general_widgets_button_hover_effect_preset(),
60 'default' => 'rtsb-sb-button-hover-effect-default',
61 ];
62 $fields['hover_animation'] = [
63 'mode' => 'responsive',
64 'type' => 'choose',
65 'label' => esc_html__( 'Hover Animation', 'shopbuilder' ),
66 'options' => [
67 'left' => [
68 'title' => esc_html__( 'Left', 'shopbuilder' ),
69 'icon' => 'eicon-h-align-left',
70 ],
71 'top' => [
72 'title' => esc_html__( 'Top', 'shopbuilder' ),
73 'icon' => 'eicon-v-align-top',
74 ],
75 'right' => [
76 'title' => esc_html__( 'Right', 'shopbuilder' ),
77 'icon' => 'eicon-h-align-right',
78 ],
79
80 ],
81 'toggle' => true,
82 'default' => 'left',
83 'condition' => [
84 'button_hover_effects' => [ 'rtsb-sb-button-hover-effect-preset2' ],
85 ],
86 ];
87
88 $fields['sb_button_end'] = $obj->end_section();
89 return $fields;
90 }
91
92 /**
93 * Style section
94 *
95 * @param object $obj Reference object.
96 *
97 * @return array
98 */
99 public static function style( $obj ) {
100 return array_merge(
101 self::button_style( $obj, 'primary' ),
102 self::button_style( $obj, 'secondary' ),
103 self::connector_style( $obj )
104 );
105 }
106
107 /**
108 * Content section
109 *
110 * @param object $obj Reference object.
111 *
112 * @return array
113 */
114 private static function button_content( $obj ) {
115 $condition = [
116 'layout_style' => [ 'rtsb-sb-button-layout2' ],
117 ];
118 $fields['sb_button_content_start'] = $obj->start_section(
119 esc_html__( 'Button', 'shopbuilder' ),
120 'content'
121 );
122 $fields['sb_button_button1_note'] = $obj->el_heading( esc_html__( 'Button 1', 'shopbuilder' ), 'default', [], [ 'layout_style' => 'rtsb-sb-button-layout2' ] );
123 $fields['sb_button__content'] = [
124 'label' => esc_html__( 'Text', 'shopbuilder' ),
125 'description' => esc_html__( 'Please enter the button text.', 'shopbuilder' ),
126 'type' => 'text',
127 'label_block' => true,
128 'default' => __( 'ShopBuilder Button', 'shopbuilder' ),
129 ];
130 $fields['sb_button_link'] = [
131 'type' => 'link',
132 'label' => esc_html__( 'Link', 'shopbuilder' ),
133 'description' => esc_html__( 'Please enter a button link.', 'shopbuilder' ),
134 'placeholder' => esc_html__( 'https://custom-link.com', 'shopbuilder' ),
135 'options' => [ 'url', 'is_external', 'nofollow' ],
136 ];
137 $fields['sb_button1_icon'] = [
138 'label' => esc_html__( 'Button Icon', 'shopbuilder' ),
139 'type' => 'icons',
140 'default' => [
141 'value' => 'fas fa-arrow-right',
142 'library' => 'fa-solid',
143 ],
144 ];
145 $fields['sb_button1_icon_position'] = [
146 'mode' => 'responsive',
147 'type' => 'choose',
148 'label' => esc_html__( 'Position', 'shopbuilder' ),
149 'options' => [
150 'left' => [
151 'title' => esc_html__( 'Left', 'shopbuilder' ),
152 'icon' => 'eicon-h-align-left',
153 ],
154 'right' => [
155 'title' => esc_html__( 'Right', 'shopbuilder' ),
156 'icon' => 'eicon-h-align-right',
157 ],
158
159 ],
160 'toggle' => true,
161 'default' => 'right',
162 ];
163 $fields['sb_button_button2_note'] = $obj->el_heading( esc_html__( 'Button 2', 'shopbuilder' ), 'default', [], $condition );
164 $fields['sb_button2__content'] = [
165 'label' => esc_html__( 'Text', 'shopbuilder' ),
166 'description' => esc_html__( 'Please enter the button text.', 'shopbuilder' ),
167 'type' => 'text',
168 'label_block' => true,
169 'default' => __( 'ShopBuilder Button', 'shopbuilder' ),
170 'condition' => $condition,
171 ];
172 $fields['sb_button2_link'] = [
173 'type' => 'link',
174 'label' => esc_html__( 'Link', 'shopbuilder' ),
175 'description' => esc_html__( 'Please enter a button link.', 'shopbuilder' ),
176 'placeholder' => esc_html__( 'https://custom-link.com', 'shopbuilder' ),
177 'options' => [ 'url', 'is_external', 'nofollow' ],
178 'condition' => $condition,
179 ];
180 $fields['sb_button2_icon'] = [
181 'label' => esc_html__( 'Button Icon', 'shopbuilder' ),
182 'type' => 'icons',
183 'default' => [
184 'value' => 'fas fa-arrow-right',
185 'library' => 'fa-solid',
186 ],
187 'condition' => $condition,
188 ];
189 $fields['sb_button2_icon_position'] = [
190 'mode' => 'responsive',
191 'type' => 'choose',
192 'label' => esc_html__( 'Position', 'shopbuilder' ),
193 'options' => [
194 'left' => [
195 'title' => esc_html__( 'Left', 'shopbuilder' ),
196 'icon' => 'eicon-h-align-left',
197 ],
198 'right' => [
199 'title' => esc_html__( 'Right', 'shopbuilder' ),
200 'icon' => 'eicon-h-align-right',
201 ],
202
203 ],
204 'condition' => $condition,
205 'toggle' => true,
206 'default' => 'right',
207 ];
208 $fields['sb_button_content_end'] = $obj->end_section();
209
210 return $fields;
211 }
212 /**
213 * Connector section
214 *
215 * @param object $obj Reference object.
216 *
217 * @return array
218 */
219 private static function connector_content( $obj ) {
220 $condition = [
221 'layout_style' => [ 'rtsb-sb-button-layout2' ],
222 ];
223 $fields['sb_button_connector_start'] = $obj->start_section(
224 esc_html__( 'Connector', 'shopbuilder' ),
225 'content',
226 [],
227 $condition
228 );
229 $fields['display_connector'] = [
230 'label' => esc_html__( 'Show Connector?', 'shopbuilder' ),
231 'description' => esc_html__( 'Switch on to show connector.', 'shopbuilder' ),
232 'label_on' => esc_html__( 'On', 'shopbuilder' ),
233 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
234 'type' => 'switch',
235 'default' => 'yes',
236 ];
237 $fields['connector_type'] = [
238 'label' => esc_html__( 'Connector Type', 'shopbuilder' ),
239 'type' => 'choose',
240 'options' => [
241 'text' => [
242 'title' => esc_html__( 'Text', 'shopbuilder' ),
243 'icon' => 'eicon-text',
244 ],
245 'icon' => [
246 'title' => esc_html__( 'Icon', 'shopbuilder' ),
247 'icon' => 'eicon-nerd',
248 ],
249 ],
250 'default' => 'text',
251 'condition' => [
252 'display_connector' => [ 'yes' ],
253 ],
254 ];
255 $fields['sb_button_connect_text'] = [
256 'label' => esc_html__( 'Text', 'shopbuilder' ),
257 'description' => esc_html__( 'Please enter the button text.', 'shopbuilder' ),
258 'type' => 'text',
259 'label_block' => true,
260 'default' => __( 'OR', 'shopbuilder' ),
261 'condition' => [
262 'display_connector' => [ 'yes' ],
263 'connector_type' => [ 'text' ],
264 ],
265 ];
266 $fields['sb_button_connect_icon'] = [
267 'label' => esc_html__( 'Icon', 'shopbuilder' ),
268 'type' => 'icons',
269 'default' => [
270 'value' => 'fas fa-arrow-right',
271 'library' => 'fa-solid',
272 ],
273 'condition' => [
274 'display_connector' => [ 'yes' ],
275 'connector_type' => [ 'icon' ],
276 ],
277 ];
278 $fields['sb_button_connector_position'] = [
279 'type' => 'slider',
280 'mode' => 'responsive',
281 'label' => esc_html__( 'Connector Position', 'shopbuilder' ),
282 'size_units' => [ '%', 'px' ],
283 'range' => [
284 '%' => [
285 'min' => 0,
286 'max' => 100,
287 ],
288 'px' => [
289 'min' => 0,
290 'max' => 1000,
291 ],
292 ],
293 'default' => [
294 'unit' => '%',
295 ],
296 'selectors' => [
297 $obj->selectors['connector_style']['connector_position'] => 'left: {{SIZE}}{{UNIT}};',
298 ],
299 ];
300 $fields['sb_button_gap'] = [
301 'type' => 'slider',
302 'mode' => 'responsive',
303 'label' => esc_html__( 'Button Gap', 'shopbuilder' ),
304 'size_units' => [ 'px','%' ],
305 'range' => [
306 'px' => [
307 'min' => 0,
308 'max' => 1000,
309 ],
310 '%' => [
311 'min' => 0,
312 'max' => 100,
313 ],
314 ],
315 'selectors' => [
316 $obj->selectors['connector_style']['button_gap'] => 'gap: {{SIZE}}{{UNIT}};',
317 ],
318 ];
319 $fields['sb_button_connector_end'] = $obj->end_section();
320
321 return $fields;
322 }
323 /**
324 * Description style section
325 *
326 * @param object $obj Reference object.
327 *
328 * @return array
329 */
330 private static function button_style( $obj, $type = 'primary' ) {
331 $condition = [];
332 if ( 'secondary' === $type ) {
333 $condition = [
334 'layout_style' => [ 'rtsb-sb-button-layout2' ],
335 ];
336 }
337 $css_selectors = $obj->selectors[ $type . '_button_style' ];
338 $title = sprintf(
339 // Translators: %s is replaced with the button type, e.g., "Primary", "Secondary", etc.
340 esc_html__( '%s Button Style', 'shopbuilder' ),
341 ucfirst( $type )
342 );
343 $selectors = [
344 'typography' => $css_selectors['typography'],
345 'alignment' => [ $css_selectors['alignment'] => 'text-align: {{VALUE}}; justify-content: {{VALUE}};' ],
346 'icon_size' => [
347 $css_selectors['icon_size']['font_size'] => 'font-size: {{SIZE}}{{UNIT}};',
348 $css_selectors['icon_size']['svg'] => 'height: {{SIZE}}{{UNIT}};width: {{SIZE}}{{UNIT}};',
349 ],
350 'icon_gap' => [ $css_selectors['icon_gap'] => 'gap: {{SIZE}}{{UNIT}};' ],
351 'btn_width' => [ $css_selectors['btn_width'] => 'min-width: {{SIZE}}{{UNIT}};' ],
352 'btn_height' => [ $css_selectors['btn_height'] => 'height: {{SIZE}}{{UNIT}};' ],
353 'color' => [ $css_selectors['color'] => 'color: {{VALUE}};' ],
354 'hover_color' => [ $css_selectors['hover_color'] => 'color: {{VALUE}};' ],
355 'gradient_bg' => $css_selectors['gradient_bg'],
356 'hover_gradient_bg' => $css_selectors['hover_gradient_bg'],
357 'border' => $css_selectors['border'],
358 'box_shadow' => $css_selectors['box_shadow'],
359 'hover_box_shadow' => $css_selectors['hover_box_shadow'],
360 'border_hover_color' => [ $css_selectors['border_hover_color'] => 'border-color: {{VALUE}};' ],
361 'padding' => [ $css_selectors['padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
362 'margin' => [ $css_selectors['margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
363 'border_radius' => [ $css_selectors['border_radius'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
364 ];
365
366 $fields = ControlHelper::general_elementor_style( 'sb_' . $type . '_button_style', $title, $obj, $condition, $selectors );
367 unset(
368 $fields[ 'sb_' . $type . '_button_style_bg_color' ],
369 $fields[ 'sb_' . $type . '_button_style_hover_bg_color' ],
370 );
371 if ( 'secondary' === $type ) {
372 unset( $fields[ 'sb_' . $type . '_button_style_alignment' ] );
373 }
374 $extra_controls[ 'sb_' . $type . '_button_style_border_radius' ] = [
375 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
376 'type' => 'dimensions',
377 'mode' => 'responsive',
378 'size_units' => [ 'px' ],
379 'selectors' => $selectors['border_radius'],
380 ];
381 $fields = Fns::insert_controls( 'sb_' . $type . '_button_style_spacing_note', $fields, $extra_controls );
382 $extra_controls2[ 'sb_' . $type . '_button_style_btn_width' ] = [
383 'type' => 'slider',
384 'mode' => 'responsive',
385 'label' => esc_html__( 'Button Width', 'shopbuilder' ),
386 'size_units' => [ 'px','%' ],
387 'range' => [
388 'px' => [
389 'min' => 10,
390 'max' => 1000,
391 ],
392 '%' => [
393 'min' => 0,
394 'max' => 100,
395 ],
396 ],
397 'selectors' => $selectors['btn_width'],
398 ];
399 $extra_controls2[ 'sb_' . $type . '_button_style_btn_height' ] = [
400 'type' => 'slider',
401 'mode' => 'responsive',
402 'label' => esc_html__( 'Button Height', 'shopbuilder' ),
403 'size_units' => [ 'px','%' ],
404 'range' => [
405 'px' => [
406 'min' => 10,
407 'max' => 1000,
408 ],
409 '%' => [
410 'min' => 0,
411 'max' => 100,
412 ],
413 ],
414 'selectors' => $selectors['btn_height'],
415 ];
416 $extra_controls2[ 'sb_' . $type . '_button_style_icon_size' ] = [
417 'type' => 'slider',
418 'mode' => 'responsive',
419 'label' => esc_html__( 'Icon Size', 'shopbuilder' ),
420 'size_units' => [ 'px' ],
421 'range' => [
422 'px' => [
423 'min' => 0,
424 'max' => 100,
425 ],
426 ],
427 'selectors' => $selectors['icon_size'],
428 ];
429 $extra_controls2[ 'sb_' . $type . '_button_style_icon_gap' ] = [
430 'type' => 'slider',
431 'mode' => 'responsive',
432 'label' => esc_html__( 'Icon Gap', 'shopbuilder' ),
433 'size_units' => [ 'px' ],
434 'range' => [
435 'px' => [
436 'min' => 0,
437 'max' => 100,
438 ],
439 ],
440 'selectors' => $selectors['icon_gap'],
441 ];
442 $fields = Fns::insert_controls( 'sb_' . $type . '_button_style_spacing_note', $fields, $extra_controls2, true );
443 $extra_controls3[ 'sb_' . $type . '_button_style_gradient_bg' ] = [
444 'label' => esc_html__( 'Background', 'shopbuilder' ),
445 'type' => 'background',
446 'mode' => 'group',
447 'selector' => $selectors['gradient_bg'],
448 ];
449 $extra_controls3[ 'sb_' . $type . '_button_style_box_shadow' ] = [
450 'type' => 'box-shadow',
451 'mode' => 'group',
452 'label' => esc_html__( 'Box Shadow', 'shopbuilder' ),
453 'selector' => $selectors['box_shadow'],
454 ];
455 $fields = Fns::insert_controls( 'sb_' . $type . '_button_style_color', $fields, $extra_controls3, true );
456 $extra_controls4[ 'sb_' . $type . '_button_style_hover_gradient_bg' ] = [
457 'label' => esc_html__( 'Hover Background', 'shopbuilder' ),
458 'type' => 'background',
459 'mode' => 'group',
460 'selector' => $selectors['hover_gradient_bg'],
461 ];
462 $extra_controls4[ 'sb_' . $type . '_button_style_hover_box_shadow' ] = [
463 'type' => 'box-shadow',
464 'mode' => 'group',
465 'label' => esc_html__( 'Hover Box Shadow', 'shopbuilder' ),
466 'selector' => $selectors['hover_box_shadow'],
467 ];
468 $fields = Fns::insert_controls( 'sb_' . $type . '_button_style_hover_color', $fields, $extra_controls4, true );
469 return $fields;
470 }
471 /**
472 * Connector style section
473 *
474 * @param object $obj Reference object.
475 *
476 * @return array
477 */
478 private static function connector_style( $obj ) {
479 $css_selectors = $obj->selectors['connector_style'];
480 $title = esc_html__( 'Connector Style', 'shopbuilder' );
481 $condition = [
482 'display_connector' => 'yes',
483 'layout_style' => 'rtsb-sb-button-layout2',
484 ];
485 $selectors = [
486 'typography' => $css_selectors['typography'],
487 'icon_size' => [
488 $css_selectors['icon_size']['font_size'] => 'font-size: {{SIZE}}{{UNIT}};',
489 $css_selectors['icon_size']['svg'] => 'height: {{SIZE}}{{UNIT}};width: {{SIZE}}{{UNIT}};',
490 ],
491 'color' => [ $css_selectors['color'] => 'color: {{VALUE}};' ],
492 'bg_color' => [ $css_selectors['bg_color'] => 'background: {{VALUE}};' ],
493 'border' => $css_selectors['border'],
494 'box_shadow' => $css_selectors['box_shadow'],
495 'border_radius' => [ $css_selectors['border_radius'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
496 'connector_width' => [ $css_selectors['connector_width'] => 'width: {{SIZE}}{{UNIT}}' ],
497 'connector_height' => [ $css_selectors['connector_height'] => 'height: {{SIZE}}{{UNIT}}' ],
498 ];
499
500 $fields = ControlHelper::general_elementor_style( 'sb_button_connector_style', $title, $obj, $condition, $selectors );
501 $extra_fields['sb_button_connector_style_icon_size'] = [
502 'type' => 'slider',
503 'mode' => 'responsive',
504 'label' => esc_html__( 'Icon Size', 'shopbuilder' ),
505 'size_units' => [ 'px' ],
506 'range' => [
507 'px' => [
508 'min' => 0,
509 'max' => 100,
510 ],
511 ],
512 'selectors' => $selectors['icon_size'],
513 'condition' => [
514 'connector_type' => [ 'icon' ],
515 ],
516 ];
517 $fields = Fns::insert_controls( 'rtsb_el_sb_button_connector_style_typography', $fields, $extra_fields, true );
518 $extra_fields2['sb_button_connector_style_border_radius'] = [
519 'label' => esc_html__( 'Border Radius', 'shopbuilder' ),
520 'type' => 'dimensions',
521 'mode' => 'responsive',
522 'size_units' => [ 'px' ],
523 'selectors' => $selectors['border_radius'],
524 ];
525 $extra_fields2['sb_button_connector_style_box_shadow'] = [
526 'type' => 'box-shadow',
527 'mode' => 'group',
528 'label' => esc_html__( 'Box Shadow', 'shopbuilder' ),
529 'selector' => $selectors['box_shadow'],
530 ];
531 $fields = Fns::insert_controls( 'rtsb_el_sb_button_connector_style_border', $fields, $extra_fields2, true );
532 $extra_controls3['sb_button_connector_style_size_note'] = $obj->el_heading(
533 esc_html__( 'Size', 'shopbuilder' ),
534 'before',
535 );
536 $extra_controls3['sb_button_style_connector_width'] = [
537 'type' => 'slider',
538 'mode' => 'responsive',
539 'label' => esc_html__( 'Width', 'shopbuilder' ),
540 'size_units' => [ 'px' ],
541 'range' => [
542 'px' => [
543 'min' => 0,
544 'max' => 100,
545 ],
546 ],
547 'selectors' => $selectors['connector_width'],
548 ];
549 $extra_controls3['sb_button_style_connector_height'] = [
550 'type' => 'slider',
551 'mode' => 'responsive',
552 'label' => esc_html__( 'Height', 'shopbuilder' ),
553 'size_units' => [ 'px' ],
554 'range' => [
555 'px' => [
556 'min' => 0,
557 'max' => 100,
558 ],
559 ],
560 'selectors' => $selectors['connector_height'],
561 ];
562 $fields = Fns::insert_controls( 'sb_button_connector_style_box_shadow', $fields, $extra_controls3, true );
563 unset(
564 $fields['sb_button_connector_style_alignment'],
565 $fields['sb_button_connector_style_color_tabs'],
566 $fields['sb_button_connector_style_color_tab'],
567 $fields['sb_button_connector_style_color_tab_end'],
568 $fields['sb_button_connector_style_hover_color_tab'],
569 $fields['sb_button_connector_style_hover_color'],
570 $fields['sb_button_connector_style_hover_bg_color'],
571 $fields['sb_button_connector_style_hover_color_tab_end'],
572 $fields['sb_button_connector_style_color_tabs_end'],
573 $fields['sb_button_connector_style_border_hover_color'],
574 $fields['sb_button_connector_style_padding'],
575 $fields['sb_button_connector_style_spacing_note'],
576 $fields['sb_button_connector_style_margin'],
577 );
578
579 return $fields;
580 }
581 }
582