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

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

563 lines 17.7 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\AdvancedHeading;
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::heading( $obj ),
35 self::sub_heading( $obj ),
36 self::description( $obj ),
37 );
38 }
39
40 /**
41 * Style section
42 *
43 * @param object $obj Reference object.
44 *
45 * @return array
46 */
47 public static function style( $obj ) {
48 return array_merge(
49 self::heading_style( $obj ),
50 self::separator_style( $obj ),
51 self::sub_heading_style( $obj ),
52 self::description_style( $obj ),
53 );
54 }
55
56 /**
57 * Preset section
58 *
59 * @param object $obj Reference object.
60 *
61 * @return array
62 */
63 private static function preset( $obj ) {
64 $fields['ah_preset'] = $obj->start_section(
65 esc_html__( 'Layout', 'shopbuilder' ),
66 'content'
67 );
68 $fields['layout_note'] = $obj->el_heading( esc_html__( 'Predefined Layouts', 'shopbuilder' ) );
69
70 $fields['layout_style'] = [
71 'type' => 'rtsb-image-selector',
72 'options' => ControlHelper::general_widgets_advanced_title_layouts(),
73 'default' => 'rtsb-advanced-heading-layout1',
74 ];
75
76 $fields['ah_element_alignment'] = [
77 'mode' => 'responsive',
78 'type' => 'choose',
79 'label' => esc_html__( 'Element Alignment', 'shopbuilder' ),
80 'options' => ControlHelper::alignment(),
81 'separator' => 'before',
82 'selectors' => [ $obj->selectors['layout']['alignment'] => 'text-align: {{VALUE}};' ],
83 ];
84
85 $fields['ah_preset_end'] = $obj->end_section();
86
87 return $fields;
88 }
89
90 /**
91 * Heading section
92 *
93 * @param object $obj Reference object.
94 *
95 * @return array
96 */
97 private static function heading( $obj ) {
98 $fields['ah_heading'] = $obj->start_section(
99 esc_html__( 'Heading', 'shopbuilder' ),
100 'content'
101 );
102
103 $fields['heading_title_html_tag'] = [
104 'label' => esc_html__( 'Title Tag', 'shopbuilder' ),
105 'description' => esc_html__( 'Please select the title tag.', 'shopbuilder' ),
106 'type' => 'select',
107 'options' => ControlHelper::heading_tags(),
108 'default' => 'h2',
109 'label_block' => true,
110 ];
111
112 $fields['heading_title_text'] = [
113 'label' => esc_html__( 'Heading Text', 'shopbuilder' ),
114 'description' => esc_html__( 'Please enter the heading text.', 'shopbuilder' ),
115 'type' => 'textarea',
116 'default' => esc_html__( 'ShopBuilder for Easy Store Customization', 'shopbuilder' ),
117 'label_block' => true,
118 ];
119
120 $fields['display_separator_note'] = $obj->el_heading(
121 esc_html__( 'Separator', 'shopbuilder' ),
122 'before',
123 );
124
125 $fields['display_separator'] = [
126 'label' => esc_html__( 'Show Separator?', 'shopbuilder' ),
127 'description' => esc_html__( 'Switch on to show separator.', 'shopbuilder' ),
128 'type' => 'switch',
129 'label_on' => esc_html__( 'On', 'shopbuilder' ),
130 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
131 'default' => 'yes',
132 ];
133
134 $fields['rtsb_separator_position'] = [
135 'mode' => 'responsive',
136 'type' => 'choose',
137 'label' => esc_html__( 'Separator Position', 'shopbuilder' ),
138 'default' => 'bottom',
139 'options' => [
140 'top' => [
141 'title' => esc_html__( 'Top', 'shopbuilder' ),
142 'icon' => 'eicon-v-align-top',
143 ],
144 'bottom' => [
145 'title' => esc_html__( 'Bottom', 'shopbuilder' ),
146 'icon' => 'eicon-v-align-bottom',
147 ],
148 ],
149 'toggle' => true,
150 'condition' => [
151 'display_separator' => 'yes',
152 ],
153 ];
154
155 $fields['ah_heading_end'] = $obj->end_section();
156
157 return $fields;
158 }
159
160 /**
161 * Sub-Heading section
162 *
163 * @param object $obj Reference object.
164 *
165 * @return array
166 */
167 private static function sub_heading( $obj ) {
168 $condition = [
169 'display_subheading' => 'yes',
170 ];
171
172 $fields['ah_sub_heading'] = $obj->start_section(
173 esc_html__( 'Sub-Heading', 'shopbuilder' ),
174 'content'
175 );
176
177 $fields['display_subheading'] = [
178 'label' => esc_html__( 'Show Sub-Heading?', 'shopbuilder' ),
179 'description' => esc_html__( 'Switch on to show sub-heading.', 'shopbuilder' ),
180 'label_on' => esc_html__( 'On', 'shopbuilder' ),
181 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
182 'type' => 'switch',
183 'default' => 'yes',
184 ];
185
186 $fields['subheading_html_tag'] = [
187 'label' => esc_html__( 'Sub-Heading Tag', 'shopbuilder' ),
188 'description' => esc_html__( 'Please select the sub-heading tag.', 'shopbuilder' ),
189 'type' => 'select',
190 'options' => ControlHelper::heading_tags(),
191 'default' => 'span',
192 'label_block' => true,
193 'condition' => $condition,
194 ];
195
196 $fields['subheading_text'] = [
197 'label' => esc_html__( 'Sub Heading Text', 'shopbuilder' ),
198 'description' => esc_html__( 'Please enter the sub-heading text.', 'shopbuilder' ),
199 'type' => 'textarea',
200 'default' => esc_html__( 'Transform Ideas into Sales', 'shopbuilder' ),
201 'label_block' => true,
202 'condition' => $condition,
203 ];
204
205 $fields['rtsb_subheading_position'] = [
206 'mode' => 'responsive',
207 'type' => 'choose',
208 'label' => esc_html__( 'Sub Heading Position', 'shopbuilder' ),
209 'options' => [
210 'top' => [
211 'title' => esc_html__( 'Top', 'shopbuilder' ),
212 'icon' => 'eicon-v-align-top',
213 ],
214 'bottom' => [
215 'title' => esc_html__( 'Bottom', 'shopbuilder' ),
216 'icon' => 'eicon-v-align-bottom',
217 ],
218
219 ],
220 'toggle' => true,
221 'default' => 'top',
222 'condition' => $condition,
223 ];
224
225 $fields['subheading_bars_note'] = $obj->el_heading(
226 esc_html__( 'Sub-Heading Bars', 'shopbuilder' ),
227 'before',
228 [],
229 $condition
230 );
231
232 $fields['display_subheading_left_bar'] = [
233 'label' => esc_html__( 'Show Left Bar?', 'shopbuilder' ),
234 'description' => esc_html__( 'Switch on to show left bar.', 'shopbuilder' ),
235 'type' => 'switch',
236 'label_on' => esc_html__( 'On', 'shopbuilder' ),
237 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
238 'default' => 'yes',
239 'condition' => $condition,
240 ];
241
242 $fields['display_subheading_right_bar'] = [
243 'label' => esc_html__( 'Show Right Bar?', 'shopbuilder' ),
244 'description' => esc_html__( 'Switch on to show right bar.', 'shopbuilder' ),
245 'type' => 'switch',
246 'label_on' => esc_html__( 'On', 'shopbuilder' ),
247 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
248 'default' => 'yes',
249 'condition' => $condition,
250 ];
251
252 $fields['ah_sub_heading_end'] = $obj->end_section();
253
254 return $fields;
255 }
256
257 /**
258 * Description section
259 *
260 * @param object $obj Reference object.
261 *
262 * @return array
263 */
264 private static function description( $obj ) {
265 $fields['ah_description'] = $obj->start_section(
266 esc_html__( 'Description', 'shopbuilder' ),
267 'content'
268 );
269
270 $fields['display_description'] = [
271 'label' => esc_html__( 'Show Description?', 'shopbuilder' ),
272 'description' => esc_html__( 'Switch on to show description.', 'shopbuilder' ),
273 'label_on' => esc_html__( 'On', 'shopbuilder' ),
274 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
275 'default' => 'yes',
276 'type' => 'switch',
277 ];
278
279 $fields['description_text'] = [
280 'label' => esc_html__( 'Description Text', 'shopbuilder' ),
281 'description' => esc_html__( 'Please enter the description text.', 'shopbuilder' ),
282 'type' => 'wysiwyg',
283 'label_block' => true,
284 'default' => esc_html__( 'ShopBuilder is a versatile plugin designed for Elementor Page Builder. This plugin helps you design and customize your online store easily, letting you create attractive product pages and improve the shopping experience for your customers.', 'shopbuilder' ),
285 'condition' => [
286 'display_description' => 'yes',
287 ],
288 ];
289
290 $fields['ah_description_end'] = $obj->end_section();
291
292 return $fields;
293 }
294
295 /**
296 * Heading style section
297 *
298 * @param object $obj Reference object.
299 *
300 * @return array
301 */
302 private static function heading_style( $obj ) {
303 $css_selectors = $obj->selectors['heading_style'];
304 $title = esc_html__( 'Heading Style', 'shopbuilder' );
305 $selectors = [
306 'typography' => $css_selectors['typography'],
307 'alignment' => [ $css_selectors['alignment'] => 'text-align: {{VALUE}}; justify-content: {{VALUE}};' ],
308 'color' => [ $css_selectors['color'] => 'color: {{VALUE}};' ],
309 'bg_color' => [ $css_selectors['bg_color'] => 'background-color: {{VALUE}};' ],
310 'border' => $css_selectors['border'],
311 'padding' => [ $css_selectors['padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
312 'margin' => [ $css_selectors['margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
313 ];
314
315 $fields = ControlHelper::general_elementor_style( 'ah_heading_style', $title, $obj, [], $selectors );
316
317 unset(
318 $fields['ah_heading_style_color_tabs'],
319 $fields['ah_heading_style_color_tab'],
320 $fields['ah_heading_style_color_tab_end'],
321 $fields['ah_heading_style_hover_color_tab'],
322 $fields['ah_heading_style_hover_color'],
323 $fields['ah_heading_style_hover_bg_color'],
324 $fields['ah_heading_style_hover_color_tab_end'],
325 $fields['ah_heading_style_color_tabs_end'],
326 $fields['ah_heading_style_border_hover_color']
327 );
328
329 return $fields;
330 }
331
332 /**
333 * Separator style section
334 *
335 * @param object $obj Reference object.
336 *
337 * @return array
338 */
339 private static function separator_style( $obj ) {
340 $css_selectors = $obj->selectors['separator_style'];
341 $title = esc_html__( 'Separator Style', 'shopbuilder' );
342 $condition = [ 'display_separator' => 'yes' ];
343 $selectors = [
344 'width' => [ $css_selectors['width'] => 'width: {{SIZE}}{{UNIT}};' ],
345 'height' => [ $css_selectors['height'] => 'border-width: {{SIZE}}{{UNIT}};' ],
346 'color' => [ $css_selectors['color'] => 'color: {{VALUE}};' ],
347 'margin' => [ $css_selectors['margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
348 ];
349
350 $fields = ControlHelper::general_elementor_style( 'ah_separator_style', $title, $obj, $condition, $selectors );
351
352 $fields['ah_separator_style_typo_note']['raw'] = '<h3 class="rtsb-elementor-group-heading">' . esc_html__( 'Dimension', 'shopbuilder' ) . '</h3>';
353
354 unset(
355 $fields['rtsb_el_ah_separator_style_typography'],
356 $fields['ah_separator_style_alignment'],
357 $fields['ah_separator_style_color_tabs'],
358 $fields['ah_separator_style_color_tab'],
359 $fields['ah_separator_style_color_tab_end'],
360 $fields['ah_separator_style_hover_color_tab'],
361 $fields['ah_separator_style_bg_color'],
362 $fields['ah_separator_style_hover_color'],
363 $fields['ah_separator_style_hover_bg_color'],
364 $fields['ah_separator_style_hover_color_tab_end'],
365 $fields['ah_separator_style_color_tabs_end'],
366 $fields['ah_separator_style_border_hover_color'],
367 $fields['ah_separator_style_border_note'],
368 $fields['rtsb_el_ah_separator_style_border'],
369 $fields['ah_separator_style_padding']
370 );
371
372 $extra_controls['ah_separator_width'] = [
373 'label' => esc_html__( 'Width', 'shopbuilder' ),
374 'type' => 'slider',
375 'mode' => 'responsive',
376 'size_units' => [ 'px', '%', 'em' ],
377 'range' => [
378 'px' => [
379 'min' => 0,
380 'max' => 1000,
381 ],
382 ],
383 'selectors' => $selectors['width'],
384 ];
385
386 $extra_controls['ah_separator_height'] = [
387 'label' => esc_html__( 'Height', 'shopbuilder' ),
388 'type' => 'slider',
389 'mode' => 'responsive',
390 'size_units' => [ 'px', '%', 'em' ],
391 'range' => [
392 'px' => [
393 'min' => 0,
394 'max' => 1000,
395 ],
396 ],
397 'selectors' => $selectors['height'],
398 ];
399
400 return Fns::insert_controls( 'ah_separator_style_typo_note', $fields, $extra_controls, true );
401 }
402
403 /**
404 * Sub-Heading style section
405 *
406 * @param object $obj Reference object.
407 *
408 * @return array
409 */
410 private static function sub_heading_style( $obj ) {
411 $css_selectors = $obj->selectors['sub_heading_style'];
412 $title = esc_html__( 'Sub-Heading Style', 'shopbuilder' );
413 $condition = [ 'display_subheading' => 'yes' ];
414 $bar_condition = [
415 'relation' => 'and',
416 'terms' => [
417 [
418 'relation' => 'or',
419 'terms' => [
420 [
421 'name' => 'display_subheading_left_bar',
422 'operator' => '==',
423 'value' => 'yes',
424 ],
425 [
426 'name' => 'display_subheading_right_bar',
427 'operator' => '==',
428 'value' => 'yes',
429 ],
430 ],
431 ],
432 ],
433 ];
434 $selectors = [
435 'typography' => $css_selectors['typography'],
436 'alignment' => [ $css_selectors['alignment'] => 'text-align: {{VALUE}}; justify-content: {{VALUE}};' ],
437 'color' => [ $css_selectors['color'] => 'color: {{VALUE}};' ],
438 'bg_color' => [ $css_selectors['bg_color'] => 'background-color: {{VALUE}};' ],
439 'border' => $css_selectors['border'],
440 'padding' => [ $css_selectors['padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
441 'margin' => [ $css_selectors['margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
442 'bar_width' => [ $css_selectors['bar_width'] => 'width: {{SIZE}}{{UNIT}};' ],
443 'bar_height' => [ $css_selectors['bar_height'] => 'height: {{SIZE}}{{UNIT}};' ],
444 'bar_gap' => [ $css_selectors['bar_gap'] => 'gap: {{SIZE}}{{UNIT}};' ],
445 'bar_color' => [ $css_selectors['bar_color'] => 'background-color: {{VALUE}};' ],
446 'bar_radius' => [ $css_selectors['bar_radius'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ],
447 ];
448
449 $fields = ControlHelper::general_elementor_style( 'ah_sub_heading_style', $title, $obj, $condition, $selectors );
450
451 unset(
452 $fields['ah_sub_heading_style_color_tabs'],
453 $fields['ah_sub_heading_style_color_tab'],
454 $fields['ah_sub_heading_style_color_tab_end'],
455 $fields['ah_sub_heading_style_hover_color_tab'],
456 $fields['ah_sub_heading_style_hover_color'],
457 $fields['ah_sub_heading_style_hover_bg_color'],
458 $fields['ah_sub_heading_style_hover_color_tab_end'],
459 $fields['ah_sub_heading_style_color_tabs_end'],
460 $fields['ah_sub_heading_style_border_hover_color']
461 );
462
463 $extra_controls['ah_sub_heading_bar_note'] = $obj->el_heading(
464 esc_html__( 'Sub-Heading Bars', 'shopbuilder' ),
465 'before',
466 $bar_condition
467 );
468
469 $extra_controls['ah_sub_heading_bar_width'] = [
470 'label' => esc_html__( 'Width', 'shopbuilder' ),
471 'type' => 'slider',
472 'mode' => 'responsive',
473 'size_units' => [ 'px', '%', 'em' ],
474 'range' => [
475 'px' => [
476 'min' => 10,
477 'max' => 1000,
478 ],
479 ],
480 'conditions' => $bar_condition,
481 'selectors' => $selectors['bar_width'],
482 ];
483
484 $extra_controls['ah_sub_heading_bar_height'] = [
485 'label' => esc_html__( 'Height', 'shopbuilder' ),
486 'type' => 'slider',
487 'mode' => 'responsive',
488 'size_units' => [ 'px', '%', 'em' ],
489 'range' => [
490 'px' => [
491 'min' => 10,
492 'max' => 1000,
493 ],
494 ],
495 'conditions' => $bar_condition,
496 'selectors' => $selectors['bar_height'],
497 ];
498
499 $extra_controls['ah_sub_heading_bar_gap'] = [
500 'label' => esc_html__( 'Gap', 'shopbuilder' ),
501 'type' => 'slider',
502 'mode' => 'responsive',
503 'conditions' => $bar_condition,
504 'selectors' => $selectors['bar_gap'],
505 ];
506
507 $extra_controls['ah_sub_heading_bar_color'] = [
508 'label' => esc_html__( 'Color', 'shopbuilder' ),
509 'type' => 'color',
510 'conditions' => $bar_condition,
511 'selectors' => $selectors['bar_color'],
512 ];
513
514 $extra_controls['sub_heading_bar_radius'] = [
515 'label' => esc_html__( 'Border Radius (px)', 'shopbuilder' ),
516 'type' => 'dimensions',
517 'size_units' => [ 'px' ],
518 'conditions' => $bar_condition,
519 'selectors' => $selectors['bar_radius'],
520 ];
521
522 return Fns::insert_controls( 'ah_sub_heading_style_margin', $fields, $extra_controls, true );
523 }
524
525 /**
526 * Description style section
527 *
528 * @param object $obj Reference object.
529 *
530 * @return array
531 */
532 private static function description_style( $obj ) {
533 $css_selectors = $obj->selectors['description_style'];
534 $title = esc_html__( 'Description Style', 'shopbuilder' );
535 $condition = [ 'display_description' => 'yes' ];
536 $selectors = [
537 'typography' => $css_selectors['typography'],
538 'alignment' => [ $css_selectors['alignment'] => 'text-align: {{VALUE}}; justify-content: {{VALUE}};' ],
539 'color' => [ $css_selectors['color'] => 'color: {{VALUE}};' ],
540 'bg_color' => [ $css_selectors['bg_color'] => 'background-color: {{VALUE}};' ],
541 'border' => $css_selectors['border'],
542 'padding' => [ $css_selectors['padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
543 'margin' => [ $css_selectors['margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ],
544 ];
545
546 $fields = ControlHelper::general_elementor_style( 'ah_description_style', $title, $obj, $condition, $selectors );
547
548 unset(
549 $fields['ah_description_style_color_tabs'],
550 $fields['ah_description_style_color_tab'],
551 $fields['ah_description_style_color_tab_end'],
552 $fields['ah_description_style_hover_color_tab'],
553 $fields['ah_description_style_hover_color'],
554 $fields['ah_description_style_hover_bg_color'],
555 $fields['ah_description_style_hover_color_tab_end'],
556 $fields['ah_description_style_color_tabs_end'],
557 $fields['ah_description_style_border_hover_color']
558 );
559
560 return $fields;
561 }
562 }
563