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-login-form/block.php +84 -101 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-login-form';
@@ -31,19 +32,15 @@
31 32 return $flag;
32 33 }
33 34
34 35 public function build_css( $attributes ) {
35 - $css_generator = new CssGenerator( $attributes );
36 -
37 - $login_form_button_desktop_css = $this->get_login_form_button_css( $attributes );
38 - if ( ! empty( $attributes['login_btn_color'] ) ) {
39 - $login_form_button_desktop_css['color'] = $attributes['login_btn_color'];
40 - }
36 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
41 37 $css_generator->add_class_styles(
42 38 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form .academy-form-group button',
43 - $login_form_button_desktop_css,
39 + $this->get_login_form_button_css( $attributes ),
44 40 $this->get_login_form_button_css( $attributes, 'Tablet' ),
45 - $this->get_login_form_button_css( $attributes, 'Mobile' )
41 + $this->get_login_form_button_css( $attributes, 'Mobile' ),
42 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_login_form_button_css( $attributes, $device ); } )
46 43 );
47 44
48 45 $css_generator->add_class_styles(
49 46 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form .academy-form-group button:hover',
@@ -48,21 +45,18 @@
48 45 $css_generator->add_class_styles(
49 46 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form .academy-form-group button:hover',
50 47 $this->get_login_btn_hover_css( $attributes ),
51 48 $this->get_login_btn_hover_css( $attributes, 'Tablet' ),
52 - $this->get_login_btn_hover_css( $attributes, 'Mobile' )
49 + $this->get_login_btn_hover_css( $attributes, 'Mobile' ),
50 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_login_btn_hover_css( $attributes, $device ); } )
53 51 );
54 -
55 - $login_form_footer_desktop_css = $this->get_login_form_footer_css( $attributes );
56 - if ( ! empty( $attributes['form_footer_title_color'] ) ) {
57 - $login_form_footer_desktop_css['color'] = $attributes['form_footer_title_color'];
58 - }
59 52 $css_generator->add_class_styles(
60 53 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form-info,
61 54 {{WRAPPER}} .academy-login-form-wrapper .academy-login-form-info a ',
62 - $login_form_footer_desktop_css,
55 + $this->get_login_form_footer_css( $attributes ),
63 56 $this->get_login_form_footer_css( $attributes, 'Tablet' ),
64 - $this->get_login_form_footer_css( $attributes, 'Mobile' )
57 + $this->get_login_form_footer_css( $attributes, 'Mobile' ),
58 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_login_form_footer_css( $attributes, $device ); } )
65 59 );
66 60
67 61 $form_title_desktop_css = $this->get_form_title_css( $attributes );
68 62 if ( ! empty( $attributes['title_color'] ) ) {
@@ -69,32 +63,24 @@
69 63 $form_title_desktop_css['color'] = $attributes['title_color'];
70 64 }
71 65 $css_generator->add_class_styles(
72 66 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form-heading',
73 - $form_title_desktop_css,
67 + $this->get_form_title_css( $attributes ),
74 68 $this->get_form_title_css( $attributes, 'Tablet' ),
75 - $this->get_form_title_css( $attributes, 'Mobile' )
69 + $this->get_form_title_css( $attributes, 'Mobile' ),
70 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_title_css( $attributes, $device ); } )
76 71 );
77 -
78 - $form_title_desktop_hover_css = [];
79 - if ( ! empty( $attributes['title_hover_color'] ) ) {
80 - $form_title_desktop_hover_css['color'] = $attributes['title_hover_color'];
81 - }
82 72 $css_generator->add_class_styles(
83 73 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form-heading:hover',
84 - $form_title_desktop_hover_css,
74 + $this->form_title_desktop_hover_css( $attributes )
85 75 );
86 -
87 - $input_field_label_desktop_css = $this->get_input_field_label_css( $attributes );
88 - if ( ! empty( $attributes['input_field_label_color'] ) ) {
89 - $input_field_label_desktop_css['color'] = $attributes['input_field_label_color'];
90 - }
91 76 $css_generator->add_class_styles(
92 77 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form label,
93 78 {{WRAPPER}} .academy-login-form-wrapper .academy-login-form a',
94 - $input_field_label_desktop_css,
79 + $this->get_input_field_label_css( $attributes ),
95 80 $this->get_input_field_label_css( $attributes, 'Tablet' ),
96 - $this->get_input_field_label_css( $attributes, 'Mobile' )
81 + $this->get_input_field_label_css( $attributes, 'Mobile' ),
82 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_field_label_css( $attributes, $device ); } )
97 83 );
98 84
99 85 $css_generator->add_class_styles(
100 86 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form label:hover,
@@ -100,9 +86,10 @@
100 86 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form label:hover,
101 87 {{WRAPPER}} .academy-login-form-wrapper .academy-login-form a:hover',
102 88 $this->get_input_field_label_hover_css( $attributes ),
103 89 $this->get_input_field_label_hover_css( $attributes, 'Tablet' ),
104 - $this->get_input_field_label_hover_css( $attributes, 'Mobile' )
90 + $this->get_input_field_label_hover_css( $attributes, 'Mobile' ),
91 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_field_label_hover_css( $attributes, $device ); } )
105 92 );
106 93
107 94 $css_generator->add_class_styles(
108 95 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form .academy-form-group input',
@@ -107,9 +94,10 @@
107 94 $css_generator->add_class_styles(
108 95 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form .academy-form-group input',
109 96 $this->get_input_field_css( $attributes ),
110 97 $this->get_input_field_css( $attributes, 'Tablet' ),
111 - $this->get_input_field_css( $attributes, 'Mobile' )
98 + $this->get_input_field_css( $attributes, 'Mobile' ),
99 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_field_css( $attributes, $device ); } )
112 100 );
113 101
114 102 $css_generator->add_class_styles(
115 103 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form .academy-form-group input::placeholder',
@@ -114,9 +102,10 @@
114 102 $css_generator->add_class_styles(
115 103 '{{WRAPPER}} .academy-login-form-wrapper .academy-login-form .academy-form-group input::placeholder',
116 104 $this->get_input_field_placeholder_css( $attributes ),
117 105 $this->get_input_field_placeholder_css( $attributes, 'Tablet' ),
118 - $this->get_input_field_placeholder_css( $attributes, 'Mobile' )
106 + $this->get_input_field_placeholder_css( $attributes, 'Mobile' ),
107 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_field_placeholder_css( $attributes, $device ); } )
119 108 );
120 109
121 110 $css_generator->add_class_styles(
122 111 '{{WRAPPER}} .academy-login-form-wrapper',
@@ -121,9 +110,10 @@
121 110 $css_generator->add_class_styles(
122 111 '{{WRAPPER}} .academy-login-form-wrapper',
123 112 $this->get_form_card_css( $attributes ),
124 113 $this->get_form_card_css( $attributes, 'Tablet' ),
125 - $this->get_form_card_css( $attributes, 'Mobile' )
114 + $this->get_form_card_css( $attributes, 'Mobile' ),
115 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_card_css( $attributes, $device ); } )
126 116 );
127 117
128 118 $css_generator->add_class_styles(
129 119 '{{WRAPPER}} .academy-login-form-wrapper:hover',
@@ -128,9 +118,10 @@
128 118 $css_generator->add_class_styles(
129 119 '{{WRAPPER}} .academy-login-form-wrapper:hover',
130 120 $this->get_form_card_hover_css( $attributes ),
131 121 $this->get_form_card_hover_css( $attributes, 'Tablet' ),
132 - $this->get_form_card_hover_css( $attributes, 'Mobile' )
122 + $this->get_form_card_hover_css( $attributes, 'Mobile' ),
123 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_card_hover_css( $attributes, $device ); } )
133 124 );
134 125
135 126 return $css_generator->generate_css();
136 127 }
@@ -135,87 +126,78 @@
135 126 return $css_generator->generate_css();
136 127 }
137 128
138 129 public function get_login_form_button_css( $attributes, $device = '' ) {
139 - $login_form_button_typography_css = ! empty( $attributes['login_btn_typography'] ) ? Typography::get_css( $attributes['login_btn_typography'], '', $device ) : array();
140 - $login_form_button_bg_css = array();
141 -
142 - if ( ! empty( $attributes['login_btn_bg_color'] ) ) {
143 - $login_form_button_bg_css['background'] = $attributes['login_btn_bg_color'];
144 - }
130 + $typographyValueGlobal = ! empty( $attributes['login_btn_typographyGlobal'] ) ? $attributes['login_btn_typographyGlobal'] : '';
131 + $login_form_button_typography_css = isset( $attributes['login_btn_typography'] ) ? $attributes['login_btn_typography'] : [];
145 132 return array_merge(
146 - $login_form_button_typography_css,
147 - $login_form_button_bg_css,
133 + Typography::get_css( $login_form_button_typography_css, '', $device, $typographyValueGlobal ),
134 + [ 'color' => Color::get_css( isset( $attributes['login_btn_color'] ) ? $attributes['login_btn_color'] : '' ) ],
135 + [ 'background' => Color::get_css( isset( $attributes['login_btn_bg_color'] ) ? $attributes['login_btn_bg_color'] : '' ) ]
148 136 );
149 137 }
150 138
151 139 public function get_login_form_footer_css( $attributes, $device = '' ) {
152 - $login_form_footer_typography_css = ! empty( $attributes['form_footer_title_typography'] ) ? Typography::get_css( $attributes['form_footer_title_typography'], '', $device ) : array();
153 - return $login_form_footer_typography_css;
140 + $typographyValueGlobal = ! empty( $attributes['form_footer_title_typographyGlobal'] ) ? $attributes['form_footer_title_typographyGlobal'] : '';
141 + $login_form_footer_typography_css = isset( $attributes['form_footer_title_typography'] ) ? $attributes['form_footer_title_typography'] : [];
142 + return array_merge(
143 + [ 'color' => Color::get_css( isset( $attributes['form_footer_title_color'] ) ? $attributes['form_footer_title_color'] : '' ) ],
144 + Typography::get_css( $login_form_footer_typography_css, '', $device, $typographyValueGlobal ),
145 + );
154 146 }
155 147
156 148 public function get_form_title_css( $attributes, $device = '' ) {
157 - $form_title_typography_css = ! empty( $attributes['title_typography'] ) ? Typography::get_css( $attributes['title_typography'], '', $device ) : array();
158 - return $form_title_typography_css;
149 + $typographyValueGlobal = ! empty( $attributes['title_typographyGlobal'] ) ? $attributes['title_typographyGlobal'] : '';
150 + $form_title_typography_css = isset( $attributes['title_typography'] ) ? $attributes['title_typography'] : [];
151 + return array_merge(
152 + [ 'color' => Color::get_css( isset( $attributes['title_color'] ) ? $attributes['title_color'] : '' ) ],
153 + Typography::get_css( $form_title_typography_css, '', $device, $typographyValueGlobal ),
154 + );
159 155 }
156 + public function form_title_desktop_hover_css( $attributes ) {
157 + return [ 'color' => Color::get_css( isset( $attributes['title_hover_color'] ) ? $attributes['title_hover_color'] : '' ) ];
160 158
159 + }
160 +
161 161 public function get_course_card_title_css( $attributes, $device = '' ) {
162 - $course_title_typography_css = ! empty( $attributes['title_typography'] ) ? Typography::get_css( $attributes['title_typography'], '', $device ) : array();
163 - return $course_title_typography_css;
162 + $typographyValueGlobal = ! empty( $attributes['title_typographyGlobal'] ) ? $attributes['title_typographyGlobal'] : '';
163 + $course_title_typography_css = isset( $attributes['title_typography'] ) ? $attributes['title_typography'] : [];
164 + return array_merge(
165 + Typography::get_css( $course_title_typography_css, '', $device, $typographyValueGlobal ),
166 + );
164 167 }
165 168
166 169 public function get_input_field_label_css( $attributes, $device = '' ) {
167 - $input_field_label_typography_css = ! empty( $attributes['input_field_label_typography'] ) ? Typography::get_css( $attributes['input_field_label_typography'], '', $device ) : array();
168 - return $input_field_label_typography_css;
170 + $typographyValueGlobal = ! empty( $attributes['input_field_label_typographyGlobal'] ) ? $attributes['input_field_label_typographyGlobal'] : '';
171 + $input_field_label_typography_css = isset( $attributes['input_field_label_typography'] ) ? $attributes['input_field_label_typography'] : [];
172 + return array_merge(
173 + [ 'color' => Color::get_css( isset( $attributes['input_field_label_color'] ) ? $attributes['input_field_label_color'] : '' ) ],
174 + Typography::get_css( $input_field_label_typography_css, '', $device, $typographyValueGlobal ),
175 + );
169 176 }
170 177
171 178 public function get_input_field_label_hover_css( $attributes, $device = '' ) {
172 - $input_field_label_hover_css = array();
173 -
174 - if ( ! empty( $attributes['input_field_label_hover_color'] ) ) {
175 - $input_field_label_hover_css['color'] = $attributes['input_field_label_hover_color'];
176 - }
177 - return $input_field_label_hover_css;
179 + return [ 'color' => Color::get_css( isset( $attributes['input_field_label_hover_color'] ) ? $attributes['input_field_label_hover_color'] : '' ) ];
178 180 }
179 181
180 182 public function get_input_field_css( $attributes, $device = '' ) {
181 - $input_field_css = array();
182 183 $input_border_css = ! empty( $attributes['input_field_border'] ) ? Border::get_css( $attributes['input_field_border'], '', $device ) : array();
183 184 $input_field_padding = ! empty( $attributes['input_field_padding'] ) ? Dimensions::get_css( $attributes['input_field_padding'], 'padding', $device ) : array();
184 - if ( ! empty( $attributes['input_field_bg_color'] ) ) {
185 - $input_field_css['background'] = $attributes['input_field_bg_color'];
186 - }
187 - if ( ! empty( $attributes['inputFieldColor'] ) ) {
188 - $input_field_css['color'] = $attributes['inputFieldColor'];
189 - }
190 185 return array_merge(
186 + [ 'color' => Color::get_css( isset( $attributes['inputFieldColor'] ) ? $attributes['inputFieldColor'] : '' ) ],
187 + [ 'background' => Color::get_css( isset( $attributes['input_field_bg_color'] ) ? $attributes['input_field_bg_color'] : '' ) ],
191 188 $input_border_css,
192 - $input_field_css,
193 189 $input_field_padding
194 190 );
195 191 }
196 192 public function get_input_field_placeholder_css( $attributes, $device = '' ) {
197 - $input_field_css = array();
198 - if ( ! empty( $attributes['inputFieldColor'] ) ) {
199 - $input_field_css['color'] = $attributes['inputFieldColor'];
200 - }
201 - return $input_field_css;
193 + return [ 'color' => Color::get_css( isset( $attributes['inputFieldColor'] ) ? $attributes['inputFieldColor'] : '' ) ];
202 194 }
203 195
204 196 public function get_login_btn_hover_css( $attributes, $device = '' ) {
205 - $login_btn_background_css = array();
206 - $login_btn_hover_color = array();
207 -
208 - if ( ! empty( $attributes['login_btn_hover_color'] ) ) {
209 - $login_btn_hover_color['color'] = $attributes['login_btn_hover_color'];
210 - }
211 - if ( ! empty( $attributes['login_btn_bg_hover_color'] ) ) {
212 - $login_btn_background_css['background'] = $attributes['login_btn_bg_hover_color'];
213 - }
214 -
215 197 return array_merge(
216 - $login_btn_background_css,
217 - $login_btn_hover_color,
198 + [ 'color' => Color::get_css( isset( $attributes['login_btn_hover_color'] ) ? $attributes['login_btn_hover_color'] : '' ) ],
199 + [ 'background' => Color::get_css( isset( $attributes['login_btn_bg_hover_color'] ) ? $attributes['login_btn_bg_hover_color'] : '' ) ]
218 200 );
219 201 }
220 202
221 203 public function get_form_card_css( $attributes, $device = '' ) {
@@ -231,33 +213,34 @@
231 213 }
232 214
233 215 public function get_form_card_hover_css( $attributes, $device = '' ) {
234 216 $form_background_hover_css = ! empty( $attributes['form_bg_color'] ) ? Background::get_hover_css( $attributes['form_bg_color'], 'background', $device ) : array();
235 -
236 - return $form_background_hover_css;
217 + $form_border = ! empty( $attributes['form_border'] ) ? Border::get_hover_css( $attributes['form_border'], '', $device ) : array();
218 + return array_merge(
219 + $form_background_hover_css,
220 + $form_border
221 + );
237 222 }
238 223
239 224
240 -
241 -
242 -
243 225 public function render_block_content( $attributes, $content, $block_instance ) {
244 226 $attr_array = [
245 - 'form_title' => Helper::get_attribute_value( $attributes, 'form_title' ),
246 - 'username_label' => Helper::get_attribute_value( $attributes, 'username_label' ),
247 - 'username_placeholder' => Helper::get_attribute_value( $attributes, 'username_placeholder' ),
248 - 'password_label' => Helper::get_attribute_value( $attributes, 'password_label' ),
249 - 'password_placeholder' => Helper::get_attribute_value( $attributes, 'password_placeholder' ),
250 - 'remember_label' => Helper::get_attribute_value( $attributes, 'remember_label' ),
251 - 'login_button_label' => Helper::get_attribute_value( $attributes, 'login_button_label' ),
252 - 'reset_password_label' => Helper::get_attribute_value( $attributes, 'reset_password_label' ),
253 - 'show_logged_in_message' => Helper::get_attribute_value( $attributes, 'show_logged_in_message' ),
254 - 'student_register_url' => Helper::get_attribute_value( $attributes, 'student_register_url' ),
255 - 'login_redirect_url' => Helper::get_attribute_value( $attributes, 'login_redirect_url' ),
256 - 'logout_redirect_url' => Helper::get_attribute_value( $attributes, 'logout_redirect_url' ),
227 + 'form_title' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'form_title' ) ),
228 + 'username_label' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'username_label' ) ),
229 + 'username_placeholder' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'username_placeholder' ) ),
230 + 'password_label' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'password_label' ) ),
231 + 'password_placeholder' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'password_placeholder' ) ),
232 + 'remember_label' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'remember_label' ) ),
233 + 'login_button_label' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'login_button_label' ) ),
234 + 'reset_password_label' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'reset_password_label' ) ),
235 + 'show_logged_in_message' => filter_var( Helper::get_attribute_value( $attributes, 'show_logged_in_message' ), FILTER_VALIDATE_BOOLEAN ),
236 + 'student_register_url' => esc_url_raw( Helper::get_attribute_value( $attributes, 'student_register_url' ) ),
237 + 'login_redirect_url' => esc_url_raw( Helper::get_attribute_value( $attributes, 'login_redirect_url' ) ),
238 + 'logout_redirect_url' => esc_url_raw( Helper::get_attribute_value( $attributes, 'logout_redirect_url' ) ),
257 239 ];
258 240
259 241 $shortcode = '[academy_login_form ' . Helper::attr_shortcode( $attr_array ) . ']';
260 242 echo do_shortcode( $shortcode );
261 243 }
244 +
262 245
263 246 }