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 +1118 -1554 1.2.711.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,58 +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 1189 if ( is_wp_error( $user ) ) {
1221 - $message = aui()->alert(
1222 - array(
1190 + $message = aui()->alert( array(
1223 1191 'type' => 'error',
1224 - 'content' => $user->get_error_message(),
1225 - )
1192 + 'content' => $user->get_error_message()
1193 + )
1226 1194 );
1227 1195 if ( wp_doing_ajax() ) {
1228 - wp_send_json_error( array( 'message' => $message ) );
1196 + wp_send_json_error( array( 'message' => $message) );
1229 1197 } else {
1230 1198 $uwp_notices[] = array( 'login' => $message );
1231 1199
1232 1200 return;
@@ -1232,31 +1200,27 @@
1232 1200 return;
1233 1201 }
1234 1202 } else {
1235 1203 do_action( 'uwp_after_process_login', $data );
1236 - $message = aui()->alert(
1237 - array(
1204 + $message = aui()->alert( array(
1238 1205 'type' => 'success',
1239 - 'content' => __( 'Login successful. Redirecting...', 'userswp' ),
1240 - )
1206 + 'content' => __( 'Login successful. Redirecting...', 'userswp' )
1207 + )
1241 1208 );
1242 1209 if ( wp_doing_ajax() ) {
1243 1210 $redirect_to = '';
1244 - if ( 1 == uwp_get_option( 'login_modal_enable_redirect' ) ) {
1211 + if(1 == uwp_get_option('login_modal_enable_redirect')){
1245 1212 $redirect_to = $this->get_login_redirect_url( $data, $user );
1246 1213 }
1247 - wp_send_json_success(
1248 - array(
1249 - 'message' => $message,
1250 - 'redirect' => $redirect_to,
1251 - )
1252 - );
1214 + wp_send_json_success( array( 'message' => $message, 'redirect' => $redirect_to ) );
1253 1215 } else {
1254 1216 $redirect_to = $this->get_login_redirect_url( $data, $user );
1255 1217 wp_safe_redirect( $redirect_to );
1256 1218 exit();
1257 1219 }
1258 -}
1220 +
1221 + }
1222 +
1259 1223 }
1260 1224
1261 1225 public function check_2fa( $user ) {
1262 1226 if ( 1 == uwp_get_option( 'disable_wp_2fa' ) ) {
@@ -1285,12 +1249,9 @@
1285 1249
1286 1250 return $errors;
1287 1251 }
1288 1252
1289 - $provider = $this->get_wp2fa_provider_for_user( $user );
1290 - if ( empty( $provider ) ) {
1291 - return;
1292 - }
1253 + $provider = \WP2FA\Authenticator\Login::get_available_providers_for_user( $user );
1293 1254
1294 1255 ob_start();
1295 1256 ?>
1296 1257
@@ -1295,13 +1256,13 @@
1295 1256 ?>
1296 1257
1297 1258 <div class="uwp-2fa-methods-wrap">
1298 1259 <form name="validate_2fa_form" id="validate_2fa_form" class="validate_2fa_form" action="" method="post"
1299 - autocomplete="off">
1260 + autocomplete="off">
1300 1261 <input type="hidden" name="provider" id="provider" value="<?php echo esc_attr( $provider ); ?>"/>
1301 1262 <input type="hidden" name="uwp-auth-id" id="uwp-auth-id" value="<?php echo esc_attr( $user->ID ); ?>"/>
1302 1263 <input type="hidden" name="wp-auth-nonce" id="wp-auth-nonce"
1303 - value="<?php echo esc_attr( $login_nonce['key'] ); ?>"/>
1264 + value="<?php echo esc_attr( $login_nonce['key'] ); ?>"/>
1304 1265 <?php
1305 1266
1306 1267 // Check to see what provider is set and give the relevant authentication page.
1307 1268 if ( 'totp' === $provider ) {
@@ -1308,10 +1269,9 @@
1308 1269 ?>
1309 1270 <p><?php esc_html_e( 'Please enter the authentication code from your 2FA authentication app below to login:', 'userswp' ); ?></p>
1310 1271 <?php
1311 1272
1312 - echo aui()->input(
1313 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1273 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1314 1274 'type' => 'tel',
1315 1275 'id' => 'authcode',
1316 1276 'name' => 'authcode',
1317 1277 'placeholder' => esc_attr__( 'Authentication Code', 'userswp' ),
@@ -1316,20 +1276,17 @@
1316 1276 'name' => 'authcode',
1317 1277 'placeholder' => esc_attr__( 'Authentication Code', 'userswp' ),
1318 1278 'value' => '',
1319 1279 'label' => esc_html__( 'Authentication Code', 'userswp' ),
1320 - )
1321 - );
1280 + ) );
1322 1281
1323 - echo aui()->button(
1324 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1282 + echo aui()->button( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1325 1283 'type' => 'submit',
1326 1284 'class' => 'btn btn-primary btn-block text-uppercase uwp-2fa-submit',
1327 1285 'name' => 'submit',
1328 1286 'icon' => '',
1329 1287 'content' => esc_html__( 'Log In', 'userswp' ),
1330 - )
1331 - );
1288 + ) );
1332 1289
1333 1290 } elseif ( 'email' === $provider ) {
1334 1291 $has_token = \WP2FA\Authenticator\Authentication::user_has_token( $user->ID );
1335 1292 if ( empty( $has_token ) || ! $has_token ) {
@@ -1337,42 +1294,33 @@
1337 1294 }
1338 1295 ?>
1339 1296 <p><?php esc_html_e( 'Please enter the 2FA verification code sent to your email address to login:', 'userswp' ); ?></p>
1340 1297 <?php
1341 - echo aui()->input(
1342 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1298 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1343 1299 'type' => 'tel',
1344 1300 'id' => 'authcode',
1345 - 'name' => 'authcode',
1301 + 'name' => 'wp-2fa-email-code',
1346 1302 'placeholder' => esc_attr__( 'Verification Code', 'userswp' ),
1347 1303 'value' => '',
1348 1304 'label' => esc_html__( 'Verification Code', 'userswp' ),
1349 - 'extra_attributes' => array(
1350 - 'size' => 20,
1351 - 'pattern' => '[0-9]*',
1352 - ),
1353 - )
1354 - );
1305 + 'extra_attributes' => array( 'size' => 20, 'pattern' => "[0-9]*" ),
1306 + ) );
1355 1307
1356 - echo aui()->button(
1357 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1308 + echo aui()->button( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1358 1309 'type' => 'submit',
1359 1310 'class' => 'btn btn-primary text-uppercase uwp-2fa-submit',
1360 1311 'name' => 'submit',
1361 1312 'icon' => '',
1362 1313 'content' => esc_html__( 'Log In', 'userswp' ),
1363 - )
1364 - );
1314 + ) );
1365 1315
1366 - echo aui()->button(
1367 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1316 + echo aui()->button( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1368 1317 'type' => 'button',
1369 1318 'class' => 'btn btn-secondary text-uppercase uwp-2fa-email-resend',
1370 1319 'name' => 'wp-2fa-email-code-resend',
1371 1320 'icon' => '',
1372 1321 'content' => esc_html__( 'Resend Code', 'userswp' ),
1373 - )
1374 - );
1322 + ) );
1375 1323
1376 1324 }
1377 1325 ?>
1378 1326 </form>
@@ -1378,23 +1326,22 @@
1378 1326 </form>
1379 1327 </div>
1380 1328
1381 1329 <?php
1382 - $codes_remaining = $this->get_wp2fa_backup_codes_remaining( $user );
1330 + $codes_remaining = \WP2FA\Authenticator\Backup_Codes::codes_remaining_for_user( $user );
1383 1331 if ( isset( $codes_remaining ) && $codes_remaining > 0 ) {
1384 1332 ?>
1385 1333 <div class="uwp-2fa-methods-wrap" style="display:none;">
1386 1334 <form name="validate_2fa_backup_codes_form" id="validate_2fa_backup_codes_form"
1387 - class="validate_2fa_backup_codes_form" action="" method="post" autocomplete="off">
1335 + class="validate_2fa_backup_codes_form" action="" method="post" autocomplete="off">
1388 1336 <input type="hidden" name="provider" id="provider" value="backup_codes"/>
1389 1337 <input type="hidden" name="uwp-auth-id" id="uwp-auth-id"
1390 - value="<?php echo esc_attr( $user->ID ); ?>"/>
1338 + value="<?php echo esc_attr( $user->ID ); ?>"/>
1391 1339 <input type="hidden" name="wp-auth-nonce" id="wp-auth-nonce"
1392 - value="<?php echo esc_attr( $login_nonce['key'] ); ?>"/>
1340 + value="<?php echo esc_attr( $login_nonce['key'] ); ?>"/>
1393 1341 <div class="uwp-backup-fields">
1394 1342 <?php
1395 - echo aui()->input(
1396 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1343 + echo aui()->input( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1397 1344 'type' => 'tel',
1398 1345 'id' => 'authcode',
1399 1346 'name' => 'wp-2fa-backup-code',
1400 1347 'placeholder' => esc_attr__( 'Enter backup code', 'userswp' ),
@@ -1399,24 +1346,18 @@
1399 1346 'name' => 'wp-2fa-backup-code',
1400 1347 'placeholder' => esc_attr__( 'Enter backup code', 'userswp' ),
1401 1348 'value' => '',
1402 1349 'label' => esc_html__( 'Backup Code', 'userswp' ),
1403 - 'extra_attributes' => array(
1404 - 'size' => 20,
1405 - 'pattern' => '[0-9]*',
1406 - ),
1407 - )
1408 - );
1350 + 'extra_attributes' => array( 'size' => 20, 'pattern' => "[0-9]*" ),
1351 + ) );
1409 1352
1410 - echo aui()->button(
1411 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1353 + echo aui()->button( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1412 1354 'type' => 'submit',
1413 1355 'class' => 'btn btn-primary btn-block text-uppercase uwp-2fa-submit',
1414 1356 'name' => 'submit',
1415 1357 'icon' => '',
1416 1358 'content' => esc_html__( 'Log In', 'userswp' ),
1417 - )
1418 - );
1359 + ) );
1419 1360 ?>
1420 1361 </div>
1421 1362 </form>
1422 1363 </div>
@@ -1436,76 +1377,9 @@
1436 1377
1437 1378 return ob_get_clean();
1438 1379 }
1439 1380
1440 - public function get_wp2fa_provider_for_user( $user ) {
1441 - if ( class_exists( '\WP2FA\Authenticator\Login' ) && method_exists( '\WP2FA\Authenticator\Login', 'get_available_providers_for_user' ) ) {
1442 - $provider = \WP2FA\Authenticator\Login::get_available_providers_for_user( $user );
1443 - if ( is_array( $provider ) ) {
1444 - $provider = key( $provider );
1445 - }
1446 -
1447 - return $provider;
1448 - }
1449 -
1450 - if ( class_exists( '\WP2FA\Admin\Helpers\User_Helper' ) && method_exists( '\WP2FA\Admin\Helpers\User_Helper', 'get_enabled_method_for_user' ) ) {
1451 - return \WP2FA\Admin\Helpers\User_Helper::get_enabled_method_for_user( $user );
1452 - }
1453 -
1454 - return '';
1455 - }
1456 -
1457 - public function get_wp2fa_backup_codes_remaining( $user ) {
1458 - if ( class_exists( '\WP2FA\Methods\Backup_Codes' ) && method_exists( '\WP2FA\Methods\Backup_Codes', 'codes_remaining_for_user' ) ) {
1459 - return \WP2FA\Methods\Backup_Codes::codes_remaining_for_user( $user );
1460 - }
1461 -
1462 - if ( class_exists( '\WP2FA\Authenticator\Backup_Codes' ) && method_exists( '\WP2FA\Authenticator\Backup_Codes', 'codes_remaining_for_user' ) ) {
1463 - return \WP2FA\Authenticator\Backup_Codes::codes_remaining_for_user( $user );
1464 - }
1465 -
1466 - return 0;
1467 - }
1468 -
1469 - public function validate_wp2fa_totp_authentication( $user ) {
1470 - if ( class_exists( '\WP2FA\Methods\TOTP' ) && method_exists( '\WP2FA\Methods\TOTP', 'validate_totp_authentication' ) ) {
1471 - return \WP2FA\Methods\TOTP::validate_totp_authentication( $user );
1472 - }
1473 -
1474 - if ( class_exists( '\WP2FA\Authenticator\Login' ) && method_exists( '\WP2FA\Authenticator\Login', 'validate_totp_authentication' ) ) {
1475 - return \WP2FA\Authenticator\Login::validate_totp_authentication( $user );
1476 - }
1477 -
1478 - return false;
1479 - }
1480 -
1481 - public function validate_wp2fa_email_authentication( $user ) {
1482 - if ( class_exists( '\WP2FA\Authenticator\Login' ) && method_exists( '\WP2FA\Authenticator\Login', 'validate_email_authentication' ) ) {
1483 - return \WP2FA\Authenticator\Login::validate_email_authentication( $user );
1484 - }
1485 -
1486 - if ( class_exists( '\WP2FA\Authenticator\Authentication' ) && method_exists( '\WP2FA\Authenticator\Authentication', 'validate_token' ) && isset( $_REQUEST['authcode'] ) ) {
1487 - return \WP2FA\Authenticator\Authentication::validate_token( $user, sanitize_text_field( wp_unslash( $_REQUEST['authcode'] ) ) );
1488 - }
1489 -
1490 - return false;
1491 - }
1492 -
1493 - public function validate_wp2fa_backup_codes( $user ) {
1494 - if ( class_exists( '\WP2FA\Methods\Backup_Codes' ) && method_exists( '\WP2FA\Methods\Backup_Codes', 'validate_backup_codes' ) ) {
1495 - return \WP2FA\Methods\Backup_Codes::validate_backup_codes( $user );
1496 - }
1497 -
1498 - if ( class_exists( '\WP2FA\Authenticator\Backup_Codes' ) && method_exists( '\WP2FA\Authenticator\Backup_Codes', 'validate_backup_codes' ) ) {
1499 - return \WP2FA\Authenticator\Backup_Codes::validate_backup_codes( $user );
1500 - }
1501 -
1502 - return false;
1503 - }
1504 -
1505 1381 public function process_login_2fa() {
1506 - global $wp2fa;
1507 -
1508 1382 if ( ! isset( $_POST['uwp-auth-id'], $_POST['wp-auth-nonce'] ) ) {
1509 1383 return;
1510 1384 }
1511 1385
@@ -1510,64 +1384,44 @@
1510 1384 }
1511 1385
1512 1386 $auth_id = (int) $_POST['uwp-auth-id'];
1513 1387 $user = get_userdata( $auth_id );
1514 -
1515 1388 if ( ! $user ) {
1516 - $message = aui()->alert(
1517 - array(
1389 + $message = aui()->alert( array(
1518 1390 'type' => 'error',
1519 - 'content' => __( 'Invalid user data. Please try again.', 'userswp' ),
1391 + 'content' => __( 'Invalid user data. Please try again.', 'userswp' )
1520 1392 )
1521 1393 );
1522 1394
1523 - wp_send_json_error( array( 'message' => $message ) );
1395 + wp_send_json_error( array( 'message' => $message) );
1524 1396 }
1525 1397
1398 + global $wp2fa;
1399 +
1526 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 ) ) {
1527 1402
1528 - if ( true !== \WP2FA\Authenticator\Login::verify_login_nonce( $user->ID, $nonce ) ) {
1529 - $message = aui()->alert(
1530 - array(
1403 + $message = aui()->alert( array(
1531 1404 'type' => 'error',
1532 - 'content' => __( 'Invalid request! Please try again.', 'userswp' ),
1405 + 'content' => __( 'Invalid request! Please try again.', 'userswp' )
1533 1406 )
1534 1407 );
1535 1408
1536 - wp_send_json_error( array( 'message' => $message ) );
1409 + wp_send_json_error( array( 'message' => $message) );
1537 1410 }
1538 1411
1539 - if ( isset( $_POST['provider'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1540 - $provider = sanitize_textarea_field( wp_unslash( $_POST['provider'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1541 - } else {
1542 - $provider = '';
1543 - }
1544 -
1545 - $error = '';
1546 -
1547 - try {
1548 - $is_enabled = \WP2FA\Admin\Controllers\Settings::is_provider_enabled_for_role( \WP2FA\Admin\Helpers\User_Helper::get_user_role( $user ), $provider );
1549 -
1550 - if ( ! $is_enabled ) {
1551 - $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;
1552 1421 }
1553 - } catch ( \Exception $e ) {
1554 - $error = $e->getMessage();
1555 1422 }
1556 1423
1557 - if ( $error ) {
1558 - do_action( 'wp_login_failed', $user->user_login );
1559 -
1560 - $message = aui()->alert(
1561 - array(
1562 - 'type' => 'error',
1563 - 'content' => $error
1564 - )
1565 - );
1566 -
1567 - wp_send_json_error( array( 'message' => $message ) );
1568 - }
1569 -
1570 1424 // If this is an email login, or if the user failed validation previously, lets send the code to the user.
1571 1425 if ( 'email' === $provider && true !== \WP2FA\Authenticator\Login::pre_process_email_authentication( $user ) ) {
1572 1426
1573 1427 }
@@ -1572,58 +1426,57 @@
1572 1426
1573 1427 }
1574 1428
1575 1429 // Validate TOTP.
1576 - if ( 'totp' === $provider && true !== $this->validate_wp2fa_totp_authentication( $user ) ) {
1430 + if ( 'totp' === $provider && true !== \WP2FA\Authenticator\Login::validate_totp_authentication( $user ) ) {
1431 +
1577 1432 do_action( 'wp_login_failed', $user->user_login );
1578 1433
1579 - $message = aui()->alert(
1580 - array(
1434 + $message = aui()->alert( array(
1581 1435 'type' => 'error',
1582 - 'content' => __( 'Invalid verification code.', 'userswp' ),
1436 + 'content' => __( 'Invalid verification code.', 'userswp' )
1583 1437 )
1584 1438 );
1585 1439
1586 - wp_send_json_error( array( 'message' => $message ) );
1440 + wp_send_json_error( array( 'message' => $message) );
1587 1441 }
1588 1442
1589 1443 // Validate Email.
1590 - if ( 'email' === $provider && true !== $this->validate_wp2fa_email_authentication( $user ) ) {
1444 + if ( 'email' === $provider && true !== \WP2FA\Authenticator\Login::validate_email_authentication( $user ) ) {
1445 +
1591 1446 do_action( 'wp_login_failed', $user->user_login );
1592 1447
1593 1448 if ( isset( $_REQUEST['wp-2fa-email-code-resend'] ) && 1 == $_REQUEST['wp-2fa-email-code-resend'] ) {
1594 - $message = aui()->alert(
1595 - array(
1449 + $message = aui()->alert( array(
1596 1450 'type' => 'info',
1597 - 'content' => __( 'A new code has been sent.', 'userswp' ),
1451 + 'content' => __( 'A new code has been sent.', 'userswp' )
1598 1452 )
1599 1453 );
1600 1454
1601 - wp_send_json_error( array( 'message' => $message ) );
1455 + wp_send_json_error( array( 'message' => $message) );
1602 1456 } else {
1603 - $message = aui()->alert(
1604 - array(
1457 + $message = aui()->alert( array(
1605 1458 'type' => 'error',
1606 - 'content' => __( 'Invalid verification code.', 'userswp' ),
1459 + 'content' => __( 'Invalid verification code.', 'userswp' )
1607 1460 )
1608 1461 );
1609 1462
1610 - wp_send_json_error( array( 'message' => $message ) );
1463 + wp_send_json_error( array( 'message' => $message) );
1611 1464 }
1612 1465 }
1613 1466
1614 1467 // Backup Codes.
1615 - 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 +
1616 1470 do_action( 'wp_login_failed', $user->user_login );
1617 1471
1618 - $message = aui()->alert(
1619 - array(
1472 + $message = aui()->alert( array(
1620 1473 'type' => 'error',
1621 - 'content' => __( 'Invalid backup code.', 'userswp' ),
1474 + 'content' => __( 'Invalid backup code.', 'userswp' )
1622 1475 )
1623 1476 );
1624 1477
1625 - wp_send_json_error( array( 'message' => $message ) );
1478 + wp_send_json_error( array( 'message' => $message) );
1626 1479 }
1627 1480
1628 1481 \WP2FA\Authenticator\Login::delete_login_nonce( $user->ID );
1629 1482
@@ -1628,9 +1481,8 @@
1628 1481 \WP2FA\Authenticator\Login::delete_login_nonce( $user->ID );
1629 1482
1630 1483 $rememberme = false;
1631 1484 $remember = ( isset( $_REQUEST['rememberme'] ) ) ? filter_var( $_REQUEST['rememberme'], FILTER_VALIDATE_BOOLEAN ) : '';
1632 -
1633 1485 if ( ! empty( $remember ) ) {
1634 1486 $rememberme = true;
1635 1487 }
1636 1488
@@ -1637,20 +1489,15 @@
1637 1489 wp_set_auth_cookie( $user->ID, $rememberme );
1638 1490
1639 1491 do_action( 'two_factor_user_authenticated', $user );
1640 1492
1641 - if ( defined( 'WP_2FA_PREFIX' ) ) {
1642 - do_action( WP_2FA_PREFIX . 'user_authenticated', $user );
1643 - }
1644 -
1645 - $message = aui()->alert(
1646 - array(
1493 + $message = aui()->alert( array(
1647 1494 'type' => 'success',
1648 - 'content' => __( 'Validation successful. Redirecting...', 'userswp' ),
1495 + 'content' => __( 'Validation successful. Redirecting...', 'userswp' )
1649 1496 )
1650 1497 );
1651 1498
1652 - wp_send_json_success( array( 'message' => $message ) );
1499 + wp_send_json_success( array( 'message' => $message) );
1653 1500 }
1654 1501
1655 1502 public function get_login_redirect_url( $data, $user ) {
1656 1503 if ( is_int( $user ) ) {
@@ -1659,15 +1506,17 @@
1659 1506
1660 1507 $redirect_page_id = uwp_get_option( 'login_redirect_to', - 1 );
1661 1508 $custom_url = uwp_get_option( 'login_redirect_custom_url' );
1662 1509
1663 - if ( $user && isset( $user->roles[0] ) ) {
1510 + if($user && isset($user->roles[0])){
1664 1511 $user_role = $user->roles[0];
1665 - $redirect_page_id = uwp_get_option( 'login_redirect_to_' . $user_role, $redirect_page_id );
1666 - $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 );
1667 1514 }
1668 1515
1669 - 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'] ) ) {
1670 1519 $redirect_to = esc_url_raw( $_REQUEST['redirect_to'] );
1671 1520 } elseif ( isset( $data['redirect_to'] ) && ! empty( $data['redirect_to'] ) ) {
1672 1521 $redirect_to = esc_url_raw( $data['redirect_to'] );
1673 1522 } elseif ( isset( $redirect_page_id ) && (int) $redirect_page_id > 0 ) {
@@ -1679,9 +1528,9 @@
1679 1528 }
1680 1529 $redirect_to = get_permalink( $redirect_page_id );
1681 1530 } elseif ( isset( $redirect_page_id ) && (int) $redirect_page_id == - 1 && wp_get_referer() ) {
1682 1531 $redirect_to = esc_url( wp_get_referer() );
1683 - } 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) ) {
1684 1533 $redirect_to = $custom_url;
1685 1534 } else {
1686 1535 $redirect_to = home_url( '/' );
1687 1536 $redirect_to = apply_filters( 'login_redirect', $redirect_to, '', $user );
@@ -1687,8 +1536,9 @@
1687 1536 $redirect_to = apply_filters( 'login_redirect', $redirect_to, '', $user );
1688 1537 }
1689 1538
1690 1539 return apply_filters( 'uwp_login_redirect', $redirect_to, $redirect_page_id, $data, $user );
1540 +
1691 1541 }
1692 1542
1693 1543 /**
1694 1544 * Processes forgot password form submission.
@@ -1705,13 +1555,12 @@
1705 1555 return;
1706 1556 }
1707 1557
1708 1558 if ( ! isset( $data['uwp_forgot_nonce'] ) || ! wp_verify_nonce( $data['uwp_forgot_nonce'], 'uwp-forgot-nonce' ) ) {
1709 - $message = aui()->alert(
1710 - array(
1559 + $message = aui()->alert( array(
1711 1560 'type' => 'error',
1712 - 'content' => __( 'Security verification failed. Try again.', 'userswp' ),
1713 - )
1561 + 'content' => __( 'Security verification failed. Try again.', 'userswp' )
1562 + )
1714 1563 );
1715 1564 if ( wp_doing_ajax() ) {
1716 1565 wp_send_json_error( $message );
1717 1566 } else {
@@ -1727,13 +1576,12 @@
1727 1576
1728 1577 $result = apply_filters( 'uwp_validate_result', $result, 'forgot', $data );
1729 1578
1730 1579 if ( is_wp_error( $result ) ) {
1731 - $message = aui()->alert(
1732 - array(
1580 + $message = aui()->alert( array(
1733 1581 'type' => 'error',
1734 - 'content' => $result->get_error_message(),
1735 - )
1582 + 'content' => $result->get_error_message()
1583 + )
1736 1584 );
1737 1585 if ( wp_doing_ajax() ) {
1738 1586 wp_send_json_error( $message );
1739 1587 } else {
@@ -1744,22 +1592,17 @@
1744 1592 }
1745 1593
1746 1594 do_action( 'uwp_after_validate', $result, 'forgot', $data );
1747 1595
1748 - $login_or_email = trim( $data['email'] );
1749 - $user_data = is_email( $login_or_email )
1750 - ? get_user_by( 'email', $login_or_email )
1751 - : get_user_by( 'login', $login_or_email );
1752 1596
1597 + $user_data = get_user_by( 'email', $data['email'] );
1598 +
1753 1599 // if no user we fake it and bail
1754 1600 if ( ! $user_data ) {
1755 - $args = apply_filters(
1756 - 'uwp_forgot_error_message',
1757 - array(
1758 - 'type' => 'error',
1759 - 'content' => __( 'Invalid username/email or user doesn\'t exist.', 'userswp' ),
1760 - )
1761 - );
1601 + $args = apply_filters('uwp_forgot_error_message', array(
1602 + 'type' => 'error',
1603 + 'content' => __( 'Invalid email or user doesn\'t exists.', 'userswp' )
1604 + ));
1762 1605
1763 1606 $message = aui()->alert( $args );
1764 1607 if ( wp_doing_ajax() ) {
1765 1608 wp_send_json_success( $message );
@@ -1772,27 +1615,18 @@
1772 1615
1773 1616 // make sure user account is active before account reset
1774 1617 $mod_value = get_user_meta( $user_data->ID, 'uwp_mod', true );
1775 1618 if ( $mod_value == 'email_unconfirmed' ) {
1776 - $resend_link = uwp_get_forgot_page_url();
1777 - $resend_link = add_query_arg(
1778 - array(
1779 - 'user_id' => $user_data->ID,
1780 - 'action' => 'uwp_resend',
1781 - '_nonce' => wp_create_nonce('uwp_resend'),
1782 - ),
1783 - $resend_link
1784 - );
1785 - $message = aui()->alert(
1786 - array(
1619 + $message = aui()->alert( array(
1787 1620 'type' => 'error',
1788 - 'content' => sprintf(__('Your account is not activated yet. Please activate your account first. <a href="%s">Resend</a>.', 'userswp'), $resend_link),
1789 - )
1621 + 'content' => __( 'Your account is not activated yet. Please activate your account first.', 'userswp' )
1622 + )
1790 1623 );
1791 1624 if ( wp_doing_ajax() ) {
1792 1625 wp_send_json_error( $message );
1793 1626 } else {
1794 1627 $uwp_notices[] = array( 'forgot' => $message );
1628 +
1795 1629 return;
1796 1630 }
1797 1631 }
1798 1632
@@ -1801,14 +1635,15 @@
1801 1635 $allow = apply_filters( 'allow_password_reset', true, $user_data->ID );
1802 1636
1803 1637 if ( ! $allow ) {
1804 1638 return false;
1805 - } elseif ( is_wp_error( $allow ) ) {
1639 + } else if ( is_wp_error( $allow ) ) {
1806 1640 return false;
1807 1641 }
1808 1642
1809 1643 $as_password = apply_filters( 'uwp_forgot_message_as_password', false );
1810 1644
1645 + global $wpdb, $wp_hasher;
1811 1646 $reset_link = '';
1812 1647
1813 1648 if ( $as_password ) {
1814 1649 $new_pass = wp_generate_password( 12, false );
@@ -1816,43 +1651,36 @@
1816 1651 if ( ! uwp_get_option( 'change_disable_password_nag' ) ) {
1817 1652 update_user_meta( $user_data->ID, 'default_password_nag', true ); //Set up the Password change nag.
1818 1653 }
1819 1654 $message = '<p><b>' . __( 'Your login Information :', 'userswp' ) . '</b></p>';
1820 - $message .= '<p>' . sprintf( __( 'Username: %s', 'userswp' ), $user_data->user_login ) . '</p>';
1821 - $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>";
1822 1657
1823 1658 } else {
1824 - // Use WordPress core to generate, hash (wp_fast_hash in WP 6.8+), and store the reset key.
1825 - // This ensures compatibility with check_password_reset_key() on all WP versions.
1826 - $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 );
1827 1661
1828 - if ( is_wp_error( $key ) ) {
1829 - if ( wp_doing_ajax() ) {
1830 - wp_send_json_error( $key->get_error_message() );
1831 - } else {
1832 - $uwp_notices[] = array( 'forgot' => aui()->alert( array( 'type' => 'error', 'content' => $key->get_error_message() ) ) );
1833 - return;
1834 - }
1662 + if ( empty( $wp_hasher ) ) {
1663 + require_once ABSPATH . 'wp-includes/class-phpass.php';
1664 + $wp_hasher = new PasswordHash( 8, true );
1835 1665 }
1836 -
1837 - $message = '<p>' . __( 'You have requested to reset your password for the following account:', 'userswp' ) . '</p>';
1838 - $message .= home_url( '/' ) . '</p>';
1839 - $message .= '<p>' . sprintf( __( 'Username: %s', 'userswp' ), $user_data->user_login ) . '</p>';
1840 - $message .= '<p>' . __( 'If this was by mistake, just ignore this email and nothing will happen.', 'userswp' ) . '</p>';
1841 - $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>";
1842 1673 $reset_page = uwp_get_page_id( 'reset_page', false );
1843 1674 if ( $reset_page ) {
1844 - $reset_link = add_query_arg(
1845 - array(
1846 - 'key' => $key,
1847 - 'login' => rawurlencode( $user_data->user_login ),
1848 - ),
1849 - get_permalink( $reset_page )
1850 - );
1851 - $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";
1852 1680 } else {
1853 1681 $reset_link = home_url( "reset?key=$key&login=" . rawurlencode( $user_data->user_login ), 'login' );
1854 - $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";
1855 1683 }
1856 1684 $message = apply_filters( 'uwp_forgot_password_message', $message, $user_data, $reset_link );
1857 1685 }
1858 1686
@@ -1867,13 +1695,12 @@
1867 1695 UsersWP_Mails::send( $user_data->user_email, 'forgot_password', $email_vars );
1868 1696
1869 1697 do_action( 'uwp_after_process_forgot', $data );
1870 1698
1871 - $message = aui()->alert(
1872 - array(
1699 + $message = aui()->alert( array(
1873 1700 'type' => 'success',
1874 - 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Please check your email.', 'userswp' ), $data ),
1875 - )
1701 + 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Please check your email.', 'userswp' ), $data )
1702 + )
1876 1703 );
1877 1704 if ( wp_doing_ajax() ) {
1878 1705 wp_send_json_success( $message );
1879 1706 } else {
@@ -1910,13 +1737,12 @@
1910 1737
1911 1738 $result = apply_filters( 'uwp_validate_result', $result, 'change', $data );
1912 1739
1913 1740 if ( is_wp_error( $result ) ) {
1914 - $message = aui()->alert(
1915 - array(
1741 + $message = aui()->alert( array(
1916 1742 'type' => 'error',
1917 - 'content' => $result->get_error_message(),
1918 - )
1743 + 'content' => $result->get_error_message()
1744 + )
1919 1745 );
1920 1746 $uwp_notices[] = array( $notice_type => $message );
1921 1747
1922 1748 return;
@@ -1926,13 +1752,12 @@
1926 1752
1927 1753 $user_data = get_user_by( 'id', get_current_user_id() );
1928 1754
1929 1755 if ( ! $user_data ) {
1930 - $message = aui()->alert(
1931 - array(
1756 + $message = aui()->alert( array(
1932 1757 'type' => 'error',
1933 - 'content' => $user_data->get_error_message(),
1934 - )
1758 + 'content' => $user_data->get_error_message()
1759 + )
1935 1760 );
1936 1761 $uwp_notices[] = array( $notice_type => $message );
1937 1762
1938 1763 return;
@@ -1950,15 +1775,14 @@
1950 1775 if ( $password_nag ) {
1951 1776 delete_user_meta( $user_data->ID, 'default_password_nag' );
1952 1777 }
1953 1778
1954 - 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');
1955 1780
1956 - $message = aui()->alert(
1957 - array(
1958 - 'type' => 'success',
1959 - 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Password changed successfully.', 'userswp' ), $data ),
1960 - )
1781 + $message = aui()->alert( array(
1782 + 'type' => 'success',
1783 + 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Password changed successfully.', 'userswp' ), $data )
1784 + )
1961 1785 );
1962 1786
1963 1787 $uwp_notices[] = array( $notice_type => $message );
1964 1788
@@ -1995,13 +1819,12 @@
1995 1819
1996 1820 $result = apply_filters( 'uwp_validate_result', $result, 'reset', $data );
1997 1821
1998 1822 if ( is_wp_error( $result ) ) {
1999 - $message = aui()->alert(
2000 - array(
1823 + $message = aui()->alert( array(
2001 1824 'type' => 'error',
2002 - 'content' => $result->get_error_message(),
2003 - )
1825 + 'content' => $result->get_error_message()
1826 + )
2004 1827 );
2005 1828 $uwp_notices[] = array( 'reset' => $message );
2006 1829
2007 1830 return;
@@ -2013,13 +1836,12 @@
2013 1836 $key = sanitize_text_field( $data['uwp_reset_key'] );
2014 1837
2015 1838 $user = get_user_by( 'login', $login );
2016 1839 if ( ! $user ) {
2017 - $message = aui()->alert(
2018 - array(
1840 + $message = aui()->alert( array(
2019 1841 'type' => 'error',
2020 - 'content' => __( 'Invalid username.', 'userswp' ),
2021 - )
1842 + 'content' => __( 'Invalid username.', 'userswp' )
1843 + )
2022 1844 );
2023 1845 $uwp_notices[] = array( 'reset' => $message );
2024 1846
2025 1847 return;
@@ -2029,14 +1851,13 @@
2029 1851
2030 1852 $user_data = check_password_reset_key( $key, $login );
2031 1853
2032 1854 if ( is_wp_error( $user_data ) ) {
2033 - $error = apply_filters( 'uwp_reset_password_error_message', $user_data->get_error_message(), $user_data );
2034 - $message = aui()->alert(
2035 - array(
1855 + $error = apply_filters('uwp_reset_password_error_message', $user_data->get_error_message(), $user_data);
1856 + $message = aui()->alert( array(
2036 1857 'type' => 'error',
2037 - 'content' => $error,
2038 - )
1858 + 'content' => $error
1859 + )
2039 1860 );
2040 1861 $uwp_notices[] = array( 'reset' => $message );
2041 1862
2042 1863 return;
@@ -2052,13 +1873,12 @@
2052 1873
2053 1874 $login_page_url = uwp_get_login_page_url();
2054 1875 $message = sprintf( __( 'Password updated successfully. Please <a href="%s">login</a> with your new password.', 'userswp' ), $login_page_url );
2055 1876 $message = apply_filters( 'uwp_reset_password_success_message', $message, $data );
2056 - $message = aui()->alert(
2057 - array(
1877 + $message = aui()->alert( array(
2058 1878 'type' => 'success',
2059 - 'content' => $message,
2060 - )
1879 + 'content' => $message
1880 + )
2061 1881 );
2062 1882 $uwp_notices[] = array( 'reset' => $message );
2063 1883
2064 1884 do_action( 'uwp_after_process_reset', $data );
@@ -2093,13 +1913,12 @@
2093 1913
2094 1914 $result = apply_filters( 'uwp_validate_result', $result, 'account', $data );
2095 1915
2096 1916 if ( is_wp_error( $result ) ) {
2097 - $message = aui()->alert(
2098 - array(
1917 + $message = aui()->alert( array(
2099 1918 'type' => 'error',
2100 - 'content' => $result->get_error_message(),
2101 - )
1919 + 'content' => $result->get_error_message()
1920 + )
2102 1921 );
2103 1922 $uwp_notices[] = array( 'account' => $message );
2104 1923
2105 1924 return;
@@ -2107,13 +1926,12 @@
2107 1926
2108 1927 $uploads_result = $file_obj->validate_uploads( $files, 'account' );
2109 1928
2110 1929 if ( is_wp_error( $uploads_result ) ) {
2111 - $message = aui()->alert(
2112 - array(
1930 + $message = aui()->alert( array(
2113 1931 'type' => 'error',
2114 - 'content' => $uploads_result->get_error_message(),
2115 - )
1932 + 'content' => $uploads_result->get_error_message()
1933 + )
2116 1934 );
2117 1935 $uwp_notices[] = array( 'account' => $message );
2118 1936
2119 1937 return;
@@ -2127,25 +1945,13 @@
2127 1945 unset( $uploads_result[ $upload_file_key ] );
2128 1946 }
2129 1947 }
2130 1948
2131 - global $wpdb;
2132 - $file_field_names = $wpdb->get_col(
2133 - $wpdb->prepare(
2134 - "SELECT htmlvar_name FROM " . uwp_get_table_prefix() . "uwp_form_fields WHERE form_type = %s AND field_type IN ('file','image')",
2135 - 'account'
2136 - )
2137 - );
2138 - foreach ( $file_field_names as $file_field_name ) {
2139 - if ( isset( $result[ $file_field_name ] ) && ! isset( $uploads_result[ $file_field_name ] ) ) {
2140 - unset( $result[ $file_field_name ] );
2141 - }
2142 - }
1949 + $result = array_merge( $result, $uploads_result );
2143 1950
2144 - $result = array_merge( $result, $uploads_result );
2145 1951
2146 1952 $args = array(
2147 - 'ID' => get_current_user_id(),
1953 + 'ID' => get_current_user_id()
2148 1954 );
2149 1955
2150 1956 if ( isset( $result['first_name'] ) && isset( $result['last_name'] ) ) {
2151 1957 $args['display_name'] = $result['first_name'] . ' ' . $result['last_name'];
@@ -2173,13 +1979,12 @@
2173 1979
2174 1980 $user_id = wp_update_user( $args );
2175 1981
2176 1982 if ( is_wp_error( $user_id ) ) {
2177 - $message = aui()->alert(
2178 - array(
1983 + $message = aui()->alert( array(
2179 1984 'type' => 'error',
2180 - 'content' => sprintf( __( '%s', 'userswp' ), $user_id->get_error_message() ),
2181 - )
1985 + 'content' => sprintf( __( '%s', 'userswp' ), $user_id->get_error_message() )
1986 + )
2182 1987 );
2183 1988 $uwp_notices[] = array( 'account' => $message );
2184 1989
2185 1990 return;
@@ -2187,13 +1992,12 @@
2187 1992
2188 1993 $res = $this->save_user_extra_fields( $user_id, $result, 'account' );
2189 1994
2190 1995 if ( ! $res ) {
2191 - $message = aui()->alert(
2192 - array(
1996 + $message = aui()->alert( array(
2193 1997 'type' => 'error',
2194 - 'content' => __( 'Something went wrong. Please contact site admin.', 'userswp' ),
2195 - )
1998 + 'content' => __( 'Something went wrong. Please contact site admin.', 'userswp' )
1999 + )
2196 2000 );
2197 2001 $uwp_notices[] = array( 'account' => $message );
2198 2002
2199 2003 return;
@@ -2209,22 +2013,21 @@
2209 2013 }
2210 2014
2211 2015 $user_data = get_userdata( $user_id );
2212 2016
2213 - $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 );
2214 2018
2215 - if ( isset( $result['email'] ) && $user_data->user_email !== trim( $result['email'] ) ) {
2019 + if ( isset( $result['email'] ) && $user_data->user_email !== trim($result['email']) ) {
2216 2020
2217 - if ( email_exists( trim( $result['email'] ) ) ) {
2218 - $message = aui()->alert(
2219 - array(
2220 - 'type' => 'error',
2221 - 'content' => __( 'This email is already registered, please choose another one.', 'userswp' ),
2222 - )
2223 - );
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 + );
2224 2027
2225 - $uwp_notices[] = array( 'account' => $message );
2226 - return;
2028 + $uwp_notices[] = array( 'account' => $message );
2029 + return;
2227 2030
2228 2031 }
2229 2032
2230 2033 $hash = md5( $result['email'] . time() . wp_rand() );
@@ -2232,22 +2035,22 @@
2232 2035 'hash' => $hash,
2233 2036 'newemail' => $result['email'],
2234 2037 );
2235 2038
2236 - 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);
2237 2040
2238 2041 $new_email_link = add_query_arg(
2239 2042 array(
2240 2043 'uwp_new_email' => 'yes',
2241 - 'key' => $hash,
2242 - 'login' => $user_data->user_login,
2044 + 'key' => $hash,
2045 + 'login' => $user_data->user_login
2243 2046 ),
2244 2047 uwp_get_account_page_url()
2245 2048 );
2246 2049
2247 2050 $email_vars = array(
2248 - 'user_id' => $user_id,
2249 - 'new_email' => $result['email'],
2051 + 'user_id' => $user_id,
2052 + 'new_email' => $result['email'],
2250 2053 'new_email_link' => esc_url( $new_email_link ),
2251 2054 );
2252 2055
2253 2056 UsersWP_Mails::send( $result['email'], 'account_new_email_activation', $email_vars );
@@ -2252,13 +2055,12 @@
2252 2055
2253 2056 UsersWP_Mails::send( $result['email'], 'account_new_email_activation', $email_vars );
2254 2057
2255 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 );
2256 - $message = aui()->alert(
2257 - array(
2059 + $message = aui()->alert( array(
2258 2060 'type' => 'success',
2259 - 'content' => $message,
2260 - )
2061 + 'content' => $message
2062 + )
2261 2063 );
2262 2064
2263 2065 $uwp_notices[] = array( 'account' => $message );
2264 2066
@@ -2270,13 +2072,12 @@
2270 2072
2271 2073 UsersWP_Mails::send( $user_data->user_email, 'account_update', $email_vars );
2272 2074
2273 2075 $message = apply_filters( 'uwp_account_update_success_message', __( 'Account updated successfully.', 'userswp' ), $data );
2274 - $message = aui()->alert(
2275 - array(
2076 + $message = aui()->alert( array(
2276 2077 'type' => 'success',
2277 - 'content' => $message,
2278 - )
2078 + 'content' => $message
2079 + )
2279 2080 );
2280 2081
2281 2082 $uwp_notices[] = array( 'account' => $message );
2282 2083 }
@@ -2281,8 +2082,9 @@
2281 2082 $uwp_notices[] = array( 'account' => $message );
2282 2083 }
2283 2084
2284 2085 do_action( 'uwp_after_process_account', $data, $user_id );
2086 +
2285 2087 }
2286 2088
2287 2089 /**
2288 2090 * Modifies the forms field in email based on the form type.
@@ -2297,11 +2099,11 @@
2297 2099 *
2298 2100 */
2299 2101 public function init_mail_form_fields( $form_fields, $type, $user_id ) {
2300 2102 switch ( $type ) {
2301 - case 'register':
2103 + case "register":
2302 2104 $form_id = get_user_meta( $user_id, '_uwp_register_form_id', true );
2303 - $fields = get_register_form_fields( $form_id );
2105 + $fields = get_register_form_fields($form_id);
2304 2106 $user_data = get_userdata( $user_id );
2305 2107 if ( ! empty( $fields ) && is_array( $fields ) ) {
2306 2108 $form_fields = '<p><b>' . __( 'User Information:', 'userswp' ) . '</b></p>';
2307 2109 $excluded = uwp_get_excluded_fields();
@@ -2323,14 +2125,14 @@
2323 2125 $field_value = uwp_maybe_serialize( $field->htmlvar_name, $field_value );
2324 2126 }
2325 2127
2326 2128 if ( isset( $field->site_title ) && ! empty( $field_value ) ) {
2327 - $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>';
2328 2130 }
2329 2131 }
2330 2132 }
2331 2133 break;
2332 - case 'account':
2134 + case "account":
2333 2135 $fields = get_account_form_fields();
2334 2136 $user_data = get_userdata( $user_id );
2335 2137 if ( ! empty( $fields ) && is_array( $fields ) ) {
2336 2138 $form_fields = '<p><b>' . __( 'User Information:', 'userswp' ) . '</b></p>';
@@ -2352,9 +2154,9 @@
2352 2154 $field_value = uwp_maybe_serialize( $field->htmlvar_name, $field_value );
2353 2155 }
2354 2156
2355 2157 if ( isset( $field->site_title ) && ! empty( $field_value ) ) {
2356 - $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>';
2357 2159 }
2358 2160 }
2359 2161 }
2360 2162 break;
@@ -2371,94 +2173,46 @@
2371 2173 * @package userswp
2372 2174 * @since 1.0.0
2373 2175 */
2374 2176 public function upload_file_remove() {
2375 - global $wpdb;
2376 -
2377 2177 check_ajax_referer( 'uwp_basic_nonce', 'security' );
2378 2178
2379 - // Check user logged in.
2380 - if ( ! is_user_logged_in() ) {
2381 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Access denied!', 'userswp' ) ) );
2382 - wp_send_json_error( array( 'message' => $message ) );
2383 - }
2384 -
2179 + $htmlvar = esc_sql( strip_tags( $_POST['htmlvar'] ) );
2385 2180 $user_id = ! empty( $_POST['uid'] ) ? absint( $_POST['uid'] ) : 0;
2386 - $htmlvar = ! empty( $_POST['htmlvar'] ) ? sanitize_key( $_POST['htmlvar'] ) : '';
2387 2181
2388 - if ( empty( $user_id ) || empty( $htmlvar ) ) {
2389 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid data!', 'userswp' ) ) );
2390 - wp_send_json_error( array( 'message' => $message ) );
2182 + if ( empty( $user_id ) ) {
2183 + wp_die( -1 );
2391 2184 }
2392 2185
2393 - // Validate the user / admin.
2394 - if ( ! ( $user_id == (int) get_current_user_id() || current_user_can( 'manage_options' ) ) ) {
2395 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid access!', 'userswp' ) ) );
2396 - 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' ) );
2397 2188 }
2398 2189
2399 - if ( $htmlvar == 'banner_thumb' ) {
2400 - $field_key = 'banner';
2190 + // Remove file
2191 + if ( $htmlvar == "banner_thumb" ) {
2192 + $file = uwp_get_usermeta( $user_id, 'banner_thumb' );
2401 2193 $type = 'banner';
2402 - } else if ( $htmlvar == 'avatar_thumb' ) {
2403 - $field_key = 'avatar';
2194 + } else if ( $htmlvar == "avatar_thumb" ) {
2195 + $file = uwp_get_usermeta( $user_id, 'avatar_thumb' );
2404 2196 $type = 'avatar';
2405 2197 } else {
2406 - $field_key = $htmlvar;
2198 + $file = '';
2407 2199 $type = '';
2408 2200 }
2409 2201
2410 - $field = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . uwp_get_table_prefix() . "uwp_form_fields WHERE htmlvar_name = %s LIMIT 1", $field_key ) );
2411 -
2412 - // Check field exists.
2413 - if ( empty( $field ) ) {
2414 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid field!', 'userswp' ) ) );
2415 - wp_send_json_error( array( 'message' => $message ) );
2416 - }
2417 -
2418 - // Validate field access.
2419 - if ( ! empty( $field->for_admin_use ) && ! current_user_can( 'manage_options' ) ) {
2420 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'You are not allowed to perform this action!', 'userswp' ) ) );
2421 - wp_send_json_error( array( 'message' => $message ) );
2422 - }
2423 -
2424 - if ( ! in_array( $field->field_type, array( 'file', 'image' ) ) ) {
2425 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid field type!', 'userswp' ) ) );
2426 - wp_send_json_error( array( 'message' => $message ) );
2427 - }
2428 -
2429 - $value = uwp_get_usermeta( $user_id, $htmlvar );
2430 -
2431 2202 uwp_update_usermeta( $user_id, $htmlvar, '' );
2432 2203
2433 - if ( $value && validate_file( $value ) === 0 ) {
2204 + if ( $file ) {
2434 2205 $uploads = wp_upload_dir();
2435 2206 $upload_path = $uploads['basedir'];
2207 + $unlink_file = untrailingslashit( $upload_path ) . '/' . ltrim( $file, '/' );
2436 2208
2437 - if ( strpos( $value, 'http://' ) === 0 || strpos( $value, 'https://' ) === 0 ) {
2438 - // Get the relative url.
2439 - $value = uwp_get_file_relative_url( $value );
2440 - }
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 );
2441 2212
2442 - $unlink_file = untrailingslashit( $upload_path ) . '/' . trim( $value, '/\\' );
2443 -
2444 - // Canonicalize and enforce containment inside the uploads directory before deleting.
2445 - $real_upload_path = realpath( $upload_path );
2446 - $real_unlink_file = realpath( $unlink_file );
2447 -
2448 - if ( $real_upload_path && $real_unlink_file && is_file( $real_unlink_file )
2449 - && strpos( $real_unlink_file, $real_upload_path . DIRECTORY_SEPARATOR ) === 0 ) {
2450 - wp_delete_file( $real_unlink_file );
2451 -
2452 - // For avatar/banner, also remove the original (non-thumb) file.
2453 - if ( $type ) {
2454 - $unlink_ori_file = str_replace( '_uwp_' . $type . '_thumb' . '.', '.', $real_unlink_file );
2455 - $real_unlink_ori_file = realpath( $unlink_ori_file );
2456 -
2457 - if ( $real_unlink_ori_file && is_file( $real_unlink_ori_file )
2458 - && strpos( $real_unlink_ori_file, $real_upload_path . DIRECTORY_SEPARATOR ) === 0 ) {
2459 - wp_delete_file( $real_unlink_ori_file );
2460 - }
2213 + if ( is_file( $unlink_ori_file ) && file_exists( $unlink_ori_file ) ) {
2214 + @unlink( $unlink_ori_file );
2461 2215 }
2462 2216 }
2463 2217 }
2464 2218
@@ -2489,15 +2243,15 @@
2489 2243
2490 2244 // If no html then we run the standard output.
2491 2245 if ( empty( $html ) ) {
2492 2246
2493 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2494 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
2495 - $bs_sr_only = $design_style ? 'sr-only' : '';
2496 - $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" : "";
2497 2251 $extra_attributes = array();
2498 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
2499 - $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') : '';
2500 2254
2501 2255 ob_start(); // Start buffering;
2502 2256
2503 2257 $extra_fields = unserialize( $field->extra_fields );
@@ -2508,8 +2262,9 @@
2508 2262
2509 2263 $date_format = $extra_fields['date_format'];
2510 2264 $jquery_date_format = $date_format;
2511 2265
2266 +
2512 2267 // check if we need to change the format or not
2513 2268 $date_format_len = strlen( str_replace( ' ', '', $date_format ) );
2514 2269 if ( $date_format_len > 5 ) {// if greater then 5 then it's the old style format.
2515 2270
@@ -2545,24 +2300,24 @@
2545 2300 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
2546 2301
2547 2302 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2548 2303 array(
2549 - 'id' => esc_attr( $field->htmlvar_name ),
2550 - 'name' => esc_attr( $field->htmlvar_name ),
2551 - 'required' => ! empty( $field->is_required ) ? true : false,
2552 - 'label' => wp_kses_post( $site_title . $required ),
2553 - 'label_show' => true,
2554 - 'label_type' => 'hidden',
2555 - 'type' => 'datepicker',
2556 - 'title' => esc_html( $site_title ),
2557 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2558 - 'class' => '',
2559 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2560 - 'value' => esc_attr( $value ),
2561 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2562 - '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 ),
2563 2318 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
2564 - 'extra_attributes' => $extra_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2319 + 'extra_attributes' => $extra_attributes // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2565 2320 )
2566 2321 );
2567 2322 } else {
2568 2323 ?>
@@ -2568,23 +2323,21 @@
2568 2323 ?>
2569 2324 <script type="text/javascript">
2570 2325
2571 2326 jQuery(function () {
2572 - jQuery("#<?php echo esc_attr( $field->htmlvar_name ); ?>").datepicker({
2327 + jQuery("#<?php echo esc_attr( $field->htmlvar_name );?>").datepicker({
2573 2328 changeMonth: true, changeYear: true
2574 - <?php
2575 - if ( $field->htmlvar_name == 'dob' ) {
2329 + <?php if ( $field->htmlvar_name == 'dob' ) {
2576 2330 echo ", yearRange: '1900:+0'";
2577 2331 } else {
2578 - echo ", yearRange: '1900:2050'";
2579 - }
2580 - ?>
2332 + echo ", yearRange: '1900:2050'";
2333 + }?>
2581 2334 <?php echo apply_filters( "uwp_datepicker_extra_{$field->htmlvar_name}", '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>});
2582 2335
2583 2336 jQuery("#<?php echo esc_attr( $field->htmlvar_name ); ?>").datepicker("option", "dateFormat", '<?php echo esc_attr( $jquery_date_format ); ?>');
2584 2337
2585 - <?php if ( ! empty( $value ) ) { ?>
2586 - 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 );?>');
2587 2340 jQuery("#<?php echo esc_attr( $field->htmlvar_name ); ?>").datepicker("setDate", parsedDate);
2588 2341 <?php } ?>
2589 2342
2590 2343 });
@@ -2590,46 +2343,37 @@
2590 2343 });
2591 2344
2592 2345 </script>
2593 2346 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
2594 - class="
2595 - <?php
2596 - if ( $field->is_required ) {
2597 - echo 'required_field';
2598 - }
2599 - ?>
2600 - 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 ); ?>">
2601 2350
2602 2351 <?php
2603 2352
2604 - if ( ! is_admin() ) {
2605 - ?>
2353 + if ( ! is_admin() ) { ?>
2606 2354 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
2607 2355 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
2608 - <?php
2609 - if ( $field->is_required ) {
2356 + <?php if ( $field->is_required ) {
2610 2357 echo '<span>*</span>';
2611 - }
2612 - ?>
2358 + } ?>
2613 2359 </label>
2614 2360 <?php } ?>
2615 2361
2616 2362 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2617 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2618 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
2619 - title="<?php echo esc_attr( $site_title ); ?>"
2620 - type="text"
2621 - <?php
2622 - 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 ) {
2623 2368 echo 'required="required"';
2624 - }
2625 - ?>
2626 - value="<?php echo esc_attr( $value ); ?>"
2627 - 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 ); ?>"/>
2628 2372
2629 2373 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
2630 2374 <?php if ( $field->is_required ) { ?>
2631 - <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>
2632 2376 <?php } ?>
2633 2377 </div>
2634 2378
2635 2379 <?php
@@ -2663,14 +2407,14 @@
2663 2407
2664 2408 // If no html then we run the standard output.
2665 2409 if ( empty( $html ) ) {
2666 2410
2667 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2668 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
2669 - $bs_sr_only = $design_style ? 'sr-only' : '';
2670 - $bs_form_control = $design_style ? 'form-control bg-white' : '';
2671 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
2672 - $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') : '';
2673 2417
2674 2418 ob_start(); // Start buffering;
2675 2419
2676 2420 if ( $value != '' ) {
@@ -2688,25 +2432,25 @@
2688 2432 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
2689 2433
2690 2434 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2691 2435 array(
2692 - 'id' => esc_attr( $field->htmlvar_name ),
2693 - 'name' => esc_attr( $field->htmlvar_name ),
2694 - 'required' => ! empty( $field->is_required ) ? true : false,
2695 - 'label' => wp_kses_post( $site_title . $required ),
2696 - 'label_show' => true,
2697 - 'label_type' => esc_attr( $label_type ),
2698 - 'type' => 'timepicker',
2699 - 'title' => esc_html( $site_title ),
2700 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2701 - 'class' => '',
2702 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2703 - 'value' => esc_attr( $value ),
2704 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2705 - '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 ),
2706 2450 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
2707 - 'extra_attributes' => $extra_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2708 - '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>',
2709 2453 )
2710 2454 );
2711 2455 } else {
2712 2456 ?>
@@ -2718,40 +2462,33 @@
2718 2462 });
2719 2463 });
2720 2464 </script>
2721 2465 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
2722 - class="
2723 - <?php
2724 - if ( $field->is_required ) {
2725 - echo 'required_field';
2726 - }
2727 - ?>
2728 - 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 ); ?>">
2729 2469
2730 2470 <?php
2731 2471 $site_title = uwp_get_form_label( $field );
2732 - if ( ! is_admin() ) {
2733 - ?>
2472 + if ( ! is_admin() ) { ?>
2734 2473 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
2735 2474 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
2736 - <?php
2737 - if ( $field->is_required ) {
2475 + <?php if ( $field->is_required ) {
2738 2476 echo '<span>*</span>';
2739 - }
2740 - ?>
2477 + } ?>
2741 2478 </label>
2742 2479 <?php } ?>
2743 2480
2744 2481 <input readonly="readonly" name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2745 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2746 - value="<?php echo esc_attr( $value ); ?>"
2747 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
2748 - type="text"
2749 - 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 ); ?>"/>
2750 2487
2751 2488 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
2752 2489 <?php if ( $field->is_required ) { ?>
2753 - <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>
2754 2491 <?php } ?>
2755 2492 </div>
2756 2493 <?php
2757 2494 }
@@ -2788,14 +2525,14 @@
2788 2525
2789 2526 // If no html then we run the standard output.
2790 2527 if ( empty( $html ) ) {
2791 2528
2792 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2793 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
2794 - $bs_sr_only = $design_style ? 'sr-only' : '';
2795 - $bs_form_control = $design_style ? 'form-control' : '';
2796 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
2797 - $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') : '';
2798 2535
2799 2536 ob_start(); // Start buffering;
2800 2537 $option_values_arr = uwp_string_values_to_options( $field->option_values, true );
2801 2538 $site_title = uwp_get_form_label( $field );
@@ -2804,46 +2541,37 @@
2804 2541 if ( $design_style ) {
2805 2542
2806 2543 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
2807 2544
2808 - echo aui()->select(
2809 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2810 - 'id' => esc_attr( $field->htmlvar_name ),
2811 - 'name' => esc_attr( $field->htmlvar_name ),
2812 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2813 - 'title' => esc_html( $site_title ),
2814 - 'value' => esc_attr( $value ),
2815 - 'required' => (bool) $field->is_required,
2816 - '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 ),
2817 2553 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
2818 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2819 - 'label' => wp_kses_post( $site_title . $required ),
2820 - 'options' => $option_values_arr, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2821 - 'select2' => true,
2822 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2823 - )
2824 - );
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 + ) );
2825 2560 } else {
2826 2561 ?>
2827 2562 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
2828 - class="
2829 - <?php
2830 - if ( $field->is_required ) {
2831 - echo 'required_field';
2832 - }
2833 - ?>
2834 - 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 ); ?>">
2835 2566
2836 2567 <?php
2837 - if ( ! is_admin() ) {
2838 - ?>
2568 + if ( ! is_admin() ) { ?>
2839 2569 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
2840 2570 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
2841 - <?php
2842 - if ( $field->is_required ) {
2571 + <?php if ( $field->is_required ) {
2843 2572 echo '<span>*</span>';
2844 - }
2845 - ?>
2573 + } ?>
2846 2574 </label>
2847 2575 <?php } ?>
2848 2576
2849 2577 <?php
@@ -2872,9 +2600,9 @@
2872 2600 ><?php echo $select_options; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
2873 2601 </select>
2874 2602 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
2875 2603 <?php if ( $field->is_required ) { ?>
2876 - <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>
2877 2605 <?php } ?>
2878 2606 </div>
2879 2607
2880 2608 <?php
@@ -2906,14 +2634,14 @@
2906 2634 }
2907 2635
2908 2636 if ( empty( $html ) ) {
2909 2637
2910 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2911 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
2912 - $bs_sr_only = $design_style ? 'sr-only' : '';
2913 - $bs_form_control = $design_style ? 'form-control' : '';
2914 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
2915 - $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') : '';
2916 2644
2917 2645 ob_start(); // Start buffering;
2918 2646
2919 2647 $multi_display = 'select';
@@ -2922,9 +2650,9 @@
2922 2650 }
2923 2651
2924 2652 $option_values_arr = uwp_string_values_to_options( $field->option_values, true );
2925 2653 $site_title = uwp_get_form_label( $field );
2926 - $value = is_array( $value ) ? $value : esc_attr( $value );
2654 + $value = is_array($value) ? $value : esc_attr($value);
2927 2655
2928 2656 // bootstrap
2929 2657 if ( $design_style ) {
2930 2658
@@ -2929,47 +2657,38 @@
2929 2657 if ( $design_style ) {
2930 2658
2931 2659 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
2932 2660
2933 - echo aui()->select(
2934 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2935 - 'id' => esc_attr( $field->htmlvar_name ),
2936 - 'name' => esc_attr( $field->htmlvar_name ),
2937 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2938 - 'title' => esc_html( $site_title ),
2939 - 'value' => $value,
2940 - 'required' => (bool) $field->is_required,
2941 - '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 ),
2942 2669 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
2943 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2944 - 'label' => wp_kses_post( $site_title . $required ),
2945 - 'options' => $option_values_arr, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2946 - 'select2' => true,
2947 - 'multiple' => true,
2948 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2949 - )
2950 - );
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 + ) );
2951 2677 } else {
2952 2678 ?>
2953 2679 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
2954 - class="
2955 - <?php
2956 - if ( $field->is_required ) {
2957 - echo 'required_field';
2958 - }
2959 - ?>
2960 - 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 ); ?>">
2961 2683
2962 2684 <?php
2963 - if ( ! is_admin() ) {
2964 - ?>
2685 + if ( ! is_admin() ) { ?>
2965 2686 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
2966 2687 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
2967 - <?php
2968 - if ( $field->is_required ) {
2688 + <?php if ( $field->is_required ) {
2969 2689 echo '<span>*</span>';
2970 - }
2971 - ?>
2690 + } ?>
2972 2691 </label>
2973 2692 <?php } ?>
2974 2693
2975 2694 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value=""/>
@@ -2982,65 +2701,62 @@
2982 2701 class="aui-select2 <?php echo esc_attr( $bs_form_control ); ?>"
2983 2702 >
2984 2703 <?php
2985 2704 } else {
2986 - ?>
2705 + ?>
2987 2706 <ul class="uwp_multi_choice">
2988 - <?php
2707 + <?php
2989 2708 }
2990 2709
2991 2710 $option_values_arr = uwp_string_values_to_options( $field->option_values, true );
2992 2711 $select_options = '';
2993 2712 if ( ! empty( $option_values_arr ) ) {
2994 - foreach ( $option_values_arr as $option_row ) {
2995 - if ( isset( $option_row['optgroup'] ) && ( $option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end' ) ) {
2996 - $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'] : '';
2997 2716
2998 - if ( $multi_display == 'select' ) {
2999 - $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
3000 - } else {
3001 - $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : '';
3002 - }
3003 - } else {
3004 - $option_label = isset( $option_row['label'] ) ? $option_row['label'] : '';
3005 - $option_value = isset( $option_row['value'] ) ? $option_row['value'] : '';
3006 - $selected = $option_value == $value ? 'selected="selected"' : '';
3007 - $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 = '';
3008 2727
3009 - if ( ( ! is_array( $value ) && trim( $value ) != '' ) || ( is_array( $value ) && ! empty( $value ) ) ) {
3010 - if ( ! is_array( $value ) ) {
3011 - $value_array = explode( ',', $value );
3012 - } else {
3013 - $value_array = $value;
3014 - }
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 + }
3015 2734
3016 - if ( is_array( $value_array ) ) {
3017 - if ( in_array( $option_value, $value_array ) ) {
3018 - $selected = 'selected="selected"';
3019 - $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 + }
3020 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 + }
3021 2748 }
3022 2749 }
3023 -
3024 - if ( $multi_display == 'select' ) {
3025 - $select_options .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . '>' . $option_label . '</option>';
3026 - } else {
3027 - $select_options .= '<li><input name="' . $field->name . '[]" ' . $checked . ' value="' . esc_attr( $option_value ) . '" class="uwp-' . $multi_display . '" type="' . $multi_display . '" />&nbsp;' . $option_label . ' </li>';
3028 - }
3029 2750 }
3030 - }
3031 - }
3032 2751 echo $select_options; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3033 2752
3034 - if ( $multi_display == 'select' ) {
3035 -
3036 - ?>
3037 - </select></div>
2753 + if ( $multi_display == 'select' ) { ?></select></div>
3038 2754 <?php } else { ?>
3039 2755 </ul>
3040 2756 <?php } ?>
3041 2757 <?php if ( $field->is_required ) { ?>
3042 - <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>
3043 2759 <?php } ?>
3044 2760 </div>
3045 2761 <?php
3046 2762 }
@@ -3074,45 +2790,38 @@
3074 2790
3075 2791 // If no html then we run the standard output.
3076 2792 if ( empty( $html ) ) {
3077 2793
3078 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2794 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3079 2795 $wrap_class = isset( $field->css_class ) ? $field->css_class : '';
3080 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3081 - $bs_sr_only = $design_style ? 'sr-only' : '';
3082 - $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" : "";
3083 2799
3084 2800 ob_start(); // Start buffering;
3085 2801
3086 2802 ?>
3087 2803 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3088 - class="
3089 - <?php
3090 - if ( $field->is_required ) {
3091 - echo 'required_field';
3092 - }
3093 - ?>
3094 - 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 ); ?>">
3095 2807
3096 2808 <?php
3097 2809 $site_title = uwp_get_form_label( $field );
3098 - if ( ! is_admin() && ! wp_doing_ajax() ) {
3099 - ?>
2810 + if ( ! is_admin() && !wp_doing_ajax() ) { ?>
3100 2811 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3101 2812 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3102 - <?php
3103 - if ( $field->is_required ) {
2813 + <?php if ( $field->is_required ) {
3104 2814 echo ' <span class="text-danger">*</span>';
3105 - }
3106 - ?>
2815 + } ?>
3107 2816 </label>
3108 2817 <?php } ?>
3109 2818
3110 2819 <?php echo $file_obj->file_upload_preview( $field, $value ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
3111 2820 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3112 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3113 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3114 - 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 ); ?>"
3115 2824 <?php
3116 2825 if ( $field->is_required == 1 ) {
3117 2826 echo 'data-is-required="1"';
3118 2827 }
@@ -3119,12 +2828,12 @@
3119 2828 if ( $field->is_required == 1 && ! $value ) {
3120 2829 echo 'required="required"';
3121 2830 }
3122 2831 ?>
3123 - type="<?php echo esc_attr( $field->field_type ); ?>">
2832 + type="<?php echo esc_attr( $field->field_type ); ?>">
3124 2833 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3125 2834 <?php if ( $field->is_required ) { ?>
3126 - <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>
3127 2836 <?php } ?>
3128 2837 </div>
3129 2838
3130 2839 <?php
@@ -3156,18 +2865,18 @@
3156 2865
3157 2866 // If no html then we run the standard output.
3158 2867 if ( empty( $html ) ) {
3159 2868
3160 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3161 - $bs_form_group = $design_style ? 'form-group mb-3 form-check' : '';
3162 - $bs_sr_only = $design_style ? 'form-check-label' : '';
3163 - $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" : "";
3164 2873
3165 2874 ob_start(); // Start buffering;
3166 2875 $site_title = uwp_get_form_label( $field );
3167 2876
3168 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3169 - $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;
3170 2879
3171 2880 $checked = $value == '1' ? true : false;
3172 2881
3173 2882 // bootstrap
@@ -3177,20 +2886,20 @@
3177 2886 echo '<input type="hidden" name="' . esc_attr( $field->htmlvar_name ) . '" id="checkbox_' . esc_attr( $id ) . '" value="0"/>';
3178 2887
3179 2888 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3180 2889 array(
3181 - 'id' => esc_attr( $id ),
3182 - 'name' => esc_attr( $field->htmlvar_name ),
3183 - 'type' => 'checkbox',
3184 - 'value' => '1',
3185 - 'title' => esc_html( $site_title ),
3186 - 'label' => wp_kses_post( $site_title . $required ),
3187 - 'label_show' => true,
3188 - 'required' => ! empty( $field->is_required ) ? true : false,
3189 - 'checked' => (bool) $checked,
3190 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3191 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3192 - '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' ) : '',
3193 2902 )
3194 2903 );
3195 2904
3196 2905 } else {
@@ -3195,44 +2904,36 @@
3195 2904
3196 2905 } else {
3197 2906 ?>
3198 2907 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3199 - class="
3200 - <?php
3201 - if ( $field->is_required ) {
3202 - echo 'required_field';
3203 - }
3204 - ?>
3205 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3206 - <?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 ) ){ ?>
3207 2912 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3208 2913 <?php } ?>
3209 2914 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value="0"/>
3210 2915 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3211 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3212 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3213 - title="<?php echo esc_attr( $site_title ); ?>"
3214 - <?php
3215 - 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 ) {
3216 2920 echo 'required="required"';
3217 - }
3218 - ?>
3219 - <?php
3220 - if ( $value == '1' ) {
2921 + } ?>
2922 + <?php if ( $value == '1' ) {
3221 2923 echo 'checked="checked"';
3222 - }
3223 - ?>
3224 - type="<?php echo esc_attr( $field->field_type ); ?>"
3225 - value="1">
2924 + } ?>
2925 + type="<?php echo esc_attr( $field->field_type ); ?>"
2926 + value="1">
3226 2927 <?php
3227 2928 echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;';
3228 2929 ?>
3229 - <?php if ( ! empty( $design_style ) ) { ?>
2930 + <?php if ( ! empty( $design_style ) ){ ?>
3230 2931 </label>
3231 2932 <?php } ?>
3232 2933 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3233 2934 <?php if ( $field->is_required ) { ?>
3234 - <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>
3235 2936 <?php } ?>
3236 2937 </div>
3237 2938
3238 2939 <?php
@@ -3268,13 +2969,13 @@
3268 2969
3269 2970 // If no html then we run the standard output.
3270 2971 if ( empty( $html ) ) {
3271 2972
3272 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3273 - $bs_form_group = $design_style ? 'form-group mb-3 form-check-inline' : '';
3274 - $bs_sr_only = $design_style ? 'sr-only' : '';
3275 - $bs_label_class = $design_style ? 'form-check-label' : '';
3276 - $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" : "";
3277 2978
3278 2979 ob_start(); // Start buffering;
3279 2980
3280 2981 if ( $design_style ) {
@@ -3294,16 +2995,16 @@
3294 2995 echo aui()->radio( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3295 2996 array(
3296 2997 'id' => esc_attr( $field->htmlvar_name ),
3297 2998 'name' => esc_attr( $field->htmlvar_name ),
3298 - 'type' => 'radio',
2999 + 'type' => "radio",
3299 3000 'title' => esc_html( $site_title ),
3300 - '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 ),
3301 3002 'label_type' => 'top',
3302 3003 'class' => '',
3303 3004 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3304 3005 'value' => esc_attr( $value ),
3305 - 'options' => $option_values, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3006 + 'options' => $option_values // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3306 3007 )
3307 3008 );
3308 3009
3309 3010 } else {
@@ -3309,32 +3010,24 @@
3309 3010 } else {
3310 3011
3311 3012 ?>
3312 3013 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3313 - class="
3314 - <?php
3315 - if ( $field->is_required ) {
3316 - echo 'required_field';
3317 - }
3318 - ?>
3319 - 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 ); ?>">
3320 3017
3321 3018 <?php
3322 3019 $site_title = uwp_get_form_label( $field );
3323 - if ( ! is_admin() ) {
3324 - ?>
3020 + if ( ! is_admin() ) { ?>
3325 3021 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3326 3022 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3327 - <?php
3328 - if ( $field->is_required ) {
3023 + <?php if ( $field->is_required ) {
3329 3024 echo '<span>*</span>';
3330 - }
3331 - ?>
3025 + } ?>
3332 3026 </label>
3333 3027 <?php } ?>
3334 3028
3335 - <?php
3336 - if ( $field->option_values ) {
3029 + <?php if ( $field->option_values ) {
3337 3030 $option_values = uwp_string_values_to_options( $field->option_values, true );
3338 3031
3339 3032 if ( ! empty( $option_values ) ) {
3340 3033 $count = 0;
@@ -3339,13 +3032,13 @@
3339 3032 if ( ! empty( $option_values ) ) {
3340 3033 $count = 0;
3341 3034 foreach ( $option_values as $option_value ) {
3342 3035 if ( empty( $option_value['optgroup'] ) ) {
3343 - ++$count;
3036 + $count ++;
3344 3037 if ( $count == 1 ) {
3345 - $class = 'uwp-radio-first';
3038 + $class = "uwp-radio-first";
3346 3039 } else {
3347 - $class = '';
3040 + $class = "";
3348 3041 }
3349 3042 ?>
3350 3043 <?php if ( ! empty( $design_style ) ) { ?>
3351 3044 <label class="<?php echo esc_attr( $bs_label_class ); ?>">
@@ -3352,18 +3045,16 @@
3352 3045 <?php } else { ?>
3353 3046 <span class="uwp-radios <?php echo esc_attr( $class ); ?>">
3354 3047 <?php } ?>
3355 3048 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3356 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3357 - 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'] ); ?>"
3358 3051 <?php checked( $value, $option_value['value'] ); ?>
3359 - <?php
3360 - if ( $field->is_required == 1 ) {
3052 + <?php if ( $field->is_required == 1 ) {
3361 3053 echo 'required="required"';
3362 - }
3363 - ?>
3364 - value="<?php echo esc_attr( $option_value['value'] ); ?>"
3365 - 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"/>
3366 3057 <?php echo esc_html( $option_value['label'] ); ?>
3367 3058 <?php if ( ! empty( $design_style ) ) { ?>
3368 3059 </label>
3369 3060 <?php } else { ?>
@@ -3376,9 +3067,9 @@
3376 3067 }
3377 3068 ?>
3378 3069 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3379 3070 <?php if ( $field->is_required ) { ?>
3380 - <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>
3381 3072 <?php } ?>
3382 3073 </div>
3383 3074 <?php
3384 3075 }
@@ -3421,140 +3112,125 @@
3421 3112 $type = 'number';
3422 3113 } elseif ( isset( $field->data_type ) && $field->data_type == 'FLOAT' ) {
3423 3114 $dp = $field->decimal_point;
3424 3115 switch ( $dp ) {
3425 - case '1':
3426 - $step = '0.1';
3116 + case "1":
3117 + $step = "0.1";
3427 3118 break;
3428 - case '2':
3429 - $step = '0.01';
3119 + case "2":
3120 + $step = "0.01";
3430 3121 break;
3431 - case '3':
3432 - $step = '0.001';
3122 + case "3":
3123 + $step = "0.001";
3433 3124 break;
3434 - case '4':
3435 - $step = '0.0001';
3125 + case "4":
3126 + $step = "0.0001";
3436 3127 break;
3437 - case '5':
3438 - $step = '0.00001';
3128 + case "5":
3129 + $step = "0.00001";
3439 3130 break;
3440 - case '6':
3441 - $step = '0.000001';
3131 + case "6":
3132 + $step = "0.000001";
3442 3133 break;
3443 - case '7':
3444 - $step = '0.0000001';
3134 + case "7":
3135 + $step = "0.0000001";
3445 3136 break;
3446 - case '8':
3447 - $step = '0.00000001';
3137 + case "8":
3138 + $step = "0.00000001";
3448 3139 break;
3449 - case '9':
3450 - $step = '0.000000001';
3140 + case "9":
3141 + $step = "0.000000001";
3451 3142 break;
3452 - case '10':
3453 - $step = '0.0000000001';
3143 + case "10":
3144 + $step = "0.0000000001";
3454 3145 break;
3455 3146 default:
3456 - $step = '0.01';
3147 + $step = "0.01";
3457 3148 break;
3458 3149 }
3459 3150 $type = 'number';
3460 3151 }
3461 3152
3153 +
3462 3154 $site_title = uwp_get_form_label( $field );
3463 3155 $placeholder = uwp_get_field_placeholder( $field );
3464 3156 $manual_label = apply_filters( 'uwp_login_username_label_manual', true );
3465 3157 if ( $manual_label
3466 - && isset( $field->form_type )
3467 - && $field->form_type == 'login'
3468 - && $field->htmlvar_name == 'username' ) {
3469 - $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' );
3470 3162 $required = ! empty( $field->is_required ) ? ' *' : '';
3471 3163 $placeholder = $site_title . $required;
3472 3164 $placeholder = apply_filters( 'uwp_get_field_placeholder', stripslashes( $placeholder ), $field );
3473 3165 }
3474 3166
3475 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3476 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3477 - $bs_sr_only = $design_style ? 'sr-only' : '';
3478 - $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" : "";
3479 3171
3480 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
3481 - $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') : '';
3482 3174
3483 3175 // bootstrap
3484 3176 if ( $design_style ) {
3485 3177 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3486 3178
3487 - echo aui()->input(
3488 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3489 - 'type' => esc_attr( $type ),
3490 - 'id' => esc_attr( $field->htmlvar_name ),
3491 - 'name' => esc_attr( $field->htmlvar_name ),
3492 - 'placeholder' => esc_attr( $placeholder ),
3493 - 'title' => esc_html( $site_title ),
3494 - 'value' => esc_attr( wp_unslash( $value ) ),
3495 - 'required' => (bool) $field->is_required,
3496 - '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 ),
3497 3188 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3498 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3499 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3500 - 'step' => esc_attr( $step ),
3501 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3502 - )
3503 - );
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 + ) );
3504 3194 } else {
3505 3195 ?>
3506 - <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row" class="
3507 - <?php
3508 - if ( $field->is_required ) {
3509 - echo 'required_field';
3510 - }
3511 - ?>
3512 - 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 ); ?>">
3513 3199 <?php
3514 3200
3515 - if ( ! is_admin() ) {
3516 - ?>
3201 + if ( ! is_admin() ) { ?>
3517 3202 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3518 3203 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3519 - <?php
3520 - if ( $field->is_required ) {
3204 + <?php if ( $field->is_required ) {
3521 3205 echo '<span>*</span>';
3522 - }
3523 - ?>
3206 + } ?>
3524 3207 </label>
3525 - <?php
3526 - }
3208 + <?php }
3527 3209 ?>
3528 3210
3529 3211 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3530 - class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
3531 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3532 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3533 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
3534 - title="<?php echo esc_attr( $site_title ); ?>"
3535 - oninvalid="this.setCustomValidity('<?php esc_attr_e( stripslashes( $field->required_msg ), 'userswp' ); ?>')"
3536 - oninput="setCustomValidity('')"
3537 - <?php
3538 - 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 ) {
3539 3220 echo 'required="required"';
3540 - }
3541 - ?>
3542 - <?php
3543 - if ( $field->for_admin_use == 1 ) {
3221 + } ?>
3222 + <?php if ( $field->for_admin_use == 1 ) {
3544 3223 echo 'readonly="readonly"';
3545 - }
3546 - ?>
3547 - type="<?php echo esc_attr( $type ); ?>"
3548 - <?php
3549 - if ( $step ) {
3224 + } ?>
3225 + type="<?php echo esc_attr( $type ); ?>"
3226 + <?php if ( $step ) {
3550 3227 echo 'step="' . esc_attr( $step ) . '"';
3551 - }
3552 - ?>
3228 + } ?>
3553 3229 />
3554 3230 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3555 3231 <?php if ( $field->is_required ) { ?>
3556 - <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>
3557 3233 <?php } ?>
3558 3234 </div>
3559 3235
3560 3236
@@ -3588,12 +3264,12 @@
3588 3264
3589 3265 // If no html then we run the standard output.
3590 3266 if ( empty( $html ) ) {
3591 3267
3592 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3593 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3594 - $bs_sr_only = $design_style ? 'sr-only' : '';
3595 - $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" : "";
3596 3272 $site_title = uwp_get_form_label( $field );
3597 3273
3598 3274 ob_start(); // Start buffering;
3599 3275
@@ -3600,10 +3276,9 @@
3600 3276 // bootstrap
3601 3277 if ( $design_style ) {
3602 3278 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3603 3279
3604 - echo aui()->textarea(
3605 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3280 + echo aui()->textarea( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3606 3281 'id' => esc_attr( $field->htmlvar_name ),
3607 3282 'name' => esc_attr( $field->htmlvar_name ),
3608 3283 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3609 3284 'title' => esc_html( $site_title ),
@@ -3608,57 +3283,47 @@
3608 3283 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3609 3284 'title' => esc_html( $site_title ),
3610 3285 'value' => wp_kses_post( stripslashes( $value ) ),
3611 3286 'required' => (bool) $field->is_required,
3612 - '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' ) : '',
3613 3288 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3614 - '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 ),
3615 3290 'rows' => '4',
3616 3291 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3617 - )
3618 - );
3292 + ) );
3619 3293 } else {
3620 3294 ?>
3621 3295
3622 3296 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3623 - class="
3624 - <?php
3625 - if ( $field->is_required ) {
3626 - echo 'required_field';
3627 - }
3628 - ?>
3629 - 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 ); ?>">
3630 3300
3631 3301 <?php
3632 3302
3633 - if ( ! is_admin() ) {
3634 - ?>
3303 + if ( ! is_admin() ) { ?>
3635 3304 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3636 3305 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3637 - <?php
3638 - if ( $field->is_required ) {
3306 + <?php if ( $field->is_required ) {
3639 3307 echo '<span>*</span>';
3640 - }
3641 - ?>
3308 + } ?>
3642 3309 </label>
3643 3310 <?php } ?>
3644 3311
3645 3312 <textarea name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3646 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3647 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3648 - title="<?php echo esc_attr( $site_title ); ?>"
3649 - oninvalid="this.setCustomValidity('<?php esc_attr_e( stripslashes( $field->required_msg ), 'userswp' ); ?>')"
3650 - oninput="setCustomValidity('')"
3651 - <?php
3652 - 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 ) {
3653 3319 echo 'required="required"';
3654 - }
3655 - ?>
3656 - type="<?php echo esc_attr( $field->field_type ); ?>"
3657 - 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>
3658 3323 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3659 3324 <?php if ( $field->is_required ) { ?>
3660 - <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>
3661 3326 <?php } ?>
3662 3327 </div>
3663 3328
3664 3329 <?php
@@ -3679,11 +3344,11 @@
3679 3344 if ( empty( $html ) ) {
3680 3345
3681 3346 ob_start();
3682 3347
3683 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3684 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3685 - $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" : "";
3686 3351 $site_title = uwp_get_form_label( $field );
3687 3352
3688 3353 $content = stripslashes( $value );
3689 3354 $editor_id = $field->htmlvar_name;
@@ -3692,54 +3357,45 @@
3692 3357 'media_buttons' => false,
3693 3358 'quicktags' => false,
3694 3359 );
3695 3360
3696 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
3697 - $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') : '';
3698 3363
3699 3364 // bootstrap
3700 3365 if ( $design_style ) {
3701 3366 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3702 3367
3703 - echo aui()->textarea(
3704 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3705 - 'id' => esc_attr( $field->htmlvar_name ),
3706 - 'name' => esc_attr( $field->htmlvar_name ),
3707 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3708 - 'title' => esc_html( $site_title ),
3709 - 'value' => wp_kses_post( stripslashes( $value ) ),
3710 - 'required' => (bool) $field->is_required,
3711 - '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 ),
3712 3376 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3713 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3714 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3715 - 'rows' => 5,
3716 - 'wysiwyg' => true,
3717 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3718 - )
3719 - );
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 + ) );
3720 3383 } else {
3721 3384 ?>
3722 3385 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3723 - class="
3724 - <?php
3725 - if ( $field->is_required ) {
3726 - echo 'required_field';
3727 - }
3728 - ?>
3729 - 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 ); ?>">
3730 3389
3731 3390 <?php
3732 3391
3733 - if ( ! is_admin() ) {
3734 - ?>
3392 + if ( ! is_admin() ) { ?>
3735 3393 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3736 3394 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3737 - <?php
3738 - if ( $field->is_required ) {
3395 + <?php if ( $field->is_required ) {
3739 3396 echo '<span>*</span>';
3740 - }
3741 - ?>
3397 + } ?>
3742 3398 </label>
3743 3399 <?php } ?>
3744 3400
3745 3401 <?php wp_editor( $content, $editor_id, $args ); ?>
@@ -3745,9 +3401,9 @@
3745 3401 <?php wp_editor( $content, $editor_id, $args ); ?>
3746 3402
3747 3403 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3748 3404 <?php if ( $field->is_required ) { ?>
3749 - <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>
3750 3406 <?php } ?>
3751 3407 </div>
3752 3408 <?php
3753 3409 }
@@ -3783,14 +3439,11 @@
3783 3439 $site_title = uwp_get_form_label( $field );
3784 3440 ?>
3785 3441 <h3 class="uwp_input_fieldset <?php echo esc_attr( $field->css_class ); ?>">
3786 3442 <?php echo esc_html( $site_title ); ?>
3787 - <?php
3788 - if ( $field->help_text != '' ) {
3443 + <?php if ( $field->help_text != '' ) {
3789 3444 echo '<small>( ' . wp_kses_post( $field->help_text ) . ' )</small>';
3790 - }
3791 - ?>
3792 - </h3>
3445 + } ?></h3>
3793 3446 <?php
3794 3447 $html = ob_get_clean();
3795 3448 }
3796 3449
@@ -3811,8 +3464,9 @@
3811 3464 * @since 1.0.0
3812 3465 */
3813 3466 public function form_input_url( $html, $field, $value, $form_type ) {
3814 3467
3468 +
3815 3469 // Check if there is a custom field specific filter.
3816 3470 if ( has_filter( "uwp_form_input_url_{$field->htmlvar_name}" ) ) {
3817 3471 $html = apply_filters( "uwp_form_input_url_{$field->htmlvar_name}", $html, $field, $value, $form_type );
3818 3472 }
@@ -3819,84 +3473,70 @@
3819 3473
3820 3474 // If no html then we run the standard output.
3821 3475 if ( empty( $html ) ) {
3822 3476
3823 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3824 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3825 - $bs_sr_only = $design_style ? 'sr-only' : '';
3826 - $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" : "";
3827 3481
3828 3482 ob_start(); // Start buffering;
3829 3483 $site_title = uwp_get_form_label( $field );
3830 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : __( 'Please enter a valid URL including https://', 'userswp' );
3831 - $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') : '';
3832 3486
3833 3487 // bootstrap
3834 3488 if ( $design_style ) {
3835 3489 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3836 3490
3837 - echo aui()->input(
3838 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3839 - 'type' => 'url',
3840 - 'id' => esc_attr( $field->htmlvar_name ),
3841 - 'name' => esc_attr( $field->htmlvar_name ),
3842 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3843 - 'title' => esc_html( $site_title ),
3844 - 'value' => esc_attr( $value ),
3845 - 'required' => (bool) $field->is_required,
3846 - '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 ),
3847 3500 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3848 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3849 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3850 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3851 - )
3852 - );
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 + ) );
3853 3505 } else {
3854 3506 ?>
3855 3507 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3856 - class="
3857 - <?php
3858 - if ( $field->is_required ) {
3859 - echo 'required_field';
3860 - }
3861 - ?>
3862 - 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 ); ?>">
3863 3511
3864 3512 <?php
3865 - if ( ! is_admin() ) {
3866 - ?>
3513 + if ( ! is_admin() ) { ?>
3867 3514 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3868 3515 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3869 - <?php
3870 - if ( $field->is_required ) {
3516 + <?php if ( $field->is_required ) {
3871 3517 echo '<span>*</span>';
3872 - }
3873 - ?>
3518 + } ?>
3874 3519 </label>
3875 3520 <?php } ?>
3876 3521
3877 3522 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3878 - class="
3879 - <?php
3880 - //echo $field->css_class;
3881 - ?>
3882 - uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
3883 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3884 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3885 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
3886 - title="<?php echo esc_attr( $site_title ); ?>"
3887 - <?php
3888 - 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 ) {
3889 3530 echo 'required="required"';
3890 - }
3891 - ?>
3892 - type="url"
3893 - oninvalid="setCustomValidity('<?php esc_attr_e( 'Please enter a valid URL including http://', 'userswp' ); ?>')"
3894 - 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){}"
3895 3535 />
3896 3536 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3897 3537 <?php if ( $field->is_required ) { ?>
3898 - <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>
3899 3539 <?php } ?>
3900 3540 </div>
3901 3541
3902 3542 <?php
@@ -3922,8 +3562,9 @@
3922 3562 * @since 1.0.0
3923 3563 */
3924 3564 public function form_input_email( $html, $field, $value, $form_type ) {
3925 3565
3566 +
3926 3567 // Check if there is a custom field specific filter.
3927 3568 if ( has_filter( "uwp_form_input_email_{$field->htmlvar_name}" ) ) {
3928 3569 $html = apply_filters( "uwp_form_input_email_{$field->htmlvar_name}", $html, $field, $value, $form_type );
3929 3570 }
@@ -3930,86 +3571,66 @@
3930 3571
3931 3572 // If no html then we run the standard output.
3932 3573 if ( empty( $html ) ) {
3933 3574
3934 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3935 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3936 - $bs_sr_only = $design_style ? 'sr-only' : '';
3937 - $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" : "";
3938 3579
3939 3580 ob_start(); // Start buffering;
3940 3581 $site_title = uwp_get_form_label( $field );
3941 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
3942 - $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') : '';
3943 3584
3944 - $is_forgot_email = ( $form_type === 'forgot' && $field->htmlvar_name === 'email' );
3945 - $input_type = $is_forgot_email ? 'text' : 'email';
3946 - if ( $is_forgot_email ) {
3947 - $site_title = __( 'Username or Email', 'userswp' );
3948 - $placeholder = $site_title . ( ! empty( $field->is_required ) ? ' *' : '' );
3949 - } else {
3950 - $placeholder = uwp_get_field_placeholder( $field );
3951 - }
3952 -
3953 3585 if ( $design_style ) {
3954 3586 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3955 3587
3956 - echo aui()->input(
3957 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3958 - 'type' => $input_type,
3959 - 'id' => esc_attr( $field->htmlvar_name ),
3960 - 'name' => esc_attr( $field->htmlvar_name ),
3961 - 'placeholder' => esc_attr( $placeholder ),
3962 - 'title' => esc_html( $site_title ),
3963 - 'value' => esc_attr( wp_unslash( $value ) ),
3964 - 'required' => (bool) $field->is_required,
3965 - '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 ),
3966 3597 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3967 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3968 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3969 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3970 - )
3971 - );
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 + ) );
3972 3602 } else {
3973 3603 ?>
3974 3604 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3975 - class="
3976 - <?php
3977 - if ( $field->is_required ) {
3978 - echo 'required_field';
3979 - }
3980 - ?>
3981 - 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 ); ?>">
3982 3608
3983 3609 <?php
3984 - if ( ! is_admin() ) {
3985 - ?>
3610 + if ( ! is_admin() ) { ?>
3986 3611 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3987 3612 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3988 - <?php
3989 - if ( $field->is_required ) {
3613 + <?php if ( $field->is_required ) {
3990 3614 echo '<span>*</span>';
3991 - }
3992 - ?>
3615 + } ?>
3993 3616 </label>
3994 3617 <?php } ?>
3995 3618
3996 3619 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3997 - class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
3998 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3999 - placeholder="<?php echo esc_attr( $placeholder ); ?>"
4000 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
4001 - title="<?php echo esc_attr( $site_title ); ?>"
4002 - <?php
4003 - 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 ) {
4004 3626 echo 'required="required"';
4005 - }
4006 - ?>
4007 - type="<?php echo esc_attr( $input_type ); ?>"
3627 + } ?>
3628 + type="email"
4008 3629 />
4009 3630 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4010 3631 <?php if ( $field->is_required ) { ?>
4011 - <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>
4012 3633 <?php } ?>
4013 3634 </div>
4014 3635
4015 3636
@@ -4040,8 +3661,9 @@
4040 3661 * @since 1.0.0
4041 3662 */
4042 3663 public function form_input_password( $html, $field, $value, $form_type ) {
4043 3664
3665 +
4044 3666 // Check if there is a custom field specific filter.
4045 3667 if ( has_filter( "uwp_form_input_password_{$field->htmlvar_name}" ) ) {
4046 3668 $html = apply_filters( "uwp_form_input_password_{$field->htmlvar_name}", $html, $field, $value, $form_type );
4047 3669 }
@@ -4048,12 +3670,12 @@
4048 3670
4049 3671 // If no html then we run the standard output.
4050 3672 if ( empty( $html ) ) {
4051 3673
4052 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4053 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4054 - $bs_sr_only = $design_style ? 'sr-only' : '';
4055 - $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" : "";
4056 3678
4057 3679 ob_start(); // Start buffering;
4058 3680 $site_title = uwp_get_form_label( $field );
4059 3681
@@ -4058,66 +3680,55 @@
4058 3680 $site_title = uwp_get_form_label( $field );
4059 3681
4060 3682 if ( $design_style ) {
4061 3683 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4062 - $required_msg = ( ! empty( $field->required_msg ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4063 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
4064 - $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';
4065 3687
4066 - echo aui()->input(
4067 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4068 - 'type' => 'password',
4069 - 'id' => esc_attr( $field->htmlvar_name ),
4070 - 'name' => esc_attr( $field->htmlvar_name ),
4071 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4072 - 'title' => esc_html( $site_title ),
4073 - 'value' => esc_attr( $value ),
4074 - 'required' => (bool) $field->is_required,
4075 - '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 ),
4076 3697 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4077 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4078 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4079 - 'wrap_class' => esc_attr( $wrap_class ),
4080 - )
4081 - );
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 + ) );
4082 3702 } else {
4083 3703 ?>
4084 - <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row" class="
4085 - <?php
4086 - if ( $field->is_required ) {
4087 - echo 'required_field';
4088 - }
4089 - ?>
4090 - 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 ); ?>">
4091 3707 <?php
4092 - if ( ! is_admin() ) {
4093 - ?>
3708 + if ( ! is_admin() ) { ?>
4094 3709 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4095 3710 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4096 - <?php
4097 - if ( $field->is_required ) {
3711 + <?php if ( $field->is_required ) {
4098 3712 echo '<span>*</span>';
4099 - }
4100 - ?>
3713 + } ?>
4101 3714 </label>
4102 3715 <?php } ?>
4103 3716
4104 3717 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4105 - class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
4106 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4107 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4108 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
4109 - title="<?php echo esc_attr( $site_title ); ?>"
4110 - <?php
4111 - 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 ) {
4112 3724 echo 'required="required"';
4113 - }
4114 - ?>
4115 - type="password"
3725 + } ?>
3726 + type="password"
4116 3727 />
4117 3728 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4118 3729 <?php if ( $field->is_required ) { ?>
4119 - <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>
4120 3731 <?php } ?>
4121 3732 </div>
4122 3733
4123 3734
@@ -4147,74 +3758,61 @@
4147 3758 *
4148 3759 */
4149 3760 public function form_input_phone( $html, $field, $value, $form_type ) {
4150 3761 if ( empty( $html ) ) {
4151 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4152 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4153 - $bs_sr_only = $design_style ? 'sr-only' : '';
4154 - $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" : "";
4155 3766 ob_start(); // Start buffering;
4156 3767 $site_title = uwp_get_form_label( $field );
4157 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4158 - $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') : '';
4159 3770
4160 3771 if ( $design_style ) {
4161 3772 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4162 3773
4163 - echo aui()->input(
4164 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4165 - 'type' => 'tel',
4166 - 'id' => esc_attr( $field->htmlvar_name ),
4167 - 'name' => esc_attr( $field->htmlvar_name ),
4168 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4169 - 'title' => esc_html( $site_title ),
4170 - 'value' => esc_attr( $value ),
4171 - 'required' => (bool) $field->is_required,
4172 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4173 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4174 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4175 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4176 - 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4177 - )
4178 - );
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 + ) );
4179 3788 } else {
4180 3789 ?>
4181 3790 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4182 - class="
4183 - <?php
4184 - if ( $field->is_required ) {
4185 - echo 'required_field';
4186 - }
4187 - ?>
4188 - 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 ); ?>">
4189 3794 <?php
4190 - if ( ! is_admin() ) {
4191 - ?>
3795 + if ( ! is_admin() ) { ?>
4192 3796 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4193 3797 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4194 - <?php
4195 - if ( $field->is_required ) {
3798 + <?php if ( $field->is_required ) {
4196 3799 echo '<span>*</span>';
4197 - }
4198 - ?>
3800 + } ?>
4199 3801 </label>
4200 3802 <?php } ?>
4201 3803 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4202 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
4203 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4204 - title="<?php echo esc_attr( $site_title ); ?>"
4205 - <?php
4206 - 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 ) {
4207 3808 echo 'readonly="readonly"';
4208 - }
4209 - ?>
4210 - <?php
4211 - if ( $field->is_required == 1 ) {
3809 + } ?>
3810 + <?php if ( $field->is_required == 1 ) {
4212 3811 echo 'required="required"';
4213 - }
4214 - ?>
4215 - type="tel"
4216 - value="<?php echo esc_html( $value ); ?>">
3812 + } ?>
3813 + type="tel"
3814 + value="<?php echo esc_html( $value ); ?>">
4217 3815 </div>
4218 3816 <?php
4219 3817 }
4220 3818 $html = ob_get_clean();
@@ -4224,22 +3822,22 @@
4224 3822 }
4225 3823
4226 3824 public function form_input_register_gdpr( $html, $field, $value, $form_type ) {
4227 3825
4228 - $form_id = isset( $field->form_id ) ? (int) $field->form_id : 1;
4229 - $reg_gdpr = uwp_get_register_form_by( $form_id, 'gdpr_page' );
4230 - 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)){
4231 3829 $reg_gdpr = uwp_get_option( 'register_gdpr_page', false );
4232 3830 }
4233 3831
4234 3832 if ( ! empty( $reg_gdpr ) ) {
4235 3833
4236 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4237 - $bs_form_group = $design_style ? 'form-group mb-3 form-check' : '';
4238 - $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" : "";
4239 3837 $site_title = uwp_get_form_label( $field );
4240 3838 $field->htmlvar_name = 'register_gdpr';
4241 - $id = wp_doing_ajax() ? $field->htmlvar_name . '_ajax' : $field->htmlvar_name;
3839 + $id = wp_doing_ajax() ? $field->htmlvar_name . "_ajax" : $field->htmlvar_name;
4242 3840
4243 3841 $gdpr_page = get_permalink( $reg_gdpr );
4244 3842 $link_start = '<a href="' . esc_url( $gdpr_page ) . '" target="_blank">';
4245 3843 $link_end = '</a>';
@@ -4245,9 +3843,9 @@
4245 3843 $link_end = '</a>';
4246 3844 $field_desc = uwp_get_field_description( $field, '' );
4247 3845 $field_desc = str_replace( '%%link_start%%', $link_start, $field_desc );
4248 3846 $field_desc = str_replace( '%%link_end%%', $link_end, $field_desc );
4249 - $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>' );
4250 3848 $checked = $value == '1' ? true : false;
4251 3849
4252 3850 ob_start(); // Start buffering;
4253 3851
@@ -4257,19 +3855,19 @@
4257 3855 echo '<input type="hidden" name="' . esc_attr( $field->htmlvar_name ) . '" id="checkbox_' . esc_attr( $id ) . '" value="0"/>';
4258 3856
4259 3857 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4260 3858 array(
4261 - 'id' => esc_attr( $id ),
4262 - 'name' => esc_attr( $field->htmlvar_name ),
4263 - 'type' => 'checkbox',
4264 - 'value' => '1',
4265 - 'title' => esc_html( $site_title ),
4266 - 'label' => wp_kses_post( $content . $required ),
4267 - 'label_show' => true,
4268 - 'required' => ! empty( $field->is_required ) ? true : false,
4269 - 'checked' => (bool) $checked,
4270 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4271 - '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' ) : '',
4272 3870 )
4273 3871 );
4274 3872
4275 3873 } else {
@@ -4274,33 +3872,27 @@
4274 3872
4275 3873 } else {
4276 3874 ?>
4277 3875 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4278 - class="
4279 - <?php
4280 - if ( $field->is_required ) {
4281 - echo 'required_field';
4282 - }
4283 - ?>
4284 - 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 ); ?>">
4285 3879 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value="0"/>
4286 3880 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4287 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
4288 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4289 - title="<?php echo esc_attr( $site_title ); ?>"
4290 - <?php
4291 - 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' ) {
4292 3885 echo 'checked="checked"';
4293 - }
4294 - ?>
4295 - type="<?php echo esc_attr( $field->field_type ); ?>"
4296 - value="1">
3886 + } ?>
3887 + type="<?php echo esc_attr( $field->field_type ); ?>"
3888 + value="1">
4297 3889 <?php
4298 3890 echo ( trim( $content ) ) ? wp_kses_post( $content ) : '&nbsp;';
4299 3891 ?>
4300 3892 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4301 3893 <?php if ( $field->is_required ) { ?>
4302 - <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>
4303 3895 <?php } ?>
4304 3896 </div>
4305 3897
4306 3898 <?php
@@ -4316,19 +3908,19 @@
4316 3908 }
4317 3909
4318 3910 public function form_input_register_tos( $html, $field, $value, $form_type ) {
4319 3911
4320 - $form_id = isset( $field->form_id ) ? (int) $field->form_id : 1;
4321 - $reg_tos = uwp_get_register_form_by( $form_id, 'tos_page' );
4322 - 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)){
4323 3915 $reg_tos = uwp_get_option( 'register_terms_page', false );
4324 3916 }
4325 3917
4326 3918 if ( ! empty( $reg_tos ) ) {
4327 3919
4328 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4329 - $bs_form_group = $design_style ? 'form-group mb-3 form-check' : '';
4330 - $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" : "";
4331 3923
4332 3924 $site_title = uwp_get_form_label( $field );
4333 3925 $terms_page = get_permalink( $reg_tos );
4334 3926 $link_start = '<a href="' . esc_url( $terms_page ) . '" target="_blank">';
@@ -4336,11 +3928,11 @@
4336 3928 $field_desc = uwp_get_field_description( $field, '' );
4337 3929 $field_desc = str_replace( '%%link_start%%', $link_start, $field_desc );
4338 3930 $field_desc = str_replace( '%%link_end%%', $link_end, $field_desc );
4339 3931 $field->htmlvar_name = 'register_tos';
4340 - $id = wp_doing_ajax() ? $field->htmlvar_name . '_ajax' : $field->htmlvar_name;
3932 + $id = wp_doing_ajax() ? $field->htmlvar_name . "_ajax" : $field->htmlvar_name;
4341 3933
4342 - $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>' );
4343 3935 $checked = $value == '1' ? true : false;
4344 3936
4345 3937 ob_start();
4346 3938
@@ -4349,19 +3941,19 @@
4349 3941 echo '<input type="hidden" name="' . esc_attr( $field->htmlvar_name ) . '" id="checkbox_' . esc_attr( $id ) . '" value="0"/>';
4350 3942
4351 3943 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4352 3944 array(
4353 - 'id' => esc_attr( $id ),
4354 - 'name' => esc_attr( $field->htmlvar_name ),
4355 - 'type' => 'checkbox',
4356 - 'value' => '1',
4357 - 'title' => esc_html( $site_title ),
4358 - 'label' => wp_kses_post( $content . $required ),
4359 - 'label_show' => true,
4360 - 'required' => ! empty( $field->is_required ) ? true : false,
4361 - 'checked' => (bool) $checked,
4362 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4363 - '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' ) : '',
4364 3956 )
4365 3957 );
4366 3958
4367 3959 } else {
@@ -4366,33 +3958,27 @@
4366 3958
4367 3959 } else {
4368 3960 ?>
4369 3961 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4370 - class="
4371 - <?php
4372 - if ( $field->is_required ) {
4373 - echo 'required_field';
4374 - }
4375 - ?>
4376 - 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 ); ?>">
4377 3965 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value="0"/>
4378 3966 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4379 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
4380 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4381 - title="<?php echo esc_attr( $site_title ); ?>"
4382 - <?php
4383 - 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' ) {
4384 3971 echo 'checked="checked"';
4385 - }
4386 - ?>
4387 - type="<?php echo esc_attr( $field->field_type ); ?>"
4388 - value="1">
3972 + } ?>
3973 + type="<?php echo esc_attr( $field->field_type ); ?>"
3974 + value="1">
4389 3975 <?php
4390 3976 echo ( trim( $content ) ) ? wp_kses_post( $content ) : '&nbsp;';
4391 3977 ?>
4392 3978 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4393 3979 <?php if ( $field->is_required ) { ?>
4394 - <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>
4395 3981 <?php } ?>
4396 3982 </div>
4397 3983
4398 3984 <?php
@@ -4418,9 +4004,9 @@
4418 4004 */
4419 4005 function add_multipart_to_admin_edit_form() {
4420 4006 global $wpdb;
4421 4007 $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
4422 - $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
4423 4009 if ( $fields ) {
4424 4010 echo 'enctype="multipart/form-data"';
4425 4011 }
4426 4012 }
@@ -4439,12 +4025,12 @@
4439 4025 global $wpdb;
4440 4026 $file_obj = new UsersWP_Files();
4441 4027 $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
4442 4028 //Normal fields
4443 - $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
4444 4030 if ( $fields ) {
4445 - if ( isset( $_POST['locale'] ) ) {
4446 - $_POST['uwp_language'] = sanitize_text_field( $_POST['locale'] );
4031 + if(isset($_POST['locale'])){
4032 + $_POST['uwp_language'] = sanitize_text_field($_POST['locale']);
4447 4033 }
4448 4034 $result = uwp_validate_fields( $_POST, 'account', $fields );
4449 4035 if ( is_wp_error( $result ) ) {
4450 4036 die( wp_kses_post( $result->get_error_message() ) );
@@ -4450,13 +4036,15 @@
4450 4036 die( wp_kses_post( $result->get_error_message() ) );
4451 4037 }
4452 4038 if ( isset( $result['display_name'] ) && ! empty( $result['display_name'] ) ) {
4453 4039 $display_name = $result['display_name'];
4454 - } elseif ( ! empty( $first_name ) || ! empty( $last_name ) ) {
4040 + } else {
4041 + if ( ! empty( $first_name ) || ! empty( $last_name ) ) {
4455 4042 $display_name = $result['first_name'] . ' ' . $result['last_name'];
4456 4043 } else {
4457 - $user_info = get_userdata( $user_id );
4458 - $display_name = $user_info->user_login;
4044 + $user_info = get_userdata( $user_id );
4045 + $display_name = $user_info->user_login;
4046 + }
4459 4047 }
4460 4048 $result['display_name'] = $display_name;
4461 4049 if ( ! is_wp_error( $result ) ) {
4462 4050 foreach ( $fields as $field ) {
@@ -4468,14 +4056,14 @@
4468 4056 }
4469 4057 }
4470 4058
4471 4059 //File fields
4472 - $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
4473 4061 if ( $fields ) {
4474 4062 $result = $file_obj->validate_uploads( $_FILES, 'account', true, $fields );
4475 4063 if ( ! is_wp_error( $result ) ) {
4476 4064 foreach ( $fields as $field ) {
4477 - $value = isset( $result[ $field->htmlvar_name ] ) ? $result[ $field->htmlvar_name ] : '';
4065 + $value = $result[ $field->htmlvar_name ];
4478 4066 if ( $value == '0' || ! empty( $value ) ) {
4479 4067 uwp_update_usermeta( $user_id, $field->htmlvar_name, $value );
4480 4068 }
4481 4069 }
@@ -4500,29 +4088,27 @@
4500 4088
4501 4089 // If no html then we run the standard output.
4502 4090 if ( empty( $html ) ) {
4503 4091
4504 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4505 - $bs_form_group = $design_style ? 'form-group m-0' : ''; // country wrapper div added by JS adds margin so we remove ours
4506 - $bs_sr_only = $design_style ? 'sr-only' : '';
4507 - $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" : "";
4508 4096
4509 4097 ob_start(); // Start buffering;
4510 4098 ?>
4511 - <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 ); ?>">
4512 4100
4513 4101 <?php
4514 4102 $site_title = uwp_get_form_label( $field );
4515 4103
4516 - if ( ! is_admin() && ! wp_doing_ajax() ) {
4104 + if ( ! is_admin() && !wp_doing_ajax() ) {
4517 4105 ?>
4518 4106 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4519 4107 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4520 - <?php
4521 - if ( $field->is_required ) {
4108 + <?php if ( $field->is_required ) {
4522 4109 echo '<span class="text-danger">*</span>';
4523 - }
4524 - ?>
4110 + } ?>
4525 4111 </label>
4526 4112 <?php
4527 4113 }
4528 4114 // if value empty set the default
@@ -4544,9 +4130,9 @@
4544 4130 <input type="hidden" id="<?php echo esc_attr( $htmlvar_name ); ?>_code" name="<?php echo esc_attr( $field->htmlvar_name ); ?>"/>
4545 4131 <script>jQuery(function(){jQuery("#<?php echo esc_js( $htmlvar_name ); ?>").countrySelect(<?php echo wp_json_encode( json_decode( $select_country_options ) ); ?>);});</script>
4546 4132 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4547 4133 <?php if ( $field->is_required ) { ?>
4548 - <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>
4549 4135 <?php } ?>
4550 4136 </div>
4551 4137 <?php
4552 4138 $html = ob_get_clean();
@@ -4572,38 +4158,31 @@
4572 4158
4573 4159 // If no html then we run the standard output.
4574 4160 if ( empty( $html ) ) {
4575 4161
4576 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4577 - $bs_form_group = $design_style ? 'form-group m-0' : '';
4578 - $bs_sr_only = $design_style ? 'sr-only' : '';
4579 - $bs_form_control = $design_style ? 'form-control' : '';
4580 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4581 - $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') : '';
4582 4168
4583 4169 ob_start(); // Start buffering;
4584 4170
4585 4171 ?>
4586 - <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4587 - class="
4588 - <?php
4589 - if ( $field->is_required ) {
4590 - echo 'required_field';
4591 - }
4592 - ?>
4593 - 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 ); ?>">
4594 4176
4595 4177 <?php
4596 4178 $site_title = uwp_get_form_label( $field );
4597 - if ( ! is_admin() && ! wp_doing_ajax() ) {
4598 - ?>
4179 + if ( ! is_admin() && !wp_doing_ajax() ) { ?>
4599 4180 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4600 4181 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4601 - <?php
4602 - if ( $field->is_required ) {
4182 + <?php if ( $field->is_required ) {
4603 4183 echo '<span class="text-danger">*</span>';
4604 - }
4605 - ?>
4184 + } ?>
4606 4185 </label>
4607 4186 <?php } ?>
4608 4187
4609 4188 <?php
@@ -4618,43 +4197,41 @@
4618 4197
4619 4198 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
4620 4199 $translations = wp_get_available_translations();
4621 4200 $available_languages = get_available_languages();
4622 - $languages = array( 'site-default' => __( 'Site Default', 'userswp' ) );
4201 + $languages = array('site-default' => __( 'Site Default', 'userswp' ));
4623 4202
4624 4203 foreach ( $available_languages as $locale ) {
4625 4204 if ( isset( $translations[ $locale ] ) ) {
4626 4205 $translation = $translations[ $locale ];
4627 - $languages[ $translation['language'] ] = $translation['native_name'];
4206 + $languages[$translation['language']] = $translation['native_name'];
4628 4207
4629 4208 // Remove installed language from available translations.
4630 4209 unset( $translations[ $locale ] );
4631 4210 } else {
4632 - $languages[ $locale ] = $translation[ $locale ];
4211 + $languages[$locale] = $translation[$locale];
4633 4212 }
4634 4213 }
4635 4214
4636 4215 if ( $design_style ) {
4637 4216
4638 - $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4217 + $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4639 4218
4640 - echo aui()->select(
4641 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4642 - 'id' => esc_attr( $field->htmlvar_name ),
4643 - 'name' => esc_attr( $field->htmlvar_name ),
4644 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4645 - 'title' => esc_attr( $site_title ),
4646 - 'value' => esc_attr( $value ),
4647 - 'required' => (bool) $field->is_required,
4648 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4649 - 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4650 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4651 - 'label' => wp_kses_post( $site_title . $required ),
4652 - 'options' => $languages, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4653 - 'select2' => true,
4654 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4655 - )
4656 - );
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 + ) );
4657 4234 } else {
4658 4235 ?>
4659 4236 <select name="<?php echo esc_attr( $field->htmlvar_name ); ?>" id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4660 4237 class="uwp_textfield aui-select2 <?php echo esc_attr( $bs_form_control ); ?>"
@@ -4662,14 +4239,14 @@
4662 4239 data-placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4663 4240 ><?php echo $select_options; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
4664 4241 </select>
4665 4242 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4666 - <?php if ( $field->is_required ) { ?>
4667 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
4668 - <?php
4669 - }
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 }
4670 4246 }
4671 4247
4248 +
4672 4249 $html = ob_get_clean();
4673 4250 }
4674 4251
4675 4252 return $html;
@@ -4698,58 +4275,53 @@
4698 4275
4699 4276 $enable_confirm_password_field = isset( $extra['confirm_password'] ) ? $extra['confirm_password'] : '0';
4700 4277 if ( $enable_confirm_password_field == '1' ) {
4701 4278
4702 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4703 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4704 - $bs_sr_only = $design_style ? 'sr-only' : '';
4705 - $bs_form_control = $design_style ? 'form-control' : '';
4706 - $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' );
4707 4284 $required = '';
4708 4285 if ( isset( $field->is_required ) && ! empty( $field->is_required ) ) {
4709 4286 $placeholder .= ' *';
4710 4287 $required = ' <span class="text-danger">*</span>';
4711 4288 }
4712 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4713 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
4714 - $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';
4715 4292
4716 4293 ob_start(); // Start buffering;
4717 4294
4718 4295 if ( $design_style ) {
4719 4296
4720 - echo aui()->input(
4721 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4722 - 'type' => 'password',
4723 - 'id' => 'confirm_password',
4724 - 'name' => 'confirm_password',
4725 - 'placeholder' => esc_attr( $placeholder ),
4726 - 'title' => esc_attr( $site_title ),
4727 - 'value' => esc_attr( $value ),
4728 - 'required' => (bool) $field->is_required,
4729 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4730 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4731 - '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 ),
4732 4308 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4733 - 'wrap_class' => esc_attr( $wrap_class ),
4734 - )
4735 - );
4309 + 'wrap_class' => esc_attr( $wrap_class ),
4310 + ) );
4736 4311 } else {
4737 4312 ?>
4738 4313 <div id="uwp_account_confirm_password_row"
4739 - 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 ); ?>">
4740 4315
4741 4316 <?php
4742 4317
4743 - if ( ! is_admin() ) {
4744 - ?>
4318 + if ( ! is_admin() ) { ?>
4745 4319 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4746 4320 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4747 - <?php
4748 - if ( $field->is_required ) {
4321 + <?php if ( $field->is_required ) {
4749 4322 echo '<span>*</span>';
4750 - }
4751 - ?>
4323 + } ?>
4752 4324 </label>
4753 4325 <?php } ?>
4754 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"/>
4755 4327 </div>
@@ -4786,15 +4358,15 @@
4786 4358 }
4787 4359 $enable_confirm_email_field = isset( $extra['confirm_email'] ) ? $extra['confirm_email'] : '0';
4788 4360 if ( $enable_confirm_email_field == '1' ) {
4789 4361
4790 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4791 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4792 - $bs_sr_only = $design_style ? 'sr-only' : '';
4793 - $bs_form_control = $design_style ? 'form-control' : '';
4794 - $site_title = __( 'Confirm Email', 'userswp' );
4795 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4796 - $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') : '';
4797 4369
4798 4370 ob_start();
4799 4371
4800 4372 if ( $design_style ) {
@@ -4799,50 +4371,45 @@
4799 4371
4800 4372 if ( $design_style ) {
4801 4373 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4802 4374
4803 - echo aui()->input(
4804 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4805 - 'type' => 'email',
4806 - 'id' => esc_attr( $field->htmlvar_name ),
4807 - 'name' => 'confirm_email',
4808 - 'placeholder' => esc_attr( $site_title ),
4809 - 'title' => esc_attr( $site_title ),
4810 - 'value' => esc_attr( $value ),
4811 - 'required' => (bool) $field->is_required,
4812 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4813 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4814 - '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 ),
4815 4386 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4816 - )
4817 - );
4387 + ) );
4818 4388 } else {
4819 4389 ?>
4820 4390 <div id="uwp_account_confirm_email_row"
4821 - 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 ); ?>">
4822 4392
4823 4393 <?php
4824 4394
4825 - if ( ! is_admin() ) {
4826 - ?>
4395 + if ( ! is_admin() ) { ?>
4827 4396 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4828 4397 <?php echo ( trim( $site_title ) ) ? esc_attr( $site_title ) : '&nbsp;'; ?>
4829 - <?php
4830 - if ( $field->is_required ) {
4398 + <?php if ( $field->is_required ) {
4831 4399 echo '<span>*</span>';
4832 - }
4833 - ?>
4400 + } ?>
4834 4401 </label>
4835 4402 <?php } ?>
4836 4403
4837 4404 <input name="confirm_email"
4838 - class="uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
4839 - id="uwp_account_confirm_email"
4840 - placeholder="<?php echo esc_attr( $site_title ); ?>"
4841 - value=""
4842 - 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 ); ?>"
4843 4410 <?php echo 'required="required"'; ?>
4844 - type="email"
4411 + type="email"
4845 4412 />
4846 4413 </div>
4847 4414 <?php
4848 4415 }
@@ -4893,10 +4460,12 @@
4893 4460 if ( $field_value == 'no' ) {
4894 4461 if ( ! in_array( $field_name, $public_fields ) ) {
4895 4462 $public_fields[] = $field_name;
4896 4463 }
4897 - } elseif ( ( $field_name = array_search( $field_name, $public_fields ) ) !== false ) {
4464 + } else {
4465 + if ( ( $field_name = array_search( $field_name, $public_fields ) ) !== false ) {
4898 4466 unset( $public_fields[ $field_name ] );
4467 + }
4899 4468 }
4900 4469 }
4901 4470
4902 4471 $value = implode( ',', $public_fields );
@@ -4904,9 +4473,9 @@
4904 4473 }
4905 4474
4906 4475 // Save tabs privacy settings
4907 4476 $tabs_table_name = uwp_get_table_prefix() . 'uwp_profile_tabs';
4908 - $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
4909 4478
4910 4479 if ( $tabs ) {
4911 4480 $public_fields = maybe_unserialize( $user_meta_info->tabs_privacy );
4912 4481 $do_tabs_update = false;
@@ -4922,10 +4491,11 @@
4922 4491 } else {
4923 4492 $public_fields[ $field_name ] = $field_value;
4924 4493 }
4925 4494 }
4926 -}
4927 4495
4496 + }
4497 +
4928 4498 if ( $do_tabs_update ) {
4929 4499 uwp_update_usermeta( $user_id, 'tabs_privacy', maybe_serialize( $public_fields ) );
4930 4500 }
4931 4501 }
@@ -4946,13 +4516,12 @@
4946 4516 }
4947 4517 }
4948 4518
4949 4519 $message = apply_filters( 'uwp_privacy_update_success_message', __( 'Privacy settings updated successfully.', 'userswp' ) );
4950 - $message = aui()->alert(
4951 - array(
4520 + $message = aui()->alert( array(
4952 4521 'type' => 'success',
4953 - 'content' => $message,
4954 - )
4522 + 'content' => $message
4523 + )
4955 4524 );
4956 4525 $uwp_notices[] = array( 'account' => $message );
4957 4526
4958 4527 }
@@ -4968,18 +4537,18 @@
4968 4537 // add the modal error container
4969 4538 add_action( 'uwp_template_display_notices', array( $this, 'modal_error_container' ) );
4970 4539
4971 4540 $args = array(
4972 - 'form_title' => __( 'Login', 'userswp' ),
4541 + 'form_title' => __('Login','userswp'),
4973 4542 );
4974 4543
4975 4544 // get the form
4976 4545 ob_start();
4977 - uwp_get_template( 'bootstrap/login.php', $args );
4546 + uwp_get_template( "bootstrap/login.php", $args );
4978 4547 $form = ob_get_clean();
4979 4548
4980 4549 // bs5
4981 - if ( function_exists( 'aui_bs_convert_sd_output' ) ) {
4550 + if( function_exists('aui_bs_convert_sd_output')){
4982 4551 $form = aui_bs_convert_sd_output( $form );
4983 4552 }
4984 4553 // send ajax response
4985 4554 wp_send_json_success( $form );
@@ -5001,19 +4570,16 @@
5001 4570 }
5002 4571
5003 4572 // do we need country code script in ajax?
5004 4573 $country_field = false;
5005 - $lightbox_forms = uwp_get_option( 'register_modal_form', 1 );
5006 4574
5007 - if ( isset( $_POST['form_id'] ) && ! empty( $_POST['form_id'] ) ) {
4575 + if(isset($_POST['form_id']) && !empty($_POST['form_id'])){
5008 4576 $form_id = (int)$_POST['form_id'];
5009 - } elseif ( is_array( $lightbox_forms ) && count( $lightbox_forms ) > 0 ) {
5010 - $form_id = reset( $lightbox_forms );
5011 4577 } else {
5012 4578 $form_id = 1;
5013 4579 }
5014 4580
5015 - $fields = get_register_form_fields( $form_id );
4581 + $fields = get_register_form_fields($form_id);
5016 4582 if ( ! empty( $fields ) ) {
5017 4583 foreach ( $fields as $field ) {
5018 4584 if ( $field->field_type_key == 'country' || $field->field_type_key == 'uwp_country' ) {
5019 4585 $country_field = true;
@@ -5025,22 +4591,23 @@
5025 4591
5026 4592 // maybe add country code JS
5027 4593 if ( $country_field ) {
5028 4594 $country_data = uwp_get_country_data();
5029 - echo '<script>var uwp_country_data = ' . json_encode( $country_data ) . '</script>';
4595 + echo "<script>var uwp_country_data = " . json_encode( $country_data ) . "</script>";
5030 4596 echo "<script type='text/javascript' src='" . esc_url( USERSWP_PLUGIN_URL ) . 'assets/js/countrySelect.min.js' . "' ></script>";
5031 4597 }
5032 4598
5033 - $args = array( 'form_title' => '' );
5034 - if ( $form_id > 0 ) {
4599 + $args = array('form_title' => '');
4600 + if($form_id > 0){
5035 4601 $args['id'] = $form_id;
5036 4602 }
5037 4603
5038 - $args['limit'] = $lightbox_forms;
4604 + $args['limit'] = uwp_get_option('register_modal_form', 1);
5039 4605
5040 4606 // get template
5041 - uwp_get_template( 'bootstrap/register.php', $args );
4607 + uwp_get_template( "bootstrap/register.php", $args );
5042 4608
4609 +
5043 4610 // only show the JS if NOT doing a block render
5044 4611 if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] != 'super_duper_output_shortcode' ) {
5045 4612 // load scripts
5046 4613 $wp_scripts->do_item( 'zxcvbn-async' );
@@ -5066,13 +4633,13 @@
5066 4633 function (event) {
5067 4634 var $form = $(this).closest('form');
5068 4635 if( ! $form.hasClass('uwp-login-form') ) {
5069 4636 uwp_checkPasswordStrength(
5070 - $form.find('input[name=password]'),
5071 - $form.find('input[name=confirm_password]'),
5072 - $form.find('#uwp-password-strength'),
5073 - $form.find('button[type="submit"], input[type="submit"]'),
5074 - ['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
5075 4642 );
5076 4643 }
5077 4644 }
5078 4645 );
@@ -5082,9 +4649,9 @@
5082 4649 }
5083 4650 $form = ob_get_clean();
5084 4651
5085 4652 // bs5
5086 - if ( function_exists( 'aui_bs_convert_sd_output' ) ) {
4653 + if( function_exists('aui_bs_convert_sd_output')){
5087 4654 $form = aui_bs_convert_sd_output( $form );
5088 4655 }
5089 4656
5090 4657 // send ajax response
@@ -5099,19 +4666,16 @@
5099 4666 public function ajax_forgot_password_form() {
5100 4667
5101 4668 // add the modal error container
5102 4669 add_action( 'uwp_template_display_notices', array( $this, 'modal_error_container' ) );
5103 - $args = array(
5104 - 'form_title' => '',
5105 - 'css_class' => ''
5106 - );
4670 +
5107 4671 // get the form
5108 4672 ob_start();
5109 - uwp_get_template( 'bootstrap/forgot.php', $args );
4673 + uwp_get_template( "bootstrap/forgot.php" );
5110 4674 $form = ob_get_clean();
5111 4675
5112 4676 // bs5
5113 - if ( function_exists( 'aui_bs_convert_sd_output' ) ) {
4677 + if( function_exists('aui_bs_convert_sd_output')){
5114 4678 $form = aui_bs_convert_sd_output( $form );
5115 4679 }
5116 4680
5117 4681 // send ajax response
@@ -5134,5 +4698,5 @@
5134 4698 $html = ! empty( $field->default_value ) ? $field->default_value : ' ';
5135 4699
5136 4700 return $html;
5137 4701 }
5138 -}
4702 +}