PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.0
2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 81 releases
← All changes | includes/blocks/academy-student-registration-form/block.php +40 -65 2.9.1 → 2.14.0 View file →
@@ -5,14 +5,15 @@
5 5 exit;
6 6 }
7 7
8 8 use ABlocks\Classes\BlockBaseAbstract;
9 -use ABlocks\Classes\CssGenerator;
9 +use ABlocks\Classes\CssGeneratorV2;
10 10 use ABlocks\Helper;
11 11 use ABlocks\Controls\Typography;
12 12 use ABlocks\Controls\Background;
13 13 use ABlocks\Controls\Border;
14 14 use ABlocks\Controls\Dimensions;
15 +use ABlocks\Controls\Color;
15 16
16 17
17 18 class Block extends BlockBaseAbstract {
18 19 protected $block_name = 'academy-student-registration-form';
@@ -33,19 +34,15 @@
33 34 }
34 35
35 36
36 37 public function build_css( $attributes ) {
37 - $css_generator = new CssGenerator( $attributes );
38 -
39 - $input_field_label_desktop_css = $this->get_form_input_label_css( $attributes );
40 - if ( ! empty( $attributes['input_label_color'] ) ) {
41 - $input_field_label_desktop_css['color'] = $attributes['input_label_color'];
42 - }
38 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
43 39 $css_generator->add_class_styles(
44 40 '{{WRAPPER}} .academy-reg-form--student .academy-form-group label',
45 - $input_field_label_desktop_css,
41 + $this->get_form_input_label_css( $attributes ),
46 42 $this->get_form_input_label_css( $attributes, 'Tablet' ),
47 - $this->get_form_input_label_css( $attributes, 'Mobile' )
43 + $this->get_form_input_label_css( $attributes, 'Mobile' ),
44 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_label_css( $attributes, $device ); } )
48 45 );
49 46
50 47 $css_generator->add_class_styles(
51 48 '{{WRAPPER}} .academy-reg-form--student .academy-form-group label:hover',
@@ -50,9 +47,10 @@
50 47 $css_generator->add_class_styles(
51 48 '{{WRAPPER}} .academy-reg-form--student .academy-form-group label:hover',
52 49 $this->get_form_input_label_hover_css( $attributes ),
53 50 $this->get_form_input_label_hover_css( $attributes, 'Tablet' ),
54 - $this->get_form_input_label_hover_css( $attributes, 'Mobile' )
51 + $this->get_form_input_label_hover_css( $attributes, 'Mobile' ),
52 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_label_hover_css( $attributes, $device ); } )
55 53 );
56 54
57 55 $css_generator->add_class_styles(
58 56 '{{WRAPPER}} .academy-reg-form--student .academy-form-group input',
@@ -57,15 +55,17 @@
57 55 $css_generator->add_class_styles(
58 56 '{{WRAPPER}} .academy-reg-form--student .academy-form-group input',
59 57 $this->get_form_input_field_css( $attributes ),
60 58 $this->get_form_input_field_css( $attributes, 'Tablet' ),
61 - $this->get_form_input_field_css( $attributes, 'Mobile' )
59 + $this->get_form_input_field_css( $attributes, 'Mobile' ),
60 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_field_css( $attributes, $device ); } )
62 61 );
63 62 $css_generator->add_class_styles(
64 63 '{{WRAPPER}} .academy-reg-form--student .academy-form-group input:hover',
65 64 $this->get_form_input_field_hover_css( $attributes ),
66 65 $this->get_form_input_field_hover_css( $attributes, 'Tablet' ),
67 - $this->get_form_input_field_hover_css( $attributes, 'Mobile' )
66 + $this->get_form_input_field_hover_css( $attributes, 'Mobile' ),
67 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_field_hover_css( $attributes, $device ); } )
68 68 );
69 69
70 70 $css_generator->add_class_styles(
71 71 '{{WRAPPER}} .academy-reg-form--student .academy-form-group input::placeholder',
@@ -70,9 +70,10 @@
70 70 $css_generator->add_class_styles(
71 71 '{{WRAPPER}} .academy-reg-form--student .academy-form-group input::placeholder',
72 72 $this->get_form_input_field_placeholder_css( $attributes ),
73 73 $this->get_form_input_field_placeholder_css( $attributes, 'Tablet' ),
74 - $this->get_form_input_field_placeholder_css( $attributes, 'Mobile' )
74 + $this->get_form_input_field_placeholder_css( $attributes, 'Mobile' ),
75 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_field_placeholder_css( $attributes, $device ); } )
75 76 );
76 77
77 78 $css_generator->add_class_styles(
78 79 '{{WRAPPER}} .academy-reg-form--student .academy-form-group button',
@@ -77,9 +78,10 @@
77 78 $css_generator->add_class_styles(
78 79 '{{WRAPPER}} .academy-reg-form--student .academy-form-group button',
79 80 $this->get_form_button_css( $attributes ),
80 81 $this->get_form_button_css( $attributes, 'Tablet' ),
81 - $this->get_form_button_css( $attributes, 'Mobile' )
82 + $this->get_form_button_css( $attributes, 'Mobile' ),
83 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_button_css( $attributes, $device ); } )
82 84 );
83 85
84 86 $css_generator->add_class_styles(
85 87 '{{WRAPPER}} .academy-reg-form--student .academy-form-group button:hover',
@@ -84,9 +86,10 @@
84 86 $css_generator->add_class_styles(
85 87 '{{WRAPPER}} .academy-reg-form--student .academy-form-group button:hover',
86 88 $this->get_form_button_hover_css( $attributes ),
87 89 $this->get_form_button_hover_css( $attributes, 'Tablet' ),
88 - $this->get_form_button_hover_css( $attributes, 'Mobile' )
90 + $this->get_form_button_hover_css( $attributes, 'Mobile' ),
91 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_button_hover_css( $attributes, $device ); } )
89 92 );
90 93
91 94 $css_generator->add_class_styles(
92 95 '{{WRAPPER}} .academy-reg-form',
@@ -91,15 +94,17 @@
91 94 $css_generator->add_class_styles(
92 95 '{{WRAPPER}} .academy-reg-form',
93 96 $this->get_form_css( $attributes ),
94 97 $this->get_form_css( $attributes, 'Tablet' ),
95 - $this->get_form_css( $attributes, 'Mobile' )
98 + $this->get_form_css( $attributes, 'Mobile' ),
99 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_css( $attributes, $device ); } )
96 100 );
97 101 $css_generator->add_class_styles(
98 102 '{{WRAPPER}} .academy-reg-form:hover',
99 103 $this->get_form_hover_css( $attributes ),
100 104 $this->get_form_hover_css( $attributes, 'Tablet' ),
101 - $this->get_form_hover_css( $attributes, 'Mobile' )
105 + $this->get_form_hover_css( $attributes, 'Mobile' ),
106 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_hover_css( $attributes, $device ); } )
102 107 );
103 108
104 109 return $css_generator->generate_css();
105 110 }
@@ -104,70 +109,48 @@
104 109 return $css_generator->generate_css();
105 110 }
106 111
107 112 public function get_form_input_label_css( $attributes, $device = '' ) {
108 - $input_label_typography_css = ! empty( $attributes['input_label_typhography'] ) ? Typography::get_css( $attributes['input_label_typhography'], '', $device ) : array();
109 - return $input_label_typography_css;
113 + $typographyValueGlobal = ! empty( $attributes['input_label_typhographyGlobal'] ) ? $attributes['input_label_typhographyGlobal'] : '';
114 + $input_label_typography_css = isset( $attributes['input_label_typhography'] ) ? $attributes['input_label_typhography'] : [];
115 + return array_merge(
116 + [ 'color' => Color::get_css( isset( $attributes['input_label_color'] ) ? $attributes['input_label_color'] : '' ) ],
117 + Typography::get_css( $input_label_typography_css, '', $device, $typographyValueGlobal ),
118 + );
110 119 }
111 120
112 121 public function get_form_input_label_hover_css( $attributes, $device = '' ) {
113 - $css = array();
114 - if ( ! empty( $attributes['input_label_hover_color'] ) ) {
115 - $css['color'] = $attributes['input_label_hover_color'];
116 - }
117 - return $css;
122 + return [ 'color' => Color::get_css( isset( $attributes['input_label_hover_color'] ) ? $attributes['input_label_hover_color'] : '' ) ];
118 123 }
119 124
120 125 public function get_form_input_field_css( $attributes, $device = '' ) {
121 - $css = array();
122 126 $input_field_border_css = ! empty( $attributes['form_field_border'] ) ? Border::get_css( $attributes['form_field_border'], '', $device ) : array();
123 - if ( ! empty( $attributes['input_field_color'] ) ) {
124 - $css['color'] = $attributes['input_field_color'];
125 - }
126 - if ( ! empty( $attributes['input_field_bg_color'] ) ) {
127 - $css['background'] = $attributes['input_field_bg_color'];
128 - }
129 -
130 127 return array_merge(
128 + [ 'color' => Color::get_css( isset( $attributes['input_field_color'] ) ? $attributes['input_field_color'] : '' ) ],
129 + [ 'background' => Color::get_css( isset( $attributes['input_field_bg_color'] ) ? $attributes['input_field_bg_color'] : '' ) ],
131 130 $input_field_border_css,
132 - $css,
133 131 );
134 132 }
135 133
136 134 public function get_form_input_field_hover_css( $attributes, $device = '' ) {
137 - $css = array();
138 135 $input_field_border_hover_css = ! empty( $attributes['form_field_border'] ) ? Border::get_hover_css( $attributes['form_field_border'], '', $device ) : array();
139 -
140 - return array_merge(
141 - $input_field_border_hover_css,
142 - $css,
143 - );
136 + return $input_field_border_hover_css;
144 137 }
145 138 public function get_form_input_field_placeholder_css( $attributes, $device = '' ) {
146 - $css = array();
147 - if ( ! empty( $attributes['input_field_placeholder_color'] ) ) {
148 - $css['color'] = $attributes['input_field_placeholder_color'];
149 - }
150 -
151 - return $css;
139 + return [ 'color' => Color::get_css( isset( $attributes['input_field_placeholder_color'] ) ? $attributes['input_field_placeholder_color'] : '' ) ];
152 140 }
153 141
154 142 public function get_form_button_css( $attributes, $device = '' ) {
155 - $css = array();
156 - if ( ! empty( $attributes['form_button_background'] ) ) {
157 - $css['background'] = $attributes['form_button_background'];
158 - }
159 - if ( ! empty( $attributes['form_button_color'] ) ) {
160 - $css['color'] = $attributes['form_button_color'];
161 - }
162 - $form_button_typography_css = ! empty( $attributes['form_button_typhography'] ) ? Typography::get_css( $attributes['form_button_typhography'], '', $device ) : array();
143 + $typographyValueGlobal = ! empty( $attributes['form_button_typhographyGlobal'] ) ? $attributes['form_button_typhographyGlobal'] : '';
144 + $form_button_typography_css = isset( $attributes['form_button_typhography'] ) ? $attributes['form_button_typhography'] : [];
163 145 $form_button_padding = ! empty( $attributes['form_button_padding'] ) ? Dimensions::get_css( $attributes['form_button_padding'], 'padding', $device ) : array();
164 146 $form_button_border_css = ! empty( $attributes['form_button_border'] ) ? Border::get_css( $attributes['form_button_border'], '', $device ) : array();
165 147 return array_merge(
166 - $form_button_typography_css,
148 + [ 'color' => Color::get_css( isset( $attributes['form_button_color'] ) ? $attributes['form_button_color'] : '' ) ],
149 + [ 'background' => Color::get_css( isset( $attributes['form_button_background'] ) ? $attributes['form_button_background'] : '' ) ],
150 + Typography::get_css( $form_button_typography_css, '', $device, $typographyValueGlobal ),
167 151 $form_button_padding,
168 152 $form_button_border_css,
169 - $css
170 153 );
171 154 }
172 155
173 156 public function get_form_css( $attributes, $device = '' ) {
@@ -191,20 +174,12 @@
191 174 );
192 175 }
193 176
194 177 public function get_form_button_hover_css( $attributes, $device = '' ) {
195 - $css = array();
196 - if ( ! empty( $attributes['form_button_hover_background'] ) ) {
197 - $css['background'] = $attributes['form_button_hover_background'];
198 - }
199 - if ( ! empty( $attributes['form_button_hover_color'] ) ) {
200 - $css['color'] = $attributes['form_button_hover_color'];
201 - }
202 -
203 178 $form_button_border = ! empty( $attributes['form_button_border'] ) ? Border::get_hover_css( $attributes['form_button_border'], '', $device ) : array();
204 -
205 179 return array_merge(
206 - $css,
180 + [ 'color' => Color::get_css( isset( $attributes['form_button_hover_color'] ) ? $attributes['form_button_hover_color'] : '' ) ],
181 + [ 'background' => Color::get_css( isset( $attributes['form_button_hover_background'] ) ? $attributes['form_button_hover_background'] : '' ) ],
207 182 $form_button_border
208 183 );
209 184 }
210 185