PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 1.3.0
JetFormBuilder — Dynamic Blocks Form Builder v1.3.0
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 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / blocks / modules / general-style-functions.php
jetformbuilder / includes / blocks / modules Last commit date
fields-errors 4 years ago base-module.php 4 years ago general-style-functions.php 4 years ago general-style.php 4 years ago
general-style-functions.php
113 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Blocks\Modules;
5
6
7 trait General_Style_Functions {
8
9 private $namespace = 'jet-form-builder';
10
11 public function maybe_add_controls_type( $type ) {
12 if ( ! in_array( $type, $this->general_style_unregister() ) ) {
13
14 if ( is_callable( $this->general_controls_callbacks()[ $type ] ) ) {
15 $this->general_controls_callbacks()[$type]();
16 }
17 }
18 }
19
20 public function additional_selectors_for_controls() {
21 return array();
22 }
23
24 public function get_additional_styles( $id ) {
25 $styles = $this->additional_selectors_for_controls();
26
27 return isset( $styles[ $id ] ) ? $styles[ $id ] : array();
28 }
29
30 public function selector( $selector = '', $prefix_base = '', $additional = '' ) {
31 $base = $prefix_base . ".$this->namespace";
32
33 if ( $selector && isset( $this->css_scheme[ $selector ] ) ) {
34 $selector = $this->css_scheme[ $selector ];
35 }
36
37 $result = "{{WRAPPER}} $base" . sprintf( $selector, $this->namespace );
38
39 if ( $additional ) {
40 $result .= $additional;
41 }
42
43 return $result;
44 }
45
46 public function selector_no_space( $selector = '' ) {
47 return ( "{{WRAPPER}}" . sprintf( $selector, $this->namespace ) );
48 }
49
50 public function button_selector( $selector, $additional = '' ) {
51 return $this->selector( $selector, 'button', $additional );
52 }
53
54 public function div_selector( $selector, $additional = '' ) {
55 return $this->selector( $selector, 'div', $additional );
56 }
57
58
59 public function get_default_margin_control( $selector ) {
60 return array(
61 'type' => 'dimensions',
62 'label' => __( 'Margin', 'jet-form-builder' ),
63 'units' => array( 'px', '%' ),
64 'css_selector' => array(
65 '{{WRAPPER}} ' . $selector => 'margin: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
66 ),
67 );
68 }
69
70 public function get_default_padding_control( $selector ) {
71 return array(
72 'type' => 'dimensions',
73 'label' => __( 'Padding', 'jet-form-builder' ),
74 'units' => array( 'px', '%' ),
75 'css_selector' => array(
76 $selector => 'padding: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
77 ),
78 );
79 }
80
81 public function add_margin_padding( $selector, $control_options ) {
82 if ( isset( $control_options['margin'] ) ) {
83
84 $options = $this->merge_controls_or_add_id(
85 $this->get_default_margin_control( $selector ),
86 $control_options['margin']
87 );
88 $this->controls_manager->add_control( $options );
89 }
90
91 if ( isset( $control_options['padding'] ) ) {
92
93 $options = $this->merge_controls_or_add_id(
94 $this->get_default_padding_control( $selector ),
95 $control_options['padding']
96 );
97 $this->controls_manager->add_control( $options );
98 }
99 }
100
101 public function merge_controls_or_add_id( $control, $options ) {
102 if ( is_array( $options ) ) {
103 return array_merge( $control, $options );
104
105 } elseif ( is_string( $options ) ) {
106
107 $control['id'] = $options;
108
109 return $control;
110 }
111 }
112
113 }