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-password-reset-form/block.php +55 -79 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 class Block extends BlockBaseAbstract {
17 18 protected $block_name = 'academy-password-reset-form';
18 19
@@ -30,21 +31,23 @@
30 31 return $flag;
31 32 }
32 33
33 34 public function build_css( $attributes ) {
34 - $css_generator = new CssGenerator( $attributes );
35 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
35 36
36 37 $css_generator->add_class_styles(
37 38 '{{WRAPPER}} .academy-password-reset-form-wrapper',
38 39 $this->getResetFormCss( $attributes ),
39 40 $this->getResetFormCss( $attributes, 'Tablet' ),
40 - $this->getResetFormCss( $attributes, 'Mobile' )
41 + $this->getResetFormCss( $attributes, 'Mobile' ),
42 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormCss( $attributes, $device ); } )
41 43 );
42 44 $css_generator->add_class_styles(
43 45 '{{WRAPPER}} .academy-password-reset-form-wrapper:hover',
44 46 $this->getResetFormHoverCss( $attributes ),
45 47 $this->getResetFormHoverCss( $attributes, 'Tablet' ),
46 - $this->getResetFormHoverCss( $attributes, 'Mobile' )
48 + $this->getResetFormHoverCss( $attributes, 'Mobile' ),
49 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormHoverCss( $attributes, $device ); } )
47 50 );
48 51
49 52 $css_generator->add_class_styles(
50 53 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group label',
@@ -49,9 +52,10 @@
49 52 $css_generator->add_class_styles(
50 53 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group label',
51 54 $this->getResetFormLabelCss( $attributes ),
52 55 $this->getResetFormLabelCss( $attributes, 'Tablet' ),
53 - $this->getResetFormLabelCss( $attributes, 'Mobile' )
56 + $this->getResetFormLabelCss( $attributes, 'Mobile' ),
57 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormLabelCss( $attributes, $device ); } )
54 58 );
55 59
56 60 $css_generator->add_class_styles(
57 61 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group input',
@@ -56,33 +60,38 @@
56 60 $css_generator->add_class_styles(
57 61 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group input',
58 62 $this->getResetFormInputCss( $attributes ),
59 63 $this->getResetFormInputCss( $attributes, 'Tablet' ),
60 - $this->getResetFormInputCss( $attributes, 'Mobile' )
64 + $this->getResetFormInputCss( $attributes, 'Mobile' ),
65 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormInputCss( $attributes, $device ); } )
61 66 );
62 67 $css_generator->add_class_styles(
63 68 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group input:hover',
64 69 $this->getResetFormInputHoverCss( $attributes ),
65 70 $this->getResetFormInputHoverCss( $attributes, 'Tablet' ),
66 - $this->getResetFormInputHoverCss( $attributes, 'Mobile' )
71 + $this->getResetFormInputHoverCss( $attributes, 'Mobile' ),
72 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormInputHoverCss( $attributes, $device ); } )
67 73 );
68 74 $css_generator->add_class_styles(
69 75 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group button',
70 76 $this->getResetFormButtonCss( $attributes ),
71 77 $this->getResetFormButtonCss( $attributes, 'Tablet' ),
72 - $this->getResetFormButtonCss( $attributes, 'Mobile' )
78 + $this->getResetFormButtonCss( $attributes, 'Mobile' ),
79 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormButtonCss( $attributes, $device ); } )
73 80 );
74 81 $css_generator->add_class_styles(
75 82 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group button:hover',
76 83 $this->getResetFormButtonHoverCss( $attributes ),
77 84 $this->getResetFormButtonHoverCss( $attributes, 'Tablet' ),
78 - $this->getResetFormButtonHoverCss( $attributes, 'Mobile' )
85 + $this->getResetFormButtonHoverCss( $attributes, 'Mobile' ),
86 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormButtonHoverCss( $attributes, $device ); } )
79 87 );
80 88 $css_generator->add_class_styles(
81 89 '{{WRAPPER}} .academy-password-reset-form-wrapper h2.academy-password-reset-form-heading',
82 90 $this->getResetFormHeaderCss( $attributes ),
83 91 $this->getResetFormHeaderCss( $attributes, 'Tablet' ),
84 - $this->getResetFormHeaderCss( $attributes, 'Mobile' )
92 + $this->getResetFormHeaderCss( $attributes, 'Mobile' ),
93 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormHeaderCss( $attributes, $device ); } )
85 94 );
86 95
87 96 $css_generator->add_class_styles(
88 97 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form-info a',
@@ -87,9 +96,10 @@
87 96 $css_generator->add_class_styles(
88 97 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form-info a',
89 98 $this->getResetFormFooterCss( $attributes ),
90 99 $this->getResetFormFooterCss( $attributes, 'Tablet' ),
91 - $this->getResetFormFooterCss( $attributes, 'Mobile' )
100 + $this->getResetFormFooterCss( $attributes, 'Mobile' ),
101 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormFooterCss( $attributes, $device ); } )
92 102 );
93 103
94 104 return $css_generator->generate_css();
95 105 }
@@ -94,130 +104,96 @@
94 104 return $css_generator->generate_css();
95 105 }
96 106
97 107 public function getResetFormCss( $attributes, $device = '' ) {
98 - $css = array();
99 108 $form_border_css = ! empty( $attributes['form_border'] ) ? Border::get_css( $attributes['form_border'], '', $device ) : array();
100 109 $form_padding_css = ! empty( $attributes['form_padding'] ) ? Dimensions::get_css( $attributes['form_padding'], 'padding', $device ) : array();
101 - if ( ! empty( $attributes['form_background_color'] ) ) {
102 - $css['background'] = $attributes['form_background_color'];
103 - }
104 110 return array_merge(
111 + [ 'background' => Color::get_css( isset( $attributes['form_background_color'] ) ? $attributes['form_background_color'] : '' ) ],
105 112 $form_border_css,
106 113 $form_padding_css,
107 - $css
108 114 );
109 115 }
110 116 public function getResetFormHoverCss( $attributes, $device = '' ) {
111 - $css = array();
112 117 $form_border_hover_css = ! empty( $attributes['form_border'] ) ? Border::get_hover_css( $attributes['form_border'], '', $device ) : array();
113 - if ( ! empty( $attributes['form_background_hover_color'] ) ) {
114 - $css['background'] = $attributes['form_background_hover_color'];
115 - }
116 118 return array_merge(
117 - $form_border_hover_css,
118 - $css
119 + [ 'background' => Color::get_css( isset( $attributes['form_background_hover_color'] ) ? $attributes['form_background_hover_color'] : '' ) ],
120 + $form_border_hover_css
119 121 );
120 122 }
121 123 public function getResetFormLabelCss( $attributes, $device = '' ) {
122 - $css = array();
123 - $reset_form_label_typography_css = ! empty( $attributes['label_typography'] ) ? Typography::get_css( $attributes['label_typography'], '', $device ) : array();
124 - if ( ! empty( $attributes['label_color'] ) ) {
125 - $css['color'] = $attributes['label_color'];
126 - }
124 + $typographyValueGlobal = ! empty( $attributes['label_typographyGlobal'] ) ? $attributes['label_typographyGlobal'] : '';
125 + $reset_form_label_typography_css = isset( $attributes['label_typography'] ) ? $attributes['label_typography'] : [];
127 126 return array_merge(
128 - $reset_form_label_typography_css,
129 - $css
127 + [ 'color' => Color::get_css( isset( $attributes['label_color'] ) ? $attributes['label_color'] : '' ) ],
128 + Typography::get_css( $reset_form_label_typography_css, '', $device, $typographyValueGlobal ),
130 129 );
131 130 }
132 131 public function getResetFormInputCss( $attributes, $device = '' ) {
133 - $css = array();
134 132 $form_input_border_css = ! empty( $attributes['input_border'] ) ? Border::get_css( $attributes['input_border'], '', $device ) : array();
135 133 $form_input_padding_css = ! empty( $attributes['input_padding'] ) ? Dimensions::get_css( $attributes['input_padding'], 'padding', $device ) : array();
136 - $form_input_typography_css = ! empty( $attributes['input_field_typography'] ) ? Typography::get_css( $attributes['input_field_typography'], '', $device ) : array();
137 - if ( ! empty( $attributes['input_field_color'] ) ) {
138 - $css['color'] = $attributes['input_field_color'];
139 - }
134 + $typographyValueGlobal = ! empty( $attributes['input_field_typographyGlobal'] ) ? $attributes['input_field_typographyGlobal'] : '';
135 + $form_input_typography_css = isset( $attributes['input_field_typography'] ) ? $attributes['input_field_typography'] : [];
140 136 return array_merge(
137 + [ 'color' => Color::get_css( isset( $attributes['input_field_color'] ) ? $attributes['input_field_color'] : '' ) ],
141 138 $form_input_border_css,
142 139 $form_input_padding_css,
143 - $form_input_typography_css,
144 - $css
140 + Typography::get_css( $form_input_typography_css, '', $device, $typographyValueGlobal ),
145 141 );
146 142 }
147 143 public function getResetFormInputHoverCss( $attributes, $device = '' ) {
148 - $css = array();
144 +
149 145 $form_input_border_hover_css = ! empty( $attributes['input_border'] ) ? Border::get_hover_css( $attributes['input_border'], '', $device ) : array();
150 - return array_merge(
151 - $form_input_border_hover_css,
152 - $css
153 - );
146 + return $form_input_border_hover_css;
154 147 }
155 148
156 149 public function getResetFormButtonCss( $attributes, $device = '' ) {
157 - $css = array();
158 150 $button_border = ! empty( $attributes['button_border'] ) ? Border::get_css( $attributes['button_border'], '', $device ) : array();
159 151 $button_padding = ! empty( $attributes['button_padding'] ) ? Dimensions::get_css( $attributes['button_padding'], 'padding', $device ) : array();
160 - $button_typography = ! empty( $attributes['button_typography'] ) ? Typography::get_css( $attributes['button_typography'], '', $device ) : array();
161 - if ( ! empty( $attributes['button_color'] ) ) {
162 - $css['color'] = $attributes['button_color'];
163 - }
164 - if ( ! empty( $attributes['button_background_color'] ) ) {
165 - $css['background'] = $attributes['button_background_color'];
166 - }
152 + $typographyValueGlobal = ! empty( $attributes['button_typographyGlobal'] ) ? $attributes['button_typographyGlobal'] : '';
153 + $button_typography = isset( $attributes['button_typography'] ) ? $attributes['button_typography'] : [];
167 154 return array_merge(
155 + [ 'color' => Color::get_css( isset( $attributes['button_color'] ) ? $attributes['button_color'] : '' ) ],
156 + [ 'background' => Color::get_css( isset( $attributes['button_background_color'] ) ? $attributes['button_background_color'] : '' ) ],
168 157 $button_border,
169 158 $button_padding,
170 - $button_typography,
171 - $css
159 + Typography::get_css( $button_typography, '', $device, $typographyValueGlobal ), $button_typography,
172 160 );
173 161 }
174 162 public function getResetFormButtonHoverCss( $attributes, $device = '' ) {
175 - $css = array();
176 163 $button_hover_border = ! empty( $attributes['button_border'] ) ? Border::get_hover_css( $attributes['button_border'], '', $device ) : array();
177 - if ( ! empty( $attributes['button_hover_color'] ) ) {
178 - $css['color'] = $attributes['button_hover_color'];
179 - }
180 - if ( ! empty( $attributes['button_background_hover_color'] ) ) {
181 - $css['background'] = $attributes['button_background_hover_color'];
182 - }
183 164 return array_merge(
165 + [ 'color' => Color::get_css( isset( $attributes['button_hover_color'] ) ? $attributes['button_hover_color'] : '' ) ],
166 + [ 'background' => Color::get_css( isset( $attributes['button_background_hover_color'] ) ? $attributes['button_background_hover_color'] : '' ) ],
184 167 $button_hover_border,
185 - $css
186 168 );
187 169 }
188 170 public function getResetFormHeaderCss( $attributes, $device = '' ) {
189 - $css = array();
190 - $form_title_typography = ! empty( $attributes['form_title_typography'] ) ? Typography::get_css( $attributes['form_title_typography'], '', $device ) : array();
191 - if ( ! empty( $attributes['form_title_color'] ) ) {
192 - $css['color'] = $attributes['form_title_color'];
193 - }
171 + $typographyValueGlobal = ! empty( $attributes['form_title_typographyGlobal'] ) ? $attributes['form_title_typographyGlobal'] : '';
172 + $form_title_typography = isset( $attributes['form_title_typography'] ) ? $attributes['form_title_typography'] : [];
194 173 return array_merge(
195 - $form_title_typography,
196 - $css
174 + [ 'color' => Color::get_css( isset( $attributes['form_title_color'] ) ? $attributes['form_title_color'] : '' ) ],
175 + Typography::get_css( $form_title_typography, '', $device, $typographyValueGlobal ),
197 176 );
198 177 }
199 178 public function getResetFormFooterCss( $attributes, $device = '' ) {
200 - $css = array();
201 - $form_footer_title_typography = ! empty( $attributes['form_footer_title_typography'] ) ? Typography::get_css( $attributes['form_footer_title_typography'], '', $device ) : array();
202 - if ( ! empty( $attributes['form_footer_title_color'] ) ) {
203 - $css['color'] = $attributes['form_footer_title_color'];
204 - }
179 + $typographyValueGlobal = ! empty( $attributes['form_footer_title_typographyGlobal'] ) ? $attributes['form_footer_title_typographyGlobal'] : '';
180 + $form_footer_title_typography = isset( $attributes['form_footer_title_typography'] ) ? $attributes['form_footer_title_typography'] : [];
205 181 return array_merge(
206 - $form_footer_title_typography,
207 - $css
182 + [ 'color' => Color::get_css( isset( $attributes['form_footer_title_color'] ) ? $attributes['form_footer_title_color'] : '' ) ],
183 + Typography::get_css( $form_footer_title_typography, '', $device, $typographyValueGlobal ),
208 184 );
209 185 }
210 186
211 -
212 187 public function render_block_content( $attributes, $content, $block_instance ) {
213 188 $attr_array = [
214 - 'form_title' => Helper::get_attribute_value( $attributes, 'form_title' ),
215 - 'username_label' => Helper::get_attribute_value( $attributes, 'username_label' ),
216 - 'reset_button_label' => Helper::get_attribute_value( $attributes, 'reset_button_label' ),
217 - 'login_button_label' => Helper::get_attribute_value( $attributes, 'login_button_label' ),
218 - 'show_logged_in_message' => Helper::get_attribute_value( $attributes, 'show_logged_in_message' ),
189 + 'form_title' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'form_title' ) ),
190 + 'username_label' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'username_label' ) ),
191 + 'reset_button_label' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'reset_button_label' ) ),
192 + 'login_button_label' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'login_button_label' ) ),
193 + 'show_logged_in_message' => filter_var( Helper::get_attribute_value( $attributes, 'show_logged_in_message' ), FILTER_VALIDATE_BOOLEAN ),
219 194 ];
195 +
220 196 $shortcode = '[academy_password_reset_form ' . Helper::attr_shortcode( $attr_array ) . ']';
221 197 echo do_shortcode( $shortcode );
222 198 }
223 199