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