PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
← All changes | includes/blocks/modules/general-style.php +608 -556 1.1.0 → 3.6.6 View file →
@@ -1,556 +1,608 @@
1 -<?php
2 -
3 -
4 -namespace Jet_Form_Builder\Blocks\Modules;
5 -
6 -
7 -trait General_Style {
8 -
9 - use General_Style_Functions;
10 -
11 - public function general_style_manager_options() {
12 - $this->maybe_add_controls_type( 'wrap' );
13 - $this->maybe_add_controls_type( 'input' );
14 - $this->maybe_add_controls_type( 'label' );
15 - $this->maybe_add_controls_type( 'required' );
16 - $this->maybe_add_controls_type( 'description' );
17 - }
18 -
19 - public function general_css_scheme() {
20 - return array(
21 - 'wrap' => $this->get_field_wrap(),
22 - 'label' => $this->get_label_selector(),
23 - 'input' => $this->get_field_input(),
24 - 'required' => $this->get_required_selector(),
25 - 'description' => $this->get_description_selector()
26 - );
27 - }
28 -
29 - public function general_controls_callbacks() {
30 - return array(
31 - 'wrap' => array( $this, 'add_content_controls' ),
32 - 'label' => array( $this, 'add_label_controls' ),
33 - 'input' => array( $this, 'add_input_controls' ),
34 - 'required' => array( $this, 'add_required_mark_controls' ),
35 - 'description' => array( $this, 'add_description_controls' ),
36 - );
37 - }
38 -
39 - public function general_style_unregister() {
40 - return array( 'input' );
41 - }
42 -
43 - public function get_label_selector() {
44 - return '__label.%1$s__label.%1$s__label';
45 - }
46 -
47 - public function get_required_selector() {
48 - return '__label span.%1$s__required.%1$s__required.%1$s__required';
49 - }
50 -
51 - public function get_description_selector() {
52 - return '__desc.%1$s__desc.%1$s__desc';
53 - }
54 -
55 - public function get_field_wrap() {
56 - return '-row.%1$s-row.%1$s-row.%1$s-row';
57 - }
58 -
59 - public function get_field_input() {
60 - return '-row.%1$s-row.%1$s-row input';
61 - }
62 -
63 -
64 - public function general_style_attributes() {
65 - return array(
66 - 'label_margin' => array(
67 - 'type' => 'object'
68 - ),
69 - 'label_padding' => array(
70 - 'type' => 'object'
71 - ),
72 - 'label_typography' => array(
73 - 'type' => 'object'
74 - ),
75 - 'label_color' => array(
76 - 'type' => 'object'
77 - ),
78 - 'label_border' => array(
79 - 'type' => 'object'
80 - ),
81 - 'label_alignment' => array(
82 - 'type' => 'object'
83 - ),
84 - 'label_background_color' => array(
85 - 'type' => 'object'
86 - ),
87 - 'description_margin' => array(
88 - 'type' => 'object'
89 - ),
90 - 'description_padding' => array(
91 - 'type' => 'object'
92 - ),
93 - 'description_typography' => array(
94 - 'type' => 'object'
95 - ),
96 - 'description_color' => array(
97 - 'type' => 'object'
98 - ),
99 - 'description_background_color' => array(
100 - 'type' => 'object'
101 - ),
102 - 'description_border' => array(
103 - 'type' => 'object'
104 - ),
105 - 'description_alignment' => array(
106 - 'type' => 'object'
107 - ),
108 - 'required_color' => array(
109 - 'type' => 'object'
110 - ),
111 - 'required_background_color' => array(
112 - 'type' => 'object'
113 - ),
114 - 'required_typography' => array(
115 - 'type' => 'object'
116 - ),
117 - );
118 - }
119 -
120 - public function _get_default_control( $selector ) {
121 - return array(
122 - 'padding' => array(
123 - 'type' => 'dimensions',
124 - 'label' => __( 'Padding', 'jet-form-builder' ),
125 - 'units' => array( 'px', '%' ),
126 - 'css_selector' => array(
127 - $selector => 'padding: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
128 - ),
129 - ),
130 - 'margin' => array(
131 - 'type' => 'dimensions',
132 - 'label' => __( 'Margin', 'jet-form-builder' ),
133 - 'units' => array( 'px', '%' ),
134 - 'css_selector' => array(
135 - $selector => 'margin: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
136 - ),
137 - )
138 - );
139 - }
140 -
141 - public function add_margin_padding( $selector, $control_options, $responsive = array() ) {
142 - foreach ( $control_options as $type => $options ) {
143 - $options = $this->merge_controls_or_add_id( $this->_get_default_control( $selector )[ $type ], $options );
144 -
145 - if ( in_array( $type, $responsive ) ) {
146 - $this->controls_manager->add_responsive_control( $options );
147 - } else {
148 - $this->controls_manager->add_control( $options );
149 - }
150 - }
151 - }
152 -
153 - public function merge_controls_or_add_id( $control, $options ) {
154 - if ( is_array( $options ) ) {
155 - return array_merge( $control, $options );
156 -
157 - } elseif ( is_string( $options ) ) {
158 -
159 - $control['id'] = $options;
160 -
161 - return $control;
162 - }
163 - }
164 -
165 -
166 - private function add_content_controls() {
167 - $this->controls_manager->start_section(
168 - 'style_controls',
169 - [
170 - 'id' => 'content_style',
171 - 'title' => __( 'Content', 'jet-form-builder' )
172 - ]
173 - );
174 -
175 - $this->add_margin_padding(
176 - $this->selector( 'wrap' ),
177 - array(
178 - 'margin' => array(
179 - 'id' => 'field_margin',
180 - 'separator' => 'after',
181 - ),
182 - 'padding' => array(
183 - 'id' => 'field_padding',
184 - 'separator' => 'after',
185 - )
186 - ),
187 - array( 'padding', 'margin' )
188 - );
189 -
190 - $this->controls_manager->add_control( [
191 - 'id' => 'field_alignment',
192 - 'type' => 'choose',
193 - 'label' => __( 'Alignment', 'jet-form-builder' ),
194 - 'separator' => 'after',
195 - 'options' => [
196 - 'left' => [
197 - 'shortcut' => __( 'Left', 'jet-form-builder' ),
198 - 'icon' => 'dashicons-editor-alignleft',
199 - ],
200 - 'center' => [
201 - 'shortcut' => __( 'Center', 'jet-form-builder' ),
202 - 'icon' => 'dashicons-editor-aligncenter',
203 - ],
204 - 'right' => [
205 - 'shortcut' => __( 'Right', 'jet-form-builder' ),
206 - 'icon' => 'dashicons-editor-alignright',
207 - ],
208 - ],
209 - 'css_selector' => [
210 - $this->selector( 'wrap' ) => 'text-align: {{VALUE}};',
211 - ],
212 - ] );
213 -
214 -
215 - $this->controls_manager->add_control( [
216 - 'id' => 'field_border',
217 - 'type' => 'border',
218 - 'label' => __( 'Border', 'jet-form-builder' ),
219 - 'separator' => 'after',
220 - 'css_selector' => array(
221 - $this->selector( 'wrap' ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
222 - ),
223 - ] );
224 -
225 - $this->controls_manager->add_control( [
226 - 'id' => 'field_background_color',
227 - 'type' => 'color-picker',
228 - 'label' => __( 'Background Color', 'jet-form-builder' ),
229 - 'css_selector' => array(
230 - $this->selector( 'wrap' ) => 'background-color: {{VALUE}}',
231 - ),
232 - ] );
233 -
234 - $this->controls_manager->end_section();
235 - }
236 -
237 - private function add_label_controls() {
238 - $this->controls_manager->start_section(
239 - 'style_controls',
240 - [
241 - 'id' => 'label_style',
242 - 'title' => __( 'Label', 'jet-form-builder' )
243 - ]
244 - );
245 -
246 - $this->add_margin_padding(
247 - $this->selector( 'label' ),
248 - array(
249 - 'margin' => array(
250 - 'id' => 'label_margin',
251 - 'separator' => 'after',
252 - ),
253 - 'padding' => array(
254 - 'id' => 'label_padding',
255 - 'separator' => 'after',
256 - )
257 - )
258 - );
259 -
260 - $this->controls_manager->add_control( [
261 - 'id' => 'label_alignment',
262 - 'type' => 'choose',
263 - 'label' => __( 'Alignment', 'jet-form-builder' ),
264 - 'separator' => 'after',
265 - 'options' => [
266 - 'left' => [
267 - 'shortcut' => __( 'Left', 'jet-form-builder' ),
268 - 'icon' => 'dashicons-editor-alignleft',
269 - ],
270 - 'center' => [
271 - 'shortcut' => __( 'Center', 'jet-form-builder' ),
272 - 'icon' => 'dashicons-editor-aligncenter',
273 - ],
274 - 'right' => [
275 - 'shortcut' => __( 'Right', 'jet-form-builder' ),
276 - 'icon' => 'dashicons-editor-alignright',
277 - ],
278 - ],
279 - 'css_selector' => [
280 - $this->selector( 'label' ) => 'text-align: {{VALUE}};',
281 - ],
282 - ] );
283 -
284 - $this->controls_manager->add_control( [
285 - 'id' => 'label_typography',
286 - 'type' => 'typography',
287 - 'separator' => 'after',
288 - 'css_selector' => [
289 - $this->selector( 'label' ) => 'font-family: {{FAMILY}}; font-weight: {{WEIGHT}}; text-transform: {{TRANSFORM}}; font-style: {{STYLE}}; text-decoration: {{DECORATION}}; line-height: {{LINEHEIGHT}}{{LH_UNIT}}; letter-spacing: {{LETTERSPACING}}{{LS_UNIT}}; font-size: {{SIZE}}{{S_UNIT}};',
290 - ],
291 - ] );
292 -
293 - $this->controls_manager->add_control( [
294 - 'id' => 'label_border',
295 - 'type' => 'border',
296 - 'label' => __( 'Border', 'jet-form-builder' ),
297 - 'separator' => 'after',
298 - 'css_selector' => array(
299 - $this->selector( 'label' ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
300 - ),
301 - ] );
302 -
303 - $this->controls_manager->add_control( [
304 - 'id' => 'label_color',
305 - 'type' => 'color-picker',
306 - 'separator' => 'after',
307 - 'label' => __( 'Text Color', 'jet-form-builder' ),
308 - 'css_selector' => array(
309 - $this->selector( 'label' ) => 'color: {{VALUE}}',
310 - ),
311 - ] );
312 -
313 - $this->controls_manager->add_control( [
314 - 'id' => 'label_background_color',
315 - 'type' => 'color-picker',
316 - 'label' => __( 'Background Color', 'jet-form-builder' ),
317 - 'css_selector' => array(
318 - $this->selector( 'label' ) => 'background-color: {{VALUE}}',
319 - ),
320 - ] );
321 -
322 - $this->controls_manager->end_section();
323 - }
324 -
325 - private function add_description_controls() {
326 - $this->controls_manager->start_section(
327 - 'style_controls',
328 - [
329 - 'id' => 'description_style',
330 - 'title' => __( 'Description', 'jet-form-builder' ),
331 - /*'condition' => array(
332 - 'desc' => true
333 - ),*/
334 - ]
335 - );
336 -
337 - $this->add_margin_padding(
338 - $this->selector( 'description' ),
339 - array(
340 - 'margin' => array(
341 - 'id' => 'description_margin',
342 - 'separator' => 'after',
343 - ),
344 - 'padding' => array(
345 - 'id' => 'description_padding',
346 - 'separator' => 'after',
347 - )
348 - )
349 - );
350 -
351 - $this->controls_manager->add_control( [
352 - 'id' => 'description_alignment',
353 - 'type' => 'choose',
354 - 'label' => __( 'Alignment', 'jet-form-builder' ),
355 - 'separator' => 'after',
356 - 'options' => [
357 - 'left' => [
358 - 'shortcut' => __( 'Left', 'jet-form-builder' ),
359 - 'icon' => 'dashicons-editor-alignleft',
360 - ],
361 - 'center' => [
362 - 'shortcut' => __( 'Center', 'jet-form-builder' ),
363 - 'icon' => 'dashicons-editor-aligncenter',
364 - ],
365 - 'right' => [
366 - 'shortcut' => __( 'Right', 'jet-form-builder' ),
367 - 'icon' => 'dashicons-editor-alignright',
368 - ],
369 - ],
370 - 'css_selector' => [
371 - $this->selector( 'description' ) => 'text-align: {{VALUE}};',
372 - ],
373 - ] );
374 -
375 - $this->controls_manager->add_control( [
376 - 'id' => 'description_border',
377 - 'type' => 'border',
378 - 'label' => __( 'Border', 'jet-form-builder' ),
379 - 'separator' => 'after',
380 - 'css_selector' => array(
381 - $this->selector( 'description' ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
382 - ),
383 - ] );
384 -
385 - $this->controls_manager->add_control( [
386 - 'id' => 'description_typography',
387 - 'type' => 'typography',
388 - 'separator' => 'after',
389 - 'css_selector' => [
390 - $this->selector( 'description' ) => 'font-family: {{FAMILY}}; font-weight: {{WEIGHT}}; text-transform: {{TRANSFORM}}; font-style: {{STYLE}}; text-decoration: {{DECORATION}}; line-height: {{LINEHEIGHT}}{{LH_UNIT}}; letter-spacing: {{LETTERSPACING}}{{LS_UNIT}}; font-size: {{SIZE}}{{S_UNIT}};',
391 - ],
392 - ] );
393 -
394 - $this->controls_manager->add_control( [
395 - 'id' => 'description_color',
396 - 'type' => 'color-picker',
397 - 'separator' => 'after',
398 - 'label' => __( 'Text Color', 'jet-form-builder' ),
399 - 'css_selector' => array(
400 - $this->selector( 'description' ) => 'color: {{VALUE}}',
401 - ),
402 - ] );
403 -
404 - $this->controls_manager->add_control( [
405 - 'id' => 'description_background_color',
406 - 'type' => 'color-picker',
407 - 'label' => __( 'Background Color', 'jet-form-builder' ),
408 - 'css_selector' => array(
409 - $this->selector( 'description' ) => 'background-color: {{VALUE}}',
410 - ),
411 - ] );
412 -
413 - $this->controls_manager->end_section();
414 - }
415 -
416 - private function add_required_mark_controls() {
417 - $this->controls_manager->start_section(
418 - 'style_controls',
419 - [
420 - 'id' => 'required_style',
421 - 'title' => __( 'Required Mark', 'jet-form-builder' )
422 - ]
423 - );
424 -
425 - $this->controls_manager->add_control( [
426 - 'id' => 'required_typography',
427 -
428 - 'disable_line_height' => true,
429 - 'disable_family' => true,
430 - 'disable_transform' => true,
431 - 'disable_style' => true,
432 - 'disable_decoration' => true,
433 - 'disable_letter_spacing' => true,
434 - 'separator' => 'after',
435 - 'type' => 'typography',
436 - 'css_selector' => [
437 - $this->selector( 'required' ) => 'font-weight: {{WEIGHT}}; font-size: {{SIZE}}{{S_UNIT}};',
438 - ],
439 - ] );
440 -
441 - $this->controls_manager->add_control( [
442 - 'id' => 'required_color',
443 - 'type' => 'color-picker',
444 - 'separator' => 'after',
445 - 'label' => __( 'Text Color', 'jet-form-builder' ),
446 - 'css_selector' => array(
447 - $this->selector( 'required' ) => 'color: {{VALUE}}',
448 - ),
449 - ] );
450 -
451 - $this->controls_manager->add_control( [
452 - 'id' => 'required_background_color',
453 - 'type' => 'color-picker',
454 - 'label' => __( 'Background Color', 'jet-form-builder' ),
455 - 'css_selector' => array(
456 - $this->selector( 'required' ) => 'background-color: {{VALUE}}',
457 - ),
458 - ] );
459 -
460 -
461 - $this->controls_manager->end_section();
462 - }
463 -
464 - private function add_input_controls() {
465 - $this->controls_manager->start_section(
466 - 'style_controls',
467 - [
468 - 'id' => 'input_style',
469 - 'title' => __( 'Field', 'jet-form-builder' )
470 - ]
471 - );
472 -
473 - $this->add_margin_padding(
474 - $this->selector( 'input' ),
475 - array(
476 - 'margin' => array(
477 - 'id' => 'input_margin',
478 - 'separator' => 'after',
479 - ),
480 - 'padding' => array(
481 - 'id' => 'input_padding',
482 - 'separator' => 'after',
483 - )
484 - )
485 - );
486 -
487 - $this->controls_manager->add_control( $this->merge_controls_or_add_id(
488 - array(
489 - 'id' => 'input_alignment',
490 - 'type' => 'choose',
491 - 'label' => __( 'Alignment', 'jet-form-builder' ),
492 - 'separator' => 'after',
493 - 'options' => [
494 - 'left' => [
495 - 'shortcut' => __( 'Left', 'jet-form-builder' ),
496 - 'icon' => 'dashicons-editor-alignleft',
497 - ],
498 - 'center' => [
499 - 'shortcut' => __( 'Center', 'jet-form-builder' ),
500 - 'icon' => 'dashicons-editor-aligncenter',
501 - ],
502 - 'right' => [
503 - 'shortcut' => __( 'Right', 'jet-form-builder' ),
504 - 'icon' => 'dashicons-editor-alignright',
505 - ],
506 - ],
507 - 'css_selector' => array(
508 - $this->selector( 'input' ) => 'text-align: {{VALUE}};',
509 - ),
510 - ),
511 - $this->get_additional_styles( 'input_alignment' )
512 - ) );
513 -
514 - $this->controls_manager->add_control( [
515 - 'id' => 'input_typography',
516 - 'type' => 'typography',
517 - 'separator' => 'after',
518 - 'css_selector' => [
519 - $this->selector( 'input' ) => 'font-family: {{FAMILY}}; font-weight: {{WEIGHT}}; text-transform: {{TRANSFORM}}; font-style: {{STYLE}}; text-decoration: {{DECORATION}}; line-height: {{LINEHEIGHT}}{{LH_UNIT}}; letter-spacing: {{LETTERSPACING}}{{LS_UNIT}}; font-size: {{SIZE}}{{S_UNIT}};',
520 - ],
521 - ] );
522 -
523 - $this->controls_manager->add_control( [
524 - 'id' => 'input_border',
525 - 'type' => 'border',
526 - 'label' => __( 'Border', 'jet-form-builder' ),
527 - 'separator' => 'after',
528 - 'css_selector' => array(
529 - $this->selector( 'input' ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
530 - ),
531 - ] );
532 -
533 - $this->controls_manager->add_control( [
534 - 'id' => 'input_color',
535 - 'type' => 'color-picker',
536 - 'separator' => 'after',
537 - 'label' => __( 'Text Color', 'jet-form-builder' ),
538 - 'css_selector' => array(
539 - $this->selector( 'input' ) => 'color: {{VALUE}}',
540 - ),
541 - ] );
542 -
543 - $this->controls_manager->add_control( [
544 - 'id' => 'input_background_color',
545 - 'type' => 'color-picker',
546 - 'label' => __( 'Background Color', 'jet-form-builder' ),
547 - 'css_selector' => array(
548 - $this->selector( 'input' ) => 'background-color: {{VALUE}}',
549 - ),
550 - ] );
551 -
552 - $this->controls_manager->end_section();
553 - }
554 -
555 -
556 -}
1 +<?php
2 +
3 +
4 +namespace Jet_Form_Builder\Blocks\Modules;
5 +
6 +use JET_SM\Gutenberg\Controls_Manager;
7 +
8 +// If this file is called directly, abort.
9 +if ( ! defined( 'WPINC' ) ) {
10 + die;
11 +}
12 +
13 +/**
14 + * @property Controls_Manager controls_manager
15 + *
16 + * Trait General_Style
17 + * @package Jet_Form_Builder\Blocks\Modules
18 + */
19 +trait General_Style {
20 +
21 + use General_Style_Functions;
22 +
23 + public function general_style_manager_options() {
24 + $this->maybe_add_controls_type( 'wrap' );
25 + $this->maybe_add_controls_type( 'input' );
26 + $this->maybe_add_controls_type( 'label' );
27 + $this->maybe_add_controls_type( 'required' );
28 + $this->maybe_add_controls_type( 'description' );
29 + }
30 +
31 + public function general_css_scheme() {
32 + return array(
33 + 'wrap' => $this->get_field_wrap(),
34 + 'label' => $this->get_label_selector(),
35 + 'input' => $this->get_field_input(),
36 + 'required' => $this->get_required_selector(),
37 + 'description' => $this->get_description_selector(),
38 + );
39 + }
40 +
41 + public function general_controls_callbacks() {
42 + return array(
43 + 'wrap' => array( $this, 'add_content_controls' ),
44 + 'label' => array( $this, 'add_label_controls' ),
45 + 'input' => array( $this, 'add_input_controls' ),
46 + 'required' => array( $this, 'add_required_mark_controls' ),
47 + 'description' => array( $this, 'add_description_controls' ),
48 + );
49 + }
50 +
51 + public function general_style_unregister() {
52 + return array( 'input' );
53 + }
54 +
55 + public function get_label_selector() {
56 + return '__label';
57 + }
58 +
59 + public function get_required_selector() {
60 + return '__label span.%1$s__required';
61 + }
62 +
63 + public function get_description_selector() {
64 + return '__desc';
65 + }
66 +
67 + public function get_field_wrap() {
68 + return '.%1$s-row';
69 + }
70 +
71 + public function get_field_input() {
72 + return '.%1$s-row input';
73 + }
74 +
75 +
76 + public function general_style_attributes() {
77 + return array(
78 + 'label_margin' => array(
79 + 'type' => 'object',
80 + ),
81 + 'label_padding' => array(
82 + 'type' => 'object',
83 + ),
84 + 'label_typography' => array(
85 + 'type' => 'object',
86 + ),
87 + 'label_color' => array(
88 + 'type' => 'object',
89 + ),
90 + 'label_border' => array(
91 + 'type' => 'object',
92 + ),
93 + 'label_alignment' => array(
94 + 'type' => 'object',
95 + ),
96 + 'label_background_color' => array(
97 + 'type' => 'object',
98 + ),
99 + 'description_margin' => array(
100 + 'type' => 'object',
101 + ),
102 + 'description_padding' => array(
103 + 'type' => 'object',
104 + ),
105 + 'description_typography' => array(
106 + 'type' => 'object',
107 + ),
108 + 'description_color' => array(
109 + 'type' => 'object',
110 + ),
111 + 'description_background_color' => array(
112 + 'type' => 'object',
113 + ),
114 + 'description_border' => array(
115 + 'type' => 'object',
116 + ),
117 + 'description_alignment' => array(
118 + 'type' => 'object',
119 + ),
120 + 'required_color' => array(
121 + 'type' => 'object',
122 + ),
123 + 'required_background_color' => array(
124 + 'type' => 'object',
125 + ),
126 + 'required_typography' => array(
127 + 'type' => 'object',
128 + ),
129 + );
130 + }
131 +
132 + // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
133 + public function _get_default_control( $selector ) {
134 + return array(
135 + 'padding' => array(
136 + 'type' => 'dimensions',
137 + 'label' => __( 'Padding', 'jet-form-builder' ),
138 + 'units' => array( 'px', '%' ),
139 + 'css_selector' => array(
140 + $selector => 'padding: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
141 + ),
142 + ),
143 + 'margin' => array(
144 + 'type' => 'dimensions',
145 + 'label' => __( 'Margin', 'jet-form-builder' ),
146 + 'units' => array( 'px', '%' ),
147 + 'css_selector' => array(
148 + $selector => 'margin: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
149 + ),
150 + ),
151 + );
152 + }
153 +
154 + public function add_margin_padding( $selector, $control_options, $responsive = array() ) {
155 + foreach ( $control_options as $type => $options ) {
156 + $options = $this->merge_controls_or_add_id( $this->_get_default_control( $selector )[ $type ], $options );
157 +
158 + if ( in_array( $type, $responsive, true ) ) {
159 + $this->controls_manager->add_responsive_control( $options );
160 + } else {
161 + $this->controls_manager->add_control( $options );
162 + }
163 + }
164 + }
165 +
166 + public function merge_controls_or_add_id( $control, $options ) {
167 + if ( is_array( $options ) ) {
168 + return array_merge( $control, $options );
169 +
170 + } elseif ( is_string( $options ) ) {
171 +
172 + $control['id'] = $options;
173 +
174 + return $control;
175 + }
176 +
177 + return $control;
178 + }
179 +
180 +
181 + private function add_content_controls() {
182 + $this->controls_manager->start_section(
183 + 'style_controls',
184 + array(
185 + 'id' => 'content_style',
186 + 'title' => __( 'Content', 'jet-form-builder' ),
187 + )
188 + );
189 +
190 + $this->add_margin_padding(
191 + $this->selector_no_space( $this->get_field_wrap() ),
192 + array(
193 + 'margin' => array(
194 + 'id' => 'field_margin',
195 + 'separator' => 'after',
196 + ),
197 + 'padding' => array(
198 + 'id' => 'field_padding',
199 + 'separator' => 'after',
200 + ),
201 + ),
202 + array( 'padding', 'margin' )
203 + );
204 +
205 + $this->controls_manager->add_control(
206 + array(
207 + 'id' => 'field_alignment',
208 + 'type' => 'choose',
209 + 'label' => __( 'Alignment', 'jet-form-builder' ),
210 + 'separator' => 'after',
211 + 'options' => array(
212 + 'left' => array(
213 + 'shortcut' => __( 'Left', 'jet-form-builder' ),
214 + 'icon' => 'dashicons-editor-alignleft',
215 + ),
216 + 'center' => array(
217 + 'shortcut' => __( 'Center', 'jet-form-builder' ),
218 + 'icon' => 'dashicons-editor-aligncenter',
219 + ),
220 + 'right' => array(
221 + 'shortcut' => __( 'Right', 'jet-form-builder' ),
222 + 'icon' => 'dashicons-editor-alignright',
223 + ),
224 + ),
225 + 'css_selector' => array(
226 + $this->selector_no_space( $this->get_field_wrap() ) => 'text-align: {{VALUE}};',
227 + ),
228 + )
229 + );
230 +
231 + $this->controls_manager->add_control(
232 + array(
233 + 'id' => 'field_border',
234 + 'type' => 'border',
235 + 'label' => __( 'Border', 'jet-form-builder' ),
236 + 'separator' => 'after',
237 + 'css_selector' => array(
238 + $this->selector_no_space( $this->get_field_wrap() ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
239 + ),
240 + )
241 + );
242 +
243 + $this->controls_manager->add_control(
244 + array(
245 + 'id' => 'field_background_color',
246 + 'type' => 'color-picker',
247 + 'label' => __( 'Background', 'jet-form-builder' ),
248 + 'css_selector' => array(
249 + $this->selector_no_space( $this->get_field_wrap() ) => 'background-color: {{VALUE}}',
250 + ),
251 + )
252 + );
253 +
254 + $this->controls_manager->end_section();
255 + }
256 +
257 + private function add_label_controls() {
258 + $this->controls_manager->start_section(
259 + 'style_controls',
260 + array(
261 + 'id' => 'label_style',
262 + 'title' => __( 'Label', 'jet-form-builder' ),
263 + )
264 + );
265 +
266 + $this->add_margin_padding(
267 + $this->selector( 'label' ),
268 + array(
269 + 'margin' => array(
270 + 'id' => 'label_margin',
271 + 'separator' => 'after',
272 + ),
273 + 'padding' => array(
274 + 'id' => 'label_padding',
275 + 'separator' => 'after',
276 + ),
277 + )
278 + );
279 +
280 + $this->controls_manager->add_control(
281 + array(
282 + 'id' => 'label_alignment',
283 + 'type' => 'choose',
284 + 'label' => __( 'Alignment', 'jet-form-builder' ),
285 + 'separator' => 'after',
286 + 'options' => array(
287 + 'left' => array(
288 + 'shortcut' => __( 'Left', 'jet-form-builder' ),
289 + 'icon' => 'dashicons-editor-alignleft',
290 + ),
291 + 'center' => array(
292 + 'shortcut' => __( 'Center', 'jet-form-builder' ),
293 + 'icon' => 'dashicons-editor-aligncenter',
294 + ),
295 + 'right' => array(
296 + 'shortcut' => __( 'Right', 'jet-form-builder' ),
297 + 'icon' => 'dashicons-editor-alignright',
298 + ),
299 + ),
300 + 'css_selector' => array(
301 + $this->selector( 'label' ) => 'text-align: {{VALUE}};',
302 + ),
303 + )
304 + );
305 +
306 + $this->controls_manager->add_control(
307 + array(
308 + 'id' => 'label_typography',
309 + 'type' => 'typography',
310 + 'separator' => 'after',
311 + 'css_selector' => array(
312 + $this->selector( 'label' ) => 'font-family: {{FAMILY}}; font-weight: {{WEIGHT}}; text-transform: {{TRANSFORM}}; font-style: {{STYLE}}; text-decoration: {{DECORATION}}; line-height: {{LINEHEIGHT}}{{LH_UNIT}}; letter-spacing: {{LETTERSPACING}}{{LS_UNIT}}; font-size: {{SIZE}}{{S_UNIT}};',
313 + ),
314 + )
315 + );
316 +
317 + $this->controls_manager->add_control(
318 + array(
319 + 'id' => 'label_border',
320 + 'type' => 'border',
321 + 'label' => __( 'Border', 'jet-form-builder' ),
322 + 'separator' => 'after',
323 + 'css_selector' => array(
324 + $this->selector( 'label' ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
325 + ),
326 + )
327 + );
328 +
329 + $this->controls_manager->add_control(
330 + array(
331 + 'id' => 'label_color',
332 + 'type' => 'color-picker',
333 + 'separator' => 'after',
334 + 'label' => __( 'Text Color', 'jet-form-builder' ),
335 + 'css_selector' => array(
336 + $this->selector( 'label' ) => 'color: {{VALUE}}',
337 + ),
338 + )
339 + );
340 +
341 + $this->controls_manager->add_control(
342 + array(
343 + 'id' => 'label_background_color',
344 + 'type' => 'color-picker',
345 + 'label' => __( 'Background', 'jet-form-builder' ),
346 + 'css_selector' => array(
347 + $this->selector( 'label' ) => 'background-color: {{VALUE}}',
348 + ),
349 + )
350 + );
351 +
352 + $this->controls_manager->end_section();
353 + }
354 +
355 + private function add_description_controls() {
356 + $this->controls_manager->start_section(
357 + 'style_controls',
358 + array(
359 + 'id' => 'description_style',
360 + 'title' => __( 'Description', 'jet-form-builder' ),
361 + )
362 + );
363 +
364 + $this->add_margin_padding(
365 + $this->selector( 'description' ),
366 + array(
367 + 'margin' => array(
368 + 'id' => 'description_margin',
369 + 'separator' => 'after',
370 + ),
371 + 'padding' => array(
372 + 'id' => 'description_padding',
373 + 'separator' => 'after',
374 + ),
375 + )
376 + );
377 +
378 + $this->controls_manager->add_control(
379 + array(
380 + 'id' => 'description_alignment',
381 + 'type' => 'choose',
382 + 'label' => __( 'Alignment', 'jet-form-builder' ),
383 + 'separator' => 'after',
384 + 'options' => array(
385 + 'left' => array(
386 + 'shortcut' => __( 'Left', 'jet-form-builder' ),
387 + 'icon' => 'dashicons-editor-alignleft',
388 + ),
389 + 'center' => array(
390 + 'shortcut' => __( 'Center', 'jet-form-builder' ),
391 + 'icon' => 'dashicons-editor-aligncenter',
392 + ),
393 + 'right' => array(
394 + 'shortcut' => __( 'Right', 'jet-form-builder' ),
395 + 'icon' => 'dashicons-editor-alignright',
396 + ),
397 + ),
398 + 'css_selector' => array(
399 + $this->selector( 'description' ) => 'text-align: {{VALUE}};',
400 + ),
401 + )
402 + );
403 +
404 + $this->controls_manager->add_control(
405 + array(
406 + 'id' => 'description_border',
407 + 'type' => 'border',
408 + 'label' => __( 'Border', 'jet-form-builder' ),
409 + 'separator' => 'after',
410 + 'css_selector' => array(
411 + $this->selector( 'description' ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
412 + ),
413 + )
414 + );
415 +
416 + $this->controls_manager->add_control(
417 + array(
418 + 'id' => 'description_typography',
419 + 'type' => 'typography',
420 + 'separator' => 'after',
421 + 'css_selector' => array(
422 + $this->selector( 'description' ) => 'font-family: {{FAMILY}}; font-weight: {{WEIGHT}}; text-transform: {{TRANSFORM}}; font-style: {{STYLE}}; text-decoration: {{DECORATION}}; line-height: {{LINEHEIGHT}}{{LH_UNIT}}; letter-spacing: {{LETTERSPACING}}{{LS_UNIT}}; font-size: {{SIZE}}{{S_UNIT}};',
423 + ),
424 + )
425 + );
426 +
427 + $this->controls_manager->add_control(
428 + array(
429 + 'id' => 'description_color',
430 + 'type' => 'color-picker',
431 + 'separator' => 'after',
432 + 'label' => __( 'Text Color', 'jet-form-builder' ),
433 + 'css_selector' => array(
434 + $this->selector( 'description' ) => 'color: {{VALUE}}',
435 + ),
436 + )
437 + );
438 +
439 + $this->controls_manager->add_control(
440 + array(
441 + 'id' => 'description_background_color',
442 + 'type' => 'color-picker',
443 + 'label' => __( 'Background', 'jet-form-builder' ),
444 + 'css_selector' => array(
445 + $this->selector( 'description' ) => 'background-color: {{VALUE}}',
446 + ),
447 + )
448 + );
449 +
450 + $this->controls_manager->end_section();
451 + }
452 +
453 + private function add_required_mark_controls() {
454 + $this->controls_manager->start_section(
455 + 'style_controls',
456 + array(
457 + 'id' => 'required_style',
458 + 'title' => __( 'Required Mark', 'jet-form-builder' ),
459 + )
460 + );
461 +
462 + $this->controls_manager->add_control(
463 + array(
464 + 'id' => 'required_typography',
465 +
466 + 'disable_line_height' => true,
467 + 'disable_family' => true,
468 + 'disable_transform' => true,
469 + 'disable_style' => true,
470 + 'disable_decoration' => true,
471 + 'disable_letter_spacing' => true,
472 + 'separator' => 'after',
473 + 'type' => 'typography',
474 + 'css_selector' => array(
475 + $this->selector( 'required' ) => 'font-weight: {{WEIGHT}}; font-size: {{SIZE}}{{S_UNIT}};',
476 + ),
477 + )
478 + );
479 +
480 + $this->controls_manager->add_control(
481 + array(
482 + 'id' => 'required_color',
483 + 'type' => 'color-picker',
484 + 'separator' => 'after',
485 + 'label' => __( 'Text Color', 'jet-form-builder' ),
486 + 'css_selector' => array(
487 + $this->selector( 'required' ) => 'color: {{VALUE}}',
488 + ),
489 + )
490 + );
491 +
492 + $this->controls_manager->add_control(
493 + array(
494 + 'id' => 'required_background_color',
495 + 'type' => 'color-picker',
496 + 'label' => __( 'Background', 'jet-form-builder' ),
497 + 'css_selector' => array(
498 + $this->selector( 'required' ) => 'background-color: {{VALUE}}',
499 + ),
500 + )
501 + );
502 +
503 + $this->controls_manager->end_section();
504 + }
505 +
506 + private function add_input_controls() {
507 + $this->controls_manager->start_section(
508 + 'style_controls',
509 + array(
510 + 'id' => 'input_style',
511 + 'title' => __( 'Field', 'jet-form-builder' ),
512 + )
513 + );
514 +
515 + $this->add_margin_padding(
516 + $this->selector_no_space( $this->get_field_input() ),
517 + array(
518 + 'margin' => array(
519 + 'id' => 'input_margin',
520 + 'separator' => 'after',
521 + ),
522 + 'padding' => array(
523 + 'id' => 'input_padding',
524 + 'separator' => 'after',
525 + ),
526 + )
527 + );
528 +
529 + $this->controls_manager->add_control(
530 + $this->merge_controls_or_add_id(
531 + array(
532 + 'id' => 'input_alignment',
533 + 'type' => 'choose',
534 + 'label' => __( 'Alignment', 'jet-form-builder' ),
535 + 'separator' => 'after',
536 + 'options' => array(
537 + 'left' => array(
538 + 'shortcut' => __( 'Left', 'jet-form-builder' ),
539 + 'icon' => 'dashicons-editor-alignleft',
540 + ),
541 + 'center' => array(
542 + 'shortcut' => __( 'Center', 'jet-form-builder' ),
543 + 'icon' => 'dashicons-editor-aligncenter',
544 + ),
545 + 'right' => array(
546 + 'shortcut' => __( 'Right', 'jet-form-builder' ),
547 + 'icon' => 'dashicons-editor-alignright',
548 + ),
549 + ),
550 + 'css_selector' => array(
551 + $this->selector_no_space( $this->get_field_input() ) => 'text-align: {{VALUE}};',
552 + ),
553 + ),
554 + $this->get_additional_styles( 'input_alignment' )
555 + )
556 + );
557 +
558 + $this->controls_manager->add_control(
559 + array(
560 + 'id' => 'input_typography',
561 + 'type' => 'typography',
562 + 'separator' => 'after',
563 + 'css_selector' => array(
564 + $this->selector_no_space( $this->get_field_input() ) => 'font-family: {{FAMILY}}; font-weight: {{WEIGHT}}; text-transform: {{TRANSFORM}}; font-style: {{STYLE}}; text-decoration: {{DECORATION}}; line-height: {{LINEHEIGHT}}{{LH_UNIT}}; letter-spacing: {{LETTERSPACING}}{{LS_UNIT}}; font-size: {{SIZE}}{{S_UNIT}};',
565 + ),
566 + )
567 + );
568 +
569 + $this->controls_manager->add_control(
570 + array(
571 + 'id' => 'input_border',
572 + 'type' => 'border',
573 + 'label' => __( 'Border', 'jet-form-builder' ),
574 + 'separator' => 'after',
575 + 'css_selector' => array(
576 + $this->selector_no_space( $this->get_field_input() ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
577 + ),
578 + )
579 + );
580 +
581 + $this->controls_manager->add_control(
582 + array(
583 + 'id' => 'input_color',
584 + 'type' => 'color-picker',
585 + 'separator' => 'after',
586 + 'label' => __( 'Text Color', 'jet-form-builder' ),
587 + 'css_selector' => array(
588 + $this->selector_no_space( $this->get_field_input() ) => 'color: {{VALUE}}',
589 + ),
590 + )
591 + );
592 +
593 + $this->controls_manager->add_control(
594 + array(
595 + 'id' => 'input_background_color',
596 + 'type' => 'color-picker',
597 + 'label' => __( 'Background', 'jet-form-builder' ),
598 + 'css_selector' => array(
599 + $this->selector_no_space( $this->get_field_input() ) => 'background-color: {{VALUE}}',
600 + ),
601 + )
602 + );
603 +
604 + $this->controls_manager->end_section();
605 + }
606 +
607 +
608 +}