PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.0.1
JetFormBuilder — Dynamic Blocks Form Builder v2.0.1
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 trait General_Style_Functions {
7
8 private $namespace = 'jet-form-builder';
9
10 public function maybe_add_controls_type( $type ) {
11 if ( ! in_array( $type, $this->general_style_unregister() ) ) {
12
13 if ( is_callable( $this->general_controls_callbacks()[ $type ] ) ) {
14 $this->general_controls_callbacks()[ $type ]();
15 }
16 }
17 }
18
19 public function additional_selectors_for_controls() {
20 return array();
21 }
22
23 public function get_additional_styles( $id ) {
24 $styles = $this->additional_selectors_for_controls();
25
26 return isset( $styles[ $id ] ) ? $styles[ $id ] : array();
27 }
28
29 public function selector( $selector = '', $prefix_base = '', $additional = '' ) {
30 $base = $prefix_base . ".$this->namespace";
31
32 if ( $selector && isset( $this->css_scheme[ $selector ] ) ) {
33 $selector = $this->css_scheme[ $selector ];
34 }
35
36 $result = "{{WRAPPER}} $base" . sprintf( $selector, $this->namespace );
37
38 if ( $additional ) {
39 $result .= $additional;
40 }
41
42 return $result;
43 }
44
45 public function selector_no_space( $selector = '' ) {
46 return ( '{{WRAPPER}}' . sprintf( $selector, $this->namespace ) );
47 }
48
49 public function button_selector( $selector, $additional = '' ) {
50 return $this->selector( $selector, 'button', $additional );
51 }
52
53 public function div_selector( $selector, $additional = '' ) {
54 return $this->selector( $selector, 'div', $additional );
55 }
56
57
58 public function get_default_margin_control( $selector ) {
59 return array(
60 'type' => 'dimensions',
61 'label' => __( 'Margin', 'jet-form-builder' ),
62 'units' => array( 'px', '%' ),
63 'css_selector' => array(
64 '{{WRAPPER}} ' . $selector => 'margin: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
65 ),
66 );
67 }
68
69 public function get_default_padding_control( $selector ) {
70 return array(
71 'type' => 'dimensions',
72 'label' => __( 'Padding', 'jet-form-builder' ),
73 'units' => array( 'px', '%' ),
74 'css_selector' => array(
75 $selector => 'padding: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
76 ),
77 );
78 }
79
80 public function add_margin_padding( $selector, $control_options ) {
81 if ( isset( $control_options['margin'] ) ) {
82
83 $options = $this->merge_controls_or_add_id(
84 $this->get_default_margin_control( $selector ),
85 $control_options['margin']
86 );
87 $this->controls_manager->add_control( $options );
88 }
89
90 if ( isset( $control_options['padding'] ) ) {
91
92 $options = $this->merge_controls_or_add_id(
93 $this->get_default_padding_control( $selector ),
94 $control_options['padding']
95 );
96 $this->controls_manager->add_control( $options );
97 }
98 }
99
100 public function merge_controls_or_add_id( $control, $options ) {
101 if ( is_array( $options ) ) {
102 return array_merge( $control, $options );
103
104 } elseif ( is_string( $options ) ) {
105
106 $control['id'] = $options;
107
108 return $control;
109 }
110 }
111
112 }
113