[ Index ] |
WordPress 5.4.1 |
[ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] [ Statistics ] |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * WordPress User Page 4 * 5 * Handles authentication, registering, resetting passwords, forgot password, 6 * and other user handling. 7 * 8 * @package WordPress 9 */ 10 11 /** Make sure that the WordPress bootstrap has run before continuing. */ 12 require __DIR__ . '/wp-load.php'; 13 14 // Redirect to HTTPS login if forced to use SSL. 15 if ( force_ssl_admin() && ! is_ssl() ) { 16 if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) { 17 wp_safe_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) ); 18 exit(); 19 } else { 20 wp_safe_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 21 exit(); 22 } 23 } 24 25 /** 26 * Output the login page header. 27 * 28 * @since 2.1.0 29 * 30 * @global string $error Login error message set by deprecated pluggable wp_login() function 31 * or plugins replacing it. 32 * @global bool|string $interim_login Whether interim login modal is being displayed. String 'success' 33 * upon successful login. 34 * @global string $action The action that brought the visitor to the login page. 35 * 36 * @param string $title Optional. WordPress login Page title to display in the `<title>` element. 37 * Default 'Log In'. 38 * @param string $message Optional. Message to display in header. Default empty. 39 * @param WP_Error $wp_error Optional. The error to pass. Default is a WP_Error instance. 40 */ 41 function login_header( $title = 'Log In', $message = '', $wp_error = null ) { 42 global $error, $interim_login, $action; 43 44 // Don't index any of these forms. 45 add_action( 'login_head', 'wp_sensitive_page_meta' ); 46 47 add_action( 'login_head', 'wp_login_viewport_meta' ); 48 49 if ( ! is_wp_error( $wp_error ) ) { 50 $wp_error = new WP_Error(); 51 } 52 53 // Shake it! 54 $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password', 'retrieve_password_email_failure' ); 55 /** 56 * Filters the error codes array for shaking the login form. 57 * 58 * @since 3.0.0 59 * 60 * @param array $shake_error_codes Error codes that shake the login form. 61 */ 62 $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes ); 63 64 if ( $shake_error_codes && $wp_error->has_errors() && in_array( $wp_error->get_error_code(), $shake_error_codes, true ) ) { 65 add_action( 'login_footer', 'wp_shake_js', 12 ); 66 } 67 68 $login_title = get_bloginfo( 'name', 'display' ); 69 70 /* translators: Login screen title. 1: Login screen name, 2: Network or site name. */ 71 $login_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $login_title ); 72 73 if ( wp_is_recovery_mode() ) { 74 /* translators: %s: Login screen title. */ 75 $login_title = sprintf( __( 'Recovery Mode — %s' ), $login_title ); 76 } 77 78 /** 79 * Filters the title tag content for login page. 80 * 81 * @since 4.9.0 82 * 83 * @param string $login_title The page title, with extra context added. 84 * @param string $title The original page title. 85 */ 86 $login_title = apply_filters( 'login_title', $login_title, $title ); 87 88 ?><!DOCTYPE html> 89 <!--[if IE 8]> 90 <html xmlns="http://www.w3.org/1999/xhtml" class="ie8" <?php language_attributes(); ?>> 91 <![endif]--> 92 <!--[if !(IE 8) ]><!--> 93 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> 94 <!--<![endif]--> 95 <head> 96 <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" /> 97 <title><?php echo $login_title; ?></title> 98 <?php 99 100 wp_enqueue_style( 'login' ); 101 102 /* 103 * Remove all stored post data on logging out. 104 * This could be added by add_action('login_head'...) like wp_shake_js(), 105 * but maybe better if it's not removable by plugins. 106 */ 107 if ( 'loggedout' === $wp_error->get_error_code() ) { 108 ?> 109 <script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script> 110 <?php 111 } 112 113 /** 114 * Enqueue scripts and styles for the login page. 115 * 116 * @since 3.1.0 117 */ 118 do_action( 'login_enqueue_scripts' ); 119 120 /** 121 * Fires in the login page header after scripts are enqueued. 122 * 123 * @since 2.1.0 124 */ 125 do_action( 'login_head' ); 126 127 $login_header_url = __( 'https://wordpress.org/' ); 128 129 /** 130 * Filters link URL of the header logo above login form. 131 * 132 * @since 2.1.0 133 * 134 * @param string $login_header_url Login header logo URL. 135 */ 136 $login_header_url = apply_filters( 'login_headerurl', $login_header_url ); 137 138 $login_header_title = ''; 139 140 /** 141 * Filters the title attribute of the header logo above login form. 142 * 143 * @since 2.1.0 144 * @deprecated 5.2.0 Use {@see 'login_headertext'} instead. 145 * 146 * @param string $login_header_title Login header logo title attribute. 147 */ 148 $login_header_title = apply_filters_deprecated( 149 'login_headertitle', 150 array( $login_header_title ), 151 '5.2.0', 152 'login_headertext', 153 __( 'Usage of the title attribute on the login logo is not recommended for accessibility reasons. Use the link text instead.' ) 154 ); 155 156 $login_header_text = empty( $login_header_title ) ? __( 'Powered by WordPress' ) : $login_header_title; 157 158 /** 159 * Filters the link text of the header logo above the login form. 160 * 161 * @since 5.2.0 162 * 163 * @param string $login_header_text The login header logo link text. 164 */ 165 $login_header_text = apply_filters( 'login_headertext', $login_header_text ); 166 167 $classes = array( 'login-action-' . $action, 'wp-core-ui' ); 168 169 if ( is_rtl() ) { 170 $classes[] = 'rtl'; 171 } 172 173 if ( $interim_login ) { 174 $classes[] = 'interim-login'; 175 176 ?> 177 <style type="text/css">html{background-color: transparent;}</style> 178 <?php 179 180 if ( 'success' === $interim_login ) { 181 $classes[] = 'interim-login-success'; 182 } 183 } 184 185 $classes[] = ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); 186 187 /** 188 * Filters the login page body classes. 189 * 190 * @since 3.5.0 191 * 192 * @param array $classes An array of body classes. 193 * @param string $action The action that brought the visitor to the login page. 194 */ 195 $classes = apply_filters( 'login_body_class', $classes, $action ); 196 197 ?> 198 </head> 199 <body class="login no-js <?php echo esc_attr( implode( ' ', $classes ) ); ?>"> 200 <script type="text/javascript"> 201 document.body.className = document.body.className.replace('no-js','js'); 202 </script> 203 <?php 204 /** 205 * Fires in the login page header after the body tag is opened. 206 * 207 * @since 4.6.0 208 */ 209 do_action( 'login_header' ); 210 211 ?> 212 <div id="login"> 213 <h1><a href="<?php echo esc_url( $login_header_url ); ?>"><?php echo $login_header_text; ?></a></h1> 214 <?php 215 /** 216 * Filters the message to display above the login form. 217 * 218 * @since 2.1.0 219 * 220 * @param string $message Login message text. 221 */ 222 $message = apply_filters( 'login_message', $message ); 223 224 if ( ! empty( $message ) ) { 225 echo $message . "\n"; 226 } 227 228 // In case a plugin uses $error rather than the $wp_errors object. 229 if ( ! empty( $error ) ) { 230 $wp_error->add( 'error', $error ); 231 unset( $error ); 232 } 233 234 if ( $wp_error->has_errors() ) { 235 $errors = ''; 236 $messages = ''; 237 238 foreach ( $wp_error->get_error_codes() as $code ) { 239 $severity = $wp_error->get_error_data( $code ); 240 foreach ( $wp_error->get_error_messages( $code ) as $error_message ) { 241 if ( 'message' === $severity ) { 242 $messages .= ' ' . $error_message . "<br />\n"; 243 } else { 244 $errors .= ' ' . $error_message . "<br />\n"; 245 } 246 } 247 } 248 249 if ( ! empty( $errors ) ) { 250 /** 251 * Filters the error messages displayed above the login form. 252 * 253 * @since 2.1.0 254 * 255 * @param string $errors Login error message. 256 */ 257 echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n"; 258 } 259 260 if ( ! empty( $messages ) ) { 261 /** 262 * Filters instructional messages displayed above the login form. 263 * 264 * @since 2.5.0 265 * 266 * @param string $messages Login messages. 267 */ 268 echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n"; 269 } 270 } 271 } // End of login_header(). 272 273 /** 274 * Outputs the footer for the login page. 275 * 276 * @since 3.1.0 277 * 278 * @global bool|string $interim_login Whether interim login modal is being displayed. String 'success' 279 * upon successful login. 280 * 281 * @param string $input_id Which input to auto-focus. 282 */ 283 function login_footer( $input_id = '' ) { 284 global $interim_login; 285 286 // Don't allow interim logins to navigate away from the page. 287 if ( ! $interim_login ) { 288 ?> 289 <p id="backtoblog"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"> 290 <?php 291 292 /* translators: %s: Site title. */ 293 printf( _x( '← Back to %s', 'site' ), get_bloginfo( 'title', 'display' ) ); 294 295 ?> 296 </a></p> 297 <?php 298 299 the_privacy_policy_link( '<div class="privacy-policy-page-link">', '</div>' ); 300 } 301 302 ?> 303 </div><?php // End of <div id="login">. ?> 304 305 <?php 306 307 if ( ! empty( $input_id ) ) { 308 ?> 309 <script type="text/javascript"> 310 try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){} 311 if(typeof wpOnload=='function')wpOnload(); 312 </script> 313 <?php 314 } 315 316 /** 317 * Fires in the login page footer. 318 * 319 * @since 3.1.0 320 */ 321 do_action( 'login_footer' ); 322 323 ?> 324 <div class="clear"></div> 325 </body> 326 </html> 327 <?php 328 } 329 330 /** 331 * Outputs the Javascript to handle the form shaking. 332 * 333 * @since 3.0.0 334 */ 335 function wp_shake_js() { 336 ?> 337 <script type="text/javascript"> 338 document.querySelector('form').classList.add('shake'); 339 </script> 340 <?php 341 } 342 343 /** 344 * Outputs the viewport meta tag. 345 * 346 * @since 3.7.0 347 */ 348 function wp_login_viewport_meta() { 349 ?> 350 <meta name="viewport" content="width=device-width" /> 351 <?php 352 } 353 354 /** 355 * Handles sending password retrieval email to user. 356 * 357 * @since 2.5.0 358 * 359 * @return bool|WP_Error True: when finish. WP_Error on error 360 */ 361 function retrieve_password() { 362 $errors = new WP_Error(); 363 $user_data = false; 364 365 if ( empty( $_POST['user_login'] ) || ! is_string( $_POST['user_login'] ) ) { 366 $errors->add( 'empty_username', __( '<strong>Error</strong>: Enter a username or email address.' ) ); 367 } elseif ( strpos( $_POST['user_login'], '@' ) ) { 368 $user_data = get_user_by( 'email', trim( wp_unslash( $_POST['user_login'] ) ) ); 369 if ( empty( $user_data ) ) { 370 $errors->add( 'invalid_email', __( '<strong>Error</strong>: There is no account with that username or email address.' ) ); 371 } 372 } else { 373 $login = trim( wp_unslash( $_POST['user_login'] ) ); 374 $user_data = get_user_by( 'login', $login ); 375 } 376 377 /** 378 * Fires before errors are returned from a password reset request. 379 * 380 * @since 2.1.0 381 * @since 4.4.0 Added the `$errors` parameter. 382 * @since 5.4.0 Added the `$user_data` parameter. 383 * 384 * @param WP_Error $errors A WP_Error object containing any errors generated 385 * by using invalid credentials. 386 * @param WP_User|false WP_User object if found, false if the user does not exist. 387 */ 388 do_action( 'lostpassword_post', $errors, $user_data ); 389 390 if ( $errors->has_errors() ) { 391 return $errors; 392 } 393 394 if ( ! $user_data ) { 395 $errors->add( 'invalidcombo', __( '<strong>Error</strong>: There is no account with that username or email address.' ) ); 396 return $errors; 397 } 398 399 // Redefining user_login ensures we return the right case in the email. 400 $user_login = $user_data->user_login; 401 $user_email = $user_data->user_email; 402 $key = get_password_reset_key( $user_data ); 403 404 if ( is_wp_error( $key ) ) { 405 return $key; 406 } 407 408 if ( is_multisite() ) { 409 $site_name = get_network()->site_name; 410 } else { 411 /* 412 * The blogname option is escaped with esc_html on the way into the database 413 * in sanitize_option we want to reverse this for the plain text arena of emails. 414 */ 415 $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 416 } 417 418 $message = __( 'Someone has requested a password reset for the following account:' ) . "\r\n\r\n"; 419 /* translators: %s: Site name. */ 420 $message .= sprintf( __( 'Site Name: %s' ), $site_name ) . "\r\n\r\n"; 421 /* translators: %s: User login. */ 422 $message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n\r\n"; 423 $message .= __( 'If this was a mistake, just ignore this email and nothing will happen.' ) . "\r\n\r\n"; 424 $message .= __( 'To reset your password, visit the following address:' ) . "\r\n\r\n"; 425 $message .= network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . "\r\n"; 426 427 /* translators: Password reset notification email subject. %s: Site title. */ 428 $title = sprintf( __( '[%s] Password Reset' ), $site_name ); 429 430 /** 431 * Filters the subject of the password reset email. 432 * 433 * @since 2.8.0 434 * @since 4.4.0 Added the `$user_login` and `$user_data` parameters. 435 * 436 * @param string $title Default email title. 437 * @param string $user_login The username for the user. 438 * @param WP_User $user_data WP_User object. 439 */ 440 $title = apply_filters( 'retrieve_password_title', $title, $user_login, $user_data ); 441 442 /** 443 * Filters the message body of the password reset mail. 444 * 445 * If the filtered message is empty, the password reset email will not be sent. 446 * 447 * @since 2.8.0 448 * @since 4.1.0 Added `$user_login` and `$user_data` parameters. 449 * 450 * @param string $message Default mail message. 451 * @param string $key The activation key. 452 * @param string $user_login The username for the user. 453 * @param WP_User $user_data WP_User object. 454 */ 455 $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data ); 456 457 if ( $message && ! wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) { 458 $errors->add( 459 'retrieve_password_email_failure', 460 sprintf( 461 /* translators: %s: Documentation URL. */ 462 __( '<strong>Error</strong>: The email could not be sent. Your site may not be correctly configured to send emails. <a href="%s">Get support for resetting your password</a>.' ), 463 esc_url( __( 'https://wordpress.org/support/article/resetting-your-password/' ) ) 464 ) 465 ); 466 return $errors; 467 } 468 469 return true; 470 } 471 472 // 473 // Main. 474 // 475 476 $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login'; 477 $errors = new WP_Error(); 478 479 if ( isset( $_GET['key'] ) ) { 480 $action = 'resetpass'; 481 } 482 483 $default_actions = array( 484 'confirm_admin_email', 485 'postpass', 486 'logout', 487 'lostpassword', 488 'retrievepassword', 489 'resetpass', 490 'rp', 491 'register', 492 'login', 493 'confirmaction', 494 WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED, 495 ); 496 497 // Validate action so as to default to the login screen. 498 if ( ! in_array( $action, $default_actions, true ) && false === has_filter( 'login_form_' . $action ) ) { 499 $action = 'login'; 500 } 501 502 nocache_headers(); 503 504 header( 'Content-Type: ' . get_bloginfo( 'html_type' ) . '; charset=' . get_bloginfo( 'charset' ) ); 505 506 if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set. 507 if ( isset( $_SERVER['PATH_INFO'] ) && ( $_SERVER['PATH_INFO'] !== $_SERVER['PHP_SELF'] ) ) { 508 $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] ); 509 } 510 511 $url = dirname( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ) ); 512 513 if ( get_option( 'siteurl' ) !== $url ) { 514 update_option( 'siteurl', $url ); 515 } 516 } 517 518 // Set a cookie now to see if they are supported by the browser. 519 $secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) ); 520 setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure ); 521 522 if ( SITECOOKIEPATH !== COOKIEPATH ) { 523 setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure ); 524 } 525 526 /** 527 * Fires when the login form is initialized. 528 * 529 * @since 3.2.0 530 */ 531 do_action( 'login_init' ); 532 533 /** 534 * Fires before a specified login form action. 535 * 536 * The dynamic portion of the hook name, `$action`, refers to the action 537 * that brought the visitor to the login form. Actions include 'postpass', 538 * 'logout', 'lostpassword', etc. 539 * 540 * @since 2.8.0 541 */ 542 do_action( "login_form_{$action}" ); 543 544 $http_post = ( 'POST' === $_SERVER['REQUEST_METHOD'] ); 545 $interim_login = isset( $_REQUEST['interim-login'] ); 546 547 /** 548 * Filters the separator used between login form navigation links. 549 * 550 * @since 4.9.0 551 * 552 * @param string $login_link_separator The separator used between login form navigation links. 553 */ 554 $login_link_separator = apply_filters( 'login_link_separator', ' | ' ); 555 556 switch ( $action ) { 557 558 case 'confirm_admin_email': 559 /* 560 * Note that `is_user_logged_in()` will return false immediately after logging in 561 * as the current user is not set, see wp-includes/pluggable.php. 562 * However this action runs on a redirect after logging in. 563 */ 564 if ( ! is_user_logged_in() ) { 565 wp_safe_redirect( wp_login_url() ); 566 exit; 567 } 568 569 if ( ! empty( $_REQUEST['redirect_to'] ) ) { 570 $redirect_to = $_REQUEST['redirect_to']; 571 } else { 572 $redirect_to = admin_url(); 573 } 574 575 if ( current_user_can( 'manage_options' ) ) { 576 $admin_email = get_option( 'admin_email' ); 577 } else { 578 wp_safe_redirect( $redirect_to ); 579 exit; 580 } 581 582 /** 583 * Filters the interval for dismissing the admin email confirmation screen. 584 * 585 * If `0` (zero) is returned, the "Remind me later" link will not be displayed. 586 * 587 * @since 5.3.1 588 * 589 * @param int $interval Interval time (in seconds). Default is 3 days. 590 */ 591 $remind_interval = (int) apply_filters( 'admin_email_remind_interval', 3 * DAY_IN_SECONDS ); 592 593 if ( ! empty( $_GET['remind_me_later'] ) ) { 594 if ( ! wp_verify_nonce( $_GET['remind_me_later'], 'remind_me_later_nonce' ) ) { 595 wp_safe_redirect( wp_login_url() ); 596 exit; 597 } 598 599 if ( $remind_interval > 0 ) { 600 update_option( 'admin_email_lifespan', time() + $remind_interval ); 601 } 602 603 wp_safe_redirect( $redirect_to ); 604 exit; 605 } 606 607 if ( ! empty( $_POST['correct-admin-email'] ) ) { 608 if ( ! check_admin_referer( 'confirm_admin_email', 'confirm_admin_email_nonce' ) ) { 609 wp_safe_redirect( wp_login_url() ); 610 exit; 611 } 612 613 /** 614 * Filters the interval for redirecting the user to the admin email confirmation screen. 615 * 616 * If `0` (zero) is returned, the user will not be redirected. 617 * 618 * @since 5.3.0 619 * 620 * @param int $interval Interval time (in seconds). Default is 6 months. 621 */ 622 $admin_email_check_interval = (int) apply_filters( 'admin_email_check_interval', 6 * MONTH_IN_SECONDS ); 623 624 if ( $admin_email_check_interval > 0 ) { 625 update_option( 'admin_email_lifespan', time() + $admin_email_check_interval ); 626 } 627 628 wp_safe_redirect( $redirect_to ); 629 exit; 630 } 631 632 login_header( __( 'Confirm your administration email' ), '', $errors ); 633 634 /** 635 * Fires before the admin email confirm form. 636 * 637 * @since 5.3.0 638 * 639 * @param WP_Error $errors A `WP_Error` object containing any errors generated by using invalid 640 * credentials. Note that the error object may not contain any errors. 641 */ 642 do_action( 'admin_email_confirm', $errors ); 643 644 ?> 645 646 <form class="admin-email-confirm-form" name="admin-email-confirm-form" action="<?php echo esc_url( site_url( 'wp-login.php?action=confirm_admin_email', 'login_post' ) ); ?>" method="post"> 647 <?php 648 /** 649 * Fires inside the admin-email-confirm-form form tags, before the hidden fields. 650 * 651 * @since 5.3.0 652 */ 653 do_action( 'admin_email_confirm_form' ); 654 655 wp_nonce_field( 'confirm_admin_email', 'confirm_admin_email_nonce' ); 656 657 ?> 658 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> 659 660 <h1 class="admin-email__heading"> 661 <?php _e( 'Administration email verification' ); ?> 662 </h1> 663 <p class="admin-email__details"> 664 <?php _e( 'Please verify that the <strong>administration email</strong> for this website is still correct.' ); ?> 665 <?php 666 667 /* translators: URL to the WordPress help section about admin email. */ 668 $admin_email_help_url = __( 'https://wordpress.org/support/article/settings-general-screen/#email-address' ); 669 670 /* translators: accessibility text */ 671 $accessibility_text = sprintf( '<span class="screen-reader-text"> %s</span>', __( '(opens in a new tab)' ) ); 672 673 printf( 674 '<a href="%s" rel="noopener noreferrer" target="_blank">%s%s</a>', 675 esc_url( $admin_email_help_url ), 676 __( 'Why is this important?' ), 677 $accessibility_text 678 ); 679 680 ?> 681 </p> 682 <p class="admin-email__details"> 683 <?php 684 685 printf( 686 /* translators: %s: Admin email address. */ 687 __( 'Current administration email: %s' ), 688 '<strong>' . esc_html( $admin_email ) . '</strong>' 689 ); 690 691 ?> 692 </p> 693 <p class="admin-email__details"> 694 <?php _e( 'This email may be different from your personal email address.' ); ?> 695 </p> 696 697 <div class="admin-email__actions"> 698 <div class="admin-email__actions-primary"> 699 <?php 700 701 $change_link = admin_url( 'options-general.php' ); 702 $change_link = add_query_arg( 'highlight', 'confirm_admin_email', $change_link ); 703 704 ?> 705 <a class="button button-large" href="<?php echo esc_url( $change_link ); ?>"><?php _e( 'Update' ); ?></a> 706 <input type="submit" name="correct-admin-email" id="correct-admin-email" class="button button-primary button-large" value="<?php esc_attr_e( 'The email is correct' ); ?>" /> 707 </div> 708 <?php if ( $remind_interval > 0 ) : ?> 709 <div class="admin-email__actions-secondary"> 710 <?php 711 712 $remind_me_link = wp_login_url( $redirect_to ); 713 $remind_me_link = add_query_arg( 714 array( 715 'action' => 'confirm_admin_email', 716 'remind_me_later' => wp_create_nonce( 'remind_me_later_nonce' ), 717 ), 718 $remind_me_link 719 ); 720 721 ?> 722 <a href="<?php echo esc_url( $remind_me_link ); ?>"><?php _e( 'Remind me later' ); ?></a> 723 </div> 724 <?php endif; ?> 725 </div> 726 </form> 727 728 <?php 729 730 login_footer(); 731 break; 732 733 case 'postpass': 734 if ( ! array_key_exists( 'post_password', $_POST ) ) { 735 wp_safe_redirect( wp_get_referer() ); 736 exit; 737 } 738 739 require_once ABSPATH . WPINC . '/class-phpass.php'; 740 $hasher = new PasswordHash( 8, true ); 741 742 /** 743 * Filters the life span of the post password cookie. 744 * 745 * By default, the cookie expires 10 days from creation. To turn this 746 * into a session cookie, return 0. 747 * 748 * @since 3.7.0 749 * 750 * @param int $expires The expiry time, as passed to setcookie(). 751 */ 752 $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS ); 753 $referer = wp_get_referer(); 754 755 if ( $referer ) { 756 $secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) ); 757 } else { 758 $secure = false; 759 } 760 761 setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure ); 762 763 wp_safe_redirect( wp_get_referer() ); 764 exit(); 765 766 case 'logout': 767 check_admin_referer( 'log-out' ); 768 769 $user = wp_get_current_user(); 770 771 wp_logout(); 772 773 if ( ! empty( $_REQUEST['redirect_to'] ) ) { 774 $redirect_to = $_REQUEST['redirect_to']; 775 $requested_redirect_to = $redirect_to; 776 } else { 777 $redirect_to = add_query_arg( 778 array( 779 'loggedout' => 'true', 780 'wp_lang' => get_user_locale( $user ), 781 ), 782 wp_login_url() 783 ); 784 785 $requested_redirect_to = ''; 786 } 787 788 /** 789 * Filters the log out redirect URL. 790 * 791 * @since 4.2.0 792 * 793 * @param string $redirect_to The redirect destination URL. 794 * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. 795 * @param WP_User $user The WP_User object for the user that's logging out. 796 */ 797 $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user ); 798 799 wp_safe_redirect( $redirect_to ); 800 exit(); 801 802 case 'lostpassword': 803 case 'retrievepassword': 804 if ( $http_post ) { 805 $errors = retrieve_password(); 806 807 if ( ! is_wp_error( $errors ) ) { 808 $redirect_to = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; 809 wp_safe_redirect( $redirect_to ); 810 exit(); 811 } 812 } 813 814 if ( isset( $_GET['error'] ) ) { 815 if ( 'invalidkey' === $_GET['error'] ) { 816 $errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) ); 817 } elseif ( 'expiredkey' === $_GET['error'] ) { 818 $errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) ); 819 } 820 } 821 822 $lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; 823 /** 824 * Filters the URL redirected to after submitting the lostpassword/retrievepassword form. 825 * 826 * @since 3.0.0 827 * 828 * @param string $lostpassword_redirect The redirect destination URL. 829 */ 830 $redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect ); 831 832 /** 833 * Fires before the lost password form. 834 * 835 * @since 1.5.1 836 * @since 5.1.0 Added the `$errors` parameter. 837 * 838 * @param WP_Error $errors A `WP_Error` object containing any errors generated by using invalid 839 * credentials. Note that the error object may not contain any errors. 840 */ 841 do_action( 'lost_password', $errors ); 842 843 login_header( __( 'Lost Password' ), '<p class="message">' . __( 'Please enter your username or email address. You will receive an email message with instructions on how to reset your password.' ) . '</p>', $errors ); 844 845 $user_login = ''; 846 847 if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) { 848 $user_login = wp_unslash( $_POST['user_login'] ); 849 } 850 851 ?> 852 853 <form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post"> 854 <p> 855 <label for="user_login"><?php _e( 'Username or Email Address' ); ?></label> 856 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" /> 857 </p> 858 <?php 859 860 /** 861 * Fires inside the lostpassword form tags, before the hidden fields. 862 * 863 * @since 2.1.0 864 */ 865 do_action( 'lostpassword_form' ); 866 867 ?> 868 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> 869 <p class="submit"> 870 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Get New Password' ); ?>" /> 871 </p> 872 </form> 873 874 <p id="nav"> 875 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> 876 <?php 877 878 if ( get_option( 'users_can_register' ) ) { 879 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); 880 881 echo esc_html( $login_link_separator ); 882 883 /** This filter is documented in wp-includes/general-template.php */ 884 echo apply_filters( 'register', $registration_url ); 885 } 886 887 ?> 888 </p> 889 <?php 890 891 login_footer( 'user_login' ); 892 break; 893 894 case 'resetpass': 895 case 'rp': 896 list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ); 897 $rp_cookie = 'wp-resetpass-' . COOKIEHASH; 898 899 if ( isset( $_GET['key'] ) ) { 900 $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) ); 901 setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); 902 903 wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) ); 904 exit; 905 } 906 907 if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) { 908 list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 ); 909 910 $user = check_password_reset_key( $rp_key, $rp_login ); 911 912 if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) { 913 $user = false; 914 } 915 } else { 916 $user = false; 917 } 918 919 if ( ! $user || is_wp_error( $user ) ) { 920 setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); 921 922 if ( $user && $user->get_error_code() === 'expired_key' ) { 923 wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); 924 } else { 925 wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); 926 } 927 928 exit; 929 } 930 931 $errors = new WP_Error(); 932 933 if ( isset( $_POST['pass1'] ) && $_POST['pass1'] !== $_POST['pass2'] ) { 934 $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); 935 } 936 937 /** 938 * Fires before the password reset procedure is validated. 939 * 940 * @since 3.5.0 941 * 942 * @param WP_Error $errors WP Error object. 943 * @param WP_User|WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise. 944 */ 945 do_action( 'validate_password_reset', $errors, $user ); 946 947 if ( ( ! $errors->has_errors() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) { 948 reset_password( $user, $_POST['pass1'] ); 949 setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); 950 login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' ); 951 login_footer(); 952 exit; 953 } 954 955 wp_enqueue_script( 'utils' ); 956 wp_enqueue_script( 'user-profile' ); 957 958 login_header( __( 'Reset Password' ), '<p class="message reset-pass">' . __( 'Enter your new password below.' ) . '</p>', $errors ); 959 960 ?> 961 <form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off"> 962 <input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" /> 963 964 <div class="user-pass1-wrap"> 965 <p> 966 <label for="pass1"><?php _e( 'New password' ); ?></label> 967 </p> 968 969 <div class="wp-pwd"> 970 <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input password-input" size="24" value="" autocomplete="off" aria-describedby="pass-strength-result" /> 971 972 <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> 973 <span class="dashicons dashicons-hidden" aria-hidden="true"></span> 974 </button> 975 <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></div> 976 </div> 977 <div class="pw-weak"> 978 <input type="checkbox" name="pw_weak" id="pw-weak" class="pw-checkbox" /> 979 <label for="pw-weak"><?php _e( 'Confirm use of weak password' ); ?></label> 980 </div> 981 </div> 982 983 <p class="user-pass2-wrap"> 984 <label for="pass2"><?php _e( 'Confirm new password' ); ?></label> 985 <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" /> 986 </p> 987 988 <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p> 989 <br class="clear" /> 990 991 <?php 992 993 /** 994 * Fires following the 'Strength indicator' meter in the user password reset form. 995 * 996 * @since 3.9.0 997 * 998 * @param WP_User $user User object of the user whose password is being reset. 999 */ 1000 do_action( 'resetpass_form', $user ); 1001 1002 ?> 1003 <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" /> 1004 <p class="submit"> 1005 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Reset Password' ); ?>" /> 1006 </p> 1007 </form> 1008 1009 <p id="nav"> 1010 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> 1011 <?php 1012 1013 if ( get_option( 'users_can_register' ) ) { 1014 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); 1015 1016 echo esc_html( $login_link_separator ); 1017 1018 /** This filter is documented in wp-includes/general-template.php */ 1019 echo apply_filters( 'register', $registration_url ); 1020 } 1021 1022 ?> 1023 </p> 1024 <?php 1025 1026 login_footer( 'user_pass' ); 1027 break; 1028 1029 case 'register': 1030 if ( is_multisite() ) { 1031 /** 1032 * Filters the Multisite sign up URL. 1033 * 1034 * @since 3.0.0 1035 * 1036 * @param string $sign_up_url The sign up URL. 1037 */ 1038 wp_redirect( apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ) ); 1039 exit; 1040 } 1041 1042 if ( ! get_option( 'users_can_register' ) ) { 1043 wp_redirect( site_url( 'wp-login.php?registration=disabled' ) ); 1044 exit(); 1045 } 1046 1047 $user_login = ''; 1048 $user_email = ''; 1049 1050 if ( $http_post ) { 1051 if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) { 1052 $user_login = wp_unslash( $_POST['user_login'] ); 1053 } 1054 1055 if ( isset( $_POST['user_email'] ) && is_string( $_POST['user_email'] ) ) { 1056 $user_email = wp_unslash( $_POST['user_email'] ); 1057 } 1058 1059 $errors = register_new_user( $user_login, $user_email ); 1060 1061 if ( ! is_wp_error( $errors ) ) { 1062 $redirect_to = ! empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered'; 1063 wp_safe_redirect( $redirect_to ); 1064 exit(); 1065 } 1066 } 1067 1068 $registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; 1069 1070 /** 1071 * Filters the registration redirect URL. 1072 * 1073 * @since 3.0.0 1074 * 1075 * @param string $registration_redirect The redirect destination URL. 1076 */ 1077 $redirect_to = apply_filters( 'registration_redirect', $registration_redirect ); 1078 1079 login_header( __( 'Registration Form' ), '<p class="message register">' . __( 'Register For This Site' ) . '</p>', $errors ); 1080 1081 ?> 1082 <form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate"> 1083 <p> 1084 <label for="user_login"><?php _e( 'Username' ); ?></label> 1085 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( wp_unslash( $user_login ) ); ?>" size="20" autocapitalize="off" /> 1086 </p> 1087 <p> 1088 <label for="user_email"><?php _e( 'Email' ); ?></label> 1089 <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /> 1090 </p> 1091 <?php 1092 1093 /** 1094 * Fires following the 'Email' field in the user registration form. 1095 * 1096 * @since 2.1.0 1097 */ 1098 do_action( 'register_form' ); 1099 1100 ?> 1101 <p id="reg_passmail"> 1102 <?php _e( 'Registration confirmation will be emailed to you.' ); ?> 1103 </p> 1104 <br class="clear" /> 1105 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> 1106 <p class="submit"> 1107 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Register' ); ?>" /> 1108 </p> 1109 </form> 1110 1111 <p id="nav"> 1112 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> 1113 <?php echo esc_html( $login_link_separator ); ?> 1114 <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a> 1115 </p> 1116 <?php 1117 1118 login_footer( 'user_login' ); 1119 break; 1120 1121 case 'confirmaction': 1122 if ( ! isset( $_GET['request_id'] ) ) { 1123 wp_die( __( 'Missing request ID.' ) ); 1124 } 1125 1126 if ( ! isset( $_GET['confirm_key'] ) ) { 1127 wp_die( __( 'Missing confirm key.' ) ); 1128 } 1129 1130 $request_id = (int) $_GET['request_id']; 1131 $key = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) ); 1132 $result = wp_validate_user_request_key( $request_id, $key ); 1133 1134 if ( is_wp_error( $result ) ) { 1135 wp_die( $result ); 1136 } 1137 1138 /** 1139 * Fires an action hook when the account action has been confirmed by the user. 1140 * 1141 * Using this you can assume the user has agreed to perform the action by 1142 * clicking on the link in the confirmation email. 1143 * 1144 * After firing this action hook the page will redirect to wp-login a callback 1145 * redirects or exits first. 1146 * 1147 * @since 4.9.6 1148 * 1149 * @param int $request_id Request ID. 1150 */ 1151 do_action( 'user_request_action_confirmed', $request_id ); 1152 1153 $message = _wp_privacy_account_request_confirmed_message( $request_id ); 1154 1155 login_header( __( 'User action confirmed.' ), $message ); 1156 login_footer(); 1157 exit; 1158 1159 case 'login': 1160 default: 1161 $secure_cookie = ''; 1162 $customize_login = isset( $_REQUEST['customize-login'] ); 1163 1164 if ( $customize_login ) { 1165 wp_enqueue_script( 'customize-base' ); 1166 } 1167 1168 // If the user wants SSL but the session is not SSL, force a secure cookie. 1169 if ( ! empty( $_POST['log'] ) && ! force_ssl_admin() ) { 1170 $user_name = sanitize_user( wp_unslash( $_POST['log'] ) ); 1171 $user = get_user_by( 'login', $user_name ); 1172 1173 if ( ! $user && strpos( $user_name, '@' ) ) { 1174 $user = get_user_by( 'email', $user_name ); 1175 } 1176 1177 if ( $user ) { 1178 if ( get_user_option( 'use_ssl', $user->ID ) ) { 1179 $secure_cookie = true; 1180 force_ssl_admin( true ); 1181 } 1182 } 1183 } 1184 1185 if ( isset( $_REQUEST['redirect_to'] ) ) { 1186 $redirect_to = $_REQUEST['redirect_to']; 1187 // Redirect to HTTPS if user wants SSL. 1188 if ( $secure_cookie && false !== strpos( $redirect_to, 'wp-admin' ) ) { 1189 $redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to ); 1190 } 1191 } else { 1192 $redirect_to = admin_url(); 1193 } 1194 1195 $reauth = empty( $_REQUEST['reauth'] ) ? false : true; 1196 1197 $user = wp_signon( array(), $secure_cookie ); 1198 1199 if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) { 1200 if ( headers_sent() ) { 1201 $user = new WP_Error( 1202 'test_cookie', 1203 sprintf( 1204 /* translators: 1: Browser cookie documentation URL, 2: Support forums URL. */ 1205 __( '<strong>Error</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ), 1206 __( 'https://wordpress.org/support/article/cookies/' ), 1207 __( 'https://wordpress.org/support/forums/' ) 1208 ) 1209 ); 1210 } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { 1211 // If cookies are disabled, we can't log in even with a valid user and password. 1212 $user = new WP_Error( 1213 'test_cookie', 1214 sprintf( 1215 /* translators: %s: Browser cookie documentation URL. */ 1216 __( '<strong>Error</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ), 1217 __( 'https://wordpress.org/support/article/cookies/#enable-cookies-in-your-browser' ) 1218 ) 1219 ); 1220 } 1221 } 1222 1223 $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; 1224 /** 1225 * Filters the login redirect URL. 1226 * 1227 * @since 3.0.0 1228 * 1229 * @param string $redirect_to The redirect destination URL. 1230 * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. 1231 * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. 1232 */ 1233 $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user ); 1234 1235 if ( ! is_wp_error( $user ) && ! $reauth ) { 1236 if ( $interim_login ) { 1237 $message = '<p class="message">' . __( 'You have logged in successfully.' ) . '</p>'; 1238 $interim_login = 'success'; 1239 login_header( '', $message ); 1240 1241 ?> 1242 </div> 1243 <?php 1244 1245 /** This action is documented in wp-login.php */ 1246 do_action( 'login_footer' ); 1247 1248 if ( $customize_login ) { 1249 ?> 1250 <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> 1251 <?php 1252 } 1253 1254 ?> 1255 </body></html> 1256 <?php 1257 1258 exit; 1259 } 1260 1261 // Check if it is time to add a redirect to the admin email confirmation screen. 1262 if ( is_a( $user, 'WP_User' ) && $user->exists() && $user->has_cap( 'manage_options' ) ) { 1263 $admin_email_lifespan = (int) get_option( 'admin_email_lifespan' ); 1264 1265 // If `0` (or anything "falsey" as it is cast to int) is returned, the user will not be redirected 1266 // to the admin email confirmation screen. 1267 /** This filter is documented in wp-login.php */ 1268 $admin_email_check_interval = (int) apply_filters( 'admin_email_check_interval', 6 * MONTH_IN_SECONDS ); 1269 1270 if ( $admin_email_check_interval > 0 && time() > $admin_email_lifespan ) { 1271 $redirect_to = add_query_arg( 1272 array( 1273 'action' => 'confirm_admin_email', 1274 'wp_lang' => get_user_locale( $user ), 1275 ), 1276 wp_login_url( $redirect_to ) 1277 ); 1278 } 1279 } 1280 1281 if ( ( empty( $redirect_to ) || 'wp-admin/' === $redirect_to || admin_url() === $redirect_to ) ) { 1282 // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. 1283 if ( is_multisite() && ! get_active_blog_for_user( $user->ID ) && ! is_super_admin( $user->ID ) ) { 1284 $redirect_to = user_admin_url(); 1285 } elseif ( is_multisite() && ! $user->has_cap( 'read' ) ) { 1286 $redirect_to = get_dashboard_url( $user->ID ); 1287 } elseif ( ! $user->has_cap( 'edit_posts' ) ) { 1288 $redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url(); 1289 } 1290 1291 wp_redirect( $redirect_to ); 1292 exit; 1293 } 1294 1295 wp_safe_redirect( $redirect_to ); 1296 exit; 1297 } 1298 1299 $errors = $user; 1300 // Clear errors if loggedout is set. 1301 if ( ! empty( $_GET['loggedout'] ) || $reauth ) { 1302 $errors = new WP_Error(); 1303 } 1304 1305 if ( empty( $_POST ) && $errors->get_error_codes() === array( 'empty_username', 'empty_password' ) ) { 1306 $errors = new WP_Error( '', '' ); 1307 } 1308 1309 if ( $interim_login ) { 1310 if ( ! $errors->has_errors() ) { 1311 $errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' ); 1312 } 1313 } else { 1314 // Some parts of this script use the main login form to display a message. 1315 if ( isset( $_GET['loggedout'] ) && $_GET['loggedout'] ) { 1316 $errors->add( 'loggedout', __( 'You are now logged out.' ), 'message' ); 1317 } elseif ( isset( $_GET['registration'] ) && 'disabled' === $_GET['registration'] ) { 1318 $errors->add( 'registerdisabled', __( 'User registration is currently not allowed.' ) ); 1319 } elseif ( isset( $_GET['checkemail'] ) && 'confirm' === $_GET['checkemail'] ) { 1320 $errors->add( 'confirm', __( 'Check your email for the confirmation link.' ), 'message' ); 1321 } elseif ( isset( $_GET['checkemail'] ) && 'newpass' === $_GET['checkemail'] ) { 1322 $errors->add( 'newpass', __( 'Check your email for your new password.' ), 'message' ); 1323 } elseif ( isset( $_GET['checkemail'] ) && 'registered' === $_GET['checkemail'] ) { 1324 $errors->add( 'registered', __( 'Registration complete. Please check your email.' ), 'message' ); 1325 } elseif ( strpos( $redirect_to, 'about.php?updated' ) ) { 1326 $errors->add( 'updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); 1327 } elseif ( WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED === $action ) { 1328 $errors->add( 'enter_recovery_mode', __( 'Recovery Mode Initialized. Please log in to continue.' ), 'message' ); 1329 } 1330 } 1331 1332 /** 1333 * Filters the login page errors. 1334 * 1335 * @since 3.6.0 1336 * 1337 * @param WP_Error $errors WP Error object. 1338 * @param string $redirect_to Redirect destination URL. 1339 */ 1340 $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); 1341 1342 // Clear any stale cookies. 1343 if ( $reauth ) { 1344 wp_clear_auth_cookie(); 1345 } 1346 1347 login_header( __( 'Log In' ), '', $errors ); 1348 1349 if ( isset( $_POST['log'] ) ) { 1350 $user_login = ( 'incorrect_password' === $errors->get_error_code() || 'empty_password' === $errors->get_error_code() ) ? esc_attr( wp_unslash( $_POST['log'] ) ) : ''; 1351 } 1352 1353 $rememberme = ! empty( $_POST['rememberme'] ); 1354 1355 if ( $errors->has_errors() ) { 1356 $aria_describedby_error = ' aria-describedby="login_error"'; 1357 } else { 1358 $aria_describedby_error = ''; 1359 } 1360 1361 wp_enqueue_script( 'user-profile' ); 1362 ?> 1363 1364 <form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post"> 1365 <p> 1366 <label for="user_login"><?php _e( 'Username or Email Address' ); ?></label> 1367 <input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" /> 1368 </p> 1369 1370 <div class="user-pass-wrap"> 1371 <label for="user_pass"><?php _e( 'Password' ); ?></label> 1372 <div class="wp-pwd"> 1373 <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input password-input" value="" size="20" /> 1374 <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Show password' ); ?>"> 1375 <span class="dashicons dashicons-visibility" aria-hidden="true"></span> 1376 </button> 1377 </div> 1378 </div> 1379 <?php 1380 1381 /** 1382 * Fires following the 'Password' field in the login form. 1383 * 1384 * @since 2.1.0 1385 */ 1386 do_action( 'login_form' ); 1387 1388 ?> 1389 <p class="forgetmenot"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked( $rememberme ); ?> /> <label for="rememberme"><?php esc_html_e( 'Remember Me' ); ?></label></p> 1390 <p class="submit"> 1391 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Log In' ); ?>" /> 1392 <?php 1393 1394 if ( $interim_login ) { 1395 ?> 1396 <input type="hidden" name="interim-login" value="1" /> 1397 <?php 1398 } else { 1399 ?> 1400 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> 1401 <?php 1402 } 1403 1404 if ( $customize_login ) { 1405 ?> 1406 <input type="hidden" name="customize-login" value="1" /> 1407 <?php 1408 } 1409 1410 ?> 1411 <input type="hidden" name="testcookie" value="1" /> 1412 </p> 1413 </form> 1414 1415 <?php 1416 1417 if ( ! $interim_login ) { 1418 ?> 1419 <p id="nav"> 1420 <?php 1421 1422 if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ), true ) ) { 1423 if ( get_option( 'users_can_register' ) ) { 1424 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); 1425 1426 /** This filter is documented in wp-includes/general-template.php */ 1427 echo apply_filters( 'register', $registration_url ); 1428 1429 echo esc_html( $login_link_separator ); 1430 } 1431 1432 ?> 1433 <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a> 1434 <?php 1435 } 1436 1437 ?> 1438 </p> 1439 <?php 1440 } 1441 1442 $login_script = 'function wp_attempt_focus() {'; 1443 $login_script .= 'setTimeout( function() {'; 1444 $login_script .= 'try {'; 1445 1446 if ( $user_login ) { 1447 $login_script .= 'd = document.getElementById( "user_pass" ); d.value = "";'; 1448 } else { 1449 $login_script .= 'd = document.getElementById( "user_login" );'; 1450 1451 if ( $errors->get_error_code() === 'invalid_username' ) { 1452 $login_script .= 'd.value = "";'; 1453 } 1454 } 1455 1456 $login_script .= 'd.focus(); d.select();'; 1457 $login_script .= '} catch( er ) {}'; 1458 $login_script .= '}, 200);'; 1459 $login_script .= "}\n"; // End of wp_attempt_focus(). 1460 1461 /** 1462 * Filters whether to print the call to `wp_attempt_focus()` on the login screen. 1463 * 1464 * @since 4.8.0 1465 * 1466 * @param bool $print Whether to print the function call. Default true. 1467 */ 1468 if ( apply_filters( 'enable_login_autofocus', true ) && ! $error ) { 1469 $login_script .= "wp_attempt_focus();\n"; 1470 } 1471 1472 // Run `wpOnload()` if defined. 1473 $login_script .= "if ( typeof wpOnload === 'function' ) { wpOnload() }"; 1474 1475 ?> 1476 <script type="text/javascript"> 1477 <?php echo $login_script; ?> 1478 </script> 1479 <?php 1480 1481 if ( $interim_login ) { 1482 ?> 1483 <script type="text/javascript"> 1484 ( function() { 1485 try { 1486 var i, links = document.getElementsByTagName( 'a' ); 1487 for ( i in links ) { 1488 if ( links[i].href ) { 1489 links[i].target = '_blank'; 1490 links[i].rel = 'noreferrer noopener'; 1491 } 1492 } 1493 } catch( er ) {} 1494 }()); 1495 </script> 1496 <?php 1497 } 1498 1499 login_footer(); 1500 break; 1501 } // End action switch.
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue May 19 15:51:04 2020 | Cross-referenced by PHPXref 0.7.1 |