PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 2.1.7
bBlocks – Essential Gutenberg Blocks & Patterns Collection v2.1.7
2.1.7 2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 All 107 releases
← All changes | includes/blocks/form/FormHandler.php +14 -13 2.0.432.1.7 View file →
@@ -9,9 +9,9 @@
9 9
10 10 function b_form_submit(){
11 11
12 12 // verify nonce
13 - if(!isset($_POST['_nonce']) || !wp_verify_nonce($_POST['_nonce'], 'wp_ajax')){
13 + if ( ! isset( $_POST['_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_nonce'] ) ), 'wp_ajax' ) ) {
14 14 wp_send_json_error([ 'message' => __( 'Something went wrong.', 'b-blocks' ) ]);
15 15 }
16 16 // sanitize field data and validate and create wp user_error
17 17
@@ -29,9 +29,9 @@
29 29 'formId' => sanitize_text_field($_POST['formId'] ?? ''),
30 30 'rememberme' => sanitize_text_field($_POST['rememberme'] ?? ''),
31 31 ];
32 32
33 - $form_type = sanitize_text_field($_POST['type']);
33 + $form_type = sanitize_text_field( $_POST['type'] ?? '' );
34 34
35 35 if($form_type === 'register'){
36 36 return $this->register_user($payload);
37 37 }
@@ -174,9 +174,9 @@
174 174
175 175 // $this->send_user_email($user_mail, $payload);
176 176 // $this->send_admin_email($admin_mail, $payload);
177 177
178 - wp_send_json_success(['message' => 'User registered successfully']);
178 + wp_send_json_success( [ 'message' => __( 'User registered successfully.', 'b-blocks' ) ] );
179 179
180 180 }
181 181
182 182 function login_user($payload){
@@ -216,21 +216,21 @@
216 216 }
217 217
218 218 private function validate_registration_data( $payload, $passwordRequirements ) {
219 219 if ( empty( $payload['username'] ) || ! validate_username( $payload['username'] ) ) {
220 - return 'Invalid username.';
220 + return __( 'Invalid username.', 'b-blocks' );
221 221 } elseif ( username_exists( $payload['username'] ) ) {
222 - return 'Username already exists.';
222 + return __( 'Username already exists.', 'b-blocks' );
223 223 }
224 224
225 225 if ( empty( $payload['email'] ) || ! is_email( $payload['email'] ) ) {
226 - return 'Invalid email address.';
226 + return __( 'Invalid email address.', 'b-blocks' );
227 227 } elseif ( email_exists( $payload['email'] ) ) {
228 - return 'Email already exists.';
228 + return __( 'Email already exists.', 'b-blocks' );
229 229 }
230 230
231 231 if ( empty( $payload['password'] ) ) {
232 - return 'Password is required.';
232 + return __( 'Password is required.', 'b-blocks' );
233 233 }
234 234
235 235 if($passwordRequirements['isWeek']){
236 236 return null;
@@ -237,29 +237,30 @@
237 237 }
238 238
239 239 if($passwordRequirements['isLowerCase']){
240 240 if ( empty( $payload['password'] ) || ! preg_match( '/[a-z]/', $payload['password'] ) ) {
241 - return 'Password must contain at least one lowercase letter.';
241 + return __( 'Password must contain at least one lowercase letter.', 'b-blocks' );
242 242 }
243 243 }
244 244 if($passwordRequirements['isNumber']){
245 245 if ( empty( $payload['password'] ) || ! preg_match( '/[0-9]/', $payload['password'] ) ) {
246 - return 'Password must contain at least one number.';
246 + return __( 'Password must contain at least one number.', 'b-blocks' );
247 247 }
248 248 }
249 249 if($passwordRequirements['isSpecialChar']){
250 250 if ( empty( $payload['password'] ) || ! preg_match( '/[^a-zA-Z0-9]/', $payload['password'] ) ) {
251 - return 'Password must contain at least one special character.';
251 + return __( 'Password must contain at least one special character.', 'b-blocks' );
252 252 }
253 253 }
254 254 if($passwordRequirements['isUpperCase']){
255 255 if ( empty( $payload['password'] ) || ! preg_match( '/[A-Z]/', $payload['password'] ) ) {
256 - return 'Password must contain at least one uppercase letter.';
256 + return __( 'Password must contain at least one uppercase letter.', 'b-blocks' );
257 257 }
258 258 }
259 259 if($passwordRequirements['minLength']){
260 260 if ( empty( $payload['password'] ) || strlen( $payload['password'] ) < $passwordRequirements['minLength'] ) {
261 - return 'Password must be at least ' . $passwordRequirements['minLength'] . ' characters.';
261 + /* translators: %d: minimum password length. */
262 + return sprintf( __( 'Password must be at least %d characters.', 'b-blocks' ), (int) $passwordRequirements['minLength'] );
262 263 }
263 264 }
264 265
265 266 return null;