PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.11
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.11
1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 All 173 releases
← All changes | includes/class-forms.php +1117 -1742 trunk1.2.11 View file →
@@ -102,27 +102,26 @@
102 102 $processed = true;
103 103 }
104 104
105 105 if ( $processed ) {
106 +
106 107 if ( is_wp_error( $errors ) ) {
107 - aui()->alert(
108 - array(
109 - 'type' => 'error',
110 - 'content' => wp_kses_post( $errors->get_error_message() )
111 - ),
112 - true
113 - );
114 - } else if ( $redirect ) {
108 + echo aui()->alert( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
109 + 'type' => 'error',
110 + 'class' => 'text-center',
111 + 'content' => wp_kses_post( $errors->get_error_message() )
112 + ) );
113 + } else {
114 + if ( $redirect ) {
115 115 wp_safe_redirect( $redirect );
116 116 exit();
117 - } else {
118 - aui()->alert(
119 - array(
117 + } else {
118 + echo aui()->alert( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
120 119 'type' => 'success',
120 + 'class' => 'text-center',
121 121 'content' => wp_kses_post( $message )
122 - ),
123 - true
124 - );
122 + ) );
123 + }
125 124 }
126 125 }
127 126
128 127 if ( $type ) {
@@ -131,8 +130,9 @@
131 130 $uwp_notices[] = ob_get_contents();
132 131 }
133 132
134 133 ob_end_clean();
134 +
135 135 }
136 136
137 137 /**
138 138 * Processes avatar and banner uploads form submission.
@@ -172,14 +172,14 @@
172 172
173 173 $url = add_query_arg(
174 174 array(
175 175 'uwp_crop' => $result[ 'uwp_' . $type . '_file' ],
176 - 'type' => $type,
176 + 'type' => $type
177 177 ),
178 - $profile_url
179 - );
178 + $profile_url );
180 179
181 180 return $url;
181 +
182 182 }
183 183
184 184 /**
185 185 * Processes avatar and banner uploads image crop.
@@ -195,49 +195,40 @@
195 195 * @since 1.0.0
196 196 */
197 197 public function process_image_crop( $data = array(), $type = 'avatar', $unlink_prev_img = false ) {
198 198 global $wpdb;
199 -
200 199 if ( ! is_user_logged_in() ) {
201 200 return false;
202 201 }
203 202
204 - if ( empty( $_POST['uwp_crop_nonce'] ) || ! wp_verify_nonce( $_POST['uwp_crop_nonce'], 'uwp_crop_nonce_' . $type ) ) {
203 + if ( empty( $_POST['uwp_crop_nonce'] ) || !wp_verify_nonce( $_POST['uwp_crop_nonce'], 'uwp_crop_nonce_'.$type ) ) {
205 204 return;
206 205 }
207 206
208 - $image_url = ! empty( $data['uwp_crop'] ) ? esc_url( $data['uwp_crop'] ) : '';
209 -
210 - if ( empty( $image_url ) ) {
211 - return new WP_Error( 'empty_image', __( 'Upload valid image.', 'userswp' ) );
212 - }
213 -
214 - // Ensure we have a valid URL with an allowed meme type.
215 - $image_url = $this->normalize_url( $image_url );
216 -
217 - $content_url = str_replace( array( 'https://', 'http://' ) , '', untrailingslashit( WP_CONTENT_URL ) );
218 - $_image_url = str_replace( array( 'https://', 'http://' ), '', $image_url );
219 - if ( strpos( $_image_url, $content_url ) !== 0 ) {
220 - return new WP_Error( 'invalid_image', __( 'Invalid image url.', 'userswp' ) );
221 - }
222 -
223 - $filetype = wp_check_filetype( $image_url );
224 -
225 - if ( empty( $filetype['ext'] ) ) {
226 - return new WP_Error( 'invalid_image', __( 'Invalid image type.', 'userswp' ) );
227 - }
228 -
229 207 // If is current user's profile (profile.php)
230 208 if ( is_admin() && defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) {
231 209 $user_id = get_current_user_id();
232 210 // If is another user's profile page
233 - } elseif ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) {
234 - $user_id = absint( $_GET['user_id'] );
211 + } elseif ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) {
212 + $user_id = absint($_GET['user_id']);
235 213 // Otherwise something is wrong.
236 214 } else {
237 215 $user_id = get_current_user_id();
238 216 }
239 217
218 + // Ensure we have a valid URL with an allowed meme type.
219 + $image_url = $this->normalize_url( esc_url( $data['uwp_crop'] ) );
220 + $filetype = wp_check_filetype( $image_url );
221 +
222 + $errors = new WP_Error();
223 + if ( empty( $image_url ) || empty( $filetype['ext'] ) ) {
224 + $errors->add( 'something_wrong', __( 'Something went wrong. Please contact site admin.', 'userswp' ) );
225 + }
226 +
227 + if ( $errors->has_errors() ) {
228 + return $errors;
229 + }
230 +
240 231 // Retrieve current thumbnail.
241 232 $current_field = 'avatar' === $type ? 'avatar_thumb' : 'banner_thumb';
242 233 $current_thumbnail = $this->normalize_url( uwp_get_usermeta( $user_id, $current_field, '' ) );
243 234 $thumb_postfix = '_uwp_' . $type . '_thumb';
@@ -246,9 +237,9 @@
246 237 if ( $type == 'avatar' ) {
247 238 $avatar_size = uwp_get_upload_image_size();
248 239 $full_width = $avatar_size['width'];
249 240 } else {
250 - $banner_size = uwp_get_upload_image_size( 'banner' );
241 + $banner_size = uwp_get_upload_image_size('banner');
251 242 $full_width = $banner_size['width'];
252 243 }
253 244
254 245 add_filter( 'upload_dir', 'uwp_handle_multisite_profile_image', 10, 1 );
@@ -260,14 +251,13 @@
260 251 $ext = $filetype['ext']; // to get extension
261 252 $name = sanitize_file_name( pathinfo( $image_path, PATHINFO_FILENAME ) ); //file name without extension
262 253 $thumb_image_name = $name . $thumb_postfix . '.' . $ext;
263 254 $thumb_image_location = str_replace( $name . '.' . $ext, $thumb_image_name, $image_path );
264 -
265 255 //Get the new coordinates to crop the image.
266 - $x = $data['uwpx'];
267 - $y = $data['uwpy'];
268 - $w = $data['uwpw'];
269 - $h = $data['uwph'];
256 + $x = $data["x"];
257 + $y = $data["y"];
258 + $w = $data["w"];
259 + $h = $data["h"];
270 260 //Scale the image based on cropped width setting
271 261 $scale = $full_width / $w;
272 262 //$scale = 1; // no scaling
273 263
@@ -273,12 +263,12 @@
273 263
274 264 // check we are not editing another user file
275 265 $db_value = trailingslashit( $uploads['subdir'] ) . $thumb_image_name;
276 266 $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';
277 - $file_exists = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM {$meta_table} WHERE ( `avatar_thumb` = %s OR `banner_thumb` = %s ) ", $db_value, $db_value ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
267 + $file_exists = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM {$meta_table} WHERE ( `avatar_thumb` = %s OR `banner_thumb` = %s ) ", $db_value, $db_value)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
278 268
279 269 // if file already exists then we should not be cropping it.
280 - if ( $file_exists ) {
270 + if( $file_exists ){
281 271 wp_die( esc_html__( 'Something went wrong. Please contact site admin.', 'userswp' ), 403 );
282 272 }
283 273
284 274 $cropped = uwp_resizeThumbnailImage( $thumb_image_location, $image_path, $x, $y, $w, $h, $scale );
@@ -319,8 +309,9 @@
319 309 $redirect_url = uwp_build_profile_tab_url( $user_id );
320 310 }
321 311
322 312 return $redirect_url;
313 +
323 314 }
324 315
325 316 /**
326 317 * Normalizes a URL.
@@ -327,11 +318,8 @@
327 318 *
328 319 */
329 320 public function normalize_url( $url ) {
330 321
331 - if ( empty( $url ) ) {
332 - return '';
333 - }
334 322 // Normalize.
335 323 $url = wp_normalize_path( $url );
336 324
337 325 // Remove query vars.
@@ -360,20 +348,22 @@
360 348 if ( ! is_user_logged_in() ) {
361 349 return false;
362 350 }
363 351
352 + if ( empty( $_POST['uwp_reset_nonce'] ) || !wp_verify_nonce( $_POST['uwp_reset_nonce'], 'uwp_reset_nonce_'.$type ) ) {
353 + return;
354 + }
355 +
364 356 if ( is_admin() && defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) {
365 357 $user_id = get_current_user_id();
366 - } elseif ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) {
367 - $user_id = absint( $_GET['user_id'] );
358 + // If is another user's profile page
359 + } elseif ( is_admin() && ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) {
360 + $user_id = absint($_GET['user_id']);
361 + // Otherwise something is wrong.
368 362 } else {
369 363 $user_id = get_current_user_id();
370 364 }
371 365
372 - if ( empty( $_POST['uwp_reset_nonce'] ) || ! wp_verify_nonce( $_POST['uwp_reset_nonce'], 'uwp_reset_nonce_' . $type . '_' . $user_id ) ) {
373 - return;
374 - }
375 -
376 366 $errors = new WP_Error();
377 367 if ( empty( $user_id ) ) {
378 368 $errors->add( 'something_wrong', __( 'Something went wrong. Please try again.', 'userswp' ) );
379 369 }
@@ -416,12 +406,12 @@
416 406 * @since 1.0.0
417 407 */
418 408 public function output_dashboard_links( $options ) {
419 409 if ( ! empty( $options ) ) {
420 - $class = uwp_get_option( 'design_style', 'bootstrap' ) == 'bootstrap' ? 'form-control' : 'aui-select2';
410 + $class = uwp_get_option( "design_style", 'bootstrap' ) == 'bootstrap' ? 'form-control' : 'aui-select2';
421 411 echo '<select class="' . esc_attr( $class ) . '" onchange="window.location = jQuery(this).val();">';
422 412 $this->output_options( $options );
423 - echo '</select>';
413 + echo "</select>";
424 414 }
425 415 }
426 416
427 417 /**
@@ -438,16 +428,18 @@
438 428 foreach ( $options as $key => $link ) {
439 429
440 430 if ( ! isset( $link['text'] ) && isset( $link[0] ) && is_array( $link[0] ) ) {
441 431 $this->output_options( $link );
442 - } elseif ( ! empty( $link['optgroup'] ) && $link['optgroup'] == 'open' ) {
432 + } else {
433 + if ( ! empty( $link['optgroup'] ) && $link['optgroup'] == 'open' ) {
443 434 echo "<optgroup label='" . esc_attr( $link['text'] ) . "'>";
444 435 } elseif ( ! empty( $link['optgroup'] ) && $link['optgroup'] == 'close' ) {
445 - echo '</optgroup>';
436 + echo "</optgroup>";
446 437 } elseif ( ! empty( $link['text'] ) ) {
447 - echo '<option value="' . ( ! empty( $link['url'] ) ? esc_url( $link['url'] ) : '' ) . '"' . selected( ! empty( $link['selected'] ), true, false ) . ( ! empty( $link['disabled'] ) ? ' disabled' : '' ) . '' . ( ! empty( $link['display_none'] ) ? ' style="display:none;"' : '' ) . '>';
448 - echo esc_attr__( $link['text'], 'userswp' );
449 - echo '</option>';
438 + echo '<option value="' . ( ! empty( $link['url'] ) ? esc_url( $link['url'] ) : '' ) . '"' . selected( ! empty( $link['selected'] ), true, false ) . ( ! empty( $link['disabled'] ) ? ' disabled' : '' ) . '' . ( ! empty( $link['display_none'] ) ? ' style="display:none;"' : '' ) . '>';
439 + echo esc_attr__( $link['text'], 'userswp' );
440 + echo "</option>";
441 + }
450 442 }
451 443 }
452 444 }
453 445 }
@@ -474,14 +466,18 @@
474 466 if ( $key == $type ) {
475 467 echo wp_kses_post( $val );
476 468 }
477 469 }
478 - } elseif ( ! empty( $notice ) ) {
470 + } else {
471 + if ( ! empty( $notice ) ) {
479 472 echo wp_kses_post( $notice );
473 + }
480 474 }
481 - }
482 - }
483 475
476 + }
477 +
478 + }
479 +
484 480 if ( $type == 'change' ) {
485 481 $user_id = get_current_user_id();
486 482 $password_nag = get_user_option( 'default_password_nag', $user_id );
487 483
@@ -491,24 +487,20 @@
491 487
492 488 if ( isset( $_GET['uwp_remove_nag'] ) && $_GET['uwp_remove_nag'] == 'yes' ) {
493 489 delete_user_meta( $user_id, 'default_password_nag' );
494 490 $message = sprintf( __( 'We have removed the system generated password warning for you. From this point forward you can continue to access our site as usual. To go to home page, <a href="%s">click here</a>.', 'userswp' ), home_url( '/' ) );
495 - echo aui()->alert(
496 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
491 + echo aui()->alert( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
497 492 'class' => 'text-center',
498 493 'type' => 'success',
499 - 'content' => wp_kses_post( $message ),
500 - )
501 - );
494 + 'content' => wp_kses_post( $message )
495 + ) );
502 496 } else {
503 497 $message = sprintf( __( '<strong>Warning</strong>: It seems like you are using a system generated password. Please change the password in this page. If this is not a problem for you, you can remove this warning by <a href="%s">clicking here</a>.', 'userswp' ), $remove_nag_url );
504 - echo aui()->alert(
505 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
498 + echo aui()->alert( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
506 499 'class' => 'text-center',
507 500 'type' => 'warning',
508 - 'content' => wp_kses_post( $message ),
509 - )
510 - );
501 + 'content' => wp_kses_post( $message )
502 + ) );
511 503 }
512 504 }
513 505 }
514 506 }
@@ -533,23 +525,16 @@
533 525 if ( isset( $data['uwp_register_hp'] ) && '' != $data['uwp_register_hp'] ) {
534 526 wp_die( esc_html__( 'No spam please!', 'userswp' ) );
535 527 }
536 528
537 - $form_id = 1;
538 -
539 - if ( ! empty( $data['uwp_register_form_id'] ) ) {
540 - $form_id = (int) $data['uwp_register_form_id'];
541 - }
542 -
543 - if ( ! isset( $data['uwp_register_nonce'] ) || ! wp_verify_nonce( $data['uwp_register_nonce'], 'uwp-register-nonce-' . $form_id ) ) {
544 - $message = aui()->alert(
545 - array(
529 + if ( ! isset( $data['uwp_register_nonce'] ) || ! wp_verify_nonce( $data['uwp_register_nonce'], 'uwp-register-nonce' ) ) {
530 + $message = aui()->alert( array(
546 531 'type' => 'error',
547 - 'content' => __( 'Security verification failed. Try again.', 'userswp' ),
548 - )
532 + 'content' => __( 'Security verification failed. Try again.', 'userswp' )
533 + )
549 534 );
550 535 if ( wp_doing_ajax() ) {
551 - wp_send_json_error( array( 'message' => $message ) );
536 + wp_send_json_error( array( 'message' => $message) );
552 537 } else {
553 538 $uwp_notices[] = array( 'register' => $message );
554 539
555 540 return;
@@ -557,16 +542,15 @@
557 542 }
558 543
559 544 $hash = substr( hash( 'SHA256', AUTH_KEY . site_url() ), 0, 25 );
560 545 if ( empty( $data['uwp_register_hash'] ) || $hash != $data['uwp_register_hash'] ) {
561 - $message = aui()->alert(
562 - array(
546 + $message = aui()->alert( array(
563 547 'type' => 'error',
564 - 'content' => __( 'Security hash failed. Try again.', 'userswp' ),
565 - )
548 + 'content' => __( 'Security hash failed. Try again.', 'userswp' )
549 + )
566 550 );
567 551 if ( wp_doing_ajax() ) {
568 - wp_send_json_error( array( 'message' => $message ) );
552 + wp_send_json_error( array( 'message' => $message) );
569 553 } else {
570 554 $uwp_notices[] = array( 'register' => $message );
571 555
572 556 return;
@@ -573,16 +557,15 @@
573 557 }
574 558 }
575 559
576 560 if ( ! get_option( 'users_can_register' ) ) {
577 - $message = aui()->alert(
578 - array(
561 + $message = aui()->alert( array(
579 562 'type' => 'error',
580 - 'content' => __( 'User registration is currently not allowed. Please check settings of your site.', 'userswp' ),
581 - )
563 + 'content' => __( 'User registration is currently not allowed. Please check settings of your site.', 'userswp' )
564 + )
582 565 );
583 566 if ( wp_doing_ajax() ) {
584 - wp_send_json_error( array( 'message' => $message ) );
567 + wp_send_json_error( array( 'message' => $message) );
585 568 } else {
586 569 $uwp_notices[] = array( 'register' => $message );
587 570
588 571 return;
@@ -599,16 +582,15 @@
599 582
600 583 $result = apply_filters( 'uwp_validate_result', $result, 'register', $data );
601 584
602 585 if ( is_wp_error( $result ) ) {
603 - $message = aui()->alert(
604 - array(
586 + $message = aui()->alert( array(
605 587 'type' => 'error',
606 - 'content' => $result->get_error_message(),
607 - )
588 + 'content' => $result->get_error_message()
589 + )
608 590 );
609 591 if ( wp_doing_ajax() ) {
610 - wp_send_json_error( array( 'message' => $message ) );
592 + wp_send_json_error( array( 'message' => $message) );
611 593 } else {
612 594 $uwp_notices[] = array( 'register' => $message );
613 595
614 596 return;
@@ -617,16 +599,15 @@
617 599
618 600 $uploads_result = $file_obj->validate_uploads( $files, 'register' );
619 601
620 602 if ( is_wp_error( $uploads_result ) ) {
621 - $message = aui()->alert(
622 - array(
603 + $message = aui()->alert( array(
623 604 'type' => 'error',
624 - 'content' => $uploads_result->get_error_message(),
625 - )
605 + 'content' => $uploads_result->get_error_message()
606 + )
626 607 );
627 608 if ( wp_doing_ajax() ) {
628 - wp_send_json_error( array( 'message' => $message ) );
609 + wp_send_json_error( array( 'message' => $message) );
629 610 } else {
630 611 $uwp_notices[] = array( 'register' => $message );
631 612
632 613 return;
@@ -645,14 +626,14 @@
645 626 $this->generated_password = $password;
646 627 $generated_password = true;
647 628 }
648 629
649 - $first_name = '';
630 + $first_name = "";
650 631 if ( isset( $result['first_name'] ) && ! empty( $result['first_name'] ) ) {
651 632 $first_name = $result['first_name'];
652 633 }
653 634
654 - $last_name = '';
635 + $last_name = "";
655 636 if ( isset( $result['last_name'] ) && ! empty( $result['last_name'] ) ) {
656 637 $last_name = $result['last_name'];
657 638 }
658 639
@@ -657,15 +638,17 @@
657 638 }
658 639
659 640 if ( isset( $result['display_name'] ) && ! empty( $result['display_name'] ) ) {
660 641 $display_name = $result['display_name'];
661 - } elseif ( ! empty( $first_name ) || ! empty( $last_name ) ) {
642 + } else {
643 + if ( ! empty( $first_name ) || ! empty( $last_name ) ) {
662 644 $display_name = $first_name . ' ' . $last_name;
663 645 } else {
664 - $display_name = ! empty( $result['username'] ) ? $result['username'] : '';
646 + $display_name = ! empty( $result['username'] ) ? $result['username'] : '';
647 + }
665 648 }
666 649
667 - $user_url = '';
650 + $user_url = "";
668 651 if ( isset( $result['user_url'] ) && ! empty( $result['user_url'] ) ) {
669 652 $user_url = esc_url_raw( $result['user_url'] );
670 653 }
671 654
@@ -687,22 +670,23 @@
687 670 if ( ! ( validate_username( $user_login ) && ! username_exists( $user_login ) ) ) {
688 671 $user_login = $email;
689 672 }
690 673 }
691 - } elseif ( ! validate_username( $user_login ) ) {
692 - $message = aui()->alert(
693 - array(
674 + } else {
675 + if ( ! validate_username( $user_login ) ) {
676 + $message = aui()->alert( array(
694 677 'type' => 'error',
695 - 'content' => __( 'Sorry, that username is not allowed.', 'userswp' ),
696 - )
678 + 'content' => __( 'Sorry, that username is not allowed.', 'userswp' )
679 + )
697 680 );
698 681 if ( wp_doing_ajax() ) {
699 - wp_send_json_error( array( 'message' => $message ) );
682 + wp_send_json_error( array( 'message' => $message) );
700 683 } else {
701 - $uwp_notices[] = array( 'register' => $message );
684 + $uwp_notices[] = array( 'register' => $message );
702 685
703 - return;
686 + return;
704 687 }
688 + }
705 689 }
706 690
707 691 $args = array(
708 692 'user_login' => sanitize_user( $user_login ),
@@ -710,38 +694,21 @@
710 694 'user_pass' => $password,
711 695 'display_name' => sanitize_text_field( $display_name ),
712 696 'first_name' => esc_attr( $first_name ),
713 697 'last_name' => esc_attr( $last_name ),
714 - 'user_url' => esc_url_raw( $user_url ),
698 + 'user_url' => esc_url_raw($user_url),
715 699 );
716 700
717 - // Set user role by form.
718 - $user_role = uwp_get_register_form_by( $form_id, 'user_role' );
719 -
720 - if ( ! empty( $user_role ) ) {
721 - $user_roles = uwp_get_user_roles();
722 - $chosen_role = strtolower( $user_role );
723 -
724 - if ( ! empty( $user_roles ) ) {
725 - $wp_roles = wp_roles();
726 -
727 - if ( $wp_roles->is_role( $chosen_role ) && in_array( $chosen_role, array_keys( $user_roles ) ) ) {
728 - $args['role'] = $chosen_role;
729 - }
730 - }
731 - }
732 -
733 701 $user_id = wp_insert_user( $args );
734 702
735 703 if ( is_wp_error( $user_id ) ) {
736 - $message = aui()->alert(
737 - array(
704 + $message = aui()->alert( array(
738 705 'type' => 'error',
739 - 'content' => $user_id->get_error_message(),
740 - )
706 + 'content' => $user_id->get_error_message()
707 + )
741 708 );
742 709 if ( wp_doing_ajax() ) {
743 - wp_send_json_error( array( 'message' => $message ) );
710 + wp_send_json_error( array( 'message' => $message) );
744 711 } else {
745 712 $uwp_notices[] = array( 'register' => $message );
746 713
747 714 return;
@@ -749,26 +716,43 @@
749 716 }
750 717
751 718 $result = apply_filters( 'uwp_before_extra_fields_save', $result, 'register', $user_id );
752 719
753 - // Save user form id.
754 - if ( ! empty( $data['uwp_register_form_id'] ) ) {
720 + $form_id = 1;
721 +
722 + if ( isset( $data['uwp_register_form_id'] ) && ! empty( $data['uwp_register_form_id'] ) ) {
755 723 update_user_meta( $user_id, '_uwp_register_form_id', (int) $data['uwp_register_form_id'] );
724 + $form_id = (int) $data['uwp_register_form_id'];
756 725 }
757 726
727 + $user_role = uwp_get_register_form_by($form_id, 'user_role');
728 +
729 + if ( isset( $user_role ) && ! empty( $user_role ) ) {
730 + $user_roles = uwp_get_user_roles();
731 + $chosen_role = strtolower( $user_role );
732 + if ( ! empty( $user_roles ) ) {
733 + $wp_roles = wp_roles();
734 + if ( $wp_roles->is_role( $chosen_role ) && in_array( $chosen_role, array_keys( $user_roles ) ) ) {
735 + $new_user = get_userdata( $user_id );
736 + if($new_user){
737 + $new_user->set_role( $chosen_role );
738 + }
739 + }
740 + }
741 + }
742 +
758 743 $save_result = $this->save_user_extra_fields( $user_id, $result, 'register' );
759 744
760 745 $save_result = apply_filters( 'uwp_after_extra_fields_save', $save_result, $result, 'register', $user_id );
761 746
762 747 if ( is_wp_error( $save_result ) ) {
763 - $message = aui()->alert(
764 - array(
748 + $message = aui()->alert( array(
765 749 'type' => 'error',
766 - 'content' => $save_result->get_error_message(),
767 - )
750 + 'content' => $save_result->get_error_message()
751 + )
768 752 );
769 753 if ( wp_doing_ajax() ) {
770 - wp_send_json_error( array( 'message' => $message ) );
754 + wp_send_json_error( array( 'message' => $message) );
771 755 } else {
772 756 $uwp_notices[] = array( 'register' => $message );
773 757
774 758 return;
@@ -775,16 +759,15 @@
775 759 }
776 760 }
777 761
778 762 if ( ! $save_result ) {
779 - $message = aui()->alert(
780 - array(
763 + $message = aui()->alert( array(
781 764 'type' => 'error',
782 - 'content' => __( 'Something went wrong. Please contact site admin.', 'userswp' ),
783 - )
765 + 'content' => __( 'Something went wrong. Please contact site admin.', 'userswp' )
766 + )
784 767 );
785 768 if ( wp_doing_ajax() ) {
786 - wp_send_json_error( array( 'message' => $message ) );
769 + wp_send_json_error( array( 'message' => $message) );
787 770 } else {
788 771 $uwp_notices[] = array( 'register' => $message );
789 772
790 773 return;
@@ -802,21 +785,21 @@
802 785
803 786 do_action( 'uwp_after_custom_fields_save', 'register', $data, $result, $user_id );
804 787
805 788 // Unset post data to empty the form on submit
806 - $excluded_post_data = apply_filters( 'uwp_register_excluded_post_reset_fields', array( 'uwp_register_nonce' ) );
807 - foreach ( $data as $key => $value ) {
808 - if ( isset( $key ) && ! in_array( $key, $excluded_post_data ) ) {
809 - unset( $_POST[ $key ] );
789 + $excluded_post_data = apply_filters('uwp_register_excluded_post_reset_fields', array('uwp_register_nonce'));
790 + foreach($data as $key=>$value){
791 + if(isset($key) && !in_array($key, $excluded_post_data)){
792 + unset($_POST[$key]);
810 793 }
811 794 }
812 795
813 - $reg_action = uwp_get_register_form_by( $form_id, 'reg_action' );
814 - if ( ! $reg_action ) {
796 + $reg_action = uwp_get_register_form_by($form_id, 'reg_action');
797 + if(!$reg_action){
815 798 $reg_action = uwp_get_option( 'uwp_registration_action', false );
816 799 }
817 800
818 - $form_fields = apply_filters( 'uwp_send_mail_form_fields', '', 'register', $user_id );
801 + $form_fields = apply_filters( 'uwp_send_mail_form_fields', "", 'register', $user_id );
819 802
820 803 if ( $reg_action == 'require_email_activation' && ! $generated_password ) {
821 804
822 805 $user_data = get_userdata( $user_id );
@@ -823,9 +806,9 @@
823 806 $activation_link = uwp_get_activation_link( $user_id );
824 807
825 808 $message = __( 'To activate your account, visit the following address:', 'userswp' ) . "\r\n\r\n";
826 809
827 - $message .= "<a href='" . esc_url_raw( $activation_link ) . "' target='_blank'>" . esc_url_raw( $activation_link ) . '</a>' . "\r\n";
810 + $message .= "<a href='" . esc_url_raw( $activation_link ) . "' target='_blank'>" . esc_url_raw( $activation_link ) . "</a>" . "\r\n";
828 811
829 812 $activate_message = '<p><b>' . __( 'Please activate your account :', 'userswp' ) . '</b></p><p>' . $message . '</p>';
830 813
831 814 $activate_message = apply_filters( 'uwp_activation_mail_message', $activate_message, $user_id );
@@ -837,20 +820,22 @@
837 820 );
838 821
839 822 UsersWP_Mails::send( $user_data->user_email, 'registration_activate', $email_vars );
840 823
841 - } elseif ( $reg_action != 'require_admin_review' ) {
824 + } else {
842 825
826 + if ( $reg_action != 'require_admin_review' ) {
827 +
843 828 $user_data = get_userdata( $user_id );
844 829
845 830 if ( isset( $this->generated_password ) && ! empty( $this->generated_password ) ) {
846 - if ( ! uwp_get_option( 'change_disable_password_nag' ) ) {
847 - update_user_meta( $user_id, 'default_password_nag', true ); //Set up the Password change nag.
831 + if ( ! uwp_get_option( 'change_disable_password_nag' ) ) {
832 + update_user_meta( $user_id, 'default_password_nag', true ); //Set up the Password change nag.
848 833 }
849 - $message_pass = $this->generated_password;
850 - $this->generated_password = false;
834 + $message_pass = $this->generated_password;
835 + $this->generated_password = false;
851 836 } else {
852 - $message_pass = __( 'Password you entered during registration.', 'userswp' );
837 + $message_pass = __( "Password you entered during registration.", 'userswp' );
853 838 }
854 839
855 840 $message = '<p><b>' . __( 'Your login Information :', 'userswp' ) . '</b></p>
856 841 <p>' . __( 'Username:', 'userswp' ) . ' ' . $user_data->user_login . '</p>
@@ -864,20 +849,20 @@
864 849 'form_fields' => $form_fields,
865 850 );
866 851
867 852 UsersWP_Mails::send( $user_data->user_email, 'registration_success', $email_vars );
853 + }
868 854 }
869 855
870 856 $error_code = $errors->get_error_code();
871 857 if ( ! empty( $error_code ) ) {
872 - $message = aui()->alert(
873 - array(
858 + $message = aui()->alert( array(
874 859 'type' => 'error',
875 - 'content' => $result->get_error_message(),
876 - )
860 + 'content' => $result->get_error_message()
861 + )
877 862 );
878 863 if ( wp_doing_ajax() ) {
879 - wp_send_json_error( array( 'message' => $message ) );
864 + wp_send_json_error( array( 'message' => $message) );
880 865 } else {
881 866 $uwp_notices[] = array( 'register' => $message );
882 867 return;
883 868 }
@@ -908,22 +893,21 @@
908 893 $res = wp_signon(
909 894 array(
910 895 'user_login' => $user_login,
911 896 'user_password' => $password,
912 - 'remember' => false,
897 + 'remember' => false
913 898 )
914 899 );
915 900
916 901 if ( is_wp_error( $res ) ) {
917 - $message = aui()->alert(
918 - array(
902 + $message = aui()->alert( array(
919 903 'type' => 'error',
920 - 'content' => $res->get_error_message(),
921 - )
904 + 'content' => $res->get_error_message()
905 + )
922 906 );
923 -
907 +
924 908 if ( wp_doing_ajax() ) {
925 - wp_send_json_error( array( 'message' => $message ) );
909 + wp_send_json_error( array( 'message' => $message) );
926 910 } else {
927 911 $uwp_notices[] = array( 'register' => $message );
928 912 }
929 913 } else {
@@ -930,13 +914,12 @@
930 914 $redirect_to = $this->get_register_redirect_url( $data, $user_id );
931 915 do_action( 'uwp_after_process_register', $result, $user_id );
932 916
933 917 if ( wp_doing_ajax() ) {
934 - $message = aui()->alert(
935 - array(
918 + $message = aui()->alert( array(
936 919 'type' => 'success',
937 - 'content' => __( 'Account registered successfully. Redirecting...', 'userswp' ),
938 - )
920 + 'content' => __( 'Account registered successfully. Redirecting...', 'userswp' )
921 + )
939 922 );
940 923 $response = array(
941 924 'message' => $message,
942 925 'redirect' => $redirect_to,
@@ -958,13 +941,12 @@
958 941 ),
959 942 $resend_link
960 943 );
961 944
962 - $message = aui()->alert(
963 - array(
945 + $message = aui()->alert( array(
964 946 'type' => 'success',
965 - 'content' => sprintf( __( 'An email has been sent to your registered email address. Please click the activation link to proceed. <a href="%s">Resend</a>.', 'userswp' ), $resend_link ),
966 - )
947 + 'content' => sprintf( __( 'An email has been sent to your registered email address. Please click the activation link to proceed. %sResend%s.', 'userswp' ), '<a href="' . $resend_link . '"">', '</a>' )
948 + )
967 949 );
968 950
969 951 } elseif ( $reg_action == 'require_admin_review' && defined( 'UWP_MOD_VERSION' ) ) {
970 952
@@ -971,13 +953,12 @@
971 953 update_user_meta( $user_id, 'uwp_mod', '1' );
972 954
973 955 do_action( 'uwp_require_admin_review', $user_id, $result );
974 956
975 - $message = aui()->alert(
976 - array(
957 + $message = aui()->alert( array(
977 958 'type' => 'success',
978 - 'content' => __( 'Your account is under moderation. We will email you once its approved.', 'userswp' ),
979 - )
959 + 'content' => __( 'Your account is under moderation. We will email you once its approved.', 'userswp' )
960 + )
980 961 );
981 962 } else {
982 963
983 964 $login_page_url = wp_login_url();
@@ -982,18 +963,17 @@
982 963
983 964 $login_page_url = wp_login_url();
984 965
985 966 if ( $generated_password ) {
986 - $msg = sprintf( __( 'Account registered successfully. A password has been generated and mailed to your registered Email ID. Please login %1$shere%2$s.', 'userswp' ), '<a href="' . $login_page_url . '">', '</a>' );
967 + $msg = sprintf( __( 'Account registered successfully. A password has been generated and mailed to your registered Email ID. Please login %shere%s.', 'userswp' ), '<a href="' . $login_page_url . '">', '</a>' );
987 968 } else {
988 - $msg = sprintf( __( 'Account registered successfully. Please login %1$shere%2$s', 'userswp' ), '<a href="' . $login_page_url . '">', '</a>' );
969 + $msg = sprintf( __( 'Account registered successfully. Please login %shere%s', 'userswp' ), '<a href="' . $login_page_url . '">', '</a>' );
989 970 }
990 971
991 - $message = aui()->alert(
992 - array(
972 + $message = aui()->alert( array(
993 973 'type' => 'success',
994 - 'content' => $msg,
995 - )
974 + 'content' => $msg
975 + )
996 976 );
997 977 }
998 978
999 979 do_action( 'uwp_after_process_register', $result, $user_id );
@@ -998,17 +978,19 @@
998 978
999 979 do_action( 'uwp_after_process_register', $result, $user_id );
1000 980
1001 981 if ( wp_doing_ajax() ) {
1002 - wp_send_json_success( array( 'message' => $message ) );
982 + wp_send_json_success( array( 'message' => $message) );
1003 983 } else {
1004 984 $uwp_notices[] = array( 'register' => $message );
1005 985 }
986 +
1006 987 }
1007 988
1008 989 if ( wp_doing_ajax() ) {
1009 990 wp_send_json_error();
1010 991 } // if we got this far there is a problem
992 +
1011 993 }
1012 994
1013 995 /**
1014 996 * Saves UsersWP related user custom fields.
@@ -1032,8 +1014,9 @@
1032 1014 if ( $type == 'login' || $type == 'forgot' ) {
1033 1015 return true;
1034 1016 }
1035 1017
1018 +
1036 1019 if ( $type == 'account' || $type == 'register' ) {
1037 1020 if ( isset( $data['password'] ) ) {
1038 1021 unset( $data['password'] );
1039 1022 }
@@ -1052,10 +1035,10 @@
1052 1035 // no extra fields. so just return
1053 1036 return true;
1054 1037 } else {
1055 1038 foreach ( $data as $key => $value ) {
1056 - if ( 'uwp_language' == $key ) {
1057 - update_user_meta( $user_id, 'locale', $value );
1039 + if('uwp_language' == $key){
1040 + update_user_meta($user_id, 'locale', $value);
1058 1041 }
1059 1042 uwp_update_usermeta( $user_id, $key, $value );
1060 1043 }
1061 1044
@@ -1070,13 +1053,13 @@
1070 1053
1071 1054 $redirect_page_id = $custom_url = '';
1072 1055 if ( isset( $data['uwp_register_form_id'] ) && ! empty( $data['uwp_register_form_id'] ) ) {
1073 1056 $form_id = (int) $data['uwp_register_form_id'];
1074 - $redirect_page_id = uwp_get_register_form_by( $form_id, 'redirect_to' );
1075 - $custom_url = uwp_get_register_form_by( $form_id, 'custom_url' );
1057 + $redirect_page_id = uwp_get_register_form_by($form_id, 'redirect_to');
1058 + $custom_url = uwp_get_register_form_by($form_id, 'custom_url');
1076 1059 }
1077 1060
1078 - if ( ! $redirect_page_id ) {
1061 + if(!$redirect_page_id){
1079 1062 $redirect_page_id = uwp_get_option( 'register_redirect_to', '' );
1080 1063 $custom_url = uwp_get_option( 'register_redirect_custom_url' );
1081 1064 }
1082 1065
@@ -1106,8 +1089,9 @@
1106 1089 $redirect_to = apply_filters( 'registration_redirect', $redirect_to );
1107 1090 }
1108 1091
1109 1092 return apply_filters( 'uwp_register_redirect', $redirect_to, $redirect_page_id, $data );
1093 +
1110 1094 }
1111 1095
1112 1096 /**
1113 1097 * Processes login form submission.
@@ -1124,16 +1108,15 @@
1124 1108 return;
1125 1109 }
1126 1110
1127 1111 if ( ! isset( $data['uwp_login_nonce'] ) || ! wp_verify_nonce( $data['uwp_login_nonce'], 'uwp-login-nonce' ) ) {
1128 - $message = aui()->alert(
1129 - array(
1112 + $message = aui()->alert( array(
1130 1113 'type' => 'error',
1131 - 'content' => __( 'Security verification failed. Try again.', 'userswp' ),
1132 - )
1114 + 'content' => __( 'Security verification failed. Try again.', 'userswp' )
1115 + )
1133 1116 );
1134 1117 if ( wp_doing_ajax() ) {
1135 - wp_send_json_error( array( 'message' => $message ) );
1118 + wp_send_json_error( array( 'message' => $message) );
1136 1119 } else {
1137 1120 return;
1138 1121 }
1139 1122 }
@@ -1146,16 +1129,15 @@
1146 1129
1147 1130 $result = apply_filters( 'uwp_validate_result', $result, 'login', $data );
1148 1131
1149 1132 if ( is_wp_error( $result ) ) {
1150 - $message = aui()->alert(
1151 - array(
1133 + $message = aui()->alert( array(
1152 1134 'type' => 'error',
1153 - 'content' => $result->get_error_message(),
1154 - )
1135 + 'content' => $result->get_error_message()
1136 + )
1155 1137 );
1156 1138 if ( wp_doing_ajax() ) {
1157 - wp_send_json_error( array( 'message' => $message ) );
1139 + wp_send_json_error( array( 'message' => $message) );
1158 1140 } else {
1159 1141 $uwp_notices[] = array( 'login' => $message );
1160 1142
1161 1143 return;
@@ -1175,70 +1157,44 @@
1175 1157 global $wp2fa;
1176 1158 if ( wp_doing_ajax() && isset( $wp2fa ) && ! empty( $wp2fa ) ) {
1177 1159 remove_action( 'wp_login', array( $wp2fa->login, 'wp_login' ), 20 );
1178 1160 }
1179 - if ( wp_doing_ajax() && class_exists( '\WP2FA\Authenticator\Login' ) ) {
1180 - remove_action( 'wp_login', array( 'WP2FA\Authenticator\Login', 'wp_login' ), 20 );
1181 - }
1182 1161
1183 1162 $user = wp_signon(
1184 1163 array(
1185 1164 'user_login' => $result['username'],
1186 1165 'user_password' => $result['password'],
1187 - 'remember' => $remember_me,
1166 + 'remember' => $remember_me
1188 1167 )
1189 1168 );
1190 1169
1191 1170 add_action( 'authenticate', 'gglcptch_login_check', 21, 1 );
1192 - if ( wp_doing_ajax() && class_exists( '\WP2FA\Authenticator\Login' ) ) {
1193 - add_action( 'wp_login', array( 'WP2FA\Authenticator\Login', 'wp_login' ), 20, 2 );
1194 - }
1195 1171
1196 - $wp2fa_available = ( isset( $wp2fa ) && ! empty( $wp2fa ) ) || class_exists( '\WP2FA\Authenticator\Login' );
1197 - if ( wp_doing_ajax() && ! is_wp_error( $user ) && $wp2fa_available ) {
1172 + if ( wp_doing_ajax() && ! is_wp_error( $user ) && isset( $wp2fa ) && ! empty( $wp2fa ) ) {
1198 1173
1199 1174 $two_fa = $this->check_2fa( $user );
1200 1175 if ( isset( $two_fa ) && ! empty( $two_fa ) ) {
1201 1176 if ( is_wp_error( $two_fa ) ) {
1202 - $message = aui()->alert(
1203 - array(
1177 + $message = aui()->alert( array(
1204 1178 'type' => 'error',
1205 - 'content' => $two_fa->get_error_message(),
1206 - )
1179 + 'content' => $two_fa->get_error_message()
1180 + )
1207 1181 );
1208 - wp_send_json_error( array( 'message' => $message ) );
1182 + wp_send_json_error( array( 'message' => $message) );
1209 1183 } else {
1210 - wp_send_json_success(
1211 - array(
1212 - 'html' => $two_fa,
1213 - 'is_2fa' => true,
1214 - )
1215 - );
1184 + wp_send_json_success( array( 'html' => $two_fa, 'is_2fa' => true ) );
1216 1185 }
1217 1186 }
1218 1187 }
1219 1188
1220 - if ( wp_doing_ajax() && is_wp_error( $user ) && $this->wordfence_2fa_available() ) {
1221 - $wfls_2fa = $this->check_wordfence_2fa( $user, $result );
1222 - if ( ! empty( $wfls_2fa ) ) {
1223 - wp_send_json_success(
1224 - array(
1225 - 'html' => $wfls_2fa,
1226 - 'is_2fa' => true,
1227 - )
1228 - );
1229 - }
1230 - }
1231 -
1232 1189 if ( is_wp_error( $user ) ) {
1233 - $message = aui()->alert(
1234 - array(
1190 + $message = aui()->alert( array(
1235 1191 'type' => 'error',
1236 - 'content' => $user->get_error_message(),
1237 - )
1192 + 'content' => $user->get_error_message()
1193 + )
1238 1194 );
1239 1195 if ( wp_doing_ajax() ) {
1240 - wp_send_json_error( array( 'message' => $message ) );
1196 + wp_send_json_error( array( 'message' => $message) );
1241 1197 } else {
1242 1198 $uwp_notices[] = array( 'login' => $message );
1243 1199
1244 1200 return;
@@ -1244,31 +1200,27 @@
1244 1200 return;
1245 1201 }
1246 1202 } else {
1247 1203 do_action( 'uwp_after_process_login', $data );
1248 - $message = aui()->alert(
1249 - array(
1204 + $message = aui()->alert( array(
1250 1205 'type' => 'success',
1251 - 'content' => __( 'Login successful. Redirecting...', 'userswp' ),
1252 - )
1206 + 'content' => __( 'Login successful. Redirecting...', 'userswp' )
1207 + )
1253 1208 );
1254 1209 if ( wp_doing_ajax() ) {
1255 1210 $redirect_to = '';
1256 - if ( 1 == uwp_get_option( 'login_modal_enable_redirect' ) ) {
1211 + if(1 == uwp_get_option('login_modal_enable_redirect')){
1257 1212 $redirect_to = $this->get_login_redirect_url( $data, $user );
1258 1213 }
1259 - wp_send_json_success(
1260 - array(
1261 - 'message' => $message,
1262 - 'redirect' => $redirect_to,
1263 - )
1264 - );
1214 + wp_send_json_success( array( 'message' => $message, 'redirect' => $redirect_to ) );
1265 1215 } else {
1266 1216 $redirect_to = $this->get_login_redirect_url( $data, $user );
1267 1217 wp_safe_redirect( $redirect_to );
1268 1218 exit();
1269 1219 }
1270 -}
1220 +
1221 + }
1222 +
1271 1223 }
1272 1224
1273 1225 public function check_2fa( $user ) {
1274 1226 if ( 1 == uwp_get_option( 'disable_wp_2fa' ) ) {
@@ -1297,12 +1249,9 @@
1297 1249
1298 1250 return $errors;
1299 1251 }
1300 1252
1301 - $provider = $this->get_wp2fa_provider_for_user( $user );
1302 - if ( empty( $provider ) ) {
1303 - return;
1304 - }
1253 + $provider = \WP2FA\Authenticator\Login::get_available_providers_for_user( $user );
1305 1254
1306 1255 ob_start();
1307 1256 ?>
1308 1257
@@ -1307,13 +1256,13 @@
1307 1256 ?>
1308 1257
1309 1258 <div class="uwp-2fa-methods-wrap">
1310 1259 <form name="validate_2fa_form" id="validate_2fa_form" class="validate_2fa_form" action="" method="post"
1311 - autocomplete="off">
1260 + autocomplete="off">
1312 1261 <input type="hidden" name="provider" id="provider" value="<?php echo esc_attr( $provider ); ?>"/>
1313 1262 <input type="hidden" name="uwp-auth-id" id="uwp-auth-id" value="<?php echo esc_attr( $user->ID ); ?>"/>
1314 1263 <input type="hidden" name="wp-auth-nonce" id="wp-auth-nonce"
1315 - value="<?php echo esc_attr( $login_nonce['key'] ); ?>"/>
1264 + value="<?php echo esc_attr( $login_nonce['key'] ); ?>"/>
1316 1265 <?php
1317 1266
1318 1267 // Check to see what provider is set and give the relevant authentication page.
1319 1268 if ( 'totp' === $provider ) {
@@ -1320,10 +1269,9 @@
1320 1269 ?>
1321 1270 <p><?php esc_html_e( 'Please enter the authentication code from your 2FA authentication app below to login:', 'userswp' ); ?></p>
1322 1271 <?php
1323 1272
1324 - echo aui()->input(
1325 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1273 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1326 1274 'type' => 'tel',
1327 1275 'id' => 'authcode',
1328 1276 'name' => 'authcode',
1329 1277 'placeholder' => esc_attr__( 'Authentication Code', 'userswp' ),
@@ -1328,20 +1276,17 @@
1328 1276 'name' => 'authcode',
1329 1277 'placeholder' => esc_attr__( 'Authentication Code', 'userswp' ),
1330 1278 'value' => '',
1331 1279 'label' => esc_html__( 'Authentication Code', 'userswp' ),
1332 - )
1333 - );
1280 + ) );
1334 1281
1335 - echo aui()->button(
1336 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1282 + echo aui()->button( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1337 1283 'type' => 'submit',
1338 1284 'class' => 'btn btn-primary btn-block text-uppercase uwp-2fa-submit',
1339 1285 'name' => 'submit',
1340 1286 'icon' => '',
1341 1287 'content' => esc_html__( 'Log In', 'userswp' ),
1342 - )
1343 - );
1288 + ) );
1344 1289
1345 1290 } elseif ( 'email' === $provider ) {
1346 1291 $has_token = \WP2FA\Authenticator\Authentication::user_has_token( $user->ID );
1347 1292 if ( empty( $has_token ) || ! $has_token ) {
@@ -1349,42 +1294,33 @@
1349 1294 }
1350 1295 ?>
1351 1296 <p><?php esc_html_e( 'Please enter the 2FA verification code sent to your email address to login:', 'userswp' ); ?></p>
1352 1297 <?php
1353 - echo aui()->input(
1354 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1298 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1355 1299 'type' => 'tel',
1356 1300 'id' => 'authcode',
1357 - 'name' => 'authcode',
1301 + 'name' => 'wp-2fa-email-code',
1358 1302 'placeholder' => esc_attr__( 'Verification Code', 'userswp' ),
1359 1303 'value' => '',
1360 1304 'label' => esc_html__( 'Verification Code', 'userswp' ),
1361 - 'extra_attributes' => array(
1362 - 'size' => 20,
1363 - 'pattern' => '[0-9]*',
1364 - ),
1365 - )
1366 - );
1305 + 'extra_attributes' => array( 'size' => 20, 'pattern' => "[0-9]*" ),
1306 + ) );
1367 1307
1368 - echo aui()->button(
1369 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1308 + echo aui()->button( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1370 1309 'type' => 'submit',
1371 1310 'class' => 'btn btn-primary text-uppercase uwp-2fa-submit',
1372 1311 'name' => 'submit',
1373 1312 'icon' => '',
1374 1313 'content' => esc_html__( 'Log In', 'userswp' ),
1375 - )
1376 - );
1314 + ) );
1377 1315
1378 - echo aui()->button(
1379 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1316 + echo aui()->button( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1380 1317 'type' => 'button',
1381 1318 'class' => 'btn btn-secondary text-uppercase uwp-2fa-email-resend',
1382 1319 'name' => 'wp-2fa-email-code-resend',
1383 1320 'icon' => '',
1384 1321 'content' => esc_html__( 'Resend Code', 'userswp' ),
1385 - )
1386 - );
1322 + ) );
1387 1323
1388 1324 }
1389 1325 ?>
1390 1326 </form>
@@ -1390,23 +1326,22 @@
1390 1326 </form>
1391 1327 </div>
1392 1328
1393 1329 <?php
1394 - $codes_remaining = $this->get_wp2fa_backup_codes_remaining( $user );
1330 + $codes_remaining = \WP2FA\Authenticator\Backup_Codes::codes_remaining_for_user( $user );
1395 1331 if ( isset( $codes_remaining ) && $codes_remaining > 0 ) {
1396 1332 ?>
1397 1333 <div class="uwp-2fa-methods-wrap" style="display:none;">
1398 1334 <form name="validate_2fa_backup_codes_form" id="validate_2fa_backup_codes_form"
1399 - class="validate_2fa_backup_codes_form" action="" method="post" autocomplete="off">
1335 + class="validate_2fa_backup_codes_form" action="" method="post" autocomplete="off">
1400 1336 <input type="hidden" name="provider" id="provider" value="backup_codes"/>
1401 1337 <input type="hidden" name="uwp-auth-id" id="uwp-auth-id"
1402 - value="<?php echo esc_attr( $user->ID ); ?>"/>
1338 + value="<?php echo esc_attr( $user->ID ); ?>"/>
1403 1339 <input type="hidden" name="wp-auth-nonce" id="wp-auth-nonce"
1404 - value="<?php echo esc_attr( $login_nonce['key'] ); ?>"/>
1340 + value="<?php echo esc_attr( $login_nonce['key'] ); ?>"/>
1405 1341 <div class="uwp-backup-fields">
1406 1342 <?php
1407 - echo aui()->input(
1408 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1343 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1409 1344 'type' => 'tel',
1410 1345 'id' => 'authcode',
1411 1346 'name' => 'wp-2fa-backup-code',
1412 1347 'placeholder' => esc_attr__( 'Enter backup code', 'userswp' ),
@@ -1411,24 +1346,18 @@
1411 1346 'name' => 'wp-2fa-backup-code',
1412 1347 'placeholder' => esc_attr__( 'Enter backup code', 'userswp' ),
1413 1348 'value' => '',
1414 1349 'label' => esc_html__( 'Backup Code', 'userswp' ),
1415 - 'extra_attributes' => array(
1416 - 'size' => 20,
1417 - 'pattern' => '[0-9]*',
1418 - ),
1419 - )
1420 - );
1350 + 'extra_attributes' => array( 'size' => 20, 'pattern' => "[0-9]*" ),
1351 + ) );
1421 1352
1422 - echo aui()->button(
1423 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1353 + echo aui()->button( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1424 1354 'type' => 'submit',
1425 1355 'class' => 'btn btn-primary btn-block text-uppercase uwp-2fa-submit',
1426 1356 'name' => 'submit',
1427 1357 'icon' => '',
1428 1358 'content' => esc_html__( 'Log In', 'userswp' ),
1429 - )
1430 - );
1359 + ) );
1431 1360 ?>
1432 1361 </div>
1433 1362 </form>
1434 1363 </div>
@@ -1448,247 +1377,9 @@
1448 1377
1449 1378 return ob_get_clean();
1450 1379 }
1451 1380
1452 - /**
1453 - * Checks if the Wordfence Login Security module (2FA) is available.
1454 - *
1455 - * @since 1.2.5
1456 - * @package userswp
1457 - *
1458 - * @return bool
1459 - */
1460 - public function wordfence_2fa_available() {
1461 - return class_exists( '\WordfenceLS\Controller_Users' ) && class_exists( '\WordfenceLS\Controller_TOTP' );
1462 - }
1463 -
1464 - /**
1465 - * Checks whether Wordfence's 2FA requires a verification code for the
1466 - * failed login attempt and, if so, returns the markup for the code entry form.
1467 - *
1468 - * @since 1.2.5
1469 - * @package userswp
1470 - *
1471 - * @param WP_Error $error The error returned by wp_signon().
1472 - * @param array $result The validated login fields (username/password).
1473 - *
1474 - * @return string|void The 2FA form markup, or nothing if not applicable.
1475 - */
1476 - public function check_wordfence_2fa( $error, $result ) {
1477 - if ( 1 == uwp_get_option( 'disable_wordfence_2fa' ) ) {
1478 - return;
1479 - }
1480 -
1481 - if ( ! $this->wordfence_2fa_available() ) {
1482 - return;
1483 - }
1484 -
1485 - if ( ! is_wp_error( $error ) || 'wfls_twofactor_required' !== $error->get_error_code() ) {
1486 - return;
1487 - }
1488 -
1489 - $username = ! empty( $result['username'] ) ? $result['username'] : '';
1490 - if ( empty( $username ) ) {
1491 - return;
1492 - }
1493 -
1494 - $user = is_email( $username ) ? get_user_by( 'email', $username ) : get_user_by( 'login', $username );
1495 - if ( ! $user ) {
1496 - return;
1497 - }
1498 -
1499 - if ( ! \WordfenceLS\Controller_Users::shared()->has_2fa_active( $user ) ) {
1500 - return;
1501 - }
1502 -
1503 - if ( \WordfenceLS\Controller_Users::shared()->has_remembered_2fa( $user ) ) {
1504 - return;
1505 - }
1506 -
1507 - $login_nonce = wp_create_nonce( 'uwp-wfls-2fa-' . $user->ID );
1508 -
1509 - ob_start();
1510 - ?>
1511 -
1512 - <div class="uwp-2fa-methods-wrap">
1513 - <form name="validate_2fa_form" id="validate_2fa_form" class="validate_2fa_form" action="" method="post"
1514 - autocomplete="off">
1515 - <input type="hidden" name="provider" id="provider" value="wordfence"/>
1516 - <input type="hidden" name="uwp-auth-id" id="uwp-auth-id" value="<?php echo esc_attr( $user->ID ); ?>"/>
1517 - <input type="hidden" name="wp-auth-nonce" id="wp-auth-nonce"
1518 - value="<?php echo esc_attr( $login_nonce ); ?>"/>
1519 -
1520 - <p><?php esc_html_e( 'Please enter the authentication code from your two-factor authentication app, or a recovery code, to login:', 'userswp' ); ?></p>
1521 -
1522 - <?php
1523 - echo aui()->input(
1524 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1525 - 'type' => 'text',
1526 - 'id' => 'authcode',
1527 - 'name' => 'authcode',
1528 - 'placeholder' => esc_attr__( 'Authentication Code', 'userswp' ),
1529 - 'value' => '',
1530 - 'label' => esc_html__( 'Authentication Code', 'userswp' ),
1531 - 'extra_attributes' => array(
1532 - 'autocomplete' => 'one-time-code',
1533 - ),
1534 - )
1535 - );
1536 -
1537 - echo aui()->button(
1538 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1539 - 'type' => 'submit',
1540 - 'class' => 'btn btn-primary btn-block text-uppercase uwp-2fa-submit',
1541 - 'name' => 'submit',
1542 - 'icon' => '',
1543 - 'content' => esc_html__( 'Log In', 'userswp' ),
1544 - )
1545 - );
1546 - ?>
1547 - </form>
1548 - </div>
1549 -
1550 - <?php
1551 - return ob_get_clean();
1552 - }
1553 -
1554 - public function get_wp2fa_provider_for_user( $user ) {
1555 - if ( class_exists( '\WP2FA\Authenticator\Login' ) && method_exists( '\WP2FA\Authenticator\Login', 'get_available_providers_for_user' ) ) {
1556 - $provider = \WP2FA\Authenticator\Login::get_available_providers_for_user( $user );
1557 - if ( is_array( $provider ) ) {
1558 - $provider = key( $provider );
1559 - }
1560 -
1561 - return $provider;
1562 - }
1563 -
1564 - if ( class_exists( '\WP2FA\Admin\Helpers\User_Helper' ) && method_exists( '\WP2FA\Admin\Helpers\User_Helper', 'get_enabled_method_for_user' ) ) {
1565 - return \WP2FA\Admin\Helpers\User_Helper::get_enabled_method_for_user( $user );
1566 - }
1567 -
1568 - return '';
1569 - }
1570 -
1571 - public function get_wp2fa_backup_codes_remaining( $user ) {
1572 - if ( class_exists( '\WP2FA\Methods\Backup_Codes' ) && method_exists( '\WP2FA\Methods\Backup_Codes', 'codes_remaining_for_user' ) ) {
1573 - return \WP2FA\Methods\Backup_Codes::codes_remaining_for_user( $user );
1574 - }
1575 -
1576 - if ( class_exists( '\WP2FA\Authenticator\Backup_Codes' ) && method_exists( '\WP2FA\Authenticator\Backup_Codes', 'codes_remaining_for_user' ) ) {
1577 - return \WP2FA\Authenticator\Backup_Codes::codes_remaining_for_user( $user );
1578 - }
1579 -
1580 - return 0;
1581 - }
1582 -
1583 - public function validate_wp2fa_totp_authentication( $user ) {
1584 - if ( class_exists( '\WP2FA\Methods\TOTP' ) && method_exists( '\WP2FA\Methods\TOTP', 'validate_totp_authentication' ) ) {
1585 - return \WP2FA\Methods\TOTP::validate_totp_authentication( $user );
1586 - }
1587 -
1588 - if ( class_exists( '\WP2FA\Authenticator\Login' ) && method_exists( '\WP2FA\Authenticator\Login', 'validate_totp_authentication' ) ) {
1589 - return \WP2FA\Authenticator\Login::validate_totp_authentication( $user );
1590 - }
1591 -
1592 - return false;
1593 - }
1594 -
1595 - public function validate_wp2fa_email_authentication( $user ) {
1596 - if ( class_exists( '\WP2FA\Authenticator\Login' ) && method_exists( '\WP2FA\Authenticator\Login', 'validate_email_authentication' ) ) {
1597 - return \WP2FA\Authenticator\Login::validate_email_authentication( $user );
1598 - }
1599 -
1600 - if ( class_exists( '\WP2FA\Authenticator\Authentication' ) && method_exists( '\WP2FA\Authenticator\Authentication', 'validate_token' ) && isset( $_REQUEST['authcode'] ) ) {
1601 - return \WP2FA\Authenticator\Authentication::validate_token( $user, sanitize_text_field( wp_unslash( $_REQUEST['authcode'] ) ) );
1602 - }
1603 -
1604 - return false;
1605 - }
1606 -
1607 - public function validate_wp2fa_backup_codes( $user ) {
1608 - if ( class_exists( '\WP2FA\Methods\Backup_Codes' ) && method_exists( '\WP2FA\Methods\Backup_Codes', 'validate_backup_codes' ) ) {
1609 - return \WP2FA\Methods\Backup_Codes::validate_backup_codes( $user );
1610 - }
1611 -
1612 - if ( class_exists( '\WP2FA\Authenticator\Backup_Codes' ) && method_exists( '\WP2FA\Authenticator\Backup_Codes', 'validate_backup_codes' ) ) {
1613 - return \WP2FA\Authenticator\Backup_Codes::validate_backup_codes( $user );
1614 - }
1615 -
1616 - return false;
1617 - }
1618 -
1619 - /**
1620 - * Validates the Wordfence 2FA code submitted from the uwp-2fa form and,
1621 - * if valid, completes the login by setting the auth cookie.
1622 - *
1623 - * @since 1.2.5
1624 - * @package userswp
1625 - *
1626 - * @param WP_User $user The user attempting to complete 2FA login.
1627 - *
1628 - * @return void
1629 - */
1630 - public function process_login_wordfence_2fa( $user ) {
1631 - if ( ! $this->wordfence_2fa_available() ) {
1632 - $message = aui()->alert(
1633 - array(
1634 - 'type' => 'error',
1635 - 'content' => __( 'Invalid request! Please try again.', 'userswp' ),
1636 - )
1637 - );
1638 -
1639 - wp_send_json_error( array( 'message' => $message ) );
1640 - }
1641 -
1642 - $nonce = ( isset( $_POST['wp-auth-nonce'] ) ) ? sanitize_textarea_field( wp_unslash( $_POST['wp-auth-nonce'] ) ) : '';
1643 -
1644 - if ( ! wp_verify_nonce( $nonce, 'uwp-wfls-2fa-' . $user->ID ) ) {
1645 - $message = aui()->alert(
1646 - array(
1647 - 'type' => 'error',
1648 - 'content' => __( 'Invalid request! Please try again.', 'userswp' ),
1649 - )
1650 - );
1651 -
1652 - wp_send_json_error( array( 'message' => $message ) );
1653 - }
1654 -
1655 - $code = isset( $_POST['authcode'] ) ? sanitize_text_field( wp_unslash( $_POST['authcode'] ) ) : '';
1656 -
1657 - if ( empty( $code ) || true !== \WordfenceLS\Controller_TOTP::shared()->validate_2fa( $user, $code ) ) {
1658 - do_action( 'wp_login_failed', $user->user_login );
1659 -
1660 - $message = aui()->alert(
1661 - array(
1662 - 'type' => 'error',
1663 - 'content' => __( 'Invalid verification code.', 'userswp' ),
1664 - )
1665 - );
1666 -
1667 - wp_send_json_error( array( 'message' => $message ) );
1668 - }
1669 -
1670 - $remember = ( isset( $_REQUEST['rememberme'] ) ) ? filter_var( $_REQUEST['rememberme'], FILTER_VALIDATE_BOOLEAN ) : false;
1671 -
1672 - // Complete the login the same way wp_signon() would have, now that 2FA has been verified.
1673 - wp_set_auth_cookie( $user->ID, $remember );
1674 - wp_set_current_user( $user->ID );
1675 -
1676 - do_action( 'wp_login', $user->user_login, $user );
1677 -
1678 - $message = aui()->alert(
1679 - array(
1680 - 'type' => 'success',
1681 - 'content' => __( 'Validation successful. Redirecting...', 'userswp' ),
1682 - )
1683 - );
1684 -
1685 - wp_send_json_success( array( 'message' => $message ) );
1686 - }
1687 -
1688 1381 public function process_login_2fa() {
1689 - global $wp2fa;
1690 -
1691 1382 if ( ! isset( $_POST['uwp-auth-id'], $_POST['wp-auth-nonce'] ) ) {
1692 1383 return;
1693 1384 }
1694 1385
@@ -1693,70 +1384,44 @@
1693 1384 }
1694 1385
1695 1386 $auth_id = (int) $_POST['uwp-auth-id'];
1696 1387 $user = get_userdata( $auth_id );
1697 -
1698 1388 if ( ! $user ) {
1699 - $message = aui()->alert(
1700 - array(
1389 + $message = aui()->alert( array(
1701 1390 'type' => 'error',
1702 - 'content' => __( 'Invalid user data. Please try again.', 'userswp' ),
1391 + 'content' => __( 'Invalid user data. Please try again.', 'userswp' )
1703 1392 )
1704 1393 );
1705 1394
1706 - wp_send_json_error( array( 'message' => $message ) );
1395 + wp_send_json_error( array( 'message' => $message) );
1707 1396 }
1708 1397
1709 - if ( isset( $_POST['provider'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1710 - $provider = sanitize_textarea_field( wp_unslash( $_POST['provider'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1711 - } else {
1712 - $provider = '';
1713 - }
1398 + global $wp2fa;
1714 1399
1715 - if ( 'wordfence' === $provider ) {
1716 - $this->process_login_wordfence_2fa( $user );
1717 -
1718 - return;
1719 - }
1720 -
1721 1400 $nonce = ( isset( $_POST['wp-auth-nonce'] ) ) ? sanitize_textarea_field( wp_unslash( $_POST['wp-auth-nonce'] ) ) : '';
1401 + if ( true !== \WP2FA\Authenticator\Login::verify_login_nonce( $user->ID, $nonce ) ) {
1722 1402
1723 - if ( true !== \WP2FA\Authenticator\Login::verify_login_nonce( $user->ID, $nonce ) ) {
1724 - $message = aui()->alert(
1725 - array(
1403 + $message = aui()->alert( array(
1726 1404 'type' => 'error',
1727 - 'content' => __( 'Invalid request! Please try again.', 'userswp' ),
1405 + 'content' => __( 'Invalid request! Please try again.', 'userswp' )
1728 1406 )
1729 1407 );
1730 1408
1731 - wp_send_json_error( array( 'message' => $message ) );
1409 + wp_send_json_error( array( 'message' => $message) );
1732 1410 }
1733 1411
1734 - $error = '';
1735 -
1736 - try {
1737 - $is_enabled = \WP2FA\Admin\Controllers\Settings::is_provider_enabled_for_role( \WP2FA\Admin\Helpers\User_Helper::get_user_role( $user ), $provider );
1738 -
1739 - if ( ! $is_enabled ) {
1740 - $error = __( 'Invalid 2FA provider for user.', 'userswp' );
1412 + if ( isset( $_POST['provider'] ) ) {
1413 + $provider = sanitize_textarea_field( wp_unslash( $_POST['provider'] ) );
1414 + $providers = \WP2FA\Authenticator\Login::get_available_providers_for_user( $user );
1415 + if ( isset( $providers[ $provider ] ) ) {
1416 + $provider = $providers[ $provider ];
1417 + } elseif ( isset( $provider ) ) {
1418 + $provider = $provider;
1419 + } else {
1420 + $provider = $provider;
1741 1421 }
1742 - } catch ( \Exception $e ) {
1743 - $error = $e->getMessage();
1744 1422 }
1745 1423
1746 - if ( $error ) {
1747 - do_action( 'wp_login_failed', $user->user_login );
1748 -
1749 - $message = aui()->alert(
1750 - array(
1751 - 'type' => 'error',
1752 - 'content' => $error
1753 - )
1754 - );
1755 -
1756 - wp_send_json_error( array( 'message' => $message ) );
1757 - }
1758 -
1759 1424 // If this is an email login, or if the user failed validation previously, lets send the code to the user.
1760 1425 if ( 'email' === $provider && true !== \WP2FA\Authenticator\Login::pre_process_email_authentication( $user ) ) {
1761 1426
1762 1427 }
@@ -1761,58 +1426,57 @@
1761 1426
1762 1427 }
1763 1428
1764 1429 // Validate TOTP.
1765 - if ( 'totp' === $provider && true !== $this->validate_wp2fa_totp_authentication( $user ) ) {
1430 + if ( 'totp' === $provider && true !== \WP2FA\Authenticator\Login::validate_totp_authentication( $user ) ) {
1431 +
1766 1432 do_action( 'wp_login_failed', $user->user_login );
1767 1433
1768 - $message = aui()->alert(
1769 - array(
1434 + $message = aui()->alert( array(
1770 1435 'type' => 'error',
1771 - 'content' => __( 'Invalid verification code.', 'userswp' ),
1436 + 'content' => __( 'Invalid verification code.', 'userswp' )
1772 1437 )
1773 1438 );
1774 1439
1775 - wp_send_json_error( array( 'message' => $message ) );
1440 + wp_send_json_error( array( 'message' => $message) );
1776 1441 }
1777 1442
1778 1443 // Validate Email.
1779 - if ( 'email' === $provider && true !== $this->validate_wp2fa_email_authentication( $user ) ) {
1444 + if ( 'email' === $provider && true !== \WP2FA\Authenticator\Login::validate_email_authentication( $user ) ) {
1445 +
1780 1446 do_action( 'wp_login_failed', $user->user_login );
1781 1447
1782 1448 if ( isset( $_REQUEST['wp-2fa-email-code-resend'] ) && 1 == $_REQUEST['wp-2fa-email-code-resend'] ) {
1783 - $message = aui()->alert(
1784 - array(
1449 + $message = aui()->alert( array(
1785 1450 'type' => 'info',
1786 - 'content' => __( 'A new code has been sent.', 'userswp' ),
1451 + 'content' => __( 'A new code has been sent.', 'userswp' )
1787 1452 )
1788 1453 );
1789 1454
1790 - wp_send_json_error( array( 'message' => $message ) );
1455 + wp_send_json_error( array( 'message' => $message) );
1791 1456 } else {
1792 - $message = aui()->alert(
1793 - array(
1457 + $message = aui()->alert( array(
1794 1458 'type' => 'error',
1795 - 'content' => __( 'Invalid verification code.', 'userswp' ),
1459 + 'content' => __( 'Invalid verification code.', 'userswp' )
1796 1460 )
1797 1461 );
1798 1462
1799 - wp_send_json_error( array( 'message' => $message ) );
1463 + wp_send_json_error( array( 'message' => $message) );
1800 1464 }
1801 1465 }
1802 1466
1803 1467 // Backup Codes.
1804 - if ( 'backup_codes' === $provider && true !== $this->validate_wp2fa_backup_codes( $user ) ) {
1468 + if ( 'backup_codes' === $provider && true !== \WP2FA\Authenticator\Login::validate_backup_codes( $user ) ) {
1469 +
1805 1470 do_action( 'wp_login_failed', $user->user_login );
1806 1471
1807 - $message = aui()->alert(
1808 - array(
1472 + $message = aui()->alert( array(
1809 1473 'type' => 'error',
1810 - 'content' => __( 'Invalid backup code.', 'userswp' ),
1474 + 'content' => __( 'Invalid backup code.', 'userswp' )
1811 1475 )
1812 1476 );
1813 1477
1814 - wp_send_json_error( array( 'message' => $message ) );
1478 + wp_send_json_error( array( 'message' => $message) );
1815 1479 }
1816 1480
1817 1481 \WP2FA\Authenticator\Login::delete_login_nonce( $user->ID );
1818 1482
@@ -1817,9 +1481,8 @@
1817 1481 \WP2FA\Authenticator\Login::delete_login_nonce( $user->ID );
1818 1482
1819 1483 $rememberme = false;
1820 1484 $remember = ( isset( $_REQUEST['rememberme'] ) ) ? filter_var( $_REQUEST['rememberme'], FILTER_VALIDATE_BOOLEAN ) : '';
1821 -
1822 1485 if ( ! empty( $remember ) ) {
1823 1486 $rememberme = true;
1824 1487 }
1825 1488
@@ -1826,20 +1489,15 @@
1826 1489 wp_set_auth_cookie( $user->ID, $rememberme );
1827 1490
1828 1491 do_action( 'two_factor_user_authenticated', $user );
1829 1492
1830 - if ( defined( 'WP_2FA_PREFIX' ) ) {
1831 - do_action( WP_2FA_PREFIX . 'user_authenticated', $user );
1832 - }
1833 -
1834 - $message = aui()->alert(
1835 - array(
1493 + $message = aui()->alert( array(
1836 1494 'type' => 'success',
1837 - 'content' => __( 'Validation successful. Redirecting...', 'userswp' ),
1495 + 'content' => __( 'Validation successful. Redirecting...', 'userswp' )
1838 1496 )
1839 1497 );
1840 1498
1841 - wp_send_json_success( array( 'message' => $message ) );
1499 + wp_send_json_success( array( 'message' => $message) );
1842 1500 }
1843 1501
1844 1502 public function get_login_redirect_url( $data, $user ) {
1845 1503 if ( is_int( $user ) ) {
@@ -1848,15 +1506,17 @@
1848 1506
1849 1507 $redirect_page_id = uwp_get_option( 'login_redirect_to', - 1 );
1850 1508 $custom_url = uwp_get_option( 'login_redirect_custom_url' );
1851 1509
1852 - if ( $user && isset( $user->roles[0] ) ) {
1510 + if($user && isset($user->roles[0])){
1853 1511 $user_role = $user->roles[0];
1854 - $redirect_page_id = uwp_get_option( 'login_redirect_to_' . $user_role, $redirect_page_id );
1855 - $custom_url = uwp_get_option( 'login_redirect_custom_url_' . $user_role );
1512 + $redirect_page_id = uwp_get_option( 'login_redirect_to_'.$user_role, $redirect_page_id );
1513 + $custom_url = uwp_get_option( 'login_redirect_custom_url_'.$user_role );
1856 1514 }
1857 1515
1858 - if ( isset( $_REQUEST['redirect_to'] ) && ! empty( $_REQUEST['redirect_to'] ) ) {
1516 + if ( $user && $user->has_cap( 'manage_options' ) ) {
1517 + $redirect_to = admin_url();
1518 + } elseif ( isset( $_REQUEST['redirect_to'] ) && ! empty( $_REQUEST['redirect_to'] ) ) {
1859 1519 $redirect_to = esc_url_raw( $_REQUEST['redirect_to'] );
1860 1520 } elseif ( isset( $data['redirect_to'] ) && ! empty( $data['redirect_to'] ) ) {
1861 1521 $redirect_to = esc_url_raw( $data['redirect_to'] );
1862 1522 } elseif ( isset( $redirect_page_id ) && (int) $redirect_page_id > 0 ) {
@@ -1868,9 +1528,9 @@
1868 1528 }
1869 1529 $redirect_to = get_permalink( $redirect_page_id );
1870 1530 } elseif ( isset( $redirect_page_id ) && (int) $redirect_page_id == - 1 && wp_get_referer() ) {
1871 1531 $redirect_to = esc_url( wp_get_referer() );
1872 - } elseif ( isset( $redirect_page_id ) && (int) $redirect_page_id == - 2 && ! empty( $custom_url ) ) {
1532 + } elseif ( isset( $redirect_page_id ) && (int) $redirect_page_id == - 2 && !empty($custom_url) ) {
1873 1533 $redirect_to = $custom_url;
1874 1534 } else {
1875 1535 $redirect_to = home_url( '/' );
1876 1536 $redirect_to = apply_filters( 'login_redirect', $redirect_to, '', $user );
@@ -1876,8 +1536,9 @@
1876 1536 $redirect_to = apply_filters( 'login_redirect', $redirect_to, '', $user );
1877 1537 }
1878 1538
1879 1539 return apply_filters( 'uwp_login_redirect', $redirect_to, $redirect_page_id, $data, $user );
1540 +
1880 1541 }
1881 1542
1882 1543 /**
1883 1544 * Processes forgot password form submission.
@@ -1894,13 +1555,12 @@
1894 1555 return;
1895 1556 }
1896 1557
1897 1558 if ( ! isset( $data['uwp_forgot_nonce'] ) || ! wp_verify_nonce( $data['uwp_forgot_nonce'], 'uwp-forgot-nonce' ) ) {
1898 - $message = aui()->alert(
1899 - array(
1559 + $message = aui()->alert( array(
1900 1560 'type' => 'error',
1901 - 'content' => __( 'Security verification failed. Try again.', 'userswp' ),
1902 - )
1561 + 'content' => __( 'Security verification failed. Try again.', 'userswp' )
1562 + )
1903 1563 );
1904 1564 if ( wp_doing_ajax() ) {
1905 1565 wp_send_json_error( $message );
1906 1566 } else {
@@ -1916,13 +1576,12 @@
1916 1576
1917 1577 $result = apply_filters( 'uwp_validate_result', $result, 'forgot', $data );
1918 1578
1919 1579 if ( is_wp_error( $result ) ) {
1920 - $message = aui()->alert(
1921 - array(
1580 + $message = aui()->alert( array(
1922 1581 'type' => 'error',
1923 - 'content' => $result->get_error_message(),
1924 - )
1582 + 'content' => $result->get_error_message()
1583 + )
1925 1584 );
1926 1585 if ( wp_doing_ajax() ) {
1927 1586 wp_send_json_error( $message );
1928 1587 } else {
@@ -1933,22 +1592,17 @@
1933 1592 }
1934 1593
1935 1594 do_action( 'uwp_after_validate', $result, 'forgot', $data );
1936 1595
1937 - $login_or_email = trim( $data['email'] );
1938 - $user_data = is_email( $login_or_email )
1939 - ? get_user_by( 'email', $login_or_email )
1940 - : get_user_by( 'login', $login_or_email );
1941 1596
1597 + $user_data = get_user_by( 'email', $data['email'] );
1598 +
1942 1599 // if no user we fake it and bail
1943 1600 if ( ! $user_data ) {
1944 - $args = apply_filters(
1945 - 'uwp_forgot_error_message',
1946 - array(
1947 - 'type' => 'error',
1948 - 'content' => __( 'Invalid username/email or user doesn\'t exist.', 'userswp' ),
1949 - )
1950 - );
1601 + $args = apply_filters('uwp_forgot_error_message', array(
1602 + 'type' => 'error',
1603 + 'content' => __( 'Invalid email or user doesn\'t exists.', 'userswp' )
1604 + ));
1951 1605
1952 1606 $message = aui()->alert( $args );
1953 1607 if ( wp_doing_ajax() ) {
1954 1608 wp_send_json_success( $message );
@@ -1961,27 +1615,18 @@
1961 1615
1962 1616 // make sure user account is active before account reset
1963 1617 $mod_value = get_user_meta( $user_data->ID, 'uwp_mod', true );
1964 1618 if ( $mod_value == 'email_unconfirmed' ) {
1965 - $resend_link = uwp_get_forgot_page_url();
1966 - $resend_link = add_query_arg(
1967 - array(
1968 - 'user_id' => $user_data->ID,
1969 - 'action' => 'uwp_resend',
1970 - '_nonce' => wp_create_nonce('uwp_resend'),
1971 - ),
1972 - $resend_link
1973 - );
1974 - $message = aui()->alert(
1975 - array(
1619 + $message = aui()->alert( array(
1976 1620 'type' => 'error',
1977 - 'content' => sprintf(__('Your account is not activated yet. Please activate your account first. <a href="%s">Resend</a>.', 'userswp'), $resend_link),
1978 - )
1621 + 'content' => __( 'Your account is not activated yet. Please activate your account first.', 'userswp' )
1622 + )
1979 1623 );
1980 1624 if ( wp_doing_ajax() ) {
1981 1625 wp_send_json_error( $message );
1982 1626 } else {
1983 1627 $uwp_notices[] = array( 'forgot' => $message );
1628 +
1984 1629 return;
1985 1630 }
1986 1631 }
1987 1632
@@ -1990,14 +1635,15 @@
1990 1635 $allow = apply_filters( 'allow_password_reset', true, $user_data->ID );
1991 1636
1992 1637 if ( ! $allow ) {
1993 1638 return false;
1994 - } elseif ( is_wp_error( $allow ) ) {
1639 + } else if ( is_wp_error( $allow ) ) {
1995 1640 return false;
1996 1641 }
1997 1642
1998 1643 $as_password = apply_filters( 'uwp_forgot_message_as_password', false );
1999 1644
1645 + global $wpdb, $wp_hasher;
2000 1646 $reset_link = '';
2001 1647
2002 1648 if ( $as_password ) {
2003 1649 $new_pass = wp_generate_password( 12, false );
@@ -2005,43 +1651,36 @@
2005 1651 if ( ! uwp_get_option( 'change_disable_password_nag' ) ) {
2006 1652 update_user_meta( $user_data->ID, 'default_password_nag', true ); //Set up the Password change nag.
2007 1653 }
2008 1654 $message = '<p><b>' . __( 'Your login Information :', 'userswp' ) . '</b></p>';
2009 - $message .= '<p>' . sprintf( __( 'Username: %s', 'userswp' ), $user_data->user_login ) . '</p>';
2010 - $message .= '<p>' . sprintf( __( 'Password: %s', 'userswp' ), $new_pass ) . '</p>';
1655 + $message .= '<p>' . sprintf( __( 'Username: %s', 'userswp' ), $user_data->user_login ) . "</p>";
1656 + $message .= '<p>' . sprintf( __( 'Password: %s', 'userswp' ), $new_pass ) . "</p>";
2011 1657
2012 1658 } else {
2013 - // Use WordPress core to generate, hash (wp_fast_hash in WP 6.8+), and store the reset key.
2014 - // This ensures compatibility with check_password_reset_key() on all WP versions.
2015 - $key = get_password_reset_key( $user_data );
1659 + $key = wp_generate_password( 20, false );
1660 + do_action( 'retrieve_password_key', $user_data->user_login, $key );
2016 1661
2017 - if ( is_wp_error( $key ) ) {
2018 - if ( wp_doing_ajax() ) {
2019 - wp_send_json_error( $key->get_error_message() );
2020 - } else {
2021 - $uwp_notices[] = array( 'forgot' => aui()->alert( array( 'type' => 'error', 'content' => $key->get_error_message() ) ) );
2022 - return;
2023 - }
1662 + if ( empty( $wp_hasher ) ) {
1663 + require_once ABSPATH . 'wp-includes/class-phpass.php';
1664 + $wp_hasher = new PasswordHash( 8, true );
2024 1665 }
2025 -
2026 - $message = '<p>' . __( 'You have requested to reset your password for the following account:', 'userswp' ) . '</p>';
2027 - $message .= home_url( '/' ) . '</p>';
2028 - $message .= '<p>' . sprintf( __( 'Username: %s', 'userswp' ), $user_data->user_login ) . '</p>';
2029 - $message .= '<p>' . __( 'If this was by mistake, just ignore this email and nothing will happen.', 'userswp' ) . '</p>';
2030 - $message .= '<p>' . __( 'To reset your password, click the following link and follow the instructions.', 'userswp' ) . '</p>';
1666 + $hashed = $wp_hasher->HashPassword( $key );
1667 + $wpdb->update( $wpdb->users, array( 'user_activation_key' => time() . ":" . $hashed ), array( 'user_login' => $user_data->user_login ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
1668 + $message = '<p>' . __( 'You have requested to reset your password for the following account:', 'userswp' ) . "</p>";
1669 + $message .= home_url( '/' ) . "</p>";
1670 + $message .= '<p>' . sprintf( __( 'Username: %s', 'userswp' ), $user_data->user_login ) . "</p>";
1671 + $message .= '<p>' . __( 'If this was by mistake, just ignore this email and nothing will happen.', 'userswp' ) . "</p>";
1672 + $message .= '<p>' . __( 'To reset your password, click the following link and follow the instructions.', 'userswp' ) . "</p>";
2031 1673 $reset_page = uwp_get_page_id( 'reset_page', false );
2032 1674 if ( $reset_page ) {
2033 - $reset_link = add_query_arg(
2034 - array(
2035 - 'key' => $key,
2036 - 'login' => rawurlencode( $user_data->user_login ),
2037 - ),
2038 - get_permalink( $reset_page )
2039 - );
2040 - $message .= "<a href='" . $reset_link . "' target='_blank'>" . $reset_link . '</a>' . "\r\n";
1675 + $reset_link = add_query_arg( array(
1676 + 'key' => $key,
1677 + 'login' => rawurlencode( $user_data->user_login ),
1678 + ), get_permalink( $reset_page ) );
1679 + $message .= "<a href='" . $reset_link . "' target='_blank'>" . $reset_link . "</a>" . "\r\n";
2041 1680 } else {
2042 1681 $reset_link = home_url( "reset?key=$key&login=" . rawurlencode( $user_data->user_login ), 'login' );
2043 - $message .= "<a href='" . $reset_link . "' target='_blank'>" . $reset_link . '</a>' . "\r\n";
1682 + $message .= "<a href='" . $reset_link . "' target='_blank'>" . $reset_link . "</a>" . "\r\n";
2044 1683 }
2045 1684 $message = apply_filters( 'uwp_forgot_password_message', $message, $user_data, $reset_link );
2046 1685 }
2047 1686
@@ -2056,13 +1695,12 @@
2056 1695 UsersWP_Mails::send( $user_data->user_email, 'forgot_password', $email_vars );
2057 1696
2058 1697 do_action( 'uwp_after_process_forgot', $data );
2059 1698
2060 - $message = aui()->alert(
2061 - array(
1699 + $message = aui()->alert( array(
2062 1700 'type' => 'success',
2063 - 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Please check your email.', 'userswp' ), $data ),
2064 - )
1701 + 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Please check your email.', 'userswp' ), $data )
1702 + )
2065 1703 );
2066 1704 if ( wp_doing_ajax() ) {
2067 1705 wp_send_json_success( $message );
2068 1706 } else {
@@ -2099,13 +1737,12 @@
2099 1737
2100 1738 $result = apply_filters( 'uwp_validate_result', $result, 'change', $data );
2101 1739
2102 1740 if ( is_wp_error( $result ) ) {
2103 - $message = aui()->alert(
2104 - array(
1741 + $message = aui()->alert( array(
2105 1742 'type' => 'error',
2106 - 'content' => $result->get_error_message(),
2107 - )
1743 + 'content' => $result->get_error_message()
1744 + )
2108 1745 );
2109 1746 $uwp_notices[] = array( $notice_type => $message );
2110 1747
2111 1748 return;
@@ -2115,13 +1752,12 @@
2115 1752
2116 1753 $user_data = get_user_by( 'id', get_current_user_id() );
2117 1754
2118 1755 if ( ! $user_data ) {
2119 - $message = aui()->alert(
2120 - array(
1756 + $message = aui()->alert( array(
2121 1757 'type' => 'error',
2122 - 'content' => $user_data->get_error_message(),
2123 - )
1758 + 'content' => $user_data->get_error_message()
1759 + )
2124 1760 );
2125 1761 $uwp_notices[] = array( $notice_type => $message );
2126 1762
2127 1763 return;
@@ -2139,15 +1775,14 @@
2139 1775 if ( $password_nag ) {
2140 1776 delete_user_meta( $user_data->ID, 'default_password_nag' );
2141 1777 }
2142 1778
2143 - delete_user_meta( $user_data->ID, 'is_uwp_social_login_no_password' );
1779 + delete_user_meta($user_data->ID, 'is_uwp_social_login_no_password');
2144 1780
2145 - $message = aui()->alert(
2146 - array(
2147 - 'type' => 'success',
2148 - 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Password changed successfully.', 'userswp' ), $data ),
2149 - )
1781 + $message = aui()->alert( array(
1782 + 'type' => 'success',
1783 + 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Password changed successfully.', 'userswp' ), $data )
1784 + )
2150 1785 );
2151 1786
2152 1787 $uwp_notices[] = array( $notice_type => $message );
2153 1788
@@ -2184,13 +1819,12 @@
2184 1819
2185 1820 $result = apply_filters( 'uwp_validate_result', $result, 'reset', $data );
2186 1821
2187 1822 if ( is_wp_error( $result ) ) {
2188 - $message = aui()->alert(
2189 - array(
1823 + $message = aui()->alert( array(
2190 1824 'type' => 'error',
2191 - 'content' => $result->get_error_message(),
2192 - )
1825 + 'content' => $result->get_error_message()
1826 + )
2193 1827 );
2194 1828 $uwp_notices[] = array( 'reset' => $message );
2195 1829
2196 1830 return;
@@ -2202,13 +1836,12 @@
2202 1836 $key = sanitize_text_field( $data['uwp_reset_key'] );
2203 1837
2204 1838 $user = get_user_by( 'login', $login );
2205 1839 if ( ! $user ) {
2206 - $message = aui()->alert(
2207 - array(
1840 + $message = aui()->alert( array(
2208 1841 'type' => 'error',
2209 - 'content' => __( 'Invalid username.', 'userswp' ),
2210 - )
1842 + 'content' => __( 'Invalid username.', 'userswp' )
1843 + )
2211 1844 );
2212 1845 $uwp_notices[] = array( 'reset' => $message );
2213 1846
2214 1847 return;
@@ -2218,14 +1851,13 @@
2218 1851
2219 1852 $user_data = check_password_reset_key( $key, $login );
2220 1853
2221 1854 if ( is_wp_error( $user_data ) ) {
2222 - $error = apply_filters( 'uwp_reset_password_error_message', $user_data->get_error_message(), $user_data );
2223 - $message = aui()->alert(
2224 - array(
1855 + $error = apply_filters('uwp_reset_password_error_message', $user_data->get_error_message(), $user_data);
1856 + $message = aui()->alert( array(
2225 1857 'type' => 'error',
2226 - 'content' => $error,
2227 - )
1858 + 'content' => $error
1859 + )
2228 1860 );
2229 1861 $uwp_notices[] = array( 'reset' => $message );
2230 1862
2231 1863 return;
@@ -2241,13 +1873,12 @@
2241 1873
2242 1874 $login_page_url = uwp_get_login_page_url();
2243 1875 $message = sprintf( __( 'Password updated successfully. Please <a href="%s">login</a> with your new password.', 'userswp' ), $login_page_url );
2244 1876 $message = apply_filters( 'uwp_reset_password_success_message', $message, $data );
2245 - $message = aui()->alert(
2246 - array(
1877 + $message = aui()->alert( array(
2247 1878 'type' => 'success',
2248 - 'content' => $message,
2249 - )
1879 + 'content' => $message
1880 + )
2250 1881 );
2251 1882 $uwp_notices[] = array( 'reset' => $message );
2252 1883
2253 1884 do_action( 'uwp_after_process_reset', $data );
@@ -2282,13 +1913,12 @@
2282 1913
2283 1914 $result = apply_filters( 'uwp_validate_result', $result, 'account', $data );
2284 1915
2285 1916 if ( is_wp_error( $result ) ) {
2286 - $message = aui()->alert(
2287 - array(
1917 + $message = aui()->alert( array(
2288 1918 'type' => 'error',
2289 - 'content' => $result->get_error_message(),
2290 - )
1919 + 'content' => $result->get_error_message()
1920 + )
2291 1921 );
2292 1922 $uwp_notices[] = array( 'account' => $message );
2293 1923
2294 1924 return;
@@ -2296,13 +1926,12 @@
2296 1926
2297 1927 $uploads_result = $file_obj->validate_uploads( $files, 'account' );
2298 1928
2299 1929 if ( is_wp_error( $uploads_result ) ) {
2300 - $message = aui()->alert(
2301 - array(
1930 + $message = aui()->alert( array(
2302 1931 'type' => 'error',
2303 - 'content' => $uploads_result->get_error_message(),
2304 - )
1932 + 'content' => $uploads_result->get_error_message()
1933 + )
2305 1934 );
2306 1935 $uwp_notices[] = array( 'account' => $message );
2307 1936
2308 1937 return;
@@ -2316,25 +1945,13 @@
2316 1945 unset( $uploads_result[ $upload_file_key ] );
2317 1946 }
2318 1947 }
2319 1948
2320 - global $wpdb;
2321 - $file_field_names = $wpdb->get_col(
2322 - $wpdb->prepare(
2323 - "SELECT htmlvar_name FROM " . uwp_get_table_prefix() . "uwp_form_fields WHERE form_type = %s AND field_type IN ('file','image')",
2324 - 'account'
2325 - )
2326 - );
2327 - foreach ( $file_field_names as $file_field_name ) {
2328 - if ( isset( $result[ $file_field_name ] ) && ! isset( $uploads_result[ $file_field_name ] ) ) {
2329 - unset( $result[ $file_field_name ] );
2330 - }
2331 - }
1949 + $result = array_merge( $result, $uploads_result );
2332 1950
2333 - $result = array_merge( $result, $uploads_result );
2334 1951
2335 1952 $args = array(
2336 - 'ID' => get_current_user_id(),
1953 + 'ID' => get_current_user_id()
2337 1954 );
2338 1955
2339 1956 if ( isset( $result['first_name'] ) && isset( $result['last_name'] ) ) {
2340 1957 $args['display_name'] = $result['first_name'] . ' ' . $result['last_name'];
@@ -2362,13 +1979,12 @@
2362 1979
2363 1980 $user_id = wp_update_user( $args );
2364 1981
2365 1982 if ( is_wp_error( $user_id ) ) {
2366 - $message = aui()->alert(
2367 - array(
1983 + $message = aui()->alert( array(
2368 1984 'type' => 'error',
2369 - 'content' => sprintf( __( '%s', 'userswp' ), $user_id->get_error_message() ),
2370 - )
1985 + 'content' => sprintf( __( '%s', 'userswp' ), $user_id->get_error_message() )
1986 + )
2371 1987 );
2372 1988 $uwp_notices[] = array( 'account' => $message );
2373 1989
2374 1990 return;
@@ -2376,13 +1992,12 @@
2376 1992
2377 1993 $res = $this->save_user_extra_fields( $user_id, $result, 'account' );
2378 1994
2379 1995 if ( ! $res ) {
2380 - $message = aui()->alert(
2381 - array(
1996 + $message = aui()->alert( array(
2382 1997 'type' => 'error',
2383 - 'content' => __( 'Something went wrong. Please contact site admin.', 'userswp' ),
2384 - )
1998 + 'content' => __( 'Something went wrong. Please contact site admin.', 'userswp' )
1999 + )
2385 2000 );
2386 2001 $uwp_notices[] = array( 'account' => $message );
2387 2002
2388 2003 return;
@@ -2398,22 +2013,21 @@
2398 2013 }
2399 2014
2400 2015 $user_data = get_userdata( $user_id );
2401 2016
2402 - $form_fields = apply_filters( 'uwp_send_mail_form_fields', '', 'account', $user_id );
2017 + $form_fields = apply_filters( 'uwp_send_mail_form_fields', "", 'account', $user_id );
2403 2018
2404 - if ( isset( $result['email'] ) && $user_data->user_email !== trim( $result['email'] ) ) {
2019 + if ( isset( $result['email'] ) && $user_data->user_email !== trim($result['email']) ) {
2405 2020
2406 - if ( email_exists( trim( $result['email'] ) ) ) {
2407 - $message = aui()->alert(
2408 - array(
2409 - 'type' => 'error',
2410 - 'content' => __( 'This email is already registered, please choose another one.', 'userswp' ),
2411 - )
2412 - );
2021 + if(email_exists(trim($result['email']))){
2022 + $message = aui()->alert( array(
2023 + 'type' => 'error',
2024 + 'content' => __( 'This email is already registered, please choose another one.', 'userswp' )
2025 + )
2026 + );
2413 2027
2414 - $uwp_notices[] = array( 'account' => $message );
2415 - return;
2028 + $uwp_notices[] = array( 'account' => $message );
2029 + return;
2416 2030
2417 2031 }
2418 2032
2419 2033 $hash = md5( $result['email'] . time() . wp_rand() );
@@ -2421,22 +2035,22 @@
2421 2035 'hash' => $hash,
2422 2036 'newemail' => $result['email'],
2423 2037 );
2424 2038
2425 - update_user_meta( get_current_user_id(), 'uwp_update_email_hash', $new_admin_email );
2039 + update_user_meta(get_current_user_id(), 'uwp_update_email_hash', $new_admin_email);
2426 2040
2427 2041 $new_email_link = add_query_arg(
2428 2042 array(
2429 2043 'uwp_new_email' => 'yes',
2430 - 'key' => $hash,
2431 - 'login' => $user_data->user_login,
2044 + 'key' => $hash,
2045 + 'login' => $user_data->user_login
2432 2046 ),
2433 2047 uwp_get_account_page_url()
2434 2048 );
2435 2049
2436 2050 $email_vars = array(
2437 - 'user_id' => $user_id,
2438 - 'new_email' => $result['email'],
2051 + 'user_id' => $user_id,
2052 + 'new_email' => $result['email'],
2439 2053 'new_email_link' => esc_url( $new_email_link ),
2440 2054 );
2441 2055
2442 2056 UsersWP_Mails::send( $result['email'], 'account_new_email_activation', $email_vars );
@@ -2441,13 +2055,12 @@
2441 2055
2442 2056 UsersWP_Mails::send( $result['email'], 'account_new_email_activation', $email_vars );
2443 2057
2444 2058 $message = apply_filters( 'uwp_account_pending_new_email_activation_message', __( 'Account updated successfully. The new address will become active once you confirm via activation link sent to your new email.', 'userswp' ), $data );
2445 - $message = aui()->alert(
2446 - array(
2059 + $message = aui()->alert( array(
2447 2060 'type' => 'success',
2448 - 'content' => $message,
2449 - )
2061 + 'content' => $message
2062 + )
2450 2063 );
2451 2064
2452 2065 $uwp_notices[] = array( 'account' => $message );
2453 2066
@@ -2459,13 +2072,12 @@
2459 2072
2460 2073 UsersWP_Mails::send( $user_data->user_email, 'account_update', $email_vars );
2461 2074
2462 2075 $message = apply_filters( 'uwp_account_update_success_message', __( 'Account updated successfully.', 'userswp' ), $data );
2463 - $message = aui()->alert(
2464 - array(
2076 + $message = aui()->alert( array(
2465 2077 'type' => 'success',
2466 - 'content' => $message,
2467 - )
2078 + 'content' => $message
2079 + )
2468 2080 );
2469 2081
2470 2082 $uwp_notices[] = array( 'account' => $message );
2471 2083 }
@@ -2470,8 +2082,9 @@
2470 2082 $uwp_notices[] = array( 'account' => $message );
2471 2083 }
2472 2084
2473 2085 do_action( 'uwp_after_process_account', $data, $user_id );
2086 +
2474 2087 }
2475 2088
2476 2089 /**
2477 2090 * Modifies the forms field in email based on the form type.
@@ -2486,11 +2099,11 @@
2486 2099 *
2487 2100 */
2488 2101 public function init_mail_form_fields( $form_fields, $type, $user_id ) {
2489 2102 switch ( $type ) {
2490 - case 'register':
2103 + case "register":
2491 2104 $form_id = get_user_meta( $user_id, '_uwp_register_form_id', true );
2492 - $fields = get_register_form_fields( $form_id );
2105 + $fields = get_register_form_fields($form_id);
2493 2106 $user_data = get_userdata( $user_id );
2494 2107 if ( ! empty( $fields ) && is_array( $fields ) ) {
2495 2108 $form_fields = '<p><b>' . __( 'User Information:', 'userswp' ) . '</b></p>';
2496 2109 $excluded = uwp_get_excluded_fields();
@@ -2512,14 +2125,14 @@
2512 2125 $field_value = uwp_maybe_serialize( $field->htmlvar_name, $field_value );
2513 2126 }
2514 2127
2515 2128 if ( isset( $field->site_title ) && ! empty( $field_value ) ) {
2516 - $form_fields .= '<p><b>' . __( wp_unslash( $field->site_title ), 'userswp' ) . '</b>:&nbsp;' . $field_value . '</p>';
2129 + $form_fields .= '<p><b>' . __( $field->site_title, 'userswp' ) . '</b>:&nbsp;' . $field_value . '</p>';
2517 2130 }
2518 2131 }
2519 2132 }
2520 2133 break;
2521 - case 'account':
2134 + case "account":
2522 2135 $fields = get_account_form_fields();
2523 2136 $user_data = get_userdata( $user_id );
2524 2137 if ( ! empty( $fields ) && is_array( $fields ) ) {
2525 2138 $form_fields = '<p><b>' . __( 'User Information:', 'userswp' ) . '</b></p>';
@@ -2541,9 +2154,9 @@
2541 2154 $field_value = uwp_maybe_serialize( $field->htmlvar_name, $field_value );
2542 2155 }
2543 2156
2544 2157 if ( isset( $field->site_title ) && ! empty( $field_value ) ) {
2545 - $form_fields .= '<p><b>' . __( wp_unslash( $field->site_title ), 'userswp' ) . '</b>:&nbsp;' . $field_value . '</p>';
2158 + $form_fields .= '<p><b>' . __( $field->site_title, 'userswp' ) . '</b>:&nbsp;' . $field_value . '</p>';
2546 2159 }
2547 2160 }
2548 2161 }
2549 2162 break;
@@ -2560,94 +2173,46 @@
2560 2173 * @package userswp
2561 2174 * @since 1.0.0
2562 2175 */
2563 2176 public function upload_file_remove() {
2564 - global $wpdb;
2565 -
2566 2177 check_ajax_referer( 'uwp_basic_nonce', 'security' );
2567 2178
2568 - // Check user logged in.
2569 - if ( ! is_user_logged_in() ) {
2570 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Access denied!', 'userswp' ) ) );
2571 - wp_send_json_error( array( 'message' => $message ) );
2572 - }
2573 -
2179 + $htmlvar = esc_sql( strip_tags( $_POST['htmlvar'] ) );
2574 2180 $user_id = ! empty( $_POST['uid'] ) ? absint( $_POST['uid'] ) : 0;
2575 - $htmlvar = ! empty( $_POST['htmlvar'] ) ? sanitize_key( $_POST['htmlvar'] ) : '';
2576 2181
2577 - if ( empty( $user_id ) || empty( $htmlvar ) ) {
2578 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid data!', 'userswp' ) ) );
2579 - wp_send_json_error( array( 'message' => $message ) );
2182 + if ( empty( $user_id ) ) {
2183 + wp_die( -1 );
2580 2184 }
2581 2185
2582 - // Validate the user / admin.
2583 - if ( ! ( $user_id == (int) get_current_user_id() || current_user_can( 'manage_options' ) ) ) {
2584 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid access!', 'userswp' ) ) );
2585 - wp_send_json_error( array( 'message' => $message ) );
2186 + if ( ! ( is_user_logged_in() && ( $user_id == (int) get_current_user_id() || current_user_can( 'manage_options' ) ) ) ) {
2187 + wp_send_json_error( __( 'Invalid access!', 'userswp' ) );
2586 2188 }
2587 2189
2588 - if ( $htmlvar == 'banner_thumb' ) {
2589 - $field_key = 'banner';
2190 + // Remove file
2191 + if ( $htmlvar == "banner_thumb" ) {
2192 + $file = uwp_get_usermeta( $user_id, 'banner_thumb' );
2590 2193 $type = 'banner';
2591 - } else if ( $htmlvar == 'avatar_thumb' ) {
2592 - $field_key = 'avatar';
2194 + } else if ( $htmlvar == "avatar_thumb" ) {
2195 + $file = uwp_get_usermeta( $user_id, 'avatar_thumb' );
2593 2196 $type = 'avatar';
2594 2197 } else {
2595 - $field_key = $htmlvar;
2198 + $file = '';
2596 2199 $type = '';
2597 2200 }
2598 2201
2599 - $field = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . uwp_get_table_prefix() . "uwp_form_fields WHERE htmlvar_name = %s LIMIT 1", $field_key ) );
2600 -
2601 - // Check field exists.
2602 - if ( empty( $field ) ) {
2603 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid field!', 'userswp' ) ) );
2604 - wp_send_json_error( array( 'message' => $message ) );
2605 - }
2606 -
2607 - // Validate field access.
2608 - if ( ! empty( $field->for_admin_use ) && ! current_user_can( 'manage_options' ) ) {
2609 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'You are not allowed to perform this action!', 'userswp' ) ) );
2610 - wp_send_json_error( array( 'message' => $message ) );
2611 - }
2612 -
2613 - if ( ! in_array( $field->field_type, array( 'file', 'image' ) ) ) {
2614 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid field type!', 'userswp' ) ) );
2615 - wp_send_json_error( array( 'message' => $message ) );
2616 - }
2617 -
2618 - $value = uwp_get_usermeta( $user_id, $htmlvar );
2619 -
2620 2202 uwp_update_usermeta( $user_id, $htmlvar, '' );
2621 2203
2622 - if ( $value && validate_file( $value ) === 0 ) {
2204 + if ( $file ) {
2623 2205 $uploads = wp_upload_dir();
2624 2206 $upload_path = $uploads['basedir'];
2207 + $unlink_file = untrailingslashit( $upload_path ) . '/' . ltrim( $file, '/' );
2625 2208
2626 - if ( strpos( $value, 'http://' ) === 0 || strpos( $value, 'https://' ) === 0 ) {
2627 - // Get the relative url.
2628 - $value = uwp_get_file_relative_url( $value );
2629 - }
2209 + if ( is_file( $unlink_file ) && file_exists( $unlink_file ) ) {
2210 + @unlink( $unlink_file );
2211 + $unlink_ori_file = str_replace( '_uwp_' . $type . '_thumb' . '.', '.', $unlink_file );
2630 2212
2631 - $unlink_file = untrailingslashit( $upload_path ) . '/' . trim( $value, '/\\' );
2632 -
2633 - // Canonicalize and enforce containment inside the uploads directory before deleting.
2634 - $real_upload_path = realpath( $upload_path );
2635 - $real_unlink_file = realpath( $unlink_file );
2636 -
2637 - if ( $real_upload_path && $real_unlink_file && is_file( $real_unlink_file )
2638 - && strpos( $real_unlink_file, $real_upload_path . DIRECTORY_SEPARATOR ) === 0 ) {
2639 - wp_delete_file( $real_unlink_file );
2640 -
2641 - // For avatar/banner, also remove the original (non-thumb) file.
2642 - if ( $type ) {
2643 - $unlink_ori_file = str_replace( '_uwp_' . $type . '_thumb' . '.', '.', $real_unlink_file );
2644 - $real_unlink_ori_file = realpath( $unlink_ori_file );
2645 -
2646 - if ( $real_unlink_ori_file && is_file( $real_unlink_ori_file )
2647 - && strpos( $real_unlink_ori_file, $real_upload_path . DIRECTORY_SEPARATOR ) === 0 ) {
2648 - wp_delete_file( $real_unlink_ori_file );
2649 - }
2213 + if ( is_file( $unlink_ori_file ) && file_exists( $unlink_ori_file ) ) {
2214 + @unlink( $unlink_ori_file );
2650 2215 }
2651 2216 }
2652 2217 }
2653 2218
@@ -2678,15 +2243,15 @@
2678 2243
2679 2244 // If no html then we run the standard output.
2680 2245 if ( empty( $html ) ) {
2681 2246
2682 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2683 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
2684 - $bs_sr_only = $design_style ? 'sr-only' : '';
2685 - $bs_form_control = $design_style ? 'form-control' : '';
2247 + $design_style = uwp_get_option( "design_style", "bootstrap" );
2248 + $bs_form_group = $design_style ? "form-group mb-3" : "";
2249 + $bs_sr_only = $design_style ? "sr-only" : "";
2250 + $bs_form_control = $design_style ? "form-control" : "";
2686 2251 $extra_attributes = array();
2687 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
2688 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
2252 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
2253 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
2689 2254
2690 2255 ob_start(); // Start buffering;
2691 2256
2692 2257 $extra_fields = unserialize( $field->extra_fields );
@@ -2697,8 +2262,9 @@
2697 2262
2698 2263 $date_format = $extra_fields['date_format'];
2699 2264 $jquery_date_format = $date_format;
2700 2265
2266 +
2701 2267 // check if we need to change the format or not
2702 2268 $date_format_len = strlen( str_replace( ' ', '', $date_format ) );
2703 2269 if ( $date_format_len > 5 ) {// if greater then 5 then it's the old style format.
2704 2270
@@ -2734,24 +2300,24 @@
2734 2300 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
2735 2301
2736 2302 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2737 2303 array(
2738 - 'id' => esc_attr( $field->htmlvar_name ),
2739 - 'name' => esc_attr( $field->htmlvar_name ),
2740 - 'required' => ! empty( $field->is_required ) ? true : false,
2741 - 'label' => wp_kses_post( $site_title . $required ),
2742 - 'label_show' => true,
2743 - 'label_type' => 'hidden',
2744 - 'type' => 'datepicker',
2745 - 'title' => esc_html( $site_title ),
2746 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2747 - 'class' => '',
2748 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2749 - 'value' => esc_attr( $value ),
2750 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2751 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
2304 + 'id' => esc_attr( $field->htmlvar_name ),
2305 + 'name' => esc_attr( $field->htmlvar_name ),
2306 + 'required' => ! empty( $field->is_required ) ? true : false,
2307 + 'label' => wp_kses_post( $site_title . $required ),
2308 + 'label_show' => true,
2309 + 'label_type' => 'hidden',
2310 + 'type' => 'datepicker',
2311 + 'title' => esc_html( $site_title ),
2312 + 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2313 + 'class' => '',
2314 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2315 + 'value' => esc_attr( $value ),
2316 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2317 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
2752 2318 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
2753 - 'extra_attributes' => $extra_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2319 + 'extra_attributes' => $extra_attributes // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2754 2320 )
2755 2321 );
2756 2322 } else {
2757 2323 ?>
@@ -2757,23 +2323,21 @@
2757 2323 ?>
2758 2324 <script type="text/javascript">
2759 2325
2760 2326 jQuery(function () {
2761 - jQuery("#<?php echo esc_attr( $field->htmlvar_name ); ?>").datepicker({
2327 + jQuery("#<?php echo esc_attr( $field->htmlvar_name );?>").datepicker({
2762 2328 changeMonth: true, changeYear: true
2763 - <?php
2764 - if ( $field->htmlvar_name == 'dob' ) {
2329 + <?php if ( $field->htmlvar_name == 'dob' ) {
2765 2330 echo ", yearRange: '1900:+0'";
2766 2331 } else {
2767 - echo ", yearRange: '1900:2050'";
2768 - }
2769 - ?>
2332 + echo ", yearRange: '1900:2050'";
2333 + }?>
2770 2334 <?php echo apply_filters( "uwp_datepicker_extra_{$field->htmlvar_name}", '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>});
2771 2335
2772 2336 jQuery("#<?php echo esc_attr( $field->htmlvar_name ); ?>").datepicker("option", "dateFormat", '<?php echo esc_attr( $jquery_date_format ); ?>');
2773 2337
2774 - <?php if ( ! empty( $value ) ) { ?>
2775 - var parsedDate = jQuery.datepicker.parseDate('yy-mm-dd', '<?php echo esc_attr( $value ); ?>');
2338 + <?php if(! empty( $value )){?>
2339 + var parsedDate = jQuery.datepicker.parseDate('yy-mm-dd', '<?php echo esc_attr( $value );?>');
2776 2340 jQuery("#<?php echo esc_attr( $field->htmlvar_name ); ?>").datepicker("setDate", parsedDate);
2777 2341 <?php } ?>
2778 2342
2779 2343 });
@@ -2779,46 +2343,37 @@
2779 2343 });
2780 2344
2781 2345 </script>
2782 2346 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
2783 - class="
2784 - <?php
2785 - if ( $field->is_required ) {
2786 - echo 'required_field';
2787 - }
2788 - ?>
2789 - clearfix uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
2347 + class="<?php if ( $field->is_required ) {
2348 + echo 'required_field';
2349 + } ?> clearfix uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
2790 2350
2791 2351 <?php
2792 2352
2793 - if ( ! is_admin() ) {
2794 - ?>
2353 + if ( ! is_admin() ) { ?>
2795 2354 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
2796 2355 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
2797 - <?php
2798 - if ( $field->is_required ) {
2356 + <?php if ( $field->is_required ) {
2799 2357 echo '<span>*</span>';
2800 - }
2801 - ?>
2358 + } ?>
2802 2359 </label>
2803 2360 <?php } ?>
2804 2361
2805 2362 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2806 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2807 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
2808 - title="<?php echo esc_attr( $site_title ); ?>"
2809 - type="text"
2810 - <?php
2811 - if ( $field->is_required == 1 ) {
2363 + id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2364 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
2365 + title="<?php echo esc_attr( $site_title ); ?>"
2366 + type="text"
2367 + <?php if ( $field->is_required == 1 ) {
2812 2368 echo 'required="required"';
2813 - }
2814 - ?>
2815 - value="<?php echo esc_attr( $value ); ?>"
2816 - class="uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"/>
2369 + } ?>
2370 + value="<?php echo esc_attr( $value ); ?>"
2371 + class="uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"/>
2817 2372
2818 2373 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
2819 2374 <?php if ( $field->is_required ) { ?>
2820 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
2375 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
2821 2376 <?php } ?>
2822 2377 </div>
2823 2378
2824 2379 <?php
@@ -2852,14 +2407,14 @@
2852 2407
2853 2408 // If no html then we run the standard output.
2854 2409 if ( empty( $html ) ) {
2855 2410
2856 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2857 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
2858 - $bs_sr_only = $design_style ? 'sr-only' : '';
2859 - $bs_form_control = $design_style ? 'form-control bg-white' : '';
2860 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
2861 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
2411 + $design_style = uwp_get_option( "design_style", "bootstrap" );
2412 + $bs_form_group = $design_style ? "form-group mb-3" : "";
2413 + $bs_sr_only = $design_style ? "sr-only" : "";
2414 + $bs_form_control = $design_style ? "form-control bg-white" : "";
2415 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
2416 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
2862 2417
2863 2418 ob_start(); // Start buffering;
2864 2419
2865 2420 if ( $value != '' ) {
@@ -2877,25 +2432,25 @@
2877 2432 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
2878 2433
2879 2434 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2880 2435 array(
2881 - 'id' => esc_attr( $field->htmlvar_name ),
2882 - 'name' => esc_attr( $field->htmlvar_name ),
2883 - 'required' => ! empty( $field->is_required ) ? true : false,
2884 - 'label' => wp_kses_post( $site_title . $required ),
2885 - 'label_show' => true,
2886 - 'label_type' => esc_attr( $label_type ),
2887 - 'type' => 'timepicker',
2888 - 'title' => esc_html( $site_title ),
2889 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2890 - 'class' => '',
2891 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2892 - 'value' => esc_attr( $value ),
2893 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2894 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
2436 + 'id' => esc_attr( $field->htmlvar_name ),
2437 + 'name' => esc_attr( $field->htmlvar_name ),
2438 + 'required' => ! empty( $field->is_required ) ? true : false,
2439 + 'label' => wp_kses_post( $site_title . $required ),
2440 + 'label_show' => true,
2441 + 'label_type' => esc_attr( $label_type ),
2442 + 'type' => 'timepicker',
2443 + 'title' => esc_html( $site_title ),
2444 + 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2445 + 'class' => '',
2446 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2447 + 'value' => esc_attr( $value ),
2448 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2449 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
2895 2450 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
2896 - 'extra_attributes' => $extra_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2897 - 'input_group_right' => '<div class="input-group-text px-2 bg-transparent border-0x" onclick="jQuery(this).parent().parent().find(\'input\').val(\'\');"><i class="fas fa-times uwp-search-input-label-clear text-muted c-pointer" title="' . esc_attr__( 'Clear field', 'userswp' ) . '" ></i></div>',
2451 + 'extra_attributes' => $extra_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2452 + 'input_group_right' => '<div class="input-group-text px-2 bg-transparent border-0x" onclick="jQuery(this).parent().parent().find(\'input\').val(\'\');"><i class="fas fa-times uwp-search-input-label-clear text-muted c-pointer" title="' . esc_attr__( 'Clear field', 'uwp-search' ) . '" ></i></div>',
2898 2453 )
2899 2454 );
2900 2455 } else {
2901 2456 ?>
@@ -2907,40 +2462,33 @@
2907 2462 });
2908 2463 });
2909 2464 </script>
2910 2465 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
2911 - class="
2912 - <?php
2913 - if ( $field->is_required ) {
2914 - echo 'required_field';
2915 - }
2916 - ?>
2917 - clearfix uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
2466 + class="<?php if ( $field->is_required ) {
2467 + echo 'required_field';
2468 + } ?> clearfix uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
2918 2469
2919 2470 <?php
2920 2471 $site_title = uwp_get_form_label( $field );
2921 - if ( ! is_admin() ) {
2922 - ?>
2472 + if ( ! is_admin() ) { ?>
2923 2473 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
2924 2474 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
2925 - <?php
2926 - if ( $field->is_required ) {
2475 + <?php if ( $field->is_required ) {
2927 2476 echo '<span>*</span>';
2928 - }
2929 - ?>
2477 + } ?>
2930 2478 </label>
2931 2479 <?php } ?>
2932 2480
2933 2481 <input readonly="readonly" name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2934 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2935 - value="<?php echo esc_attr( $value ); ?>"
2936 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
2937 - type="text"
2938 - class="uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"/>
2482 + id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2483 + value="<?php echo esc_attr( $value ); ?>"
2484 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
2485 + type="text"
2486 + class="uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"/>
2939 2487
2940 2488 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
2941 2489 <?php if ( $field->is_required ) { ?>
2942 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
2490 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
2943 2491 <?php } ?>
2944 2492 </div>
2945 2493 <?php
2946 2494 }
@@ -2977,14 +2525,14 @@
2977 2525
2978 2526 // If no html then we run the standard output.
2979 2527 if ( empty( $html ) ) {
2980 2528
2981 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2982 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
2983 - $bs_sr_only = $design_style ? 'sr-only' : '';
2984 - $bs_form_control = $design_style ? 'form-control' : '';
2985 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
2986 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
2529 + $design_style = uwp_get_option( "design_style", "bootstrap" );
2530 + $bs_form_group = $design_style ? "form-group mb-3" : "";
2531 + $bs_sr_only = $design_style ? "sr-only" : "";
2532 + $bs_form_control = $design_style ? "form-control" : "";
2533 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
2534 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
2987 2535
2988 2536 ob_start(); // Start buffering;
2989 2537 $option_values_arr = uwp_string_values_to_options( $field->option_values, true );
2990 2538 $site_title = uwp_get_form_label( $field );
@@ -2993,46 +2541,37 @@
2993 2541 if ( $design_style ) {
2994 2542
2995 2543 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
2996 2544
2997 - echo aui()->select(
2998 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2999 - 'id' => esc_attr( $field->htmlvar_name ),
3000 - 'name' => esc_attr( $field->htmlvar_name ),
3001 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3002 - 'title' => esc_html( $site_title ),
3003 - 'value' => esc_attr( $value ),
3004 - 'required' => (bool) $field->is_required,
3005 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
2545 + echo aui()->select( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2546 + 'id' => esc_attr( $field->htmlvar_name ),
2547 + 'name' => esc_attr( $field->htmlvar_name ),
2548 + 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2549 + 'title' => esc_html( $site_title ),
2550 + 'value' => esc_attr( $value ),
2551 + 'required' => (bool) $field->is_required,
2552 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
3006 2553 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3007 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3008 - 'label' => wp_kses_post( $site_title . $required ),
3009 - 'options' => $option_values_arr, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3010 - 'select2' => true,
3011 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3012 - )
3013 - );
2554 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2555 + 'label' => wp_kses_post( $site_title . $required ),
2556 + 'options' => $option_values_arr, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2557 + 'select2' => true,
2558 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2559 + ) );
3014 2560 } else {
3015 2561 ?>
3016 2562 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3017 - class="
3018 - <?php
3019 - if ( $field->is_required ) {
3020 - echo 'required_field';
3021 - }
3022 - ?>
3023 - uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
2563 + class="<?php if ( $field->is_required ) {
2564 + echo 'required_field';
2565 + } ?> uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3024 2566
3025 2567 <?php
3026 - if ( ! is_admin() ) {
3027 - ?>
2568 + if ( ! is_admin() ) { ?>
3028 2569 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3029 2570 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3030 - <?php
3031 - if ( $field->is_required ) {
2571 + <?php if ( $field->is_required ) {
3032 2572 echo '<span>*</span>';
3033 - }
3034 - ?>
2573 + } ?>
3035 2574 </label>
3036 2575 <?php } ?>
3037 2576
3038 2577 <?php
@@ -3061,9 +2600,9 @@
3061 2600 ><?php echo $select_options; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
3062 2601 </select>
3063 2602 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3064 2603 <?php if ( $field->is_required ) { ?>
3065 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
2604 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
3066 2605 <?php } ?>
3067 2606 </div>
3068 2607
3069 2608 <?php
@@ -3095,14 +2634,14 @@
3095 2634 }
3096 2635
3097 2636 if ( empty( $html ) ) {
3098 2637
3099 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3100 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3101 - $bs_sr_only = $design_style ? 'sr-only' : '';
3102 - $bs_form_control = $design_style ? 'form-control' : '';
3103 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
3104 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
2638 + $design_style = uwp_get_option( "design_style", "bootstrap" );
2639 + $bs_form_group = $design_style ? "form-group mb-3" : "";
2640 + $bs_sr_only = $design_style ? "sr-only" : "";
2641 + $bs_form_control = $design_style ? "form-control" : "";
2642 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
2643 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
3105 2644
3106 2645 ob_start(); // Start buffering;
3107 2646
3108 2647 $multi_display = 'select';
@@ -3111,9 +2650,9 @@
3111 2650 }
3112 2651
3113 2652 $option_values_arr = uwp_string_values_to_options( $field->option_values, true );
3114 2653 $site_title = uwp_get_form_label( $field );
3115 - $value = is_array( $value ) ? $value : esc_attr( $value );
2654 + $value = is_array($value) ? $value : esc_attr($value);
3116 2655
3117 2656 // bootstrap
3118 2657 if ( $design_style ) {
3119 2658
@@ -3118,47 +2657,38 @@
3118 2657 if ( $design_style ) {
3119 2658
3120 2659 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3121 2660
3122 - echo aui()->select(
3123 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3124 - 'id' => esc_attr( $field->htmlvar_name ),
3125 - 'name' => esc_attr( $field->htmlvar_name ),
3126 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3127 - 'title' => esc_html( $site_title ),
3128 - 'value' => $value,
3129 - 'required' => (bool) $field->is_required,
3130 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
2661 + echo aui()->select( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2662 + 'id' => esc_attr( $field->htmlvar_name ),
2663 + 'name' => esc_attr( $field->htmlvar_name ),
2664 + 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2665 + 'title' => esc_html( $site_title ),
2666 + 'value' => $value,
2667 + 'required' => (bool) $field->is_required,
2668 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
3131 2669 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3132 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3133 - 'label' => wp_kses_post( $site_title . $required ),
3134 - 'options' => $option_values_arr, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3135 - 'select2' => true,
3136 - 'multiple' => true,
3137 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3138 - )
3139 - );
2670 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2671 + 'label' => wp_kses_post( $site_title . $required ),
2672 + 'options' => $option_values_arr, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2673 + 'select2' => true,
2674 + 'multiple' => true,
2675 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2676 + ) );
3140 2677 } else {
3141 2678 ?>
3142 2679 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3143 - class="
3144 - <?php
3145 - if ( $field->is_required ) {
3146 - echo 'required_field';
3147 - }
3148 - ?>
3149 - uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
2680 + class="<?php if ( $field->is_required ) {
2681 + echo 'required_field';
2682 + } ?> uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3150 2683
3151 2684 <?php
3152 - if ( ! is_admin() ) {
3153 - ?>
2685 + if ( ! is_admin() ) { ?>
3154 2686 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3155 2687 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3156 - <?php
3157 - if ( $field->is_required ) {
2688 + <?php if ( $field->is_required ) {
3158 2689 echo '<span>*</span>';
3159 - }
3160 - ?>
2690 + } ?>
3161 2691 </label>
3162 2692 <?php } ?>
3163 2693
3164 2694 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value=""/>
@@ -3171,65 +2701,62 @@
3171 2701 class="aui-select2 <?php echo esc_attr( $bs_form_control ); ?>"
3172 2702 >
3173 2703 <?php
3174 2704 } else {
3175 - ?>
2705 + ?>
3176 2706 <ul class="uwp_multi_choice">
3177 - <?php
2707 + <?php
3178 2708 }
3179 2709
3180 2710 $option_values_arr = uwp_string_values_to_options( $field->option_values, true );
3181 2711 $select_options = '';
3182 2712 if ( ! empty( $option_values_arr ) ) {
3183 - foreach ( $option_values_arr as $option_row ) {
3184 - if ( isset( $option_row['optgroup'] ) && ( $option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end' ) ) {
3185 - $option_label = isset( $option_row['label'] ) ? $option_row['label'] : '';
2713 + foreach ( $option_values_arr as $option_row ) {
2714 + if ( isset( $option_row['optgroup'] ) && ( $option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end' ) ) {
2715 + $option_label = isset( $option_row['label'] ) ? $option_row['label'] : '';
3186 2716
3187 - if ( $multi_display == 'select' ) {
3188 - $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
3189 - } else {
3190 - $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : '';
3191 - }
3192 - } else {
3193 - $option_label = isset( $option_row['label'] ) ? $option_row['label'] : '';
3194 - $option_value = isset( $option_row['value'] ) ? $option_row['value'] : '';
3195 - $selected = $option_value == $value ? 'selected="selected"' : '';
3196 - $checked = '';
2717 + if ( $multi_display == 'select' ) {
2718 + $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
2719 + } else {
2720 + $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : '';
2721 + }
2722 + } else {
2723 + $option_label = isset( $option_row['label'] ) ? $option_row['label'] : '';
2724 + $option_value = isset( $option_row['value'] ) ? $option_row['value'] : '';
2725 + $selected = $option_value == $value ? 'selected="selected"' : '';
2726 + $checked = '';
3197 2727
3198 - if ( ( ! is_array( $value ) && trim( $value ) != '' ) || ( is_array( $value ) && ! empty( $value ) ) ) {
3199 - if ( ! is_array( $value ) ) {
3200 - $value_array = explode( ',', $value );
3201 - } else {
3202 - $value_array = $value;
3203 - }
2728 + if ( ( ! is_array( $value ) && trim( $value ) != '' ) || ( is_array( $value ) && ! empty( $value ) ) ) {
2729 + if ( ! is_array( $value ) ) {
2730 + $value_array = explode( ',', $value );
2731 + } else {
2732 + $value_array = $value;
2733 + }
3204 2734
3205 - if ( is_array( $value_array ) ) {
3206 - if ( in_array( $option_value, $value_array ) ) {
3207 - $selected = 'selected="selected"';
3208 - $checked = 'checked="checked"';
2735 + if ( is_array( $value_array ) ) {
2736 + if ( in_array( $option_value, $value_array ) ) {
2737 + $selected = 'selected="selected"';
2738 + $checked = 'checked="checked"';
2739 + }
2740 + }
3209 2741 }
2742 +
2743 + if ( $multi_display == 'select' ) {
2744 + $select_options .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . '>' . $option_label . '</option>';
2745 + } else {
2746 + $select_options .= '<li><input name="' . $field->name . '[]" ' . $checked . ' value="' . esc_attr( $option_value ) . '" class="uwp-' . $multi_display . '" type="' . $multi_display . '" />&nbsp;' . $option_label . ' </li>';
2747 + }
3210 2748 }
3211 2749 }
3212 -
3213 - if ( $multi_display == 'select' ) {
3214 - $select_options .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . '>' . $option_label . '</option>';
3215 - } else {
3216 - $select_options .= '<li><input name="' . $field->name . '[]" ' . $checked . ' value="' . esc_attr( $option_value ) . '" class="uwp-' . $multi_display . '" type="' . $multi_display . '" />&nbsp;' . $option_label . ' </li>';
3217 - }
3218 2750 }
3219 - }
3220 - }
3221 2751 echo $select_options; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3222 2752
3223 - if ( $multi_display == 'select' ) {
3224 -
3225 - ?>
3226 - </select></div>
2753 + if ( $multi_display == 'select' ) { ?></select></div>
3227 2754 <?php } else { ?>
3228 2755 </ul>
3229 2756 <?php } ?>
3230 2757 <?php if ( $field->is_required ) { ?>
3231 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
2758 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
3232 2759 <?php } ?>
3233 2760 </div>
3234 2761 <?php
3235 2762 }
@@ -3263,45 +2790,38 @@
3263 2790
3264 2791 // If no html then we run the standard output.
3265 2792 if ( empty( $html ) ) {
3266 2793
3267 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2794 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3268 2795 $wrap_class = isset( $field->css_class ) ? $field->css_class : '';
3269 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3270 - $bs_sr_only = $design_style ? 'sr-only' : '';
3271 - $bs_form_control = $design_style ? 'form-control' : '';
2796 + $bs_form_group = $design_style ? "form-group mb-3" : "";
2797 + $bs_sr_only = $design_style ? "sr-only" : "";
2798 + $bs_form_control = $design_style ? "form-control" : "";
3272 2799
3273 2800 ob_start(); // Start buffering;
3274 2801
3275 2802 ?>
3276 2803 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3277 - class="
3278 - <?php
3279 - if ( $field->is_required ) {
3280 - echo 'required_field';
3281 - }
3282 - ?>
3283 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group . $wrap_class ); ?>">
2804 + class="<?php if ( $field->is_required ) {
2805 + echo 'required_field';
2806 + } ?> uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group . $wrap_class ); ?>">
3284 2807
3285 2808 <?php
3286 2809 $site_title = uwp_get_form_label( $field );
3287 - if ( ! is_admin() && ! wp_doing_ajax() ) {
3288 - ?>
2810 + if ( ! is_admin() && !wp_doing_ajax() ) { ?>
3289 2811 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3290 2812 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3291 - <?php
3292 - if ( $field->is_required ) {
2813 + <?php if ( $field->is_required ) {
3293 2814 echo ' <span class="text-danger">*</span>';
3294 - }
3295 - ?>
2815 + } ?>
3296 2816 </label>
3297 2817 <?php } ?>
3298 2818
3299 2819 <?php echo $file_obj->file_upload_preview( $field, $value ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
3300 2820 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3301 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3302 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3303 - title="<?php echo esc_attr( $site_title ); ?>"
2821 + class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
2822 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
2823 + title="<?php echo esc_attr( $site_title ); ?>"
3304 2824 <?php
3305 2825 if ( $field->is_required == 1 ) {
3306 2826 echo 'data-is-required="1"';
3307 2827 }
@@ -3308,12 +2828,12 @@
3308 2828 if ( $field->is_required == 1 && ! $value ) {
3309 2829 echo 'required="required"';
3310 2830 }
3311 2831 ?>
3312 - type="<?php echo esc_attr( $field->field_type ); ?>">
2832 + type="<?php echo esc_attr( $field->field_type ); ?>">
3313 2833 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3314 2834 <?php if ( $field->is_required ) { ?>
3315 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
2835 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
3316 2836 <?php } ?>
3317 2837 </div>
3318 2838
3319 2839 <?php
@@ -3345,18 +2865,18 @@
3345 2865
3346 2866 // If no html then we run the standard output.
3347 2867 if ( empty( $html ) ) {
3348 2868
3349 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3350 - $bs_form_group = $design_style ? 'form-group mb-3 form-check' : '';
3351 - $bs_sr_only = $design_style ? 'form-check-label' : '';
3352 - $bs_form_control = $design_style ? 'form-check-input' : '';
2869 + $design_style = uwp_get_option( "design_style", "bootstrap" );
2870 + $bs_form_group = $design_style ? "form-group mb-3 form-check" : "";
2871 + $bs_sr_only = $design_style ? "form-check-label" : "";
2872 + $bs_form_control = $design_style ? "form-check-input" : "";
3353 2873
3354 2874 ob_start(); // Start buffering;
3355 2875 $site_title = uwp_get_form_label( $field );
3356 2876
3357 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3358 - $id = wp_doing_ajax() ? $field->htmlvar_name . '_ajax' : $field->htmlvar_name;
2877 + $design_style = uwp_get_option( "design_style", "bootstrap" );
2878 + $id = wp_doing_ajax() ? $field->htmlvar_name . "_ajax" : $field->htmlvar_name;
3359 2879
3360 2880 $checked = $value == '1' ? true : false;
3361 2881
3362 2882 // bootstrap
@@ -3366,20 +2886,20 @@
3366 2886 echo '<input type="hidden" name="' . esc_attr( $field->htmlvar_name ) . '" id="checkbox_' . esc_attr( $id ) . '" value="0"/>';
3367 2887
3368 2888 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3369 2889 array(
3370 - 'id' => esc_attr( $id ),
3371 - 'name' => esc_attr( $field->htmlvar_name ),
3372 - 'type' => 'checkbox',
3373 - 'value' => '1',
3374 - 'title' => esc_html( $site_title ),
3375 - 'label' => wp_kses_post( $site_title . $required ),
3376 - 'label_show' => true,
3377 - 'required' => ! empty( $field->is_required ) ? true : false,
3378 - 'checked' => (bool) $checked,
3379 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3380 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3381 - 'validation_text' => ! empty( $field->is_required ) ? esc_attr__( stripslashes( $field->required_msg ), 'userswp' ) : '',
2890 + 'id' => esc_attr( $id ),
2891 + 'name' => esc_attr( $field->htmlvar_name ),
2892 + 'type' => "checkbox",
2893 + 'value' => '1',
2894 + 'title' => esc_html( $site_title ),
2895 + 'label' => wp_kses_post( $site_title . $required ),
2896 + 'label_show' => true,
2897 + 'required' => ! empty( $field->is_required ) ? true : false,
2898 + 'checked' => (bool) $checked,
2899 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2900 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2901 + 'validation_text' => ! empty( $field->is_required ) ? esc_attr__( $field->required_msg, 'userswp' ) : '',
3382 2902 )
3383 2903 );
3384 2904
3385 2905 } else {
@@ -3384,44 +2904,36 @@
3384 2904
3385 2905 } else {
3386 2906 ?>
3387 2907 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3388 - class="
3389 - <?php
3390 - if ( $field->is_required ) {
3391 - echo 'required_field';
3392 - }
3393 - ?>
3394 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3395 - <?php if ( ! empty( $design_style ) ) { ?>
2908 + class="<?php if ( $field->is_required ) {
2909 + echo 'required_field';
2910 + } ?> uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
2911 + <?php if ( ! empty( $design_style ) ){ ?>
3396 2912 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3397 2913 <?php } ?>
3398 2914 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value="0"/>
3399 2915 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3400 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3401 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3402 - title="<?php echo esc_attr( $site_title ); ?>"
3403 - <?php
3404 - if ( $field->is_required == 1 ) {
2916 + class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
2917 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
2918 + title="<?php echo esc_attr( $site_title ); ?>"
2919 + <?php if ( $field->is_required == 1 ) {
3405 2920 echo 'required="required"';
3406 - }
3407 - ?>
3408 - <?php
3409 - if ( $value == '1' ) {
2921 + } ?>
2922 + <?php if ( $value == '1' ) {
3410 2923 echo 'checked="checked"';
3411 - }
3412 - ?>
3413 - type="<?php echo esc_attr( $field->field_type ); ?>"
3414 - value="1">
2924 + } ?>
2925 + type="<?php echo esc_attr( $field->field_type ); ?>"
2926 + value="1">
3415 2927 <?php
3416 2928 echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;';
3417 2929 ?>
3418 - <?php if ( ! empty( $design_style ) ) { ?>
2930 + <?php if ( ! empty( $design_style ) ){ ?>
3419 2931 </label>
3420 2932 <?php } ?>
3421 2933 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3422 2934 <?php if ( $field->is_required ) { ?>
3423 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
2935 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
3424 2936 <?php } ?>
3425 2937 </div>
3426 2938
3427 2939 <?php
@@ -3457,13 +2969,13 @@
3457 2969
3458 2970 // If no html then we run the standard output.
3459 2971 if ( empty( $html ) ) {
3460 2972
3461 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3462 - $bs_form_group = $design_style ? 'form-group mb-3 form-check-inline' : '';
3463 - $bs_sr_only = $design_style ? 'sr-only' : '';
3464 - $bs_label_class = $design_style ? 'form-check-label' : '';
3465 - $bs_form_control = $design_style ? 'form-check-input' : '';
2973 + $design_style = uwp_get_option( "design_style", "bootstrap" );
2974 + $bs_form_group = $design_style ? "form-group mb-3 form-check-inline" : "";
2975 + $bs_sr_only = $design_style ? "sr-only" : "";
2976 + $bs_label_class = $design_style ? "form-check-label" : "";
2977 + $bs_form_control = $design_style ? "form-check-input" : "";
3466 2978
3467 2979 ob_start(); // Start buffering;
3468 2980
3469 2981 if ( $design_style ) {
@@ -3483,16 +2995,16 @@
3483 2995 echo aui()->radio( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3484 2996 array(
3485 2997 'id' => esc_attr( $field->htmlvar_name ),
3486 2998 'name' => esc_attr( $field->htmlvar_name ),
3487 - 'type' => 'radio',
2999 + 'type' => "radio",
3488 3000 'title' => esc_html( $site_title ),
3489 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3001 + 'label' => is_admin() && !wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3490 3002 'label_type' => 'top',
3491 3003 'class' => '',
3492 3004 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3493 3005 'value' => esc_attr( $value ),
3494 - 'options' => $option_values, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3006 + 'options' => $option_values // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3495 3007 )
3496 3008 );
3497 3009
3498 3010 } else {
@@ -3498,32 +3010,24 @@
3498 3010 } else {
3499 3011
3500 3012 ?>
3501 3013 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3502 - class="
3503 - <?php
3504 - if ( $field->is_required ) {
3505 - echo 'required_field';
3506 - }
3507 - ?>
3508 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3014 + class="<?php if ( $field->is_required ) {
3015 + echo 'required_field';
3016 + } ?> uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3509 3017
3510 3018 <?php
3511 3019 $site_title = uwp_get_form_label( $field );
3512 - if ( ! is_admin() ) {
3513 - ?>
3020 + if ( ! is_admin() ) { ?>
3514 3021 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3515 3022 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3516 - <?php
3517 - if ( $field->is_required ) {
3023 + <?php if ( $field->is_required ) {
3518 3024 echo '<span>*</span>';
3519 - }
3520 - ?>
3025 + } ?>
3521 3026 </label>
3522 3027 <?php } ?>
3523 3028
3524 - <?php
3525 - if ( $field->option_values ) {
3029 + <?php if ( $field->option_values ) {
3526 3030 $option_values = uwp_string_values_to_options( $field->option_values, true );
3527 3031
3528 3032 if ( ! empty( $option_values ) ) {
3529 3033 $count = 0;
@@ -3528,13 +3032,13 @@
3528 3032 if ( ! empty( $option_values ) ) {
3529 3033 $count = 0;
3530 3034 foreach ( $option_values as $option_value ) {
3531 3035 if ( empty( $option_value['optgroup'] ) ) {
3532 - ++$count;
3036 + $count ++;
3533 3037 if ( $count == 1 ) {
3534 - $class = 'uwp-radio-first';
3038 + $class = "uwp-radio-first";
3535 3039 } else {
3536 - $class = '';
3040 + $class = "";
3537 3041 }
3538 3042 ?>
3539 3043 <?php if ( ! empty( $design_style ) ) { ?>
3540 3044 <label class="<?php echo esc_attr( $bs_label_class ); ?>">
@@ -3541,18 +3045,16 @@
3541 3045 <?php } else { ?>
3542 3046 <span class="uwp-radios <?php echo esc_attr( $class ); ?>">
3543 3047 <?php } ?>
3544 3048 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3545 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3546 - title="<?php echo esc_attr( $option_value['label'] ); ?>"
3049 + id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3050 + title="<?php echo esc_attr( $option_value['label'] ); ?>"
3547 3051 <?php checked( $value, $option_value['value'] ); ?>
3548 - <?php
3549 - if ( $field->is_required == 1 ) {
3052 + <?php if ( $field->is_required == 1 ) {
3550 3053 echo 'required="required"';
3551 - }
3552 - ?>
3553 - value="<?php echo esc_attr( $option_value['value'] ); ?>"
3554 - class="uwp-radio <?php echo esc_attr( $bs_form_control ); ?>" type="radio"/>
3054 + } ?>
3055 + value="<?php echo esc_attr( $option_value['value'] ); ?>"
3056 + class="uwp-radio <?php echo esc_attr( $bs_form_control ); ?>" type="radio"/>
3555 3057 <?php echo esc_html( $option_value['label'] ); ?>
3556 3058 <?php if ( ! empty( $design_style ) ) { ?>
3557 3059 </label>
3558 3060 <?php } else { ?>
@@ -3565,9 +3067,9 @@
3565 3067 }
3566 3068 ?>
3567 3069 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3568 3070 <?php if ( $field->is_required ) { ?>
3569 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
3071 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
3570 3072 <?php } ?>
3571 3073 </div>
3572 3074 <?php
3573 3075 }
@@ -3610,140 +3112,125 @@
3610 3112 $type = 'number';
3611 3113 } elseif ( isset( $field->data_type ) && $field->data_type == 'FLOAT' ) {
3612 3114 $dp = $field->decimal_point;
3613 3115 switch ( $dp ) {
3614 - case '1':
3615 - $step = '0.1';
3116 + case "1":
3117 + $step = "0.1";
3616 3118 break;
3617 - case '2':
3618 - $step = '0.01';
3119 + case "2":
3120 + $step = "0.01";
3619 3121 break;
3620 - case '3':
3621 - $step = '0.001';
3122 + case "3":
3123 + $step = "0.001";
3622 3124 break;
3623 - case '4':
3624 - $step = '0.0001';
3125 + case "4":
3126 + $step = "0.0001";
3625 3127 break;
3626 - case '5':
3627 - $step = '0.00001';
3128 + case "5":
3129 + $step = "0.00001";
3628 3130 break;
3629 - case '6':
3630 - $step = '0.000001';
3131 + case "6":
3132 + $step = "0.000001";
3631 3133 break;
3632 - case '7':
3633 - $step = '0.0000001';
3134 + case "7":
3135 + $step = "0.0000001";
3634 3136 break;
3635 - case '8':
3636 - $step = '0.00000001';
3137 + case "8":
3138 + $step = "0.00000001";
3637 3139 break;
3638 - case '9':
3639 - $step = '0.000000001';
3140 + case "9":
3141 + $step = "0.000000001";
3640 3142 break;
3641 - case '10':
3642 - $step = '0.0000000001';
3143 + case "10":
3144 + $step = "0.0000000001";
3643 3145 break;
3644 3146 default:
3645 - $step = '0.01';
3147 + $step = "0.01";
3646 3148 break;
3647 3149 }
3648 3150 $type = 'number';
3649 3151 }
3650 3152
3153 +
3651 3154 $site_title = uwp_get_form_label( $field );
3652 3155 $placeholder = uwp_get_field_placeholder( $field );
3653 3156 $manual_label = apply_filters( 'uwp_login_username_label_manual', true );
3654 3157 if ( $manual_label
3655 - && isset( $field->form_type )
3656 - && $field->form_type == 'login'
3657 - && $field->htmlvar_name == 'username' ) {
3658 - $site_title = __( 'Username or Email', 'userswp' );
3158 + && isset( $field->form_type )
3159 + && $field->form_type == 'login'
3160 + && $field->htmlvar_name == 'username' ) {
3161 + $site_title = __( "Username or Email", 'userswp' );
3659 3162 $required = ! empty( $field->is_required ) ? ' *' : '';
3660 3163 $placeholder = $site_title . $required;
3661 3164 $placeholder = apply_filters( 'uwp_get_field_placeholder', stripslashes( $placeholder ), $field );
3662 3165 }
3663 3166
3664 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3665 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3666 - $bs_sr_only = $design_style ? 'sr-only' : '';
3667 - $bs_form_control = $design_style ? 'form-control' : '';
3167 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3168 + $bs_form_group = $design_style ? "form-group mb-3" : "";
3169 + $bs_sr_only = $design_style ? "sr-only" : "";
3170 + $bs_form_control = $design_style ? "form-control" : "";
3668 3171
3669 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
3670 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
3172 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
3173 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
3671 3174
3672 3175 // bootstrap
3673 3176 if ( $design_style ) {
3674 3177 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3675 3178
3676 - echo aui()->input(
3677 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3678 - 'type' => esc_attr( $type ),
3679 - 'id' => esc_attr( $field->htmlvar_name ),
3680 - 'name' => esc_attr( $field->htmlvar_name ),
3681 - 'placeholder' => esc_attr( $placeholder ),
3682 - 'title' => esc_html( $site_title ),
3683 - 'value' => esc_attr( wp_unslash( $value ) ),
3684 - 'required' => (bool) $field->is_required,
3685 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
3179 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3180 + 'type' => esc_attr( $type ),
3181 + 'id' => esc_attr( $field->htmlvar_name ),
3182 + 'name' => esc_attr( $field->htmlvar_name ),
3183 + 'placeholder' => esc_attr( $placeholder ),
3184 + 'title' => esc_html( $site_title ),
3185 + 'value' => esc_attr( wp_unslash( $value ) ),
3186 + 'required' => (bool) $field->is_required,
3187 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
3686 3188 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3687 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3688 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3689 - 'step' => esc_attr( $step ),
3690 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3691 - )
3692 - );
3189 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3190 + 'label' => is_admin() && !wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3191 + 'step' => esc_attr( $step ),
3192 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3193 + ) );
3693 3194 } else {
3694 3195 ?>
3695 - <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row" class="
3696 - <?php
3697 - if ( $field->is_required ) {
3698 - echo 'required_field';
3699 - }
3700 - ?>
3701 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3196 + <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row" class="<?php if ( $field->is_required ) {
3197 + echo 'required_field';
3198 + } ?> uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3702 3199 <?php
3703 3200
3704 - if ( ! is_admin() ) {
3705 - ?>
3201 + if ( ! is_admin() ) { ?>
3706 3202 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3707 3203 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3708 - <?php
3709 - if ( $field->is_required ) {
3204 + <?php if ( $field->is_required ) {
3710 3205 echo '<span>*</span>';
3711 - }
3712 - ?>
3206 + } ?>
3713 3207 </label>
3714 - <?php
3715 - }
3208 + <?php }
3716 3209 ?>
3717 3210
3718 3211 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3719 - class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
3720 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3721 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3722 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
3723 - title="<?php echo esc_attr( $site_title ); ?>"
3724 - oninvalid="this.setCustomValidity('<?php esc_attr_e( stripslashes( $field->required_msg ), 'userswp' ); ?>')"
3725 - oninput="setCustomValidity('')"
3726 - <?php
3727 - if ( $field->is_required == 1 ) {
3212 + class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
3213 + id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3214 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3215 + value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
3216 + title="<?php echo esc_attr( $site_title ); ?>"
3217 + oninvalid="this.setCustomValidity('<?php esc_attr_e( $field->required_msg, 'userswp' ); ?>')"
3218 + oninput="setCustomValidity('')"
3219 + <?php if ( $field->is_required == 1 ) {
3728 3220 echo 'required="required"';
3729 - }
3730 - ?>
3731 - <?php
3732 - if ( $field->for_admin_use == 1 ) {
3221 + } ?>
3222 + <?php if ( $field->for_admin_use == 1 ) {
3733 3223 echo 'readonly="readonly"';
3734 - }
3735 - ?>
3736 - type="<?php echo esc_attr( $type ); ?>"
3737 - <?php
3738 - if ( $step ) {
3224 + } ?>
3225 + type="<?php echo esc_attr( $type ); ?>"
3226 + <?php if ( $step ) {
3739 3227 echo 'step="' . esc_attr( $step ) . '"';
3740 - }
3741 - ?>
3228 + } ?>
3742 3229 />
3743 3230 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3744 3231 <?php if ( $field->is_required ) { ?>
3745 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
3232 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
3746 3233 <?php } ?>
3747 3234 </div>
3748 3235
3749 3236
@@ -3777,12 +3264,12 @@
3777 3264
3778 3265 // If no html then we run the standard output.
3779 3266 if ( empty( $html ) ) {
3780 3267
3781 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3782 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3783 - $bs_sr_only = $design_style ? 'sr-only' : '';
3784 - $bs_form_control = $design_style ? 'form-control' : '';
3268 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3269 + $bs_form_group = $design_style ? "form-group mb-3" : "";
3270 + $bs_sr_only = $design_style ? "sr-only" : "";
3271 + $bs_form_control = $design_style ? "form-control" : "";
3785 3272 $site_title = uwp_get_form_label( $field );
3786 3273
3787 3274 ob_start(); // Start buffering;
3788 3275
@@ -3789,10 +3276,9 @@
3789 3276 // bootstrap
3790 3277 if ( $design_style ) {
3791 3278 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3792 3279
3793 - echo aui()->textarea(
3794 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3280 + echo aui()->textarea( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3795 3281 'id' => esc_attr( $field->htmlvar_name ),
3796 3282 'name' => esc_attr( $field->htmlvar_name ),
3797 3283 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3798 3284 'title' => esc_html( $site_title ),
@@ -3797,57 +3283,47 @@
3797 3283 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3798 3284 'title' => esc_html( $site_title ),
3799 3285 'value' => wp_kses_post( stripslashes( $value ) ),
3800 3286 'required' => (bool) $field->is_required,
3801 - 'validation_text' => ! empty( $field->is_required ) ? esc_attr__( stripslashes( $field->required_msg ), 'userswp' ) : '',
3287 + 'validation_text' => ! empty( $field->is_required ) ? esc_attr__( $field->required_msg, 'userswp' ) : '',
3802 3288 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3803 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3289 + 'label' => is_admin() && !wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3804 3290 'rows' => '4',
3805 3291 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3806 - )
3807 - );
3292 + ) );
3808 3293 } else {
3809 3294 ?>
3810 3295
3811 3296 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3812 - class="
3813 - <?php
3814 - if ( $field->is_required ) {
3815 - echo 'required_field';
3816 - }
3817 - ?>
3818 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3297 + class="<?php if ( $field->is_required ) {
3298 + echo 'required_field';
3299 + } ?> uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3819 3300
3820 3301 <?php
3821 3302
3822 - if ( ! is_admin() ) {
3823 - ?>
3303 + if ( ! is_admin() ) { ?>
3824 3304 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3825 3305 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3826 - <?php
3827 - if ( $field->is_required ) {
3306 + <?php if ( $field->is_required ) {
3828 3307 echo '<span>*</span>';
3829 - }
3830 - ?>
3308 + } ?>
3831 3309 </label>
3832 3310 <?php } ?>
3833 3311
3834 3312 <textarea name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3835 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3836 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3837 - title="<?php echo esc_attr( $site_title ); ?>"
3838 - oninvalid="this.setCustomValidity('<?php esc_attr_e( stripslashes( $field->required_msg ), 'userswp' ); ?>')"
3839 - oninput="setCustomValidity('')"
3840 - <?php
3841 - if ( $field->is_required == 1 ) {
3313 + class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3314 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3315 + title="<?php echo esc_attr( $site_title ); ?>"
3316 + oninvalid="this.setCustomValidity('<?php esc_attr_e( $field->required_msg, 'userswp' ); ?>')"
3317 + oninput="setCustomValidity('')"
3318 + <?php if ( $field->is_required == 1 ) {
3842 3319 echo 'required="required"';
3843 - }
3844 - ?>
3845 - type="<?php echo esc_attr( $field->field_type ); ?>"
3846 - rows="4"><?php echo wp_kses_post( stripslashes( $value ) ); ?></textarea>
3320 + } ?>
3321 + type="<?php echo esc_attr( $field->field_type ); ?>"
3322 + rows="4"><?php echo wp_kses_post( stripslashes( $value ) ); ?></textarea>
3847 3323 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3848 3324 <?php if ( $field->is_required ) { ?>
3849 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
3325 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
3850 3326 <?php } ?>
3851 3327 </div>
3852 3328
3853 3329 <?php
@@ -3868,11 +3344,11 @@
3868 3344 if ( empty( $html ) ) {
3869 3345
3870 3346 ob_start();
3871 3347
3872 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3873 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3874 - $bs_sr_only = $design_style ? 'sr-only' : '';
3348 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3349 + $bs_form_group = $design_style ? "form-group mb-3" : "";
3350 + $bs_sr_only = $design_style ? "sr-only" : "";
3875 3351 $site_title = uwp_get_form_label( $field );
3876 3352
3877 3353 $content = stripslashes( $value );
3878 3354 $editor_id = $field->htmlvar_name;
@@ -3881,54 +3357,45 @@
3881 3357 'media_buttons' => false,
3882 3358 'quicktags' => false,
3883 3359 );
3884 3360
3885 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
3886 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
3361 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
3362 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
3887 3363
3888 3364 // bootstrap
3889 3365 if ( $design_style ) {
3890 3366 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3891 3367
3892 - echo aui()->textarea(
3893 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3894 - 'id' => esc_attr( $field->htmlvar_name ),
3895 - 'name' => esc_attr( $field->htmlvar_name ),
3896 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3897 - 'title' => esc_html( $site_title ),
3898 - 'value' => wp_kses_post( stripslashes( $value ) ),
3899 - 'required' => (bool) $field->is_required,
3900 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
3368 + echo aui()->textarea( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3369 + 'id' => esc_attr( $field->htmlvar_name ),
3370 + 'name' => esc_attr( $field->htmlvar_name ),
3371 + 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3372 + 'title' => esc_html( $site_title ),
3373 + 'value' => wp_kses_post( stripslashes( $value ) ),
3374 + 'required' => (bool) $field->is_required,
3375 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
3901 3376 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3902 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3903 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3904 - 'rows' => 5,
3905 - 'wysiwyg' => true,
3906 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3907 - )
3908 - );
3377 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3378 + 'label' => is_admin() && !wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3379 + 'rows' => 5,
3380 + 'wysiwyg' => true,
3381 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3382 + ) );
3909 3383 } else {
3910 3384 ?>
3911 3385 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3912 - class="
3913 - <?php
3914 - if ( $field->is_required ) {
3915 - echo 'required_field';
3916 - }
3917 - ?>
3918 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3386 + class="<?php if ( $field->is_required ) {
3387 + echo 'required_field';
3388 + } ?> uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3919 3389
3920 3390 <?php
3921 3391
3922 - if ( ! is_admin() ) {
3923 - ?>
3392 + if ( ! is_admin() ) { ?>
3924 3393 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3925 3394 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3926 - <?php
3927 - if ( $field->is_required ) {
3395 + <?php if ( $field->is_required ) {
3928 3396 echo '<span>*</span>';
3929 - }
3930 - ?>
3397 + } ?>
3931 3398 </label>
3932 3399 <?php } ?>
3933 3400
3934 3401 <?php wp_editor( $content, $editor_id, $args ); ?>
@@ -3934,9 +3401,9 @@
3934 3401 <?php wp_editor( $content, $editor_id, $args ); ?>
3935 3402
3936 3403 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3937 3404 <?php if ( $field->is_required ) { ?>
3938 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
3405 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
3939 3406 <?php } ?>
3940 3407 </div>
3941 3408 <?php
3942 3409 }
@@ -3972,14 +3439,11 @@
3972 3439 $site_title = uwp_get_form_label( $field );
3973 3440 ?>
3974 3441 <h3 class="uwp_input_fieldset <?php echo esc_attr( $field->css_class ); ?>">
3975 3442 <?php echo esc_html( $site_title ); ?>
3976 - <?php
3977 - if ( $field->help_text != '' ) {
3443 + <?php if ( $field->help_text != '' ) {
3978 3444 echo '<small>( ' . wp_kses_post( $field->help_text ) . ' )</small>';
3979 - }
3980 - ?>
3981 - </h3>
3445 + } ?></h3>
3982 3446 <?php
3983 3447 $html = ob_get_clean();
3984 3448 }
3985 3449
@@ -4000,8 +3464,9 @@
4000 3464 * @since 1.0.0
4001 3465 */
4002 3466 public function form_input_url( $html, $field, $value, $form_type ) {
4003 3467
3468 +
4004 3469 // Check if there is a custom field specific filter.
4005 3470 if ( has_filter( "uwp_form_input_url_{$field->htmlvar_name}" ) ) {
4006 3471 $html = apply_filters( "uwp_form_input_url_{$field->htmlvar_name}", $html, $field, $value, $form_type );
4007 3472 }
@@ -4008,84 +3473,70 @@
4008 3473
4009 3474 // If no html then we run the standard output.
4010 3475 if ( empty( $html ) ) {
4011 3476
4012 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4013 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4014 - $bs_sr_only = $design_style ? 'sr-only' : '';
4015 - $bs_form_control = $design_style ? 'form-control' : '';
3477 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3478 + $bs_form_group = $design_style ? "form-group mb-3" : "";
3479 + $bs_sr_only = $design_style ? "sr-only" : "";
3480 + $bs_form_control = $design_style ? "form-control" : "";
4016 3481
4017 3482 ob_start(); // Start buffering;
4018 3483 $site_title = uwp_get_form_label( $field );
4019 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : __( 'Please enter a valid URL including https://', 'userswp' );
4020 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
3484 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : __( 'Please enter a valid URL including https://', 'userswp' );
3485 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
4021 3486
4022 3487 // bootstrap
4023 3488 if ( $design_style ) {
4024 3489 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4025 3490
4026 - echo aui()->input(
4027 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4028 - 'type' => 'url',
4029 - 'id' => esc_attr( $field->htmlvar_name ),
4030 - 'name' => esc_attr( $field->htmlvar_name ),
4031 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4032 - 'title' => esc_html( $site_title ),
4033 - 'value' => esc_attr( $value ),
4034 - 'required' => (bool) $field->is_required,
4035 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
3491 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3492 + 'type' => 'url',
3493 + 'id' => esc_attr( $field->htmlvar_name ),
3494 + 'name' => esc_attr( $field->htmlvar_name ),
3495 + 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3496 + 'title' => esc_html( $site_title ),
3497 + 'value' => esc_attr( $value ),
3498 + 'required' => (bool) $field->is_required,
3499 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4036 3500 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4037 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4038 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4039 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4040 - )
4041 - );
3501 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3502 + 'label' => is_admin() && !wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3503 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3504 + ) );
4042 3505 } else {
4043 3506 ?>
4044 3507 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4045 - class="
4046 - <?php
4047 - if ( $field->is_required ) {
4048 - echo 'required_field';
4049 - }
4050 - ?>
4051 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3508 + class="<?php if ( $field->is_required ) {
3509 + echo 'required_field';
3510 + } ?> uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
4052 3511
4053 3512 <?php
4054 - if ( ! is_admin() ) {
4055 - ?>
3513 + if ( ! is_admin() ) { ?>
4056 3514 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4057 3515 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4058 - <?php
4059 - if ( $field->is_required ) {
3516 + <?php if ( $field->is_required ) {
4060 3517 echo '<span>*</span>';
4061 - }
4062 - ?>
3518 + } ?>
4063 3519 </label>
4064 3520 <?php } ?>
4065 3521
4066 3522 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4067 - class="
4068 - <?php
4069 - //echo $field->css_class;
4070 - ?>
4071 - uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
4072 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4073 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4074 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
4075 - title="<?php echo esc_attr( $site_title ); ?>"
4076 - <?php
4077 - if ( $field->is_required == 1 ) {
3523 + class="<?php //echo $field->css_class;
3524 + ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
3525 + id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3526 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3527 + value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
3528 + title="<?php echo esc_attr( $site_title ); ?>"
3529 + <?php if ( $field->is_required == 1 ) {
4078 3530 echo 'required="required"';
4079 - }
4080 - ?>
4081 - type="url"
4082 - oninvalid="setCustomValidity('<?php esc_attr_e( 'Please enter a valid URL including http://', 'userswp' ); ?>')"
4083 - onchange="try{setCustomValidity('')}catch(e){}"
3531 + } ?>
3532 + type="url"
3533 + oninvalid="setCustomValidity('<?php esc_attr_e( 'Please enter a valid URL including http://', 'userswp' ); ?>')"
3534 + onchange="try{setCustomValidity('')}catch(e){}"
4084 3535 />
4085 3536 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4086 3537 <?php if ( $field->is_required ) { ?>
4087 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
3538 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
4088 3539 <?php } ?>
4089 3540 </div>
4090 3541
4091 3542 <?php
@@ -4111,8 +3562,9 @@
4111 3562 * @since 1.0.0
4112 3563 */
4113 3564 public function form_input_email( $html, $field, $value, $form_type ) {
4114 3565
3566 +
4115 3567 // Check if there is a custom field specific filter.
4116 3568 if ( has_filter( "uwp_form_input_email_{$field->htmlvar_name}" ) ) {
4117 3569 $html = apply_filters( "uwp_form_input_email_{$field->htmlvar_name}", $html, $field, $value, $form_type );
4118 3570 }
@@ -4119,86 +3571,66 @@
4119 3571
4120 3572 // If no html then we run the standard output.
4121 3573 if ( empty( $html ) ) {
4122 3574
4123 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4124 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4125 - $bs_sr_only = $design_style ? 'sr-only' : '';
4126 - $bs_form_control = $design_style ? 'form-control' : '';
3575 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3576 + $bs_form_group = $design_style ? "form-group mb-3" : "";
3577 + $bs_sr_only = $design_style ? "sr-only" : "";
3578 + $bs_form_control = $design_style ? "form-control" : "";
4127 3579
4128 3580 ob_start(); // Start buffering;
4129 3581 $site_title = uwp_get_form_label( $field );
4130 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4131 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
3582 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
3583 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
4132 3584
4133 - $is_forgot_email = ( $form_type === 'forgot' && $field->htmlvar_name === 'email' );
4134 - $input_type = $is_forgot_email ? 'text' : 'email';
4135 - if ( $is_forgot_email ) {
4136 - $site_title = __( 'Username or Email', 'userswp' );
4137 - $placeholder = $site_title . ( ! empty( $field->is_required ) ? ' *' : '' );
4138 - } else {
4139 - $placeholder = uwp_get_field_placeholder( $field );
4140 - }
4141 -
4142 3585 if ( $design_style ) {
4143 3586 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4144 3587
4145 - echo aui()->input(
4146 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4147 - 'type' => $input_type,
4148 - 'id' => esc_attr( $field->htmlvar_name ),
4149 - 'name' => esc_attr( $field->htmlvar_name ),
4150 - 'placeholder' => esc_attr( $placeholder ),
4151 - 'title' => esc_html( $site_title ),
4152 - 'value' => esc_attr( wp_unslash( $value ) ),
4153 - 'required' => (bool) $field->is_required,
4154 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
3588 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3589 + 'type' => 'email',
3590 + 'id' => esc_attr( $field->htmlvar_name ),
3591 + 'name' => esc_attr( $field->htmlvar_name ),
3592 + 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3593 + 'title' => esc_html( $site_title ),
3594 + 'value' => esc_attr( wp_unslash( $value ) ),
3595 + 'required' => (bool) $field->is_required,
3596 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4155 3597 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4156 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4157 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4158 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4159 - )
4160 - );
3598 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3599 + 'label' => is_admin() && !wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3600 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3601 + ) );
4161 3602 } else {
4162 3603 ?>
4163 3604 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4164 - class="
4165 - <?php
4166 - if ( $field->is_required ) {
4167 - echo 'required_field';
4168 - }
4169 - ?>
4170 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3605 + class="<?php if ( $field->is_required ) {
3606 + echo 'required_field';
3607 + } ?> uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
4171 3608
4172 3609 <?php
4173 - if ( ! is_admin() ) {
4174 - ?>
3610 + if ( ! is_admin() ) { ?>
4175 3611 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4176 3612 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4177 - <?php
4178 - if ( $field->is_required ) {
3613 + <?php if ( $field->is_required ) {
4179 3614 echo '<span>*</span>';
4180 - }
4181 - ?>
3615 + } ?>
4182 3616 </label>
4183 3617 <?php } ?>
4184 3618
4185 3619 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4186 - class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
4187 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4188 - placeholder="<?php echo esc_attr( $placeholder ); ?>"
4189 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
4190 - title="<?php echo esc_attr( $site_title ); ?>"
4191 - <?php
4192 - if ( $field->is_required == 1 ) {
3620 + class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
3621 + id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3622 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3623 + value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
3624 + title="<?php echo esc_attr( $site_title ); ?>"
3625 + <?php if ( $field->is_required == 1 ) {
4193 3626 echo 'required="required"';
4194 - }
4195 - ?>
4196 - type="<?php echo esc_attr( $input_type ); ?>"
3627 + } ?>
3628 + type="email"
4197 3629 />
4198 3630 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4199 3631 <?php if ( $field->is_required ) { ?>
4200 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
3632 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
4201 3633 <?php } ?>
4202 3634 </div>
4203 3635
4204 3636
@@ -4229,8 +3661,9 @@
4229 3661 * @since 1.0.0
4230 3662 */
4231 3663 public function form_input_password( $html, $field, $value, $form_type ) {
4232 3664
3665 +
4233 3666 // Check if there is a custom field specific filter.
4234 3667 if ( has_filter( "uwp_form_input_password_{$field->htmlvar_name}" ) ) {
4235 3668 $html = apply_filters( "uwp_form_input_password_{$field->htmlvar_name}", $html, $field, $value, $form_type );
4236 3669 }
@@ -4237,12 +3670,12 @@
4237 3670
4238 3671 // If no html then we run the standard output.
4239 3672 if ( empty( $html ) ) {
4240 3673
4241 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4242 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4243 - $bs_sr_only = $design_style ? 'sr-only' : '';
4244 - $bs_form_control = $design_style ? 'form-control' : '';
3674 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3675 + $bs_form_group = $design_style ? "form-group mb-3" : "";
3676 + $bs_sr_only = $design_style ? "sr-only" : "";
3677 + $bs_form_control = $design_style ? "form-control" : "";
4245 3678
4246 3679 ob_start(); // Start buffering;
4247 3680 $site_title = uwp_get_form_label( $field );
4248 3681
@@ -4247,66 +3680,55 @@
4247 3680 $site_title = uwp_get_form_label( $field );
4248 3681
4249 3682 if ( $design_style ) {
4250 3683 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4251 - $required_msg = ( ! empty( $field->required_msg ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4252 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
4253 - $wrap_class = isset( $field->css_class ) ? $field->css_class . ' uwp-password-wrap' : 'uwp-password-wrap';
3684 + $required_msg = (!empty( $field->required_msg ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
3685 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
3686 + $wrap_class = isset( $field->css_class ) ? $field->css_class.' uwp-password-wrap' : 'uwp-password-wrap';
4254 3687
4255 - echo aui()->input(
4256 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4257 - 'type' => 'password',
4258 - 'id' => esc_attr( $field->htmlvar_name ),
4259 - 'name' => esc_attr( $field->htmlvar_name ),
4260 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4261 - 'title' => esc_html( $site_title ),
4262 - 'value' => esc_attr( $value ),
4263 - 'required' => (bool) $field->is_required,
4264 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
3688 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3689 + 'type' => 'password',
3690 + 'id' => esc_attr( $field->htmlvar_name ),
3691 + 'name' => esc_attr( $field->htmlvar_name ),
3692 + 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3693 + 'title' => esc_html( $site_title ),
3694 + 'value' => esc_attr( $value ),
3695 + 'required' => (bool) $field->is_required,
3696 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4265 3697 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4266 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4267 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4268 - 'wrap_class' => esc_attr( $wrap_class ),
4269 - )
4270 - );
3698 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3699 + 'label' => is_admin() && !wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3700 + 'wrap_class' => esc_attr( $wrap_class ),
3701 + ) );
4271 3702 } else {
4272 3703 ?>
4273 - <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row" class="
4274 - <?php
4275 - if ( $field->is_required ) {
4276 - echo 'required_field';
4277 - }
4278 - ?>
4279 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3704 + <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row" class="<?php if ( $field->is_required ) {
3705 + echo 'required_field';
3706 + } ?> uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
4280 3707 <?php
4281 - if ( ! is_admin() ) {
4282 - ?>
3708 + if ( ! is_admin() ) { ?>
4283 3709 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4284 3710 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4285 - <?php
4286 - if ( $field->is_required ) {
3711 + <?php if ( $field->is_required ) {
4287 3712 echo '<span>*</span>';
4288 - }
4289 - ?>
3713 + } ?>
4290 3714 </label>
4291 3715 <?php } ?>
4292 3716
4293 3717 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4294 - class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
4295 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4296 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4297 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
4298 - title="<?php echo esc_attr( $site_title ); ?>"
4299 - <?php
4300 - if ( $field->is_required == 1 ) {
3718 + class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
3719 + id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3720 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3721 + value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
3722 + title="<?php echo esc_attr( $site_title ); ?>"
3723 + <?php if ( $field->is_required == 1 ) {
4301 3724 echo 'required="required"';
4302 - }
4303 - ?>
4304 - type="password"
3725 + } ?>
3726 + type="password"
4305 3727 />
4306 3728 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4307 3729 <?php if ( $field->is_required ) { ?>
4308 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
3730 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
4309 3731 <?php } ?>
4310 3732 </div>
4311 3733
4312 3734
@@ -4336,74 +3758,61 @@
4336 3758 *
4337 3759 */
4338 3760 public function form_input_phone( $html, $field, $value, $form_type ) {
4339 3761 if ( empty( $html ) ) {
4340 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4341 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4342 - $bs_sr_only = $design_style ? 'sr-only' : '';
4343 - $bs_form_control = $design_style ? 'form-control' : '';
3762 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3763 + $bs_form_group = $design_style ? "form-group mb-3" : "";
3764 + $bs_sr_only = $design_style ? "sr-only" : "";
3765 + $bs_form_control = $design_style ? "form-control" : "";
4344 3766 ob_start(); // Start buffering;
4345 3767 $site_title = uwp_get_form_label( $field );
4346 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4347 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
3768 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
3769 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
4348 3770
4349 3771 if ( $design_style ) {
4350 3772 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4351 3773
4352 - echo aui()->input(
4353 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4354 - 'type' => 'tel',
4355 - 'id' => esc_attr( $field->htmlvar_name ),
4356 - 'name' => esc_attr( $field->htmlvar_name ),
4357 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4358 - 'title' => esc_html( $site_title ),
4359 - 'value' => esc_attr( $value ),
4360 - 'required' => (bool) $field->is_required,
4361 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4362 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4363 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4364 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4365 - 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4366 - )
4367 - );
3774 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3775 + 'type' => 'tel',
3776 + 'id' => esc_attr( $field->htmlvar_name ),
3777 + 'name' => esc_attr( $field->htmlvar_name ),
3778 + 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3779 + 'title' => esc_html( $site_title ),
3780 + 'value' => esc_attr( $value ),
3781 + 'required' => (bool) $field->is_required,
3782 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3783 + 'label' => is_admin() && !wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3784 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3785 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
3786 + 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash($field->validation_pattern) ) : '',
3787 + ) );
4368 3788 } else {
4369 3789 ?>
4370 3790 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4371 - class="
4372 - <?php
4373 - if ( $field->is_required ) {
4374 - echo 'required_field';
4375 - }
4376 - ?>
4377 - clearfix uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3791 + class="<?php if ( $field->is_required ) {
3792 + echo 'required_field';
3793 + } ?> clearfix uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
4378 3794 <?php
4379 - if ( ! is_admin() ) {
4380 - ?>
3795 + if ( ! is_admin() ) { ?>
4381 3796 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4382 3797 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4383 - <?php
4384 - if ( $field->is_required ) {
3798 + <?php if ( $field->is_required ) {
4385 3799 echo '<span>*</span>';
4386 - }
4387 - ?>
3800 + } ?>
4388 3801 </label>
4389 3802 <?php } ?>
4390 3803 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4391 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
4392 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4393 - title="<?php echo esc_attr( $site_title ); ?>"
4394 - <?php
4395 - if ( $field->for_admin_use == 1 ) {
3804 + class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3805 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3806 + title="<?php echo esc_attr( $site_title ); ?>"
3807 + <?php if ( $field->for_admin_use == 1 ) {
4396 3808 echo 'readonly="readonly"';
4397 - }
4398 - ?>
4399 - <?php
4400 - if ( $field->is_required == 1 ) {
3809 + } ?>
3810 + <?php if ( $field->is_required == 1 ) {
4401 3811 echo 'required="required"';
4402 - }
4403 - ?>
4404 - type="tel"
4405 - value="<?php echo esc_html( $value ); ?>">
3812 + } ?>
3813 + type="tel"
3814 + value="<?php echo esc_html( $value ); ?>">
4406 3815 </div>
4407 3816 <?php
4408 3817 }
4409 3818 $html = ob_get_clean();
@@ -4413,22 +3822,22 @@
4413 3822 }
4414 3823
4415 3824 public function form_input_register_gdpr( $html, $field, $value, $form_type ) {
4416 3825
4417 - $form_id = isset( $field->form_id ) ? (int) $field->form_id : 1;
4418 - $reg_gdpr = uwp_get_register_form_by( $form_id, 'gdpr_page' );
4419 - if ( empty( $reg_gdpr ) ) {
3826 + $form_id = isset($field->form_id) ? (int) $field->form_id : 1;
3827 + $reg_gdpr = uwp_get_register_form_by($form_id, 'gdpr_page');
3828 + if(empty($reg_gdpr)){
4420 3829 $reg_gdpr = uwp_get_option( 'register_gdpr_page', false );
4421 3830 }
4422 3831
4423 3832 if ( ! empty( $reg_gdpr ) ) {
4424 3833
4425 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4426 - $bs_form_group = $design_style ? 'form-group mb-3 form-check' : '';
4427 - $bs_form_control = $design_style ? 'form-check-input' : '';
3834 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3835 + $bs_form_group = $design_style ? "form-group mb-3 form-check" : "";
3836 + $bs_form_control = $design_style ? "form-check-input" : "";
4428 3837 $site_title = uwp_get_form_label( $field );
4429 3838 $field->htmlvar_name = 'register_gdpr';
4430 - $id = wp_doing_ajax() ? $field->htmlvar_name . '_ajax' : $field->htmlvar_name;
3839 + $id = wp_doing_ajax() ? $field->htmlvar_name . "_ajax" : $field->htmlvar_name;
4431 3840
4432 3841 $gdpr_page = get_permalink( $reg_gdpr );
4433 3842 $link_start = '<a href="' . esc_url( $gdpr_page ) . '" target="_blank">';
4434 3843 $link_end = '</a>';
@@ -4434,9 +3843,9 @@
4434 3843 $link_end = '</a>';
4435 3844 $field_desc = uwp_get_field_description( $field, '' );
4436 3845 $field_desc = str_replace( '%%link_start%%', $link_start, $field_desc );
4437 3846 $field_desc = str_replace( '%%link_end%%', $link_end, $field_desc );
4438 - $content = $field_desc ? $field_desc : sprintf( __( 'By using this form I agree to the storage and handling of my data by this website. View our %1$s %2$s %3$s.', 'userswp' ), '<a href="' . esc_url( $gdpr_page ) . '" target="_blank">', $site_title, '</a>' );
3847 + $content = $field_desc ? $field_desc : sprintf( __( 'By using this form I agree to the storage and handling of my data by this website. View our %s %s %s.', 'userswp' ), '<a href="' . esc_url( $gdpr_page ) . '" target="_blank">', $site_title, '</a>' );
4439 3848 $checked = $value == '1' ? true : false;
4440 3849
4441 3850 ob_start(); // Start buffering;
4442 3851
@@ -4446,19 +3855,19 @@
4446 3855 echo '<input type="hidden" name="' . esc_attr( $field->htmlvar_name ) . '" id="checkbox_' . esc_attr( $id ) . '" value="0"/>';
4447 3856
4448 3857 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4449 3858 array(
4450 - 'id' => esc_attr( $id ),
4451 - 'name' => esc_attr( $field->htmlvar_name ),
4452 - 'type' => 'checkbox',
4453 - 'value' => '1',
4454 - 'title' => esc_html( $site_title ),
4455 - 'label' => wp_kses_post( $content . $required ),
4456 - 'label_show' => true,
4457 - 'required' => ! empty( $field->is_required ) ? true : false,
4458 - 'checked' => (bool) $checked,
4459 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4460 - 'validation_text' => ! empty( $field->is_required ) ? esc_attr__( stripslashes( $field->required_msg ), 'userswp' ) : '',
3859 + 'id' => esc_attr( $id ),
3860 + 'name' => esc_attr( $field->htmlvar_name ),
3861 + 'type' => "checkbox",
3862 + 'value' => '1',
3863 + 'title' => esc_html( $site_title ),
3864 + 'label' => wp_kses_post( $content . $required ),
3865 + 'label_show' => true,
3866 + 'required' => ! empty( $field->is_required ) ? true : false,
3867 + 'checked' => (bool) $checked,
3868 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3869 + 'validation_text' => ! empty( $field->is_required ) ? esc_attr__( $field->required_msg, 'userswp' ) : '',
4461 3870 )
4462 3871 );
4463 3872
4464 3873 } else {
@@ -4463,33 +3872,27 @@
4463 3872
4464 3873 } else {
4465 3874 ?>
4466 3875 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4467 - class="
4468 - <?php
4469 - if ( $field->is_required ) {
4470 - echo 'required_field';
4471 - }
4472 - ?>
4473 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3876 + class="<?php if ( $field->is_required ) {
3877 + echo 'required_field';
3878 + } ?> uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
4474 3879 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value="0"/>
4475 3880 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4476 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
4477 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4478 - title="<?php echo esc_attr( $site_title ); ?>"
4479 - <?php
4480 - if ( $value == '1' ) {
3881 + class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3882 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3883 + title="<?php echo esc_attr( $site_title ); ?>"
3884 + <?php if ( $value == '1' ) {
4481 3885 echo 'checked="checked"';
4482 - }
4483 - ?>
4484 - type="<?php echo esc_attr( $field->field_type ); ?>"
4485 - value="1">
3886 + } ?>
3887 + type="<?php echo esc_attr( $field->field_type ); ?>"
3888 + value="1">
4486 3889 <?php
4487 3890 echo ( trim( $content ) ) ? wp_kses_post( $content ) : '&nbsp;';
4488 3891 ?>
4489 3892 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4490 3893 <?php if ( $field->is_required ) { ?>
4491 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
3894 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
4492 3895 <?php } ?>
4493 3896 </div>
4494 3897
4495 3898 <?php
@@ -4505,19 +3908,19 @@
4505 3908 }
4506 3909
4507 3910 public function form_input_register_tos( $html, $field, $value, $form_type ) {
4508 3911
4509 - $form_id = isset( $field->form_id ) ? (int) $field->form_id : 1;
4510 - $reg_tos = uwp_get_register_form_by( $form_id, 'tos_page' );
4511 - if ( empty( $reg_tos ) ) {
3912 + $form_id = isset($field->form_id) ? (int) $field->form_id : 1;
3913 + $reg_tos = uwp_get_register_form_by($form_id, 'tos_page');
3914 + if(empty($reg_tos)){
4512 3915 $reg_tos = uwp_get_option( 'register_terms_page', false );
4513 3916 }
4514 3917
4515 3918 if ( ! empty( $reg_tos ) ) {
4516 3919
4517 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4518 - $bs_form_group = $design_style ? 'form-group mb-3 form-check' : '';
4519 - $bs_form_control = $design_style ? 'form-check-input' : '';
3920 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3921 + $bs_form_group = $design_style ? "form-group mb-3 form-check" : "";
3922 + $bs_form_control = $design_style ? "form-check-input" : "";
4520 3923
4521 3924 $site_title = uwp_get_form_label( $field );
4522 3925 $terms_page = get_permalink( $reg_tos );
4523 3926 $link_start = '<a href="' . esc_url( $terms_page ) . '" target="_blank">';
@@ -4525,11 +3928,11 @@
4525 3928 $field_desc = uwp_get_field_description( $field, '' );
4526 3929 $field_desc = str_replace( '%%link_start%%', $link_start, $field_desc );
4527 3930 $field_desc = str_replace( '%%link_end%%', $link_end, $field_desc );
4528 3931 $field->htmlvar_name = 'register_tos';
4529 - $id = wp_doing_ajax() ? $field->htmlvar_name . '_ajax' : $field->htmlvar_name;
3932 + $id = wp_doing_ajax() ? $field->htmlvar_name . "_ajax" : $field->htmlvar_name;
4530 3933
4531 - $content = $field_desc ? $field_desc : sprintf( __( 'I accept the %1$s %2$s %3$s.', 'userswp' ), '<a href="' . esc_url( $terms_page ) . '" target="_blank">', $site_title, '</a>' );
3934 + $content = $field_desc ? $field_desc : sprintf( __( 'I accept the %s %s %s.', 'userswp' ), '<a href="' . esc_url( $terms_page ) . '" target="_blank">', $site_title, '</a>' );
4532 3935 $checked = $value == '1' ? true : false;
4533 3936
4534 3937 ob_start();
4535 3938
@@ -4538,19 +3941,19 @@
4538 3941 echo '<input type="hidden" name="' . esc_attr( $field->htmlvar_name ) . '" id="checkbox_' . esc_attr( $id ) . '" value="0"/>';
4539 3942
4540 3943 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4541 3944 array(
4542 - 'id' => esc_attr( $id ),
4543 - 'name' => esc_attr( $field->htmlvar_name ),
4544 - 'type' => 'checkbox',
4545 - 'value' => '1',
4546 - 'title' => esc_html( $site_title ),
4547 - 'label' => wp_kses_post( $content . $required ),
4548 - 'label_show' => true,
4549 - 'required' => ! empty( $field->is_required ) ? true : false,
4550 - 'checked' => (bool) $checked,
4551 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4552 - 'validation_text' => ! empty( $field->is_required ) ? esc_attr__( stripslashes( $field->required_msg ), 'userswp' ) : '',
3945 + 'id' => esc_attr( $id ),
3946 + 'name' => esc_attr( $field->htmlvar_name ),
3947 + 'type' => "checkbox",
3948 + 'value' => '1',
3949 + 'title' => esc_html( $site_title ),
3950 + 'label' => wp_kses_post( $content . $required ),
3951 + 'label_show' => true,
3952 + 'required' => ! empty( $field->is_required ) ? true : false,
3953 + 'checked' => (bool) $checked,
3954 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3955 + 'validation_text' => ! empty( $field->is_required ) ? esc_attr__( $field->required_msg, 'userswp' ) : '',
4553 3956 )
4554 3957 );
4555 3958
4556 3959 } else {
@@ -4555,33 +3958,27 @@
4555 3958
4556 3959 } else {
4557 3960 ?>
4558 3961 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4559 - class="
4560 - <?php
4561 - if ( $field->is_required ) {
4562 - echo 'required_field';
4563 - }
4564 - ?>
4565 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3962 + class="<?php if ( $field->is_required ) {
3963 + echo 'required_field';
3964 + } ?> uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
4566 3965 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value="0"/>
4567 3966 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4568 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
4569 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4570 - title="<?php echo esc_attr( $site_title ); ?>"
4571 - <?php
4572 - if ( $value == '1' ) {
3967 + class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3968 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3969 + title="<?php echo esc_attr( $site_title ); ?>"
3970 + <?php if ( $value == '1' ) {
4573 3971 echo 'checked="checked"';
4574 - }
4575 - ?>
4576 - type="<?php echo esc_attr( $field->field_type ); ?>"
4577 - value="1">
3972 + } ?>
3973 + type="<?php echo esc_attr( $field->field_type ); ?>"
3974 + value="1">
4578 3975 <?php
4579 3976 echo ( trim( $content ) ) ? wp_kses_post( $content ) : '&nbsp;';
4580 3977 ?>
4581 3978 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4582 3979 <?php if ( $field->is_required ) { ?>
4583 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
3980 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
4584 3981 <?php } ?>
4585 3982 </div>
4586 3983
4587 3984 <?php
@@ -4607,9 +4004,9 @@
4607 4004 */
4608 4005 function add_multipart_to_admin_edit_form() {
4609 4006 global $wpdb;
4610 4007 $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
4611 - $fields = $wpdb->get_results( 'SELECT * FROM ' . $table_name . " WHERE form_type = 'account' AND field_type = 'file' AND is_default = '0' ORDER BY sort_order ASC" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
4008 + $fields = $wpdb->get_results( "SELECT * FROM " . $table_name . " WHERE form_type = 'account' AND field_type = 'file' AND is_default = '0' ORDER BY sort_order ASC" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
4612 4009 if ( $fields ) {
4613 4010 echo 'enctype="multipart/form-data"';
4614 4011 }
4615 4012 }
@@ -4628,12 +4025,12 @@
4628 4025 global $wpdb;
4629 4026 $file_obj = new UsersWP_Files();
4630 4027 $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
4631 4028 //Normal fields
4632 - $fields = $wpdb->get_results( 'SELECT * FROM ' . $table_name . " WHERE form_type = 'account' AND field_type != 'file' AND field_type != 'fieldset' ORDER BY sort_order ASC" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
4029 + $fields = $wpdb->get_results( "SELECT * FROM " . $table_name . " WHERE form_type = 'account' AND field_type != 'file' AND field_type != 'fieldset' ORDER BY sort_order ASC" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
4633 4030 if ( $fields ) {
4634 - if ( isset( $_POST['locale'] ) ) {
4635 - $_POST['uwp_language'] = sanitize_text_field( $_POST['locale'] );
4031 + if(isset($_POST['locale'])){
4032 + $_POST['uwp_language'] = sanitize_text_field($_POST['locale']);
4636 4033 }
4637 4034 $result = uwp_validate_fields( $_POST, 'account', $fields );
4638 4035 if ( is_wp_error( $result ) ) {
4639 4036 die( wp_kses_post( $result->get_error_message() ) );
@@ -4639,13 +4036,15 @@
4639 4036 die( wp_kses_post( $result->get_error_message() ) );
4640 4037 }
4641 4038 if ( isset( $result['display_name'] ) && ! empty( $result['display_name'] ) ) {
4642 4039 $display_name = $result['display_name'];
4643 - } elseif ( ! empty( $first_name ) || ! empty( $last_name ) ) {
4040 + } else {
4041 + if ( ! empty( $first_name ) || ! empty( $last_name ) ) {
4644 4042 $display_name = $result['first_name'] . ' ' . $result['last_name'];
4645 4043 } else {
4646 - $user_info = get_userdata( $user_id );
4647 - $display_name = $user_info->user_login;
4044 + $user_info = get_userdata( $user_id );
4045 + $display_name = $user_info->user_login;
4046 + }
4648 4047 }
4649 4048 $result['display_name'] = $display_name;
4650 4049 if ( ! is_wp_error( $result ) ) {
4651 4050 foreach ( $fields as $field ) {
@@ -4657,14 +4056,14 @@
4657 4056 }
4658 4057 }
4659 4058
4660 4059 //File fields
4661 - $fields = $wpdb->get_results( 'SELECT * FROM ' . $table_name . " WHERE form_type = 'account' AND field_type = 'file' AND is_default = '0' ORDER BY sort_order ASC" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
4060 + $fields = $wpdb->get_results( "SELECT * FROM " . $table_name . " WHERE form_type = 'account' AND field_type = 'file' AND is_default = '0' ORDER BY sort_order ASC" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
4662 4061 if ( $fields ) {
4663 4062 $result = $file_obj->validate_uploads( $_FILES, 'account', true, $fields );
4664 4063 if ( ! is_wp_error( $result ) ) {
4665 4064 foreach ( $fields as $field ) {
4666 - $value = isset( $result[ $field->htmlvar_name ] ) ? $result[ $field->htmlvar_name ] : '';
4065 + $value = $result[ $field->htmlvar_name ];
4667 4066 if ( $value == '0' || ! empty( $value ) ) {
4668 4067 uwp_update_usermeta( $user_id, $field->htmlvar_name, $value );
4669 4068 }
4670 4069 }
@@ -4689,29 +4088,27 @@
4689 4088
4690 4089 // If no html then we run the standard output.
4691 4090 if ( empty( $html ) ) {
4692 4091
4693 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4694 - $bs_form_group = $design_style ? 'form-group m-0' : ''; // country wrapper div added by JS adds margin so we remove ours
4695 - $bs_sr_only = $design_style ? 'sr-only' : '';
4696 - $bs_form_control = $design_style ? 'form-control' : '';
4092 + $design_style = uwp_get_option( "design_style", "bootstrap" );
4093 + $bs_form_group = $design_style ? "form-group m-0" : ""; // country wrapper div added by JS adds marginso we remove ours
4094 + $bs_sr_only = $design_style ? "sr-only" : "";
4095 + $bs_form_control = $design_style ? "form-control" : "";
4697 4096
4698 4097 ob_start(); // Start buffering;
4699 4098 ?>
4700 - <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row" class="<?php echo ( $field->is_required ? 'required_field' : '' ); ?> uwp_clear <?php echo esc_attr( $bs_form_group . ' ' . $field->css_class ); ?>">
4099 + <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row" class="<?php echo ( $field->is_required ? 'required_field' : '' ); ?> uwp_clear <?php echo esc_attr( $bs_form_group. ' ' . $field->css_class ); ?>">
4701 4100
4702 4101 <?php
4703 4102 $site_title = uwp_get_form_label( $field );
4704 4103
4705 - if ( ! is_admin() && ! wp_doing_ajax() ) {
4104 + if ( ! is_admin() && !wp_doing_ajax() ) {
4706 4105 ?>
4707 4106 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4708 4107 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4709 - <?php
4710 - if ( $field->is_required ) {
4108 + <?php if ( $field->is_required ) {
4711 4109 echo '<span class="text-danger">*</span>';
4712 - }
4713 - ?>
4110 + } ?>
4714 4111 </label>
4715 4112 <?php
4716 4113 }
4717 4114 // if value empty set the default
@@ -4733,9 +4130,9 @@
4733 4130 <input type="hidden" id="<?php echo esc_attr( $htmlvar_name ); ?>_code" name="<?php echo esc_attr( $field->htmlvar_name ); ?>"/>
4734 4131 <script>jQuery(function(){jQuery("#<?php echo esc_js( $htmlvar_name ); ?>").countrySelect(<?php echo wp_json_encode( json_decode( $select_country_options ) ); ?>);});</script>
4735 4132 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4736 4133 <?php if ( $field->is_required ) { ?>
4737 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
4134 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
4738 4135 <?php } ?>
4739 4136 </div>
4740 4137 <?php
4741 4138 $html = ob_get_clean();
@@ -4761,38 +4158,31 @@
4761 4158
4762 4159 // If no html then we run the standard output.
4763 4160 if ( empty( $html ) ) {
4764 4161
4765 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4766 - $bs_form_group = $design_style ? 'form-group m-0' : '';
4767 - $bs_sr_only = $design_style ? 'sr-only' : '';
4768 - $bs_form_control = $design_style ? 'form-control' : '';
4769 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4770 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
4162 + $design_style = uwp_get_option( "design_style", "bootstrap" );
4163 + $bs_form_group = $design_style ? "form-group m-0" : "";
4164 + $bs_sr_only = $design_style ? "sr-only" : "";
4165 + $bs_form_control = $design_style ? "form-control" : "";
4166 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
4167 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
4771 4168
4772 4169 ob_start(); // Start buffering;
4773 4170
4774 4171 ?>
4775 - <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4776 - class="
4777 - <?php
4778 - if ( $field->is_required ) {
4779 - echo 'required_field';
4780 - }
4781 - ?>
4782 - uwp_clear <?php echo esc_attr( $bs_form_group . ' ' . $field->css_class ); ?>">
4172 + <div id="<?php echo esc_attr($field->htmlvar_name); ?>_row"
4173 + class="<?php if ( $field->is_required ) {
4174 + echo 'required_field';
4175 + } ?> uwp_clear <?php echo esc_attr( $bs_form_group. ' '.$field->css_class ); ?>">
4783 4176
4784 4177 <?php
4785 4178 $site_title = uwp_get_form_label( $field );
4786 - if ( ! is_admin() && ! wp_doing_ajax() ) {
4787 - ?>
4179 + if ( ! is_admin() && !wp_doing_ajax() ) { ?>
4788 4180 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4789 4181 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4790 - <?php
4791 - if ( $field->is_required ) {
4182 + <?php if ( $field->is_required ) {
4792 4183 echo '<span class="text-danger">*</span>';
4793 - }
4794 - ?>
4184 + } ?>
4795 4185 </label>
4796 4186 <?php } ?>
4797 4187
4798 4188 <?php
@@ -4807,43 +4197,41 @@
4807 4197
4808 4198 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
4809 4199 $translations = wp_get_available_translations();
4810 4200 $available_languages = get_available_languages();
4811 - $languages = array( 'site-default' => __( 'Site Default', 'userswp' ) );
4201 + $languages = array('site-default' => __( 'Site Default', 'userswp' ));
4812 4202
4813 4203 foreach ( $available_languages as $locale ) {
4814 4204 if ( isset( $translations[ $locale ] ) ) {
4815 4205 $translation = $translations[ $locale ];
4816 - $languages[ $translation['language'] ] = $translation['native_name'];
4206 + $languages[$translation['language']] = $translation['native_name'];
4817 4207
4818 4208 // Remove installed language from available translations.
4819 4209 unset( $translations[ $locale ] );
4820 4210 } else {
4821 - $languages[ $locale ] = $translation[ $locale ];
4211 + $languages[$locale] = $translation[$locale];
4822 4212 }
4823 4213 }
4824 4214
4825 4215 if ( $design_style ) {
4826 4216
4827 - $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4217 + $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4828 4218
4829 - echo aui()->select(
4830 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4831 - 'id' => esc_attr( $field->htmlvar_name ),
4832 - 'name' => esc_attr( $field->htmlvar_name ),
4833 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4834 - 'title' => esc_attr( $site_title ),
4835 - 'value' => esc_attr( $value ),
4836 - 'required' => (bool) $field->is_required,
4837 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4838 - 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4839 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4840 - 'label' => wp_kses_post( $site_title . $required ),
4841 - 'options' => $languages, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4842 - 'select2' => true,
4843 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4844 - )
4845 - );
4219 + echo aui()->select( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4220 + 'id' => esc_attr( $field->htmlvar_name ),
4221 + 'name' => esc_attr( $field->htmlvar_name ),
4222 + 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4223 + 'title' => esc_attr( $site_title ),
4224 + 'value' => esc_attr( $value ),
4225 + 'required' => (bool) $field->is_required,
4226 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4227 + 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4228 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4229 + 'label' => wp_kses_post( $site_title . $required ),
4230 + 'options' => $languages, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4231 + 'select2' => true,
4232 + 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4233 + ) );
4846 4234 } else {
4847 4235 ?>
4848 4236 <select name="<?php echo esc_attr( $field->htmlvar_name ); ?>" id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4849 4237 class="uwp_textfield aui-select2 <?php echo esc_attr( $bs_form_control ); ?>"
@@ -4851,14 +4239,14 @@
4851 4239 data-placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4852 4240 ><?php echo $select_options; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
4853 4241 </select>
4854 4242 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4855 - <?php if ( $field->is_required ) { ?>
4856 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
4857 - <?php
4858 - }
4243 + <?php if ( $field->is_required ) { ?>
4244 + <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( $field->required_msg, 'userswp' ); ?></span>
4245 + <?php }
4859 4246 }
4860 4247
4248 +
4861 4249 $html = ob_get_clean();
4862 4250 }
4863 4251
4864 4252 return $html;
@@ -4887,58 +4275,53 @@
4887 4275
4888 4276 $enable_confirm_password_field = isset( $extra['confirm_password'] ) ? $extra['confirm_password'] : '0';
4889 4277 if ( $enable_confirm_password_field == '1' ) {
4890 4278
4891 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4892 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4893 - $bs_sr_only = $design_style ? 'sr-only' : '';
4894 - $bs_form_control = $design_style ? 'form-control' : '';
4895 - $site_title = $placeholder = __( 'Confirm Password', 'userswp' );
4279 + $design_style = uwp_get_option( "design_style", "bootstrap" );
4280 + $bs_form_group = $design_style ? "form-group mb-3" : "";
4281 + $bs_sr_only = $design_style ? "sr-only" : "";
4282 + $bs_form_control = $design_style ? "form-control" : "";
4283 + $site_title = $placeholder = __( "Confirm Password", 'userswp' );
4896 4284 $required = '';
4897 4285 if ( isset( $field->is_required ) && ! empty( $field->is_required ) ) {
4898 4286 $placeholder .= ' *';
4899 4287 $required = ' <span class="text-danger">*</span>';
4900 4288 }
4901 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4902 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
4903 - $wrap_class = isset( $field->css_class ) ? $field->css_class . ' uwp-password-wrap' : 'uwp-password-wrap';
4289 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
4290 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
4291 + $wrap_class = isset( $field->css_class ) ? $field->css_class.' uwp-password-wrap' : 'uwp-password-wrap';
4904 4292
4905 4293 ob_start(); // Start buffering;
4906 4294
4907 4295 if ( $design_style ) {
4908 4296
4909 - echo aui()->input(
4910 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4911 - 'type' => 'password',
4912 - 'id' => 'confirm_password',
4913 - 'name' => 'confirm_password',
4914 - 'placeholder' => esc_attr( $placeholder ),
4915 - 'title' => esc_attr( $site_title ),
4916 - 'value' => esc_attr( $value ),
4917 - 'required' => (bool) $field->is_required,
4918 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4919 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4920 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4297 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4298 + 'type' => 'password',
4299 + 'id' => 'confirm_password',
4300 + 'name' => 'confirm_password',
4301 + 'placeholder' => esc_attr( $placeholder ),
4302 + 'title' => esc_attr( $site_title ),
4303 + 'value' => esc_attr( $value ),
4304 + 'required' => (bool) $field->is_required,
4305 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4306 + 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4307 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4921 4308 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4922 - 'wrap_class' => esc_attr( $wrap_class ),
4923 - )
4924 - );
4309 + 'wrap_class' => esc_attr( $wrap_class ),
4310 + ) );
4925 4311 } else {
4926 4312 ?>
4927 4313 <div id="uwp_account_confirm_password_row"
4928 - class="<?php echo 'required_field'; ?> uwp_form_password_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
4314 + class="<?php echo 'required_field'; ?> uwp_form_password_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
4929 4315
4930 4316 <?php
4931 4317
4932 - if ( ! is_admin() ) {
4933 - ?>
4318 + if ( ! is_admin() ) { ?>
4934 4319 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4935 4320 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4936 - <?php
4937 - if ( $field->is_required ) {
4321 + <?php if ( $field->is_required ) {
4938 4322 echo '<span>*</span>';
4939 - }
4940 - ?>
4323 + } ?>
4941 4324 </label>
4942 4325 <?php } ?>
4943 4326 <input name="confirm_password" class="uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>" id="uwp_account_confirm_password" placeholder="<?php echo esc_attr( $placeholder ); ?>" value="" title="<?php echo esc_attr( $site_title ); ?>" <?php echo 'required="required"'; ?> type="password"/>
4944 4327 </div>
@@ -4975,15 +4358,15 @@
4975 4358 }
4976 4359 $enable_confirm_email_field = isset( $extra['confirm_email'] ) ? $extra['confirm_email'] : '0';
4977 4360 if ( $enable_confirm_email_field == '1' ) {
4978 4361
4979 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4980 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4981 - $bs_sr_only = $design_style ? 'sr-only' : '';
4982 - $bs_form_control = $design_style ? 'form-control' : '';
4983 - $site_title = __( 'Confirm Email', 'userswp' );
4984 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4985 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
4362 + $design_style = uwp_get_option( "design_style", "bootstrap" );
4363 + $bs_form_group = $design_style ? "form-group mb-3" : "";
4364 + $bs_sr_only = $design_style ? "sr-only" : "";
4365 + $bs_form_control = $design_style ? "form-control" : "";
4366 + $site_title = __( "Confirm Email", 'userswp' );
4367 + $required_msg = (!empty( $field->is_required ) && $field->required_msg != '') ? __( $field->required_msg, 'userswp' ) : '';
4368 + $validation_text = !empty($field->validation_msg) ? __($field->validation_msg, 'userswp') : '';
4986 4369
4987 4370 ob_start();
4988 4371
4989 4372 if ( $design_style ) {
@@ -4988,50 +4371,45 @@
4988 4371
4989 4372 if ( $design_style ) {
4990 4373 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4991 4374
4992 - echo aui()->input(
4993 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4994 - 'type' => 'email',
4995 - 'id' => esc_attr( $field->htmlvar_name ),
4996 - 'name' => 'confirm_email',
4997 - 'placeholder' => esc_attr( $site_title ),
4998 - 'title' => esc_attr( $site_title ),
4999 - 'value' => esc_attr( $value ),
5000 - 'required' => (bool) $field->is_required,
5001 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
5002 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
5003 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4375 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4376 + 'type' => 'email',
4377 + 'id' => esc_attr( $field->htmlvar_name ),
4378 + 'name' => 'confirm_email',
4379 + 'placeholder' => esc_attr( $site_title ),
4380 + 'title' => esc_attr( $site_title ),
4381 + 'value' => esc_attr( $value ),
4382 + 'required' => (bool) $field->is_required,
4383 + 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4384 + 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4385 + 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
5004 4386 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
5005 - )
5006 - );
4387 + ) );
5007 4388 } else {
5008 4389 ?>
5009 4390 <div id="uwp_account_confirm_email_row"
5010 - class="<?php echo 'required_field'; ?> uwp_form_email_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
4391 + class="<?php echo 'required_field'; ?> uwp_form_email_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
5011 4392
5012 4393 <?php
5013 4394
5014 - if ( ! is_admin() ) {
5015 - ?>
4395 + if ( ! is_admin() ) { ?>
5016 4396 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
5017 4397 <?php echo ( trim( $site_title ) ) ? esc_attr( $site_title ) : '&nbsp;'; ?>
5018 - <?php
5019 - if ( $field->is_required ) {
4398 + <?php if ( $field->is_required ) {
5020 4399 echo '<span>*</span>';
5021 - }
5022 - ?>
4400 + } ?>
5023 4401 </label>
5024 4402 <?php } ?>
5025 4403
5026 4404 <input name="confirm_email"
5027 - class="uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
5028 - id="uwp_account_confirm_email"
5029 - placeholder="<?php echo esc_attr( $site_title ); ?>"
5030 - value=""
5031 - title="<?php echo esc_attr( $site_title ); ?>"
4405 + class="uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
4406 + id="uwp_account_confirm_email"
4407 + placeholder="<?php echo esc_attr( $site_title ); ?>"
4408 + value=""
4409 + title="<?php echo esc_attr( $site_title ); ?>"
5032 4410 <?php echo 'required="required"'; ?>
5033 - type="email"
4411 + type="email"
5034 4412 />
5035 4413 </div>
5036 4414 <?php
5037 4415 }
@@ -5082,10 +4460,12 @@
5082 4460 if ( $field_value == 'no' ) {
5083 4461 if ( ! in_array( $field_name, $public_fields ) ) {
5084 4462 $public_fields[] = $field_name;
5085 4463 }
5086 - } elseif ( ( $field_name = array_search( $field_name, $public_fields ) ) !== false ) {
4464 + } else {
4465 + if ( ( $field_name = array_search( $field_name, $public_fields ) ) !== false ) {
5087 4466 unset( $public_fields[ $field_name ] );
4467 + }
5088 4468 }
5089 4469 }
5090 4470
5091 4471 $value = implode( ',', $public_fields );
@@ -5093,9 +4473,9 @@
5093 4473 }
5094 4474
5095 4475 // Save tabs privacy settings
5096 4476 $tabs_table_name = uwp_get_table_prefix() . 'uwp_profile_tabs';
5097 - $tabs = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $tabs_table_name . ' WHERE form_type=%s AND user_decided = 1 ORDER BY sort_order ASC', 'profile-tabs' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
4477 + $tabs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $tabs_table_name . " WHERE form_type=%s AND user_decided = 1 ORDER BY sort_order ASC", 'profile-tabs' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
5098 4478
5099 4479 if ( $tabs ) {
5100 4480 $public_fields = maybe_unserialize( $user_meta_info->tabs_privacy );
5101 4481 $do_tabs_update = false;
@@ -5111,10 +4491,11 @@
5111 4491 } else {
5112 4492 $public_fields[ $field_name ] = $field_value;
5113 4493 }
5114 4494 }
5115 -}
5116 4495
4496 + }
4497 +
5117 4498 if ( $do_tabs_update ) {
5118 4499 uwp_update_usermeta( $user_id, 'tabs_privacy', maybe_serialize( $public_fields ) );
5119 4500 }
5120 4501 }
@@ -5135,13 +4516,12 @@
5135 4516 }
5136 4517 }
5137 4518
5138 4519 $message = apply_filters( 'uwp_privacy_update_success_message', __( 'Privacy settings updated successfully.', 'userswp' ) );
5139 - $message = aui()->alert(
5140 - array(
4520 + $message = aui()->alert( array(
5141 4521 'type' => 'success',
5142 - 'content' => $message,
5143 - )
4522 + 'content' => $message
4523 + )
5144 4524 );
5145 4525 $uwp_notices[] = array( 'account' => $message );
5146 4526
5147 4527 }
@@ -5157,18 +4537,18 @@
5157 4537 // add the modal error container
5158 4538 add_action( 'uwp_template_display_notices', array( $this, 'modal_error_container' ) );
5159 4539
5160 4540 $args = array(
5161 - 'form_title' => __( 'Login', 'userswp' ),
4541 + 'form_title' => __('Login','userswp'),
5162 4542 );
5163 4543
5164 4544 // get the form
5165 4545 ob_start();
5166 - uwp_get_template( 'bootstrap/login.php', $args );
4546 + uwp_get_template( "bootstrap/login.php", $args );
5167 4547 $form = ob_get_clean();
5168 4548
5169 4549 // bs5
5170 - if ( function_exists( 'aui_bs_convert_sd_output' ) ) {
4550 + if( function_exists('aui_bs_convert_sd_output')){
5171 4551 $form = aui_bs_convert_sd_output( $form );
5172 4552 }
5173 4553 // send ajax response
5174 4554 wp_send_json_success( $form );
@@ -5190,19 +4570,16 @@
5190 4570 }
5191 4571
5192 4572 // do we need country code script in ajax?
5193 4573 $country_field = false;
5194 - $lightbox_forms = uwp_get_option( 'register_modal_form', 1 );
5195 4574
5196 - if ( isset( $_POST['form_id'] ) && ! empty( $_POST['form_id'] ) ) {
4575 + if(isset($_POST['form_id']) && !empty($_POST['form_id'])){
5197 4576 $form_id = (int)$_POST['form_id'];
5198 - } elseif ( is_array( $lightbox_forms ) && count( $lightbox_forms ) > 0 ) {
5199 - $form_id = reset( $lightbox_forms );
5200 4577 } else {
5201 4578 $form_id = 1;
5202 4579 }
5203 4580
5204 - $fields = get_register_form_fields( $form_id );
4581 + $fields = get_register_form_fields($form_id);
5205 4582 if ( ! empty( $fields ) ) {
5206 4583 foreach ( $fields as $field ) {
5207 4584 if ( $field->field_type_key == 'country' || $field->field_type_key == 'uwp_country' ) {
5208 4585 $country_field = true;
@@ -5214,22 +4591,23 @@
5214 4591
5215 4592 // maybe add country code JS
5216 4593 if ( $country_field ) {
5217 4594 $country_data = uwp_get_country_data();
5218 - echo '<script>var uwp_country_data = ' . json_encode( $country_data ) . '</script>';
4595 + echo "<script>var uwp_country_data = " . json_encode( $country_data ) . "</script>";
5219 4596 echo "<script type='text/javascript' src='" . esc_url( USERSWP_PLUGIN_URL ) . 'assets/js/countrySelect.min.js' . "' ></script>";
5220 4597 }
5221 4598
5222 - $args = array( 'form_title' => '' );
5223 - if ( $form_id > 0 ) {
4599 + $args = array('form_title' => '');
4600 + if($form_id > 0){
5224 4601 $args['id'] = $form_id;
5225 4602 }
5226 4603
5227 - $args['limit'] = $lightbox_forms;
4604 + $args['limit'] = uwp_get_option('register_modal_form', 1);
5228 4605
5229 4606 // get template
5230 - uwp_get_template( 'bootstrap/register.php', $args );
4607 + uwp_get_template( "bootstrap/register.php", $args );
5231 4608
4609 +
5232 4610 // only show the JS if NOT doing a block render
5233 4611 if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] != 'super_duper_output_shortcode' ) {
5234 4612 // load scripts
5235 4613 $wp_scripts->do_item( 'zxcvbn-async' );
@@ -5255,13 +4633,13 @@
5255 4633 function (event) {
5256 4634 var $form = $(this).closest('form');
5257 4635 if( ! $form.hasClass('uwp-login-form') ) {
5258 4636 uwp_checkPasswordStrength(
5259 - $form.find('input[name=password]'),
5260 - $form.find('input[name=confirm_password]'),
5261 - $form.find('#uwp-password-strength'),
5262 - $form.find('button[type="submit"], input[type="submit"]'),
5263 - ['black', 'listed', 'word']
4637 + $('input[name=password]', $form), // First password field
4638 + $('input[name=confirm_password]', $form), // Second password field
4639 + $('#uwp-password-strength', $form), // Strength meter
4640 + $('input[type=submit]', $form), // Submit button
4641 + ['black', 'listed', 'word'] // Blacklisted words
5264 4642 );
5265 4643 }
5266 4644 }
5267 4645 );
@@ -5271,9 +4649,9 @@
5271 4649 }
5272 4650 $form = ob_get_clean();
5273 4651
5274 4652 // bs5
5275 - if ( function_exists( 'aui_bs_convert_sd_output' ) ) {
4653 + if( function_exists('aui_bs_convert_sd_output')){
5276 4654 $form = aui_bs_convert_sd_output( $form );
5277 4655 }
5278 4656
5279 4657 // send ajax response
@@ -5288,19 +4666,16 @@
5288 4666 public function ajax_forgot_password_form() {
5289 4667
5290 4668 // add the modal error container
5291 4669 add_action( 'uwp_template_display_notices', array( $this, 'modal_error_container' ) );
5292 - $args = array(
5293 - 'form_title' => '',
5294 - 'css_class' => ''
5295 - );
4670 +
5296 4671 // get the form
5297 4672 ob_start();
5298 - uwp_get_template( 'bootstrap/forgot.php', $args );
4673 + uwp_get_template( "bootstrap/forgot.php" );
5299 4674 $form = ob_get_clean();
5300 4675
5301 4676 // bs5
5302 - if ( function_exists( 'aui_bs_convert_sd_output' ) ) {
4677 + if( function_exists('aui_bs_convert_sd_output')){
5303 4678 $form = aui_bs_convert_sd_output( $form );
5304 4679 }
5305 4680
5306 4681 // send ajax response
@@ -5323,5 +4698,5 @@
5323 4698 $html = ! empty( $field->default_value ) ? $field->default_value : ' ';
5324 4699
5325 4700 return $html;
5326 4701 }
5327 -}
4702 +}