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.74 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 All 174 releases
← All changes | includes/class-forms.php +1116 -1520 1.2.681.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,19 +1592,17 @@
1744 1592 }
1745 1593
1746 1594 do_action( 'uwp_after_validate', $result, 'forgot', $data );
1747 1595
1596 +
1748 1597 $user_data = get_user_by( 'email', $data['email'] );
1749 1598
1750 1599 // if no user we fake it and bail
1751 1600 if ( ! $user_data ) {
1752 - $args = apply_filters(
1753 - 'uwp_forgot_error_message',
1754 - array(
1755 - 'type' => 'error',
1756 - 'content' => __( 'Invalid email or user doesn\'t exists.', 'userswp' ),
1757 - )
1758 - );
1601 + $args = apply_filters('uwp_forgot_error_message', array(
1602 + 'type' => 'error',
1603 + 'content' => __( 'Invalid email or user doesn\'t exists.', 'userswp' )
1604 + ));
1759 1605
1760 1606 $message = aui()->alert( $args );
1761 1607 if ( wp_doing_ajax() ) {
1762 1608 wp_send_json_success( $message );
@@ -1769,27 +1615,18 @@
1769 1615
1770 1616 // make sure user account is active before account reset
1771 1617 $mod_value = get_user_meta( $user_data->ID, 'uwp_mod', true );
1772 1618 if ( $mod_value == 'email_unconfirmed' ) {
1773 - $resend_link = uwp_get_forgot_page_url();
1774 - $resend_link = add_query_arg(
1775 - array(
1776 - 'user_id' => $user_data->ID,
1777 - 'action' => 'uwp_resend',
1778 - '_nonce' => wp_create_nonce('uwp_resend'),
1779 - ),
1780 - $resend_link
1781 - );
1782 - $message = aui()->alert(
1783 - array(
1619 + $message = aui()->alert( array(
1784 1620 'type' => 'error',
1785 - 'content' => sprintf(__('Your account is not activated yet. Please activate your account first. <a href="%s">Resend</a>.', 'userswp'), $resend_link),
1786 - )
1621 + 'content' => __( 'Your account is not activated yet. Please activate your account first.', 'userswp' )
1622 + )
1787 1623 );
1788 1624 if ( wp_doing_ajax() ) {
1789 1625 wp_send_json_error( $message );
1790 1626 } else {
1791 1627 $uwp_notices[] = array( 'forgot' => $message );
1628 +
1792 1629 return;
1793 1630 }
1794 1631 }
1795 1632
@@ -1798,14 +1635,15 @@
1798 1635 $allow = apply_filters( 'allow_password_reset', true, $user_data->ID );
1799 1636
1800 1637 if ( ! $allow ) {
1801 1638 return false;
1802 - } elseif ( is_wp_error( $allow ) ) {
1639 + } else if ( is_wp_error( $allow ) ) {
1803 1640 return false;
1804 1641 }
1805 1642
1806 1643 $as_password = apply_filters( 'uwp_forgot_message_as_password', false );
1807 1644
1645 + global $wpdb, $wp_hasher;
1808 1646 $reset_link = '';
1809 1647
1810 1648 if ( $as_password ) {
1811 1649 $new_pass = wp_generate_password( 12, false );
@@ -1813,43 +1651,36 @@
1813 1651 if ( ! uwp_get_option( 'change_disable_password_nag' ) ) {
1814 1652 update_user_meta( $user_data->ID, 'default_password_nag', true ); //Set up the Password change nag.
1815 1653 }
1816 1654 $message = '<p><b>' . __( 'Your login Information :', 'userswp' ) . '</b></p>';
1817 - $message .= '<p>' . sprintf( __( 'Username: %s', 'userswp' ), $user_data->user_login ) . '</p>';
1818 - $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>";
1819 1657
1820 1658 } else {
1821 - // Use WordPress core to generate, hash (wp_fast_hash in WP 6.8+), and store the reset key.
1822 - // This ensures compatibility with check_password_reset_key() on all WP versions.
1823 - $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 );
1824 1661
1825 - if ( is_wp_error( $key ) ) {
1826 - if ( wp_doing_ajax() ) {
1827 - wp_send_json_error( $key->get_error_message() );
1828 - } else {
1829 - $uwp_notices[] = array( 'forgot' => aui()->alert( array( 'type' => 'error', 'content' => $key->get_error_message() ) ) );
1830 - return;
1831 - }
1662 + if ( empty( $wp_hasher ) ) {
1663 + require_once ABSPATH . 'wp-includes/class-phpass.php';
1664 + $wp_hasher = new PasswordHash( 8, true );
1832 1665 }
1833 -
1834 - $message = '<p>' . __( 'You have requested to reset your password for the following account:', 'userswp' ) . '</p>';
1835 - $message .= home_url( '/' ) . '</p>';
1836 - $message .= '<p>' . sprintf( __( 'Username: %s', 'userswp' ), $user_data->user_login ) . '</p>';
1837 - $message .= '<p>' . __( 'If this was by mistake, just ignore this email and nothing will happen.', 'userswp' ) . '</p>';
1838 - $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>";
1839 1673 $reset_page = uwp_get_page_id( 'reset_page', false );
1840 1674 if ( $reset_page ) {
1841 - $reset_link = add_query_arg(
1842 - array(
1843 - 'key' => $key,
1844 - 'login' => rawurlencode( $user_data->user_login ),
1845 - ),
1846 - get_permalink( $reset_page )
1847 - );
1848 - $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";
1849 1680 } else {
1850 1681 $reset_link = home_url( "reset?key=$key&login=" . rawurlencode( $user_data->user_login ), 'login' );
1851 - $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";
1852 1683 }
1853 1684 $message = apply_filters( 'uwp_forgot_password_message', $message, $user_data, $reset_link );
1854 1685 }
1855 1686
@@ -1864,13 +1695,12 @@
1864 1695 UsersWP_Mails::send( $user_data->user_email, 'forgot_password', $email_vars );
1865 1696
1866 1697 do_action( 'uwp_after_process_forgot', $data );
1867 1698
1868 - $message = aui()->alert(
1869 - array(
1699 + $message = aui()->alert( array(
1870 1700 'type' => 'success',
1871 - 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Please check your email.', 'userswp' ), $data ),
1872 - )
1701 + 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Please check your email.', 'userswp' ), $data )
1702 + )
1873 1703 );
1874 1704 if ( wp_doing_ajax() ) {
1875 1705 wp_send_json_success( $message );
1876 1706 } else {
@@ -1907,13 +1737,12 @@
1907 1737
1908 1738 $result = apply_filters( 'uwp_validate_result', $result, 'change', $data );
1909 1739
1910 1740 if ( is_wp_error( $result ) ) {
1911 - $message = aui()->alert(
1912 - array(
1741 + $message = aui()->alert( array(
1913 1742 'type' => 'error',
1914 - 'content' => $result->get_error_message(),
1915 - )
1743 + 'content' => $result->get_error_message()
1744 + )
1916 1745 );
1917 1746 $uwp_notices[] = array( $notice_type => $message );
1918 1747
1919 1748 return;
@@ -1923,13 +1752,12 @@
1923 1752
1924 1753 $user_data = get_user_by( 'id', get_current_user_id() );
1925 1754
1926 1755 if ( ! $user_data ) {
1927 - $message = aui()->alert(
1928 - array(
1756 + $message = aui()->alert( array(
1929 1757 'type' => 'error',
1930 - 'content' => $user_data->get_error_message(),
1931 - )
1758 + 'content' => $user_data->get_error_message()
1759 + )
1932 1760 );
1933 1761 $uwp_notices[] = array( $notice_type => $message );
1934 1762
1935 1763 return;
@@ -1947,15 +1775,14 @@
1947 1775 if ( $password_nag ) {
1948 1776 delete_user_meta( $user_data->ID, 'default_password_nag' );
1949 1777 }
1950 1778
1951 - 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');
1952 1780
1953 - $message = aui()->alert(
1954 - array(
1955 - 'type' => 'success',
1956 - 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Password changed successfully.', 'userswp' ), $data ),
1957 - )
1781 + $message = aui()->alert( array(
1782 + 'type' => 'success',
1783 + 'content' => apply_filters( 'uwp_change_password_success_message', __( 'Password changed successfully.', 'userswp' ), $data )
1784 + )
1958 1785 );
1959 1786
1960 1787 $uwp_notices[] = array( $notice_type => $message );
1961 1788
@@ -1992,13 +1819,12 @@
1992 1819
1993 1820 $result = apply_filters( 'uwp_validate_result', $result, 'reset', $data );
1994 1821
1995 1822 if ( is_wp_error( $result ) ) {
1996 - $message = aui()->alert(
1997 - array(
1823 + $message = aui()->alert( array(
1998 1824 'type' => 'error',
1999 - 'content' => $result->get_error_message(),
2000 - )
1825 + 'content' => $result->get_error_message()
1826 + )
2001 1827 );
2002 1828 $uwp_notices[] = array( 'reset' => $message );
2003 1829
2004 1830 return;
@@ -2010,13 +1836,12 @@
2010 1836 $key = sanitize_text_field( $data['uwp_reset_key'] );
2011 1837
2012 1838 $user = get_user_by( 'login', $login );
2013 1839 if ( ! $user ) {
2014 - $message = aui()->alert(
2015 - array(
1840 + $message = aui()->alert( array(
2016 1841 'type' => 'error',
2017 - 'content' => __( 'Invalid username.', 'userswp' ),
2018 - )
1842 + 'content' => __( 'Invalid username.', 'userswp' )
1843 + )
2019 1844 );
2020 1845 $uwp_notices[] = array( 'reset' => $message );
2021 1846
2022 1847 return;
@@ -2026,14 +1851,13 @@
2026 1851
2027 1852 $user_data = check_password_reset_key( $key, $login );
2028 1853
2029 1854 if ( is_wp_error( $user_data ) ) {
2030 - $error = apply_filters( 'uwp_reset_password_error_message', $user_data->get_error_message(), $user_data );
2031 - $message = aui()->alert(
2032 - array(
1855 + $error = apply_filters('uwp_reset_password_error_message', $user_data->get_error_message(), $user_data);
1856 + $message = aui()->alert( array(
2033 1857 'type' => 'error',
2034 - 'content' => $error,
2035 - )
1858 + 'content' => $error
1859 + )
2036 1860 );
2037 1861 $uwp_notices[] = array( 'reset' => $message );
2038 1862
2039 1863 return;
@@ -2049,13 +1873,12 @@
2049 1873
2050 1874 $login_page_url = uwp_get_login_page_url();
2051 1875 $message = sprintf( __( 'Password updated successfully. Please <a href="%s">login</a> with your new password.', 'userswp' ), $login_page_url );
2052 1876 $message = apply_filters( 'uwp_reset_password_success_message', $message, $data );
2053 - $message = aui()->alert(
2054 - array(
1877 + $message = aui()->alert( array(
2055 1878 'type' => 'success',
2056 - 'content' => $message,
2057 - )
1879 + 'content' => $message
1880 + )
2058 1881 );
2059 1882 $uwp_notices[] = array( 'reset' => $message );
2060 1883
2061 1884 do_action( 'uwp_after_process_reset', $data );
@@ -2090,13 +1913,12 @@
2090 1913
2091 1914 $result = apply_filters( 'uwp_validate_result', $result, 'account', $data );
2092 1915
2093 1916 if ( is_wp_error( $result ) ) {
2094 - $message = aui()->alert(
2095 - array(
1917 + $message = aui()->alert( array(
2096 1918 'type' => 'error',
2097 - 'content' => $result->get_error_message(),
2098 - )
1919 + 'content' => $result->get_error_message()
1920 + )
2099 1921 );
2100 1922 $uwp_notices[] = array( 'account' => $message );
2101 1923
2102 1924 return;
@@ -2104,13 +1926,12 @@
2104 1926
2105 1927 $uploads_result = $file_obj->validate_uploads( $files, 'account' );
2106 1928
2107 1929 if ( is_wp_error( $uploads_result ) ) {
2108 - $message = aui()->alert(
2109 - array(
1930 + $message = aui()->alert( array(
2110 1931 'type' => 'error',
2111 - 'content' => $uploads_result->get_error_message(),
2112 - )
1932 + 'content' => $uploads_result->get_error_message()
1933 + )
2113 1934 );
2114 1935 $uwp_notices[] = array( 'account' => $message );
2115 1936
2116 1937 return;
@@ -2126,10 +1947,11 @@
2126 1947 }
2127 1948
2128 1949 $result = array_merge( $result, $uploads_result );
2129 1950
1951 +
2130 1952 $args = array(
2131 - 'ID' => get_current_user_id(),
1953 + 'ID' => get_current_user_id()
2132 1954 );
2133 1955
2134 1956 if ( isset( $result['first_name'] ) && isset( $result['last_name'] ) ) {
2135 1957 $args['display_name'] = $result['first_name'] . ' ' . $result['last_name'];
@@ -2157,13 +1979,12 @@
2157 1979
2158 1980 $user_id = wp_update_user( $args );
2159 1981
2160 1982 if ( is_wp_error( $user_id ) ) {
2161 - $message = aui()->alert(
2162 - array(
1983 + $message = aui()->alert( array(
2163 1984 'type' => 'error',
2164 - 'content' => sprintf( __( '%s', 'userswp' ), $user_id->get_error_message() ),
2165 - )
1985 + 'content' => sprintf( __( '%s', 'userswp' ), $user_id->get_error_message() )
1986 + )
2166 1987 );
2167 1988 $uwp_notices[] = array( 'account' => $message );
2168 1989
2169 1990 return;
@@ -2171,13 +1992,12 @@
2171 1992
2172 1993 $res = $this->save_user_extra_fields( $user_id, $result, 'account' );
2173 1994
2174 1995 if ( ! $res ) {
2175 - $message = aui()->alert(
2176 - array(
1996 + $message = aui()->alert( array(
2177 1997 'type' => 'error',
2178 - 'content' => __( 'Something went wrong. Please contact site admin.', 'userswp' ),
2179 - )
1998 + 'content' => __( 'Something went wrong. Please contact site admin.', 'userswp' )
1999 + )
2180 2000 );
2181 2001 $uwp_notices[] = array( 'account' => $message );
2182 2002
2183 2003 return;
@@ -2193,22 +2013,21 @@
2193 2013 }
2194 2014
2195 2015 $user_data = get_userdata( $user_id );
2196 2016
2197 - $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 );
2198 2018
2199 - if ( isset( $result['email'] ) && $user_data->user_email !== trim( $result['email'] ) ) {
2019 + if ( isset( $result['email'] ) && $user_data->user_email !== trim($result['email']) ) {
2200 2020
2201 - if ( email_exists( trim( $result['email'] ) ) ) {
2202 - $message = aui()->alert(
2203 - array(
2204 - 'type' => 'error',
2205 - 'content' => __( 'This email is already registered, please choose another one.', 'userswp' ),
2206 - )
2207 - );
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 + );
2208 2027
2209 - $uwp_notices[] = array( 'account' => $message );
2210 - return;
2028 + $uwp_notices[] = array( 'account' => $message );
2029 + return;
2211 2030
2212 2031 }
2213 2032
2214 2033 $hash = md5( $result['email'] . time() . wp_rand() );
@@ -2216,22 +2035,22 @@
2216 2035 'hash' => $hash,
2217 2036 'newemail' => $result['email'],
2218 2037 );
2219 2038
2220 - 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);
2221 2040
2222 2041 $new_email_link = add_query_arg(
2223 2042 array(
2224 2043 'uwp_new_email' => 'yes',
2225 - 'key' => $hash,
2226 - 'login' => $user_data->user_login,
2044 + 'key' => $hash,
2045 + 'login' => $user_data->user_login
2227 2046 ),
2228 2047 uwp_get_account_page_url()
2229 2048 );
2230 2049
2231 2050 $email_vars = array(
2232 - 'user_id' => $user_id,
2233 - 'new_email' => $result['email'],
2051 + 'user_id' => $user_id,
2052 + 'new_email' => $result['email'],
2234 2053 'new_email_link' => esc_url( $new_email_link ),
2235 2054 );
2236 2055
2237 2056 UsersWP_Mails::send( $result['email'], 'account_new_email_activation', $email_vars );
@@ -2236,13 +2055,12 @@
2236 2055
2237 2056 UsersWP_Mails::send( $result['email'], 'account_new_email_activation', $email_vars );
2238 2057
2239 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 );
2240 - $message = aui()->alert(
2241 - array(
2059 + $message = aui()->alert( array(
2242 2060 'type' => 'success',
2243 - 'content' => $message,
2244 - )
2061 + 'content' => $message
2062 + )
2245 2063 );
2246 2064
2247 2065 $uwp_notices[] = array( 'account' => $message );
2248 2066
@@ -2254,13 +2072,12 @@
2254 2072
2255 2073 UsersWP_Mails::send( $user_data->user_email, 'account_update', $email_vars );
2256 2074
2257 2075 $message = apply_filters( 'uwp_account_update_success_message', __( 'Account updated successfully.', 'userswp' ), $data );
2258 - $message = aui()->alert(
2259 - array(
2076 + $message = aui()->alert( array(
2260 2077 'type' => 'success',
2261 - 'content' => $message,
2262 - )
2078 + 'content' => $message
2079 + )
2263 2080 );
2264 2081
2265 2082 $uwp_notices[] = array( 'account' => $message );
2266 2083 }
@@ -2265,8 +2082,9 @@
2265 2082 $uwp_notices[] = array( 'account' => $message );
2266 2083 }
2267 2084
2268 2085 do_action( 'uwp_after_process_account', $data, $user_id );
2086 +
2269 2087 }
2270 2088
2271 2089 /**
2272 2090 * Modifies the forms field in email based on the form type.
@@ -2281,11 +2099,11 @@
2281 2099 *
2282 2100 */
2283 2101 public function init_mail_form_fields( $form_fields, $type, $user_id ) {
2284 2102 switch ( $type ) {
2285 - case 'register':
2103 + case "register":
2286 2104 $form_id = get_user_meta( $user_id, '_uwp_register_form_id', true );
2287 - $fields = get_register_form_fields( $form_id );
2105 + $fields = get_register_form_fields($form_id);
2288 2106 $user_data = get_userdata( $user_id );
2289 2107 if ( ! empty( $fields ) && is_array( $fields ) ) {
2290 2108 $form_fields = '<p><b>' . __( 'User Information:', 'userswp' ) . '</b></p>';
2291 2109 $excluded = uwp_get_excluded_fields();
@@ -2307,14 +2125,14 @@
2307 2125 $field_value = uwp_maybe_serialize( $field->htmlvar_name, $field_value );
2308 2126 }
2309 2127
2310 2128 if ( isset( $field->site_title ) && ! empty( $field_value ) ) {
2311 - $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>';
2312 2130 }
2313 2131 }
2314 2132 }
2315 2133 break;
2316 - case 'account':
2134 + case "account":
2317 2135 $fields = get_account_form_fields();
2318 2136 $user_data = get_userdata( $user_id );
2319 2137 if ( ! empty( $fields ) && is_array( $fields ) ) {
2320 2138 $form_fields = '<p><b>' . __( 'User Information:', 'userswp' ) . '</b></p>';
@@ -2336,9 +2154,9 @@
2336 2154 $field_value = uwp_maybe_serialize( $field->htmlvar_name, $field_value );
2337 2155 }
2338 2156
2339 2157 if ( isset( $field->site_title ) && ! empty( $field_value ) ) {
2340 - $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>';
2341 2159 }
2342 2160 }
2343 2161 }
2344 2162 break;
@@ -2355,87 +2173,46 @@
2355 2173 * @package userswp
2356 2174 * @since 1.0.0
2357 2175 */
2358 2176 public function upload_file_remove() {
2359 - global $wpdb;
2360 -
2361 2177 check_ajax_referer( 'uwp_basic_nonce', 'security' );
2362 2178
2363 - // Check user logged in.
2364 - if ( ! is_user_logged_in() ) {
2365 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Access denied!', 'userswp' ) ) );
2366 - wp_send_json_error( array( 'message' => $message ) );
2367 - }
2368 -
2179 + $htmlvar = esc_sql( strip_tags( $_POST['htmlvar'] ) );
2369 2180 $user_id = ! empty( $_POST['uid'] ) ? absint( $_POST['uid'] ) : 0;
2370 - $htmlvar = ! empty( $_POST['htmlvar'] ) ? sanitize_key( $_POST['htmlvar'] ) : '';
2371 2181
2372 - if ( empty( $user_id ) || empty( $htmlvar ) ) {
2373 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid data!', 'userswp' ) ) );
2374 - wp_send_json_error( array( 'message' => $message ) );
2182 + if ( empty( $user_id ) ) {
2183 + wp_die( -1 );
2375 2184 }
2376 2185
2377 - // Validate the user / admin.
2378 - if ( ! ( $user_id == (int) get_current_user_id() || current_user_can( 'manage_options' ) ) ) {
2379 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid access!', 'userswp' ) ) );
2380 - 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' ) );
2381 2188 }
2382 2189
2383 - if ( $htmlvar == 'banner_thumb' ) {
2384 - $field_key = 'banner';
2190 + // Remove file
2191 + if ( $htmlvar == "banner_thumb" ) {
2192 + $file = uwp_get_usermeta( $user_id, 'banner_thumb' );
2385 2193 $type = 'banner';
2386 - } else if ( $htmlvar == 'avatar_thumb' ) {
2387 - $field_key = 'avatar';
2194 + } else if ( $htmlvar == "avatar_thumb" ) {
2195 + $file = uwp_get_usermeta( $user_id, 'avatar_thumb' );
2388 2196 $type = 'avatar';
2389 2197 } else {
2390 - $field_key = $htmlvar;
2198 + $file = '';
2391 2199 $type = '';
2392 2200 }
2393 2201
2394 - $field = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . uwp_get_table_prefix() . "uwp_form_fields WHERE htmlvar_name = %s LIMIT 1", $field_key ) );
2395 -
2396 - // Check field exists.
2397 - if ( empty( $field ) ) {
2398 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid field!', 'userswp' ) ) );
2399 - wp_send_json_error( array( 'message' => $message ) );
2400 - }
2401 -
2402 - // Validate field access.
2403 - if ( ! empty( $field->for_admin_use ) && ! current_user_can( 'manage_options' ) ) {
2404 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'You are not allowed to perform this action!', 'userswp' ) ) );
2405 - wp_send_json_error( array( 'message' => $message ) );
2406 - }
2407 -
2408 - if ( ! in_array( $field->field_type, array( 'file', 'image' ) ) ) {
2409 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid field type!', 'userswp' ) ) );
2410 - wp_send_json_error( array( 'message' => $message ) );
2411 - }
2412 -
2413 - $value = uwp_get_usermeta( $user_id, $htmlvar );
2414 -
2415 2202 uwp_update_usermeta( $user_id, $htmlvar, '' );
2416 2203
2417 - if ( $value && validate_file( $value ) === 0 ) {
2204 + if ( $file ) {
2418 2205 $uploads = wp_upload_dir();
2419 2206 $upload_path = $uploads['basedir'];
2207 + $unlink_file = untrailingslashit( $upload_path ) . '/' . ltrim( $file, '/' );
2420 2208
2421 - if ( strpos( $value, 'http://' ) === 0 || strpos( $value, 'https://' ) === 0 ) {
2422 - // Get the relative url.
2423 - $value = uwp_get_file_relative_url( $value );
2424 - }
2425 -
2426 - $unlink_file = untrailingslashit( $upload_path ) . '/' . trim( $value, '/\\' );
2427 -
2428 2209 if ( is_file( $unlink_file ) && file_exists( $unlink_file ) ) {
2429 - wp_delete_file( $unlink_file );
2210 + @unlink( $unlink_file );
2211 + $unlink_ori_file = str_replace( '_uwp_' . $type . '_thumb' . '.', '.', $unlink_file );
2430 2212
2431 - // For avatar/banner, also remove the original (non-thumb) file.
2432 - if ( $type ) {
2433 - $unlink_ori_file = str_replace( '_uwp_' . $type . '_thumb' . '.', '.', $unlink_file );
2434 -
2435 - if ( is_file( $unlink_ori_file ) && file_exists( $unlink_ori_file ) ) {
2436 - wp_delete_file( $unlink_ori_file );
2437 - }
2213 + if ( is_file( $unlink_ori_file ) && file_exists( $unlink_ori_file ) ) {
2214 + @unlink( $unlink_ori_file );
2438 2215 }
2439 2216 }
2440 2217 }
2441 2218
@@ -2466,15 +2243,15 @@
2466 2243
2467 2244 // If no html then we run the standard output.
2468 2245 if ( empty( $html ) ) {
2469 2246
2470 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2471 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
2472 - $bs_sr_only = $design_style ? 'sr-only' : '';
2473 - $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" : "";
2474 2251 $extra_attributes = array();
2475 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
2476 - $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') : '';
2477 2254
2478 2255 ob_start(); // Start buffering;
2479 2256
2480 2257 $extra_fields = unserialize( $field->extra_fields );
@@ -2485,8 +2262,9 @@
2485 2262
2486 2263 $date_format = $extra_fields['date_format'];
2487 2264 $jquery_date_format = $date_format;
2488 2265
2266 +
2489 2267 // check if we need to change the format or not
2490 2268 $date_format_len = strlen( str_replace( ' ', '', $date_format ) );
2491 2269 if ( $date_format_len > 5 ) {// if greater then 5 then it's the old style format.
2492 2270
@@ -2522,24 +2300,24 @@
2522 2300 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
2523 2301
2524 2302 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2525 2303 array(
2526 - 'id' => esc_attr( $field->htmlvar_name ),
2527 - 'name' => esc_attr( $field->htmlvar_name ),
2528 - 'required' => ! empty( $field->is_required ) ? true : false,
2529 - 'label' => wp_kses_post( $site_title . $required ),
2530 - 'label_show' => true,
2531 - 'label_type' => 'hidden',
2532 - 'type' => 'datepicker',
2533 - 'title' => esc_html( $site_title ),
2534 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2535 - 'class' => '',
2536 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2537 - 'value' => esc_attr( $value ),
2538 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2539 - '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 ),
2540 2318 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
2541 - 'extra_attributes' => $extra_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2319 + 'extra_attributes' => $extra_attributes // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2542 2320 )
2543 2321 );
2544 2322 } else {
2545 2323 ?>
@@ -2545,23 +2323,21 @@
2545 2323 ?>
2546 2324 <script type="text/javascript">
2547 2325
2548 2326 jQuery(function () {
2549 - jQuery("#<?php echo esc_attr( $field->htmlvar_name ); ?>").datepicker({
2327 + jQuery("#<?php echo esc_attr( $field->htmlvar_name );?>").datepicker({
2550 2328 changeMonth: true, changeYear: true
2551 - <?php
2552 - if ( $field->htmlvar_name == 'dob' ) {
2329 + <?php if ( $field->htmlvar_name == 'dob' ) {
2553 2330 echo ", yearRange: '1900:+0'";
2554 2331 } else {
2555 - echo ", yearRange: '1900:2050'";
2556 - }
2557 - ?>
2332 + echo ", yearRange: '1900:2050'";
2333 + }?>
2558 2334 <?php echo apply_filters( "uwp_datepicker_extra_{$field->htmlvar_name}", '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>});
2559 2335
2560 2336 jQuery("#<?php echo esc_attr( $field->htmlvar_name ); ?>").datepicker("option", "dateFormat", '<?php echo esc_attr( $jquery_date_format ); ?>');
2561 2337
2562 - <?php if ( ! empty( $value ) ) { ?>
2563 - 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 );?>');
2564 2340 jQuery("#<?php echo esc_attr( $field->htmlvar_name ); ?>").datepicker("setDate", parsedDate);
2565 2341 <?php } ?>
2566 2342
2567 2343 });
@@ -2567,46 +2343,37 @@
2567 2343 });
2568 2344
2569 2345 </script>
2570 2346 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
2571 - class="
2572 - <?php
2573 - if ( $field->is_required ) {
2574 - echo 'required_field';
2575 - }
2576 - ?>
2577 - 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 ); ?>">
2578 2350
2579 2351 <?php
2580 2352
2581 - if ( ! is_admin() ) {
2582 - ?>
2353 + if ( ! is_admin() ) { ?>
2583 2354 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
2584 2355 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
2585 - <?php
2586 - if ( $field->is_required ) {
2356 + <?php if ( $field->is_required ) {
2587 2357 echo '<span>*</span>';
2588 - }
2589 - ?>
2358 + } ?>
2590 2359 </label>
2591 2360 <?php } ?>
2592 2361
2593 2362 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2594 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2595 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
2596 - title="<?php echo esc_attr( $site_title ); ?>"
2597 - type="text"
2598 - <?php
2599 - 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 ) {
2600 2368 echo 'required="required"';
2601 - }
2602 - ?>
2603 - value="<?php echo esc_attr( $value ); ?>"
2604 - 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 ); ?>"/>
2605 2372
2606 2373 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
2607 2374 <?php if ( $field->is_required ) { ?>
2608 - <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>
2609 2376 <?php } ?>
2610 2377 </div>
2611 2378
2612 2379 <?php
@@ -2640,14 +2407,14 @@
2640 2407
2641 2408 // If no html then we run the standard output.
2642 2409 if ( empty( $html ) ) {
2643 2410
2644 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2645 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
2646 - $bs_sr_only = $design_style ? 'sr-only' : '';
2647 - $bs_form_control = $design_style ? 'form-control bg-white' : '';
2648 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
2649 - $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') : '';
2650 2417
2651 2418 ob_start(); // Start buffering;
2652 2419
2653 2420 if ( $value != '' ) {
@@ -2665,25 +2432,25 @@
2665 2432 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
2666 2433
2667 2434 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2668 2435 array(
2669 - 'id' => esc_attr( $field->htmlvar_name ),
2670 - 'name' => esc_attr( $field->htmlvar_name ),
2671 - 'required' => ! empty( $field->is_required ) ? true : false,
2672 - 'label' => wp_kses_post( $site_title . $required ),
2673 - 'label_show' => true,
2674 - 'label_type' => esc_attr( $label_type ),
2675 - 'type' => 'timepicker',
2676 - 'title' => esc_html( $site_title ),
2677 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2678 - 'class' => '',
2679 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2680 - 'value' => esc_attr( $value ),
2681 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2682 - '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 ),
2683 2450 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
2684 - 'extra_attributes' => $extra_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2685 - '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>',
2686 2453 )
2687 2454 );
2688 2455 } else {
2689 2456 ?>
@@ -2695,40 +2462,33 @@
2695 2462 });
2696 2463 });
2697 2464 </script>
2698 2465 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
2699 - class="
2700 - <?php
2701 - if ( $field->is_required ) {
2702 - echo 'required_field';
2703 - }
2704 - ?>
2705 - 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 ); ?>">
2706 2469
2707 2470 <?php
2708 2471 $site_title = uwp_get_form_label( $field );
2709 - if ( ! is_admin() ) {
2710 - ?>
2472 + if ( ! is_admin() ) { ?>
2711 2473 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
2712 2474 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
2713 - <?php
2714 - if ( $field->is_required ) {
2475 + <?php if ( $field->is_required ) {
2715 2476 echo '<span>*</span>';
2716 - }
2717 - ?>
2477 + } ?>
2718 2478 </label>
2719 2479 <?php } ?>
2720 2480
2721 2481 <input readonly="readonly" name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2722 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
2723 - value="<?php echo esc_attr( $value ); ?>"
2724 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
2725 - type="text"
2726 - 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 ); ?>"/>
2727 2487
2728 2488 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
2729 2489 <?php if ( $field->is_required ) { ?>
2730 - <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>
2731 2491 <?php } ?>
2732 2492 </div>
2733 2493 <?php
2734 2494 }
@@ -2765,14 +2525,14 @@
2765 2525
2766 2526 // If no html then we run the standard output.
2767 2527 if ( empty( $html ) ) {
2768 2528
2769 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2770 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
2771 - $bs_sr_only = $design_style ? 'sr-only' : '';
2772 - $bs_form_control = $design_style ? 'form-control' : '';
2773 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
2774 - $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') : '';
2775 2535
2776 2536 ob_start(); // Start buffering;
2777 2537 $option_values_arr = uwp_string_values_to_options( $field->option_values, true );
2778 2538 $site_title = uwp_get_form_label( $field );
@@ -2781,46 +2541,37 @@
2781 2541 if ( $design_style ) {
2782 2542
2783 2543 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
2784 2544
2785 - echo aui()->select(
2786 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2787 - 'id' => esc_attr( $field->htmlvar_name ),
2788 - 'name' => esc_attr( $field->htmlvar_name ),
2789 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2790 - 'title' => esc_html( $site_title ),
2791 - 'value' => esc_attr( $value ),
2792 - 'required' => (bool) $field->is_required,
2793 - '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 ),
2794 2553 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
2795 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2796 - 'label' => wp_kses_post( $site_title . $required ),
2797 - 'options' => $option_values_arr, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2798 - 'select2' => true,
2799 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2800 - )
2801 - );
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 + ) );
2802 2560 } else {
2803 2561 ?>
2804 2562 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
2805 - class="
2806 - <?php
2807 - if ( $field->is_required ) {
2808 - echo 'required_field';
2809 - }
2810 - ?>
2811 - 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 ); ?>">
2812 2566
2813 2567 <?php
2814 - if ( ! is_admin() ) {
2815 - ?>
2568 + if ( ! is_admin() ) { ?>
2816 2569 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
2817 2570 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
2818 - <?php
2819 - if ( $field->is_required ) {
2571 + <?php if ( $field->is_required ) {
2820 2572 echo '<span>*</span>';
2821 - }
2822 - ?>
2573 + } ?>
2823 2574 </label>
2824 2575 <?php } ?>
2825 2576
2826 2577 <?php
@@ -2849,9 +2600,9 @@
2849 2600 ><?php echo $select_options; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
2850 2601 </select>
2851 2602 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
2852 2603 <?php if ( $field->is_required ) { ?>
2853 - <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>
2854 2605 <?php } ?>
2855 2606 </div>
2856 2607
2857 2608 <?php
@@ -2883,14 +2634,14 @@
2883 2634 }
2884 2635
2885 2636 if ( empty( $html ) ) {
2886 2637
2887 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2888 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
2889 - $bs_sr_only = $design_style ? 'sr-only' : '';
2890 - $bs_form_control = $design_style ? 'form-control' : '';
2891 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
2892 - $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') : '';
2893 2644
2894 2645 ob_start(); // Start buffering;
2895 2646
2896 2647 $multi_display = 'select';
@@ -2899,9 +2650,9 @@
2899 2650 }
2900 2651
2901 2652 $option_values_arr = uwp_string_values_to_options( $field->option_values, true );
2902 2653 $site_title = uwp_get_form_label( $field );
2903 - $value = is_array( $value ) ? $value : esc_attr( $value );
2654 + $value = is_array($value) ? $value : esc_attr($value);
2904 2655
2905 2656 // bootstrap
2906 2657 if ( $design_style ) {
2907 2658
@@ -2906,47 +2657,38 @@
2906 2657 if ( $design_style ) {
2907 2658
2908 2659 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
2909 2660
2910 - echo aui()->select(
2911 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2912 - 'id' => esc_attr( $field->htmlvar_name ),
2913 - 'name' => esc_attr( $field->htmlvar_name ),
2914 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
2915 - 'title' => esc_html( $site_title ),
2916 - 'value' => $value,
2917 - 'required' => (bool) $field->is_required,
2918 - '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 ),
2919 2669 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
2920 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2921 - 'label' => wp_kses_post( $site_title . $required ),
2922 - 'options' => $option_values_arr, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2923 - 'select2' => true,
2924 - 'multiple' => true,
2925 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
2926 - )
2927 - );
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 + ) );
2928 2677 } else {
2929 2678 ?>
2930 2679 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
2931 - class="
2932 - <?php
2933 - if ( $field->is_required ) {
2934 - echo 'required_field';
2935 - }
2936 - ?>
2937 - 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 ); ?>">
2938 2683
2939 2684 <?php
2940 - if ( ! is_admin() ) {
2941 - ?>
2685 + if ( ! is_admin() ) { ?>
2942 2686 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
2943 2687 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
2944 - <?php
2945 - if ( $field->is_required ) {
2688 + <?php if ( $field->is_required ) {
2946 2689 echo '<span>*</span>';
2947 - }
2948 - ?>
2690 + } ?>
2949 2691 </label>
2950 2692 <?php } ?>
2951 2693
2952 2694 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value=""/>
@@ -2959,65 +2701,62 @@
2959 2701 class="aui-select2 <?php echo esc_attr( $bs_form_control ); ?>"
2960 2702 >
2961 2703 <?php
2962 2704 } else {
2963 - ?>
2705 + ?>
2964 2706 <ul class="uwp_multi_choice">
2965 - <?php
2707 + <?php
2966 2708 }
2967 2709
2968 2710 $option_values_arr = uwp_string_values_to_options( $field->option_values, true );
2969 2711 $select_options = '';
2970 2712 if ( ! empty( $option_values_arr ) ) {
2971 - foreach ( $option_values_arr as $option_row ) {
2972 - if ( isset( $option_row['optgroup'] ) && ( $option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end' ) ) {
2973 - $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'] : '';
2974 2716
2975 - if ( $multi_display == 'select' ) {
2976 - $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
2977 - } else {
2978 - $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : '';
2979 - }
2980 - } else {
2981 - $option_label = isset( $option_row['label'] ) ? $option_row['label'] : '';
2982 - $option_value = isset( $option_row['value'] ) ? $option_row['value'] : '';
2983 - $selected = $option_value == $value ? 'selected="selected"' : '';
2984 - $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 = '';
2985 2727
2986 - if ( ( ! is_array( $value ) && trim( $value ) != '' ) || ( is_array( $value ) && ! empty( $value ) ) ) {
2987 - if ( ! is_array( $value ) ) {
2988 - $value_array = explode( ',', $value );
2989 - } else {
2990 - $value_array = $value;
2991 - }
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 + }
2992 2734
2993 - if ( is_array( $value_array ) ) {
2994 - if ( in_array( $option_value, $value_array ) ) {
2995 - $selected = 'selected="selected"';
2996 - $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 + }
2997 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 + }
2998 2748 }
2999 2749 }
3000 -
3001 - if ( $multi_display == 'select' ) {
3002 - $select_options .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . '>' . $option_label . '</option>';
3003 - } else {
3004 - $select_options .= '<li><input name="' . $field->name . '[]" ' . $checked . ' value="' . esc_attr( $option_value ) . '" class="uwp-' . $multi_display . '" type="' . $multi_display . '" />&nbsp;' . $option_label . ' </li>';
3005 - }
3006 2750 }
3007 - }
3008 - }
3009 2751 echo $select_options; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3010 2752
3011 - if ( $multi_display == 'select' ) {
3012 -
3013 - ?>
3014 - </select></div>
2753 + if ( $multi_display == 'select' ) { ?></select></div>
3015 2754 <?php } else { ?>
3016 2755 </ul>
3017 2756 <?php } ?>
3018 2757 <?php if ( $field->is_required ) { ?>
3019 - <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>
3020 2759 <?php } ?>
3021 2760 </div>
3022 2761 <?php
3023 2762 }
@@ -3051,45 +2790,38 @@
3051 2790
3052 2791 // If no html then we run the standard output.
3053 2792 if ( empty( $html ) ) {
3054 2793
3055 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
2794 + $design_style = uwp_get_option( "design_style", "bootstrap" );
3056 2795 $wrap_class = isset( $field->css_class ) ? $field->css_class : '';
3057 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3058 - $bs_sr_only = $design_style ? 'sr-only' : '';
3059 - $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" : "";
3060 2799
3061 2800 ob_start(); // Start buffering;
3062 2801
3063 2802 ?>
3064 2803 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3065 - class="
3066 - <?php
3067 - if ( $field->is_required ) {
3068 - echo 'required_field';
3069 - }
3070 - ?>
3071 - 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 ); ?>">
3072 2807
3073 2808 <?php
3074 2809 $site_title = uwp_get_form_label( $field );
3075 - if ( ! is_admin() && ! wp_doing_ajax() ) {
3076 - ?>
2810 + if ( ! is_admin() && !wp_doing_ajax() ) { ?>
3077 2811 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3078 2812 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3079 - <?php
3080 - if ( $field->is_required ) {
2813 + <?php if ( $field->is_required ) {
3081 2814 echo ' <span class="text-danger">*</span>';
3082 - }
3083 - ?>
2815 + } ?>
3084 2816 </label>
3085 2817 <?php } ?>
3086 2818
3087 2819 <?php echo $file_obj->file_upload_preview( $field, $value ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
3088 2820 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3089 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3090 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3091 - 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 ); ?>"
3092 2824 <?php
3093 2825 if ( $field->is_required == 1 ) {
3094 2826 echo 'data-is-required="1"';
3095 2827 }
@@ -3096,12 +2828,12 @@
3096 2828 if ( $field->is_required == 1 && ! $value ) {
3097 2829 echo 'required="required"';
3098 2830 }
3099 2831 ?>
3100 - type="<?php echo esc_attr( $field->field_type ); ?>">
2832 + type="<?php echo esc_attr( $field->field_type ); ?>">
3101 2833 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3102 2834 <?php if ( $field->is_required ) { ?>
3103 - <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>
3104 2836 <?php } ?>
3105 2837 </div>
3106 2838
3107 2839 <?php
@@ -3133,18 +2865,18 @@
3133 2865
3134 2866 // If no html then we run the standard output.
3135 2867 if ( empty( $html ) ) {
3136 2868
3137 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3138 - $bs_form_group = $design_style ? 'form-group mb-3 form-check' : '';
3139 - $bs_sr_only = $design_style ? 'form-check-label' : '';
3140 - $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" : "";
3141 2873
3142 2874 ob_start(); // Start buffering;
3143 2875 $site_title = uwp_get_form_label( $field );
3144 2876
3145 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3146 - $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;
3147 2879
3148 2880 $checked = $value == '1' ? true : false;
3149 2881
3150 2882 // bootstrap
@@ -3154,20 +2886,20 @@
3154 2886 echo '<input type="hidden" name="' . esc_attr( $field->htmlvar_name ) . '" id="checkbox_' . esc_attr( $id ) . '" value="0"/>';
3155 2887
3156 2888 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3157 2889 array(
3158 - 'id' => esc_attr( $id ),
3159 - 'name' => esc_attr( $field->htmlvar_name ),
3160 - 'type' => 'checkbox',
3161 - 'value' => '1',
3162 - 'title' => esc_html( $site_title ),
3163 - 'label' => wp_kses_post( $site_title . $required ),
3164 - 'label_show' => true,
3165 - 'required' => ! empty( $field->is_required ) ? true : false,
3166 - 'checked' => (bool) $checked,
3167 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3168 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3169 - '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' ) : '',
3170 2902 )
3171 2903 );
3172 2904
3173 2905 } else {
@@ -3172,44 +2904,36 @@
3172 2904
3173 2905 } else {
3174 2906 ?>
3175 2907 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3176 - class="
3177 - <?php
3178 - if ( $field->is_required ) {
3179 - echo 'required_field';
3180 - }
3181 - ?>
3182 - uwp_form_<?php echo esc_attr( $field->field_type ); ?>_row uwp_clear <?php echo esc_attr( $bs_form_group ); ?>">
3183 - <?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 ) ){ ?>
3184 2912 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3185 2913 <?php } ?>
3186 2914 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value="0"/>
3187 2915 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3188 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3189 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3190 - title="<?php echo esc_attr( $site_title ); ?>"
3191 - <?php
3192 - 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 ) {
3193 2920 echo 'required="required"';
3194 - }
3195 - ?>
3196 - <?php
3197 - if ( $value == '1' ) {
2921 + } ?>
2922 + <?php if ( $value == '1' ) {
3198 2923 echo 'checked="checked"';
3199 - }
3200 - ?>
3201 - type="<?php echo esc_attr( $field->field_type ); ?>"
3202 - value="1">
2924 + } ?>
2925 + type="<?php echo esc_attr( $field->field_type ); ?>"
2926 + value="1">
3203 2927 <?php
3204 2928 echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;';
3205 2929 ?>
3206 - <?php if ( ! empty( $design_style ) ) { ?>
2930 + <?php if ( ! empty( $design_style ) ){ ?>
3207 2931 </label>
3208 2932 <?php } ?>
3209 2933 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3210 2934 <?php if ( $field->is_required ) { ?>
3211 - <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>
3212 2936 <?php } ?>
3213 2937 </div>
3214 2938
3215 2939 <?php
@@ -3245,13 +2969,13 @@
3245 2969
3246 2970 // If no html then we run the standard output.
3247 2971 if ( empty( $html ) ) {
3248 2972
3249 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3250 - $bs_form_group = $design_style ? 'form-group mb-3 form-check-inline' : '';
3251 - $bs_sr_only = $design_style ? 'sr-only' : '';
3252 - $bs_label_class = $design_style ? 'form-check-label' : '';
3253 - $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" : "";
3254 2978
3255 2979 ob_start(); // Start buffering;
3256 2980
3257 2981 if ( $design_style ) {
@@ -3271,16 +2995,16 @@
3271 2995 echo aui()->radio( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3272 2996 array(
3273 2997 'id' => esc_attr( $field->htmlvar_name ),
3274 2998 'name' => esc_attr( $field->htmlvar_name ),
3275 - 'type' => 'radio',
2999 + 'type' => "radio",
3276 3000 'title' => esc_html( $site_title ),
3277 - '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 ),
3278 3002 'label_type' => 'top',
3279 3003 'class' => '',
3280 3004 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3281 3005 'value' => esc_attr( $value ),
3282 - 'options' => $option_values, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3006 + 'options' => $option_values // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3283 3007 )
3284 3008 );
3285 3009
3286 3010 } else {
@@ -3286,32 +3010,24 @@
3286 3010 } else {
3287 3011
3288 3012 ?>
3289 3013 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3290 - class="
3291 - <?php
3292 - if ( $field->is_required ) {
3293 - echo 'required_field';
3294 - }
3295 - ?>
3296 - 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 ); ?>">
3297 3017
3298 3018 <?php
3299 3019 $site_title = uwp_get_form_label( $field );
3300 - if ( ! is_admin() ) {
3301 - ?>
3020 + if ( ! is_admin() ) { ?>
3302 3021 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3303 3022 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3304 - <?php
3305 - if ( $field->is_required ) {
3023 + <?php if ( $field->is_required ) {
3306 3024 echo '<span>*</span>';
3307 - }
3308 - ?>
3025 + } ?>
3309 3026 </label>
3310 3027 <?php } ?>
3311 3028
3312 - <?php
3313 - if ( $field->option_values ) {
3029 + <?php if ( $field->option_values ) {
3314 3030 $option_values = uwp_string_values_to_options( $field->option_values, true );
3315 3031
3316 3032 if ( ! empty( $option_values ) ) {
3317 3033 $count = 0;
@@ -3316,13 +3032,13 @@
3316 3032 if ( ! empty( $option_values ) ) {
3317 3033 $count = 0;
3318 3034 foreach ( $option_values as $option_value ) {
3319 3035 if ( empty( $option_value['optgroup'] ) ) {
3320 - ++$count;
3036 + $count ++;
3321 3037 if ( $count == 1 ) {
3322 - $class = 'uwp-radio-first';
3038 + $class = "uwp-radio-first";
3323 3039 } else {
3324 - $class = '';
3040 + $class = "";
3325 3041 }
3326 3042 ?>
3327 3043 <?php if ( ! empty( $design_style ) ) { ?>
3328 3044 <label class="<?php echo esc_attr( $bs_label_class ); ?>">
@@ -3329,18 +3045,16 @@
3329 3045 <?php } else { ?>
3330 3046 <span class="uwp-radios <?php echo esc_attr( $class ); ?>">
3331 3047 <?php } ?>
3332 3048 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3333 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3334 - 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'] ); ?>"
3335 3051 <?php checked( $value, $option_value['value'] ); ?>
3336 - <?php
3337 - if ( $field->is_required == 1 ) {
3052 + <?php if ( $field->is_required == 1 ) {
3338 3053 echo 'required="required"';
3339 - }
3340 - ?>
3341 - value="<?php echo esc_attr( $option_value['value'] ); ?>"
3342 - 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"/>
3343 3057 <?php echo esc_html( $option_value['label'] ); ?>
3344 3058 <?php if ( ! empty( $design_style ) ) { ?>
3345 3059 </label>
3346 3060 <?php } else { ?>
@@ -3353,9 +3067,9 @@
3353 3067 }
3354 3068 ?>
3355 3069 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3356 3070 <?php if ( $field->is_required ) { ?>
3357 - <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>
3358 3072 <?php } ?>
3359 3073 </div>
3360 3074 <?php
3361 3075 }
@@ -3398,140 +3112,125 @@
3398 3112 $type = 'number';
3399 3113 } elseif ( isset( $field->data_type ) && $field->data_type == 'FLOAT' ) {
3400 3114 $dp = $field->decimal_point;
3401 3115 switch ( $dp ) {
3402 - case '1':
3403 - $step = '0.1';
3116 + case "1":
3117 + $step = "0.1";
3404 3118 break;
3405 - case '2':
3406 - $step = '0.01';
3119 + case "2":
3120 + $step = "0.01";
3407 3121 break;
3408 - case '3':
3409 - $step = '0.001';
3122 + case "3":
3123 + $step = "0.001";
3410 3124 break;
3411 - case '4':
3412 - $step = '0.0001';
3125 + case "4":
3126 + $step = "0.0001";
3413 3127 break;
3414 - case '5':
3415 - $step = '0.00001';
3128 + case "5":
3129 + $step = "0.00001";
3416 3130 break;
3417 - case '6':
3418 - $step = '0.000001';
3131 + case "6":
3132 + $step = "0.000001";
3419 3133 break;
3420 - case '7':
3421 - $step = '0.0000001';
3134 + case "7":
3135 + $step = "0.0000001";
3422 3136 break;
3423 - case '8':
3424 - $step = '0.00000001';
3137 + case "8":
3138 + $step = "0.00000001";
3425 3139 break;
3426 - case '9':
3427 - $step = '0.000000001';
3140 + case "9":
3141 + $step = "0.000000001";
3428 3142 break;
3429 - case '10':
3430 - $step = '0.0000000001';
3143 + case "10":
3144 + $step = "0.0000000001";
3431 3145 break;
3432 3146 default:
3433 - $step = '0.01';
3147 + $step = "0.01";
3434 3148 break;
3435 3149 }
3436 3150 $type = 'number';
3437 3151 }
3438 3152
3153 +
3439 3154 $site_title = uwp_get_form_label( $field );
3440 3155 $placeholder = uwp_get_field_placeholder( $field );
3441 3156 $manual_label = apply_filters( 'uwp_login_username_label_manual', true );
3442 3157 if ( $manual_label
3443 - && isset( $field->form_type )
3444 - && $field->form_type == 'login'
3445 - && $field->htmlvar_name == 'username' ) {
3446 - $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' );
3447 3162 $required = ! empty( $field->is_required ) ? ' *' : '';
3448 3163 $placeholder = $site_title . $required;
3449 3164 $placeholder = apply_filters( 'uwp_get_field_placeholder', stripslashes( $placeholder ), $field );
3450 3165 }
3451 3166
3452 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3453 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3454 - $bs_sr_only = $design_style ? 'sr-only' : '';
3455 - $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" : "";
3456 3171
3457 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
3458 - $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') : '';
3459 3174
3460 3175 // bootstrap
3461 3176 if ( $design_style ) {
3462 3177 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3463 3178
3464 - echo aui()->input(
3465 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3466 - 'type' => esc_attr( $type ),
3467 - 'id' => esc_attr( $field->htmlvar_name ),
3468 - 'name' => esc_attr( $field->htmlvar_name ),
3469 - 'placeholder' => esc_attr( $placeholder ),
3470 - 'title' => esc_html( $site_title ),
3471 - 'value' => esc_attr( wp_unslash( $value ) ),
3472 - 'required' => (bool) $field->is_required,
3473 - '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 ),
3474 3188 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3475 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3476 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3477 - 'step' => esc_attr( $step ),
3478 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3479 - )
3480 - );
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 + ) );
3481 3194 } else {
3482 3195 ?>
3483 - <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row" class="
3484 - <?php
3485 - if ( $field->is_required ) {
3486 - echo 'required_field';
3487 - }
3488 - ?>
3489 - 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 ); ?>">
3490 3199 <?php
3491 3200
3492 - if ( ! is_admin() ) {
3493 - ?>
3201 + if ( ! is_admin() ) { ?>
3494 3202 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3495 3203 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3496 - <?php
3497 - if ( $field->is_required ) {
3204 + <?php if ( $field->is_required ) {
3498 3205 echo '<span>*</span>';
3499 - }
3500 - ?>
3206 + } ?>
3501 3207 </label>
3502 - <?php
3503 - }
3208 + <?php }
3504 3209 ?>
3505 3210
3506 3211 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3507 - class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
3508 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3509 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3510 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
3511 - title="<?php echo esc_attr( $site_title ); ?>"
3512 - oninvalid="this.setCustomValidity('<?php esc_attr_e( stripslashes( $field->required_msg ), 'userswp' ); ?>')"
3513 - oninput="setCustomValidity('')"
3514 - <?php
3515 - 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 ) {
3516 3220 echo 'required="required"';
3517 - }
3518 - ?>
3519 - <?php
3520 - if ( $field->for_admin_use == 1 ) {
3221 + } ?>
3222 + <?php if ( $field->for_admin_use == 1 ) {
3521 3223 echo 'readonly="readonly"';
3522 - }
3523 - ?>
3524 - type="<?php echo esc_attr( $type ); ?>"
3525 - <?php
3526 - if ( $step ) {
3224 + } ?>
3225 + type="<?php echo esc_attr( $type ); ?>"
3226 + <?php if ( $step ) {
3527 3227 echo 'step="' . esc_attr( $step ) . '"';
3528 - }
3529 - ?>
3228 + } ?>
3530 3229 />
3531 3230 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3532 3231 <?php if ( $field->is_required ) { ?>
3533 - <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>
3534 3233 <?php } ?>
3535 3234 </div>
3536 3235
3537 3236
@@ -3565,12 +3264,12 @@
3565 3264
3566 3265 // If no html then we run the standard output.
3567 3266 if ( empty( $html ) ) {
3568 3267
3569 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3570 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3571 - $bs_sr_only = $design_style ? 'sr-only' : '';
3572 - $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" : "";
3573 3272 $site_title = uwp_get_form_label( $field );
3574 3273
3575 3274 ob_start(); // Start buffering;
3576 3275
@@ -3577,10 +3276,9 @@
3577 3276 // bootstrap
3578 3277 if ( $design_style ) {
3579 3278 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3580 3279
3581 - echo aui()->textarea(
3582 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3280 + echo aui()->textarea( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3583 3281 'id' => esc_attr( $field->htmlvar_name ),
3584 3282 'name' => esc_attr( $field->htmlvar_name ),
3585 3283 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3586 3284 'title' => esc_html( $site_title ),
@@ -3585,57 +3283,47 @@
3585 3283 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3586 3284 'title' => esc_html( $site_title ),
3587 3285 'value' => wp_kses_post( stripslashes( $value ) ),
3588 3286 'required' => (bool) $field->is_required,
3589 - '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' ) : '',
3590 3288 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3591 - '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 ),
3592 3290 'rows' => '4',
3593 3291 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3594 - )
3595 - );
3292 + ) );
3596 3293 } else {
3597 3294 ?>
3598 3295
3599 3296 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3600 - class="
3601 - <?php
3602 - if ( $field->is_required ) {
3603 - echo 'required_field';
3604 - }
3605 - ?>
3606 - 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 ); ?>">
3607 3300
3608 3301 <?php
3609 3302
3610 - if ( ! is_admin() ) {
3611 - ?>
3303 + if ( ! is_admin() ) { ?>
3612 3304 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3613 3305 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3614 - <?php
3615 - if ( $field->is_required ) {
3306 + <?php if ( $field->is_required ) {
3616 3307 echo '<span>*</span>';
3617 - }
3618 - ?>
3308 + } ?>
3619 3309 </label>
3620 3310 <?php } ?>
3621 3311
3622 3312 <textarea name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3623 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
3624 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3625 - title="<?php echo esc_attr( $site_title ); ?>"
3626 - oninvalid="this.setCustomValidity('<?php esc_attr_e( stripslashes( $field->required_msg ), 'userswp' ); ?>')"
3627 - oninput="setCustomValidity('')"
3628 - <?php
3629 - 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 ) {
3630 3319 echo 'required="required"';
3631 - }
3632 - ?>
3633 - type="<?php echo esc_attr( $field->field_type ); ?>"
3634 - 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>
3635 3323 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3636 3324 <?php if ( $field->is_required ) { ?>
3637 - <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>
3638 3326 <?php } ?>
3639 3327 </div>
3640 3328
3641 3329 <?php
@@ -3656,11 +3344,11 @@
3656 3344 if ( empty( $html ) ) {
3657 3345
3658 3346 ob_start();
3659 3347
3660 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3661 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3662 - $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" : "";
3663 3351 $site_title = uwp_get_form_label( $field );
3664 3352
3665 3353 $content = stripslashes( $value );
3666 3354 $editor_id = $field->htmlvar_name;
@@ -3669,54 +3357,45 @@
3669 3357 'media_buttons' => false,
3670 3358 'quicktags' => false,
3671 3359 );
3672 3360
3673 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
3674 - $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') : '';
3675 3363
3676 3364 // bootstrap
3677 3365 if ( $design_style ) {
3678 3366 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3679 3367
3680 - echo aui()->textarea(
3681 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3682 - 'id' => esc_attr( $field->htmlvar_name ),
3683 - 'name' => esc_attr( $field->htmlvar_name ),
3684 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3685 - 'title' => esc_html( $site_title ),
3686 - 'value' => wp_kses_post( stripslashes( $value ) ),
3687 - 'required' => (bool) $field->is_required,
3688 - '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 ),
3689 3376 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3690 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3691 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3692 - 'rows' => 5,
3693 - 'wysiwyg' => true,
3694 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3695 - )
3696 - );
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 + ) );
3697 3383 } else {
3698 3384 ?>
3699 3385 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3700 - class="
3701 - <?php
3702 - if ( $field->is_required ) {
3703 - echo 'required_field';
3704 - }
3705 - ?>
3706 - 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 ); ?>">
3707 3389
3708 3390 <?php
3709 3391
3710 - if ( ! is_admin() ) {
3711 - ?>
3392 + if ( ! is_admin() ) { ?>
3712 3393 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3713 3394 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3714 - <?php
3715 - if ( $field->is_required ) {
3395 + <?php if ( $field->is_required ) {
3716 3396 echo '<span>*</span>';
3717 - }
3718 - ?>
3397 + } ?>
3719 3398 </label>
3720 3399 <?php } ?>
3721 3400
3722 3401 <?php wp_editor( $content, $editor_id, $args ); ?>
@@ -3722,9 +3401,9 @@
3722 3401 <?php wp_editor( $content, $editor_id, $args ); ?>
3723 3402
3724 3403 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3725 3404 <?php if ( $field->is_required ) { ?>
3726 - <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>
3727 3406 <?php } ?>
3728 3407 </div>
3729 3408 <?php
3730 3409 }
@@ -3760,14 +3439,11 @@
3760 3439 $site_title = uwp_get_form_label( $field );
3761 3440 ?>
3762 3441 <h3 class="uwp_input_fieldset <?php echo esc_attr( $field->css_class ); ?>">
3763 3442 <?php echo esc_html( $site_title ); ?>
3764 - <?php
3765 - if ( $field->help_text != '' ) {
3443 + <?php if ( $field->help_text != '' ) {
3766 3444 echo '<small>( ' . wp_kses_post( $field->help_text ) . ' )</small>';
3767 - }
3768 - ?>
3769 - </h3>
3445 + } ?></h3>
3770 3446 <?php
3771 3447 $html = ob_get_clean();
3772 3448 }
3773 3449
@@ -3788,8 +3464,9 @@
3788 3464 * @since 1.0.0
3789 3465 */
3790 3466 public function form_input_url( $html, $field, $value, $form_type ) {
3791 3467
3468 +
3792 3469 // Check if there is a custom field specific filter.
3793 3470 if ( has_filter( "uwp_form_input_url_{$field->htmlvar_name}" ) ) {
3794 3471 $html = apply_filters( "uwp_form_input_url_{$field->htmlvar_name}", $html, $field, $value, $form_type );
3795 3472 }
@@ -3796,84 +3473,70 @@
3796 3473
3797 3474 // If no html then we run the standard output.
3798 3475 if ( empty( $html ) ) {
3799 3476
3800 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3801 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3802 - $bs_sr_only = $design_style ? 'sr-only' : '';
3803 - $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" : "";
3804 3481
3805 3482 ob_start(); // Start buffering;
3806 3483 $site_title = uwp_get_form_label( $field );
3807 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : __( 'Please enter a valid URL including https://', 'userswp' );
3808 - $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') : '';
3809 3486
3810 3487 // bootstrap
3811 3488 if ( $design_style ) {
3812 3489 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3813 3490
3814 - echo aui()->input(
3815 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3816 - 'type' => 'url',
3817 - 'id' => esc_attr( $field->htmlvar_name ),
3818 - 'name' => esc_attr( $field->htmlvar_name ),
3819 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3820 - 'title' => esc_html( $site_title ),
3821 - 'value' => esc_attr( $value ),
3822 - 'required' => (bool) $field->is_required,
3823 - '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 ),
3824 3500 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3825 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3826 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3827 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3828 - )
3829 - );
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 + ) );
3830 3505 } else {
3831 3506 ?>
3832 3507 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3833 - class="
3834 - <?php
3835 - if ( $field->is_required ) {
3836 - echo 'required_field';
3837 - }
3838 - ?>
3839 - 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 ); ?>">
3840 3511
3841 3512 <?php
3842 - if ( ! is_admin() ) {
3843 - ?>
3513 + if ( ! is_admin() ) { ?>
3844 3514 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3845 3515 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3846 - <?php
3847 - if ( $field->is_required ) {
3516 + <?php if ( $field->is_required ) {
3848 3517 echo '<span>*</span>';
3849 - }
3850 - ?>
3518 + } ?>
3851 3519 </label>
3852 3520 <?php } ?>
3853 3521
3854 3522 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3855 - class="
3856 - <?php
3857 - //echo $field->css_class;
3858 - ?>
3859 - uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
3860 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3861 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3862 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
3863 - title="<?php echo esc_attr( $site_title ); ?>"
3864 - <?php
3865 - 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 ) {
3866 3530 echo 'required="required"';
3867 - }
3868 - ?>
3869 - type="url"
3870 - oninvalid="setCustomValidity('<?php esc_attr_e( 'Please enter a valid URL including http://', 'userswp' ); ?>')"
3871 - 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){}"
3872 3535 />
3873 3536 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3874 3537 <?php if ( $field->is_required ) { ?>
3875 - <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>
3876 3539 <?php } ?>
3877 3540 </div>
3878 3541
3879 3542 <?php
@@ -3899,8 +3562,9 @@
3899 3562 * @since 1.0.0
3900 3563 */
3901 3564 public function form_input_email( $html, $field, $value, $form_type ) {
3902 3565
3566 +
3903 3567 // Check if there is a custom field specific filter.
3904 3568 if ( has_filter( "uwp_form_input_email_{$field->htmlvar_name}" ) ) {
3905 3569 $html = apply_filters( "uwp_form_input_email_{$field->htmlvar_name}", $html, $field, $value, $form_type );
3906 3570 }
@@ -3907,77 +3571,66 @@
3907 3571
3908 3572 // If no html then we run the standard output.
3909 3573 if ( empty( $html ) ) {
3910 3574
3911 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
3912 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
3913 - $bs_sr_only = $design_style ? 'sr-only' : '';
3914 - $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" : "";
3915 3579
3916 3580 ob_start(); // Start buffering;
3917 3581 $site_title = uwp_get_form_label( $field );
3918 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
3919 - $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') : '';
3920 3584
3921 3585 if ( $design_style ) {
3922 3586 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
3923 3587
3924 - echo aui()->input(
3925 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3926 - 'type' => 'email',
3927 - 'id' => esc_attr( $field->htmlvar_name ),
3928 - 'name' => esc_attr( $field->htmlvar_name ),
3929 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
3930 - 'title' => esc_html( $site_title ),
3931 - 'value' => esc_attr( wp_unslash( $value ) ),
3932 - 'required' => (bool) $field->is_required,
3933 - '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 ),
3934 3597 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
3935 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
3936 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
3937 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
3938 - )
3939 - );
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 + ) );
3940 3602 } else {
3941 3603 ?>
3942 3604 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
3943 - class="
3944 - <?php
3945 - if ( $field->is_required ) {
3946 - echo 'required_field';
3947 - }
3948 - ?>
3949 - 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 ); ?>">
3950 3608
3951 3609 <?php
3952 - if ( ! is_admin() ) {
3953 - ?>
3610 + if ( ! is_admin() ) { ?>
3954 3611 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
3955 3612 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
3956 - <?php
3957 - if ( $field->is_required ) {
3613 + <?php if ( $field->is_required ) {
3958 3614 echo '<span>*</span>';
3959 - }
3960 - ?>
3615 + } ?>
3961 3616 </label>
3962 3617 <?php } ?>
3963 3618
3964 3619 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3965 - class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
3966 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
3967 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
3968 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
3969 - title="<?php echo esc_attr( $site_title ); ?>"
3970 - <?php
3971 - 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 ) {
3972 3626 echo 'required="required"';
3973 - }
3974 - ?>
3975 - type="email"
3627 + } ?>
3628 + type="email"
3976 3629 />
3977 3630 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
3978 3631 <?php if ( $field->is_required ) { ?>
3979 - <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>
3980 3633 <?php } ?>
3981 3634 </div>
3982 3635
3983 3636
@@ -4008,8 +3661,9 @@
4008 3661 * @since 1.0.0
4009 3662 */
4010 3663 public function form_input_password( $html, $field, $value, $form_type ) {
4011 3664
3665 +
4012 3666 // Check if there is a custom field specific filter.
4013 3667 if ( has_filter( "uwp_form_input_password_{$field->htmlvar_name}" ) ) {
4014 3668 $html = apply_filters( "uwp_form_input_password_{$field->htmlvar_name}", $html, $field, $value, $form_type );
4015 3669 }
@@ -4016,12 +3670,12 @@
4016 3670
4017 3671 // If no html then we run the standard output.
4018 3672 if ( empty( $html ) ) {
4019 3673
4020 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4021 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4022 - $bs_sr_only = $design_style ? 'sr-only' : '';
4023 - $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" : "";
4024 3678
4025 3679 ob_start(); // Start buffering;
4026 3680 $site_title = uwp_get_form_label( $field );
4027 3681
@@ -4026,66 +3680,55 @@
4026 3680 $site_title = uwp_get_form_label( $field );
4027 3681
4028 3682 if ( $design_style ) {
4029 3683 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4030 - $required_msg = ( ! empty( $field->required_msg ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4031 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
4032 - $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';
4033 3687
4034 - echo aui()->input(
4035 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4036 - 'type' => 'password',
4037 - 'id' => esc_attr( $field->htmlvar_name ),
4038 - 'name' => esc_attr( $field->htmlvar_name ),
4039 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4040 - 'title' => esc_html( $site_title ),
4041 - 'value' => esc_attr( $value ),
4042 - 'required' => (bool) $field->is_required,
4043 - '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 ),
4044 3697 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4045 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4046 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4047 - 'wrap_class' => esc_attr( $wrap_class ),
4048 - )
4049 - );
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 + ) );
4050 3702 } else {
4051 3703 ?>
4052 - <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row" class="
4053 - <?php
4054 - if ( $field->is_required ) {
4055 - echo 'required_field';
4056 - }
4057 - ?>
4058 - 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 ); ?>">
4059 3707 <?php
4060 - if ( ! is_admin() ) {
4061 - ?>
3708 + if ( ! is_admin() ) { ?>
4062 3709 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4063 3710 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4064 - <?php
4065 - if ( $field->is_required ) {
3711 + <?php if ( $field->is_required ) {
4066 3712 echo '<span>*</span>';
4067 - }
4068 - ?>
3713 + } ?>
4069 3714 </label>
4070 3715 <?php } ?>
4071 3716
4072 3717 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4073 - class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
4074 - id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4075 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4076 - value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
4077 - title="<?php echo esc_attr( $site_title ); ?>"
4078 - <?php
4079 - 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 ) {
4080 3724 echo 'required="required"';
4081 - }
4082 - ?>
4083 - type="password"
3725 + } ?>
3726 + type="password"
4084 3727 />
4085 3728 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4086 3729 <?php if ( $field->is_required ) { ?>
4087 - <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>
4088 3731 <?php } ?>
4089 3732 </div>
4090 3733
4091 3734
@@ -4115,74 +3758,61 @@
4115 3758 *
4116 3759 */
4117 3760 public function form_input_phone( $html, $field, $value, $form_type ) {
4118 3761 if ( empty( $html ) ) {
4119 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4120 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4121 - $bs_sr_only = $design_style ? 'sr-only' : '';
4122 - $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" : "";
4123 3766 ob_start(); // Start buffering;
4124 3767 $site_title = uwp_get_form_label( $field );
4125 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4126 - $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') : '';
4127 3770
4128 3771 if ( $design_style ) {
4129 3772 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4130 3773
4131 - echo aui()->input(
4132 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4133 - 'type' => 'tel',
4134 - 'id' => esc_attr( $field->htmlvar_name ),
4135 - 'name' => esc_attr( $field->htmlvar_name ),
4136 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4137 - 'title' => esc_html( $site_title ),
4138 - 'value' => esc_attr( $value ),
4139 - 'required' => (bool) $field->is_required,
4140 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4141 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4142 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4143 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4144 - 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4145 - )
4146 - );
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 + ) );
4147 3788 } else {
4148 3789 ?>
4149 3790 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4150 - class="
4151 - <?php
4152 - if ( $field->is_required ) {
4153 - echo 'required_field';
4154 - }
4155 - ?>
4156 - 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 ); ?>">
4157 3794 <?php
4158 - if ( ! is_admin() ) {
4159 - ?>
3795 + if ( ! is_admin() ) { ?>
4160 3796 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4161 3797 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4162 - <?php
4163 - if ( $field->is_required ) {
3798 + <?php if ( $field->is_required ) {
4164 3799 echo '<span>*</span>';
4165 - }
4166 - ?>
3800 + } ?>
4167 3801 </label>
4168 3802 <?php } ?>
4169 3803 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4170 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
4171 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4172 - title="<?php echo esc_attr( $site_title ); ?>"
4173 - <?php
4174 - 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 ) {
4175 3808 echo 'readonly="readonly"';
4176 - }
4177 - ?>
4178 - <?php
4179 - if ( $field->is_required == 1 ) {
3809 + } ?>
3810 + <?php if ( $field->is_required == 1 ) {
4180 3811 echo 'required="required"';
4181 - }
4182 - ?>
4183 - type="tel"
4184 - value="<?php echo esc_html( $value ); ?>">
3812 + } ?>
3813 + type="tel"
3814 + value="<?php echo esc_html( $value ); ?>">
4185 3815 </div>
4186 3816 <?php
4187 3817 }
4188 3818 $html = ob_get_clean();
@@ -4192,22 +3822,22 @@
4192 3822 }
4193 3823
4194 3824 public function form_input_register_gdpr( $html, $field, $value, $form_type ) {
4195 3825
4196 - $form_id = isset( $field->form_id ) ? (int) $field->form_id : 1;
4197 - $reg_gdpr = uwp_get_register_form_by( $form_id, 'gdpr_page' );
4198 - 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)){
4199 3829 $reg_gdpr = uwp_get_option( 'register_gdpr_page', false );
4200 3830 }
4201 3831
4202 3832 if ( ! empty( $reg_gdpr ) ) {
4203 3833
4204 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4205 - $bs_form_group = $design_style ? 'form-group mb-3 form-check' : '';
4206 - $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" : "";
4207 3837 $site_title = uwp_get_form_label( $field );
4208 3838 $field->htmlvar_name = 'register_gdpr';
4209 - $id = wp_doing_ajax() ? $field->htmlvar_name . '_ajax' : $field->htmlvar_name;
3839 + $id = wp_doing_ajax() ? $field->htmlvar_name . "_ajax" : $field->htmlvar_name;
4210 3840
4211 3841 $gdpr_page = get_permalink( $reg_gdpr );
4212 3842 $link_start = '<a href="' . esc_url( $gdpr_page ) . '" target="_blank">';
4213 3843 $link_end = '</a>';
@@ -4213,9 +3843,9 @@
4213 3843 $link_end = '</a>';
4214 3844 $field_desc = uwp_get_field_description( $field, '' );
4215 3845 $field_desc = str_replace( '%%link_start%%', $link_start, $field_desc );
4216 3846 $field_desc = str_replace( '%%link_end%%', $link_end, $field_desc );
4217 - $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>' );
4218 3848 $checked = $value == '1' ? true : false;
4219 3849
4220 3850 ob_start(); // Start buffering;
4221 3851
@@ -4225,19 +3855,19 @@
4225 3855 echo '<input type="hidden" name="' . esc_attr( $field->htmlvar_name ) . '" id="checkbox_' . esc_attr( $id ) . '" value="0"/>';
4226 3856
4227 3857 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4228 3858 array(
4229 - 'id' => esc_attr( $id ),
4230 - 'name' => esc_attr( $field->htmlvar_name ),
4231 - 'type' => 'checkbox',
4232 - 'value' => '1',
4233 - 'title' => esc_html( $site_title ),
4234 - 'label' => wp_kses_post( $content . $required ),
4235 - 'label_show' => true,
4236 - 'required' => ! empty( $field->is_required ) ? true : false,
4237 - 'checked' => (bool) $checked,
4238 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4239 - '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' ) : '',
4240 3870 )
4241 3871 );
4242 3872
4243 3873 } else {
@@ -4242,33 +3872,27 @@
4242 3872
4243 3873 } else {
4244 3874 ?>
4245 3875 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4246 - class="
4247 - <?php
4248 - if ( $field->is_required ) {
4249 - echo 'required_field';
4250 - }
4251 - ?>
4252 - 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 ); ?>">
4253 3879 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value="0"/>
4254 3880 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4255 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
4256 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4257 - title="<?php echo esc_attr( $site_title ); ?>"
4258 - <?php
4259 - 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' ) {
4260 3885 echo 'checked="checked"';
4261 - }
4262 - ?>
4263 - type="<?php echo esc_attr( $field->field_type ); ?>"
4264 - value="1">
3886 + } ?>
3887 + type="<?php echo esc_attr( $field->field_type ); ?>"
3888 + value="1">
4265 3889 <?php
4266 3890 echo ( trim( $content ) ) ? wp_kses_post( $content ) : '&nbsp;';
4267 3891 ?>
4268 3892 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4269 3893 <?php if ( $field->is_required ) { ?>
4270 - <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>
4271 3895 <?php } ?>
4272 3896 </div>
4273 3897
4274 3898 <?php
@@ -4284,19 +3908,19 @@
4284 3908 }
4285 3909
4286 3910 public function form_input_register_tos( $html, $field, $value, $form_type ) {
4287 3911
4288 - $form_id = isset( $field->form_id ) ? (int) $field->form_id : 1;
4289 - $reg_tos = uwp_get_register_form_by( $form_id, 'tos_page' );
4290 - 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)){
4291 3915 $reg_tos = uwp_get_option( 'register_terms_page', false );
4292 3916 }
4293 3917
4294 3918 if ( ! empty( $reg_tos ) ) {
4295 3919
4296 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4297 - $bs_form_group = $design_style ? 'form-group mb-3 form-check' : '';
4298 - $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" : "";
4299 3923
4300 3924 $site_title = uwp_get_form_label( $field );
4301 3925 $terms_page = get_permalink( $reg_tos );
4302 3926 $link_start = '<a href="' . esc_url( $terms_page ) . '" target="_blank">';
@@ -4304,11 +3928,11 @@
4304 3928 $field_desc = uwp_get_field_description( $field, '' );
4305 3929 $field_desc = str_replace( '%%link_start%%', $link_start, $field_desc );
4306 3930 $field_desc = str_replace( '%%link_end%%', $link_end, $field_desc );
4307 3931 $field->htmlvar_name = 'register_tos';
4308 - $id = wp_doing_ajax() ? $field->htmlvar_name . '_ajax' : $field->htmlvar_name;
3932 + $id = wp_doing_ajax() ? $field->htmlvar_name . "_ajax" : $field->htmlvar_name;
4309 3933
4310 - $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>' );
4311 3935 $checked = $value == '1' ? true : false;
4312 3936
4313 3937 ob_start();
4314 3938
@@ -4317,19 +3941,19 @@
4317 3941 echo '<input type="hidden" name="' . esc_attr( $field->htmlvar_name ) . '" id="checkbox_' . esc_attr( $id ) . '" value="0"/>';
4318 3942
4319 3943 echo aui()->input( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4320 3944 array(
4321 - 'id' => esc_attr( $id ),
4322 - 'name' => esc_attr( $field->htmlvar_name ),
4323 - 'type' => 'checkbox',
4324 - 'value' => '1',
4325 - 'title' => esc_html( $site_title ),
4326 - 'label' => wp_kses_post( $content . $required ),
4327 - 'label_show' => true,
4328 - 'required' => ! empty( $field->is_required ) ? true : false,
4329 - 'checked' => (bool) $checked,
4330 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4331 - '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' ) : '',
4332 3956 )
4333 3957 );
4334 3958
4335 3959 } else {
@@ -4334,33 +3958,27 @@
4334 3958
4335 3959 } else {
4336 3960 ?>
4337 3961 <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4338 - class="
4339 - <?php
4340 - if ( $field->is_required ) {
4341 - echo 'required_field';
4342 - }
4343 - ?>
4344 - 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 ); ?>">
4345 3965 <input type="hidden" name="<?php echo esc_attr( $field->htmlvar_name ); ?>" value="0"/>
4346 3966 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4347 - class="<?php echo esc_attr( $field->css_class ); ?> <?php echo esc_attr( $bs_form_control ); ?>"
4348 - placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4349 - title="<?php echo esc_attr( $site_title ); ?>"
4350 - <?php
4351 - 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' ) {
4352 3971 echo 'checked="checked"';
4353 - }
4354 - ?>
4355 - type="<?php echo esc_attr( $field->field_type ); ?>"
4356 - value="1">
3972 + } ?>
3973 + type="<?php echo esc_attr( $field->field_type ); ?>"
3974 + value="1">
4357 3975 <?php
4358 3976 echo ( trim( $content ) ) ? wp_kses_post( $content ) : '&nbsp;';
4359 3977 ?>
4360 3978 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4361 3979 <?php if ( $field->is_required ) { ?>
4362 - <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>
4363 3981 <?php } ?>
4364 3982 </div>
4365 3983
4366 3984 <?php
@@ -4386,9 +4004,9 @@
4386 4004 */
4387 4005 function add_multipart_to_admin_edit_form() {
4388 4006 global $wpdb;
4389 4007 $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
4390 - $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
4391 4009 if ( $fields ) {
4392 4010 echo 'enctype="multipart/form-data"';
4393 4011 }
4394 4012 }
@@ -4407,12 +4025,12 @@
4407 4025 global $wpdb;
4408 4026 $file_obj = new UsersWP_Files();
4409 4027 $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
4410 4028 //Normal fields
4411 - $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
4412 4030 if ( $fields ) {
4413 - if ( isset( $_POST['locale'] ) ) {
4414 - $_POST['uwp_language'] = sanitize_text_field( $_POST['locale'] );
4031 + if(isset($_POST['locale'])){
4032 + $_POST['uwp_language'] = sanitize_text_field($_POST['locale']);
4415 4033 }
4416 4034 $result = uwp_validate_fields( $_POST, 'account', $fields );
4417 4035 if ( is_wp_error( $result ) ) {
4418 4036 die( wp_kses_post( $result->get_error_message() ) );
@@ -4418,13 +4036,15 @@
4418 4036 die( wp_kses_post( $result->get_error_message() ) );
4419 4037 }
4420 4038 if ( isset( $result['display_name'] ) && ! empty( $result['display_name'] ) ) {
4421 4039 $display_name = $result['display_name'];
4422 - } elseif ( ! empty( $first_name ) || ! empty( $last_name ) ) {
4040 + } else {
4041 + if ( ! empty( $first_name ) || ! empty( $last_name ) ) {
4423 4042 $display_name = $result['first_name'] . ' ' . $result['last_name'];
4424 4043 } else {
4425 - $user_info = get_userdata( $user_id );
4426 - $display_name = $user_info->user_login;
4044 + $user_info = get_userdata( $user_id );
4045 + $display_name = $user_info->user_login;
4046 + }
4427 4047 }
4428 4048 $result['display_name'] = $display_name;
4429 4049 if ( ! is_wp_error( $result ) ) {
4430 4050 foreach ( $fields as $field ) {
@@ -4436,14 +4056,14 @@
4436 4056 }
4437 4057 }
4438 4058
4439 4059 //File fields
4440 - $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
4441 4061 if ( $fields ) {
4442 4062 $result = $file_obj->validate_uploads( $_FILES, 'account', true, $fields );
4443 4063 if ( ! is_wp_error( $result ) ) {
4444 4064 foreach ( $fields as $field ) {
4445 - $value = isset( $result[ $field->htmlvar_name ] ) ? $result[ $field->htmlvar_name ] : '';
4065 + $value = $result[ $field->htmlvar_name ];
4446 4066 if ( $value == '0' || ! empty( $value ) ) {
4447 4067 uwp_update_usermeta( $user_id, $field->htmlvar_name, $value );
4448 4068 }
4449 4069 }
@@ -4468,29 +4088,27 @@
4468 4088
4469 4089 // If no html then we run the standard output.
4470 4090 if ( empty( $html ) ) {
4471 4091
4472 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4473 - $bs_form_group = $design_style ? 'form-group m-0' : ''; // country wrapper div added by JS adds margin so we remove ours
4474 - $bs_sr_only = $design_style ? 'sr-only' : '';
4475 - $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" : "";
4476 4096
4477 4097 ob_start(); // Start buffering;
4478 4098 ?>
4479 - <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 ); ?>">
4480 4100
4481 4101 <?php
4482 4102 $site_title = uwp_get_form_label( $field );
4483 4103
4484 - if ( ! is_admin() && ! wp_doing_ajax() ) {
4104 + if ( ! is_admin() && !wp_doing_ajax() ) {
4485 4105 ?>
4486 4106 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4487 4107 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4488 - <?php
4489 - if ( $field->is_required ) {
4108 + <?php if ( $field->is_required ) {
4490 4109 echo '<span class="text-danger">*</span>';
4491 - }
4492 - ?>
4110 + } ?>
4493 4111 </label>
4494 4112 <?php
4495 4113 }
4496 4114 // if value empty set the default
@@ -4512,9 +4130,9 @@
4512 4130 <input type="hidden" id="<?php echo esc_attr( $htmlvar_name ); ?>_code" name="<?php echo esc_attr( $field->htmlvar_name ); ?>"/>
4513 4131 <script>jQuery(function(){jQuery("#<?php echo esc_js( $htmlvar_name ); ?>").countrySelect(<?php echo wp_json_encode( json_decode( $select_country_options ) ); ?>);});</script>
4514 4132 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4515 4133 <?php if ( $field->is_required ) { ?>
4516 - <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>
4517 4135 <?php } ?>
4518 4136 </div>
4519 4137 <?php
4520 4138 $html = ob_get_clean();
@@ -4540,38 +4158,31 @@
4540 4158
4541 4159 // If no html then we run the standard output.
4542 4160 if ( empty( $html ) ) {
4543 4161
4544 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4545 - $bs_form_group = $design_style ? 'form-group m-0' : '';
4546 - $bs_sr_only = $design_style ? 'sr-only' : '';
4547 - $bs_form_control = $design_style ? 'form-control' : '';
4548 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4549 - $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') : '';
4550 4168
4551 4169 ob_start(); // Start buffering;
4552 4170
4553 4171 ?>
4554 - <div id="<?php echo esc_attr( $field->htmlvar_name ); ?>_row"
4555 - class="
4556 - <?php
4557 - if ( $field->is_required ) {
4558 - echo 'required_field';
4559 - }
4560 - ?>
4561 - 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 ); ?>">
4562 4176
4563 4177 <?php
4564 4178 $site_title = uwp_get_form_label( $field );
4565 - if ( ! is_admin() && ! wp_doing_ajax() ) {
4566 - ?>
4179 + if ( ! is_admin() && !wp_doing_ajax() ) { ?>
4567 4180 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4568 4181 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4569 - <?php
4570 - if ( $field->is_required ) {
4182 + <?php if ( $field->is_required ) {
4571 4183 echo '<span class="text-danger">*</span>';
4572 - }
4573 - ?>
4184 + } ?>
4574 4185 </label>
4575 4186 <?php } ?>
4576 4187
4577 4188 <?php
@@ -4586,43 +4197,41 @@
4586 4197
4587 4198 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
4588 4199 $translations = wp_get_available_translations();
4589 4200 $available_languages = get_available_languages();
4590 - $languages = array( 'site-default' => __( 'Site Default', 'userswp' ) );
4201 + $languages = array('site-default' => __( 'Site Default', 'userswp' ));
4591 4202
4592 4203 foreach ( $available_languages as $locale ) {
4593 4204 if ( isset( $translations[ $locale ] ) ) {
4594 4205 $translation = $translations[ $locale ];
4595 - $languages[ $translation['language'] ] = $translation['native_name'];
4206 + $languages[$translation['language']] = $translation['native_name'];
4596 4207
4597 4208 // Remove installed language from available translations.
4598 4209 unset( $translations[ $locale ] );
4599 4210 } else {
4600 - $languages[ $locale ] = $translation[ $locale ];
4211 + $languages[$locale] = $translation[$locale];
4601 4212 }
4602 4213 }
4603 4214
4604 4215 if ( $design_style ) {
4605 4216
4606 - $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4217 + $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4607 4218
4608 - echo aui()->select(
4609 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4610 - 'id' => esc_attr( $field->htmlvar_name ),
4611 - 'name' => esc_attr( $field->htmlvar_name ),
4612 - 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4613 - 'title' => esc_attr( $site_title ),
4614 - 'value' => esc_attr( $value ),
4615 - 'required' => (bool) $field->is_required,
4616 - 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
4617 - 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4618 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4619 - 'label' => wp_kses_post( $site_title . $required ),
4620 - 'options' => $languages, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4621 - 'select2' => true,
4622 - 'wrap_class' => isset( $field->css_class ) ? esc_attr( $field->css_class ) : '',
4623 - )
4624 - );
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 + ) );
4625 4234 } else {
4626 4235 ?>
4627 4236 <select name="<?php echo esc_attr( $field->htmlvar_name ); ?>" id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4628 4237 class="uwp_textfield aui-select2 <?php echo esc_attr( $bs_form_control ); ?>"
@@ -4630,14 +4239,14 @@
4630 4239 data-placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4631 4240 ><?php echo $select_options; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
4632 4241 </select>
4633 4242 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4634 - <?php if ( $field->is_required ) { ?>
4635 - <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
4636 - <?php
4637 - }
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 }
4638 4246 }
4639 4247
4248 +
4640 4249 $html = ob_get_clean();
4641 4250 }
4642 4251
4643 4252 return $html;
@@ -4666,58 +4275,53 @@
4666 4275
4667 4276 $enable_confirm_password_field = isset( $extra['confirm_password'] ) ? $extra['confirm_password'] : '0';
4668 4277 if ( $enable_confirm_password_field == '1' ) {
4669 4278
4670 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4671 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4672 - $bs_sr_only = $design_style ? 'sr-only' : '';
4673 - $bs_form_control = $design_style ? 'form-control' : '';
4674 - $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' );
4675 4284 $required = '';
4676 4285 if ( isset( $field->is_required ) && ! empty( $field->is_required ) ) {
4677 4286 $placeholder .= ' *';
4678 4287 $required = ' <span class="text-danger">*</span>';
4679 4288 }
4680 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4681 - $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
4682 - $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';
4683 4292
4684 4293 ob_start(); // Start buffering;
4685 4294
4686 4295 if ( $design_style ) {
4687 4296
4688 - echo aui()->input(
4689 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4690 - 'type' => 'password',
4691 - 'id' => 'confirm_password',
4692 - 'name' => 'confirm_password',
4693 - 'placeholder' => esc_attr( $placeholder ),
4694 - 'title' => esc_attr( $site_title ),
4695 - 'value' => esc_attr( $value ),
4696 - 'required' => (bool) $field->is_required,
4697 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4698 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4699 - '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 ),
4700 4308 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4701 - 'wrap_class' => esc_attr( $wrap_class ),
4702 - )
4703 - );
4309 + 'wrap_class' => esc_attr( $wrap_class ),
4310 + ) );
4704 4311 } else {
4705 4312 ?>
4706 4313 <div id="uwp_account_confirm_password_row"
4707 - 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 ); ?>">
4708 4315
4709 4316 <?php
4710 4317
4711 - if ( ! is_admin() ) {
4712 - ?>
4318 + if ( ! is_admin() ) { ?>
4713 4319 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4714 4320 <?php echo ( trim( $site_title ) ) ? esc_html( $site_title ) : '&nbsp;'; ?>
4715 - <?php
4716 - if ( $field->is_required ) {
4321 + <?php if ( $field->is_required ) {
4717 4322 echo '<span>*</span>';
4718 - }
4719 - ?>
4323 + } ?>
4720 4324 </label>
4721 4325 <?php } ?>
4722 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"/>
4723 4327 </div>
@@ -4754,15 +4358,15 @@
4754 4358 }
4755 4359 $enable_confirm_email_field = isset( $extra['confirm_email'] ) ? $extra['confirm_email'] : '0';
4756 4360 if ( $enable_confirm_email_field == '1' ) {
4757 4361
4758 - $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4759 - $bs_form_group = $design_style ? 'form-group mb-3' : '';
4760 - $bs_sr_only = $design_style ? 'sr-only' : '';
4761 - $bs_form_control = $design_style ? 'form-control' : '';
4762 - $site_title = __( 'Confirm Email', 'userswp' );
4763 - $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4764 - $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') : '';
4765 4369
4766 4370 ob_start();
4767 4371
4768 4372 if ( $design_style ) {
@@ -4767,50 +4371,45 @@
4767 4371
4768 4372 if ( $design_style ) {
4769 4373 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4770 4374
4771 - echo aui()->input(
4772 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4773 - 'type' => 'email',
4774 - 'id' => esc_attr( $field->htmlvar_name ),
4775 - 'name' => 'confirm_email',
4776 - 'placeholder' => esc_attr( $site_title ),
4777 - 'title' => esc_attr( $site_title ),
4778 - 'value' => esc_attr( $value ),
4779 - 'required' => (bool) $field->is_required,
4780 - 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
4781 - 'label' => is_admin() && ! wp_doing_ajax() ? '' : wp_kses_post( $site_title . $required ),
4782 - '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 ),
4783 4386 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
4784 - )
4785 - );
4387 + ) );
4786 4388 } else {
4787 4389 ?>
4788 4390 <div id="uwp_account_confirm_email_row"
4789 - 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 ); ?>">
4790 4392
4791 4393 <?php
4792 4394
4793 - if ( ! is_admin() ) {
4794 - ?>
4395 + if ( ! is_admin() ) { ?>
4795 4396 <label class="<?php echo esc_attr( $bs_sr_only ); ?>">
4796 4397 <?php echo ( trim( $site_title ) ) ? esc_attr( $site_title ) : '&nbsp;'; ?>
4797 - <?php
4798 - if ( $field->is_required ) {
4398 + <?php if ( $field->is_required ) {
4799 4399 echo '<span>*</span>';
4800 - }
4801 - ?>
4400 + } ?>
4802 4401 </label>
4803 4402 <?php } ?>
4804 4403
4805 4404 <input name="confirm_email"
4806 - class="uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
4807 - id="uwp_account_confirm_email"
4808 - placeholder="<?php echo esc_attr( $site_title ); ?>"
4809 - value=""
4810 - 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 ); ?>"
4811 4410 <?php echo 'required="required"'; ?>
4812 - type="email"
4411 + type="email"
4813 4412 />
4814 4413 </div>
4815 4414 <?php
4816 4415 }
@@ -4861,10 +4460,12 @@
4861 4460 if ( $field_value == 'no' ) {
4862 4461 if ( ! in_array( $field_name, $public_fields ) ) {
4863 4462 $public_fields[] = $field_name;
4864 4463 }
4865 - } elseif ( ( $field_name = array_search( $field_name, $public_fields ) ) !== false ) {
4464 + } else {
4465 + if ( ( $field_name = array_search( $field_name, $public_fields ) ) !== false ) {
4866 4466 unset( $public_fields[ $field_name ] );
4467 + }
4867 4468 }
4868 4469 }
4869 4470
4870 4471 $value = implode( ',', $public_fields );
@@ -4872,9 +4473,9 @@
4872 4473 }
4873 4474
4874 4475 // Save tabs privacy settings
4875 4476 $tabs_table_name = uwp_get_table_prefix() . 'uwp_profile_tabs';
4876 - $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
4877 4478
4878 4479 if ( $tabs ) {
4879 4480 $public_fields = maybe_unserialize( $user_meta_info->tabs_privacy );
4880 4481 $do_tabs_update = false;
@@ -4890,10 +4491,11 @@
4890 4491 } else {
4891 4492 $public_fields[ $field_name ] = $field_value;
4892 4493 }
4893 4494 }
4894 -}
4895 4495
4496 + }
4497 +
4896 4498 if ( $do_tabs_update ) {
4897 4499 uwp_update_usermeta( $user_id, 'tabs_privacy', maybe_serialize( $public_fields ) );
4898 4500 }
4899 4501 }
@@ -4914,13 +4516,12 @@
4914 4516 }
4915 4517 }
4916 4518
4917 4519 $message = apply_filters( 'uwp_privacy_update_success_message', __( 'Privacy settings updated successfully.', 'userswp' ) );
4918 - $message = aui()->alert(
4919 - array(
4520 + $message = aui()->alert( array(
4920 4521 'type' => 'success',
4921 - 'content' => $message,
4922 - )
4522 + 'content' => $message
4523 + )
4923 4524 );
4924 4525 $uwp_notices[] = array( 'account' => $message );
4925 4526
4926 4527 }
@@ -4936,18 +4537,18 @@
4936 4537 // add the modal error container
4937 4538 add_action( 'uwp_template_display_notices', array( $this, 'modal_error_container' ) );
4938 4539
4939 4540 $args = array(
4940 - 'form_title' => __( 'Login', 'userswp' ),
4541 + 'form_title' => __('Login','userswp'),
4941 4542 );
4942 4543
4943 4544 // get the form
4944 4545 ob_start();
4945 - uwp_get_template( 'bootstrap/login.php', $args );
4546 + uwp_get_template( "bootstrap/login.php", $args );
4946 4547 $form = ob_get_clean();
4947 4548
4948 4549 // bs5
4949 - if ( function_exists( 'aui_bs_convert_sd_output' ) ) {
4550 + if( function_exists('aui_bs_convert_sd_output')){
4950 4551 $form = aui_bs_convert_sd_output( $form );
4951 4552 }
4952 4553 // send ajax response
4953 4554 wp_send_json_success( $form );
@@ -4969,19 +4570,16 @@
4969 4570 }
4970 4571
4971 4572 // do we need country code script in ajax?
4972 4573 $country_field = false;
4973 - $lightbox_forms = uwp_get_option( 'register_modal_form', 1 );
4974 4574
4975 - if ( isset( $_POST['form_id'] ) && ! empty( $_POST['form_id'] ) ) {
4575 + if(isset($_POST['form_id']) && !empty($_POST['form_id'])){
4976 4576 $form_id = (int)$_POST['form_id'];
4977 - } elseif ( is_array( $lightbox_forms ) && count( $lightbox_forms ) > 0 ) {
4978 - $form_id = reset( $lightbox_forms );
4979 4577 } else {
4980 4578 $form_id = 1;
4981 4579 }
4982 4580
4983 - $fields = get_register_form_fields( $form_id );
4581 + $fields = get_register_form_fields($form_id);
4984 4582 if ( ! empty( $fields ) ) {
4985 4583 foreach ( $fields as $field ) {
4986 4584 if ( $field->field_type_key == 'country' || $field->field_type_key == 'uwp_country' ) {
4987 4585 $country_field = true;
@@ -4993,22 +4591,23 @@
4993 4591
4994 4592 // maybe add country code JS
4995 4593 if ( $country_field ) {
4996 4594 $country_data = uwp_get_country_data();
4997 - echo '<script>var uwp_country_data = ' . json_encode( $country_data ) . '</script>';
4595 + echo "<script>var uwp_country_data = " . json_encode( $country_data ) . "</script>";
4998 4596 echo "<script type='text/javascript' src='" . esc_url( USERSWP_PLUGIN_URL ) . 'assets/js/countrySelect.min.js' . "' ></script>";
4999 4597 }
5000 4598
5001 - $args = array( 'form_title' => '' );
5002 - if ( $form_id > 0 ) {
4599 + $args = array('form_title' => '');
4600 + if($form_id > 0){
5003 4601 $args['id'] = $form_id;
5004 4602 }
5005 4603
5006 - $args['limit'] = $lightbox_forms;
4604 + $args['limit'] = uwp_get_option('register_modal_form', 1);
5007 4605
5008 4606 // get template
5009 - uwp_get_template( 'bootstrap/register.php', $args );
4607 + uwp_get_template( "bootstrap/register.php", $args );
5010 4608
4609 +
5011 4610 // only show the JS if NOT doing a block render
5012 4611 if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] != 'super_duper_output_shortcode' ) {
5013 4612 // load scripts
5014 4613 $wp_scripts->do_item( 'zxcvbn-async' );
@@ -5034,13 +4633,13 @@
5034 4633 function (event) {
5035 4634 var $form = $(this).closest('form');
5036 4635 if( ! $form.hasClass('uwp-login-form') ) {
5037 4636 uwp_checkPasswordStrength(
5038 - $form.find('input[name=password]'),
5039 - $form.find('input[name=confirm_password]'),
5040 - $form.find('#uwp-password-strength'),
5041 - $form.find('button[type="submit"], input[type="submit"]'),
5042 - ['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
5043 4642 );
5044 4643 }
5045 4644 }
5046 4645 );
@@ -5050,9 +4649,9 @@
5050 4649 }
5051 4650 $form = ob_get_clean();
5052 4651
5053 4652 // bs5
5054 - if ( function_exists( 'aui_bs_convert_sd_output' ) ) {
4653 + if( function_exists('aui_bs_convert_sd_output')){
5055 4654 $form = aui_bs_convert_sd_output( $form );
5056 4655 }
5057 4656
5058 4657 // send ajax response
@@ -5067,19 +4666,16 @@
5067 4666 public function ajax_forgot_password_form() {
5068 4667
5069 4668 // add the modal error container
5070 4669 add_action( 'uwp_template_display_notices', array( $this, 'modal_error_container' ) );
5071 - $args = array(
5072 - 'form_title' => '',
5073 - 'css_class' => ''
5074 - );
4670 +
5075 4671 // get the form
5076 4672 ob_start();
5077 - uwp_get_template( 'bootstrap/forgot.php', $args );
4673 + uwp_get_template( "bootstrap/forgot.php" );
5078 4674 $form = ob_get_clean();
5079 4675
5080 4676 // bs5
5081 - if ( function_exists( 'aui_bs_convert_sd_output' ) ) {
4677 + if( function_exists('aui_bs_convert_sd_output')){
5082 4678 $form = aui_bs_convert_sd_output( $form );
5083 4679 }
5084 4680
5085 4681 // send ajax response
@@ -5102,5 +4698,5 @@
5102 4698 $html = ! empty( $field->default_value ) ? $field->default_value : ' ';
5103 4699
5104 4700 return $html;
5105 4701 }
5106 -}
4702 +}