[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/ -> wp-login.php (source)

   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( dirname( __FILE__ ) . '/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   * @param string   $title    Optional. WordPress login Page title to display in the `<title>` element.
  31   *                           Default 'Log In'.
  32   * @param string   $message  Optional. Message to display in header. Default empty.
  33   * @param WP_Error $wp_error Optional. The error to pass. Default is a WP_Error instance.
  34   */
  35  function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
  36      global $error, $interim_login, $action;
  37  
  38      // Don't index any of these forms
  39      add_action( 'login_head', 'wp_sensitive_page_meta' );
  40  
  41      add_action( 'login_head', 'wp_login_viewport_meta' );
  42  
  43      if ( ! is_wp_error( $wp_error ) ) {
  44          $wp_error = new WP_Error();
  45      }
  46  
  47      // Shake it!
  48      $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password', 'retrieve_password_email_failure' );
  49      /**
  50       * Filters the error codes array for shaking the login form.
  51       *
  52       * @since 3.0.0
  53       *
  54       * @param array $shake_error_codes Error codes that shake the login form.
  55       */
  56      $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes );
  57  
  58      if ( $shake_error_codes && $wp_error->has_errors() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) {
  59          add_action( 'login_head', 'wp_shake_js', 12 );
  60      }
  61  
  62      $login_title = get_bloginfo( 'name', 'display' );
  63  
  64      /* translators: Login screen title. 1: Login screen name, 2: Network or site name */
  65      $login_title = sprintf( __( '%1$s &lsaquo; %2$s &#8212; WordPress' ), $title, $login_title );
  66  
  67      if ( wp_is_recovery_mode() ) {
  68          /* translators: %s: Login screen title. */
  69          $login_title = sprintf( __( 'Recovery Mode &#8212; %s' ), $login_title );
  70      }
  71  
  72      /**
  73       * Filters the title tag content for login page.
  74       *
  75       * @since 4.9.0
  76       *
  77       * @param string $login_title The page title, with extra context added.
  78       * @param string $title       The original page title.
  79       */
  80      $login_title = apply_filters( 'login_title', $login_title, $title );
  81  
  82      ?><!DOCTYPE html>
  83      <!--[if IE 8]>
  84          <html xmlns="http://www.w3.org/1999/xhtml" class="ie8" <?php language_attributes(); ?>>
  85      <![endif]-->
  86      <!--[if !(IE 8) ]><!-->
  87          <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
  88      <!--<![endif]-->
  89      <head>
  90      <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" />
  91      <title><?php echo $login_title; ?></title>
  92      <?php
  93  
  94      wp_enqueue_style( 'login' );
  95  
  96      /*
  97       * Remove all stored post data on logging out.
  98       * This could be added by add_action('login_head'...) like wp_shake_js(),
  99       * but maybe better if it's not removable by plugins.
 100       */
 101      if ( 'loggedout' == $wp_error->get_error_code() ) {
 102          ?>
 103          <script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script>
 104          <?php
 105      }
 106  
 107      /**
 108       * Enqueue scripts and styles for the login page.
 109       *
 110       * @since 3.1.0
 111       */
 112      do_action( 'login_enqueue_scripts' );
 113  
 114      /**
 115       * Fires in the login page header after scripts are enqueued.
 116       *
 117       * @since 2.1.0
 118       */
 119      do_action( 'login_head' );
 120  
 121      $login_header_url = __( 'https://wordpress.org/' );
 122  
 123      /**
 124       * Filters link URL of the header logo above login form.
 125       *
 126       * @since 2.1.0
 127       *
 128       * @param string $login_header_url Login header logo URL.
 129       */
 130      $login_header_url = apply_filters( 'login_headerurl', $login_header_url );
 131  
 132      $login_header_title = '';
 133  
 134      /**
 135       * Filters the title attribute of the header logo above login form.
 136       *
 137       * @since 2.1.0
 138       * @deprecated 5.2.0 Use login_headertext
 139       *
 140       * @param string $login_header_title Login header logo title attribute.
 141       */
 142      $login_header_title = apply_filters_deprecated(
 143          'login_headertitle',
 144          array( $login_header_title ),
 145          '5.2.0',
 146          'login_headertext',
 147          __( 'Usage of the title attribute on the login logo is not recommended for accessibility reasons. Use the link text instead.' )
 148      );
 149  
 150      $login_header_text = empty( $login_header_title ) ? __( 'Powered by WordPress' ) : $login_header_title;
 151  
 152      /**
 153       * Filters the link text of the header logo above the login form.
 154       *
 155       * @since 5.2.0
 156       *
 157       * @param string $login_header_text The login header logo link text.
 158       */
 159      $login_header_text = apply_filters( 'login_headertext', $login_header_text );
 160  
 161      $classes = array( 'login-action-' . $action, 'wp-core-ui' );
 162      if ( is_rtl() ) {
 163          $classes[] = 'rtl';
 164      }
 165      if ( $interim_login ) {
 166          $classes[] = 'interim-login';
 167          ?>
 168          <style type="text/css">html{background-color: transparent;}</style>
 169          <?php
 170  
 171          if ( 'success' === $interim_login ) {
 172              $classes[] = 'interim-login-success';
 173          }
 174      }
 175      $classes[] = ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
 176  
 177      /**
 178       * Filters the login page body classes.
 179       *
 180       * @since 3.5.0
 181       *
 182       * @param array  $classes An array of body classes.
 183       * @param string $action  The action that brought the visitor to the login page.
 184       */
 185      $classes = apply_filters( 'login_body_class', $classes, $action );
 186  
 187      ?>
 188      </head>
 189      <body class="login <?php echo esc_attr( implode( ' ', $classes ) ); ?>">
 190      <?php
 191      /**
 192       * Fires in the login page header after the body tag is opened.
 193       *
 194       * @since 4.6.0
 195       */
 196      do_action( 'login_header' );
 197      ?>
 198      <div id="login">
 199          <h1><a href="<?php echo esc_url( $login_header_url ); ?>"><?php echo $login_header_text; ?></a></h1>
 200      <?php
 201      /**
 202       * Filters the message to display above the login form.
 203       *
 204       * @since 2.1.0
 205       *
 206       * @param string $message Login message text.
 207       */
 208      $message = apply_filters( 'login_message', $message );
 209      if ( ! empty( $message ) ) {
 210          echo $message . "\n";
 211      }
 212  
 213      // In case a plugin uses $error rather than the $wp_errors object.
 214      if ( ! empty( $error ) ) {
 215          $wp_error->add( 'error', $error );
 216          unset( $error );
 217      }
 218  
 219      if ( $wp_error->has_errors() ) {
 220          $errors   = '';
 221          $messages = '';
 222          foreach ( $wp_error->get_error_codes() as $code ) {
 223              $severity = $wp_error->get_error_data( $code );
 224              foreach ( $wp_error->get_error_messages( $code ) as $error_message ) {
 225                  if ( 'message' == $severity ) {
 226                      $messages .= '    ' . $error_message . "<br />\n";
 227                  } else {
 228                      $errors .= '    ' . $error_message . "<br />\n";
 229                  }
 230              }
 231          }
 232          if ( ! empty( $errors ) ) {
 233              /**
 234               * Filters the error messages displayed above the login form.
 235               *
 236               * @since 2.1.0
 237               *
 238               * @param string $errors Login error message.
 239               */
 240              echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n";
 241          }
 242          if ( ! empty( $messages ) ) {
 243              /**
 244               * Filters instructional messages displayed above the login form.
 245               *
 246               * @since 2.5.0
 247               *
 248               * @param string $messages Login messages.
 249               */
 250              echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n";
 251          }
 252      }
 253  } // End of login_header()
 254  
 255  /**
 256   * Outputs the footer for the login page.
 257   *
 258   * @since 3.1.0
 259   *
 260   * @param string $input_id Which input to auto-focus.
 261   */
 262  function login_footer( $input_id = '' ) {
 263      global $interim_login;
 264  
 265      // Don't allow interim logins to navigate away from the page.
 266      if ( ! $interim_login ) :
 267          ?>
 268      <p id="backtoblog"><a href="<?php echo esc_url( home_url( '/' ) ); ?>">
 269          <?php
 270          /* translators: %s: site title */
 271          printf( _x( '&larr; Back to %s', 'site' ), get_bloginfo( 'title', 'display' ) );
 272          ?>
 273      </a></p>
 274          <?php the_privacy_policy_link( '<div class="privacy-policy-page-link">', '</div>' ); ?>
 275      <?php endif; ?>
 276  
 277      </div>
 278  
 279      <?php if ( ! empty( $input_id ) ) : ?>
 280      <script type="text/javascript">
 281      try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){}
 282      if(typeof wpOnload=='function')wpOnload();
 283      </script>
 284      <?php endif; ?>
 285  
 286      <?php
 287      /**
 288       * Fires in the login page footer.
 289       *
 290       * @since 3.1.0
 291       */
 292      do_action( 'login_footer' );
 293      ?>
 294      <div class="clear"></div>
 295      </body>
 296      </html>
 297      <?php
 298  }
 299  
 300  /**
 301   * Outputs the Javascript to handle the form shaking.
 302   *
 303   * @since 3.0.0
 304   */
 305  function wp_shake_js() {
 306      ?>
 307  <script type="text/javascript">
 308  addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
 309  function s(id,pos){g(id).left=pos+'px';}
 310  function g(id){return document.getElementById(id).style;}
 311  function shake(id,a,d){c=a.shift();s(id,c);if(a.length>0){setTimeout(function(){shake(id,a,d);},d);}else{try{g(id).position='static';wp_attempt_focus();}catch(e){}}}
 312  addLoadEvent(function(){ var p=new Array(15,30,15,0,-15,-30,-15,0);p=p.concat(p.concat(p));var i=document.forms[0].id;g(i).position='relative';shake(i,p,20);});
 313  </script>
 314      <?php
 315  }
 316  
 317  /**
 318   * Outputs the viewport meta tag.
 319   *
 320   * @since 3.7.0
 321   */
 322  function wp_login_viewport_meta() {
 323      ?>
 324      <meta name="viewport" content="width=device-width" />
 325      <?php
 326  }
 327  
 328  /**
 329   * Handles sending password retrieval email to user.
 330   *
 331   * @since 2.5.0
 332   *
 333   * @return bool|WP_Error True: when finish. WP_Error on error
 334   */
 335  function retrieve_password() {
 336      $errors = new WP_Error();
 337  
 338      if ( empty( $_POST['user_login'] ) || ! is_string( $_POST['user_login'] ) ) {
 339          $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Enter a username or email address.' ) );
 340      } elseif ( strpos( $_POST['user_login'], '@' ) ) {
 341          $user_data = get_user_by( 'email', trim( wp_unslash( $_POST['user_login'] ) ) );
 342          if ( empty( $user_data ) ) {
 343              $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: There is no account with that username or email address.' ) );
 344          }
 345      } else {
 346          $login     = trim( $_POST['user_login'] );
 347          $user_data = get_user_by( 'login', $login );
 348      }
 349  
 350      /**
 351       * Fires before errors are returned from a password reset request.
 352       *
 353       * @since 2.1.0
 354       * @since 4.4.0 Added the `$errors` parameter.
 355       *
 356       * @param WP_Error $errors A WP_Error object containing any errors generated
 357       *                         by using invalid credentials.
 358       */
 359      do_action( 'lostpassword_post', $errors );
 360  
 361      if ( $errors->has_errors() ) {
 362          return $errors;
 363      }
 364  
 365      if ( ! $user_data ) {
 366          $errors->add( 'invalidcombo', __( '<strong>ERROR</strong>: There is no account with that username or email address.' ) );
 367          return $errors;
 368      }
 369  
 370      // Redefining user_login ensures we return the right case in the email.
 371      $user_login = $user_data->user_login;
 372      $user_email = $user_data->user_email;
 373      $key        = get_password_reset_key( $user_data );
 374  
 375      if ( is_wp_error( $key ) ) {
 376          return $key;
 377      }
 378  
 379      if ( is_multisite() ) {
 380          $site_name = get_network()->site_name;
 381      } else {
 382          /*
 383           * The blogname option is escaped with esc_html on the way into the database
 384           * in sanitize_option we want to reverse this for the plain text arena of emails.
 385           */
 386          $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
 387      }
 388  
 389      $message = __( 'Someone has requested a password reset for the following account:' ) . "\r\n\r\n";
 390      /* translators: %s: site name */
 391      $message .= sprintf( __( 'Site Name: %s' ), $site_name ) . "\r\n\r\n";
 392      /* translators: %s: user login */
 393      $message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n\r\n";
 394      $message .= __( 'If this was a mistake, just ignore this email and nothing will happen.' ) . "\r\n\r\n";
 395      $message .= __( 'To reset your password, visit the following address:' ) . "\r\n\r\n";
 396      $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . ">\r\n";
 397  
 398      /* translators: Password reset notification email subject. %s: Site title */
 399      $title = sprintf( __( '[%s] Password Reset' ), $site_name );
 400  
 401      /**
 402       * Filters the subject of the password reset email.
 403       *
 404       * @since 2.8.0
 405       * @since 4.4.0 Added the `$user_login` and `$user_data` parameters.
 406       *
 407       * @param string  $title      Default email title.
 408       * @param string  $user_login The username for the user.
 409       * @param WP_User $user_data  WP_User object.
 410       */
 411      $title = apply_filters( 'retrieve_password_title', $title, $user_login, $user_data );
 412  
 413      /**
 414       * Filters the message body of the password reset mail.
 415       *
 416       * If the filtered message is empty, the password reset email will not be sent.
 417       *
 418       * @since 2.8.0
 419       * @since 4.1.0 Added `$user_login` and `$user_data` parameters.
 420       *
 421       * @param string  $message    Default mail message.
 422       * @param string  $key        The activation key.
 423       * @param string  $user_login The username for the user.
 424       * @param WP_User $user_data  WP_User object.
 425       */
 426      $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );
 427  
 428      if ( $message && ! wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) {
 429          /* translators: URL to support page for resetting your password */
 430          $support = __( 'https://wordpress.org/support/article/resetting-your-password/' );
 431          $errors->add(
 432              'retrieve_password_email_failure',
 433              sprintf(
 434                  __( '<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>.' ),
 435                  esc_url( $support )
 436              )
 437          );
 438          return $errors;
 439      }
 440  
 441      return true;
 442  }
 443  
 444  //
 445  // Main.
 446  //
 447  
 448  $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login';
 449  $errors = new WP_Error();
 450  
 451  if ( isset( $_GET['key'] ) ) {
 452      $action = 'resetpass';
 453  }
 454  
 455  // Validate action so as to default to the login screen.
 456  if ( ! in_array( $action, array( 'postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login', 'confirmaction', WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED ), true ) && false === has_filter( 'login_form_' . $action ) ) {
 457      $action = 'login';
 458  }
 459  
 460  nocache_headers();
 461  
 462  header( 'Content-Type: ' . get_bloginfo( 'html_type' ) . '; charset=' . get_bloginfo( 'charset' ) );
 463  
 464  if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set
 465      if ( isset( $_SERVER['PATH_INFO'] ) && ( $_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'] ) ) {
 466          $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
 467      }
 468  
 469      $url = dirname( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ) );
 470      if ( $url != get_option( 'siteurl' ) ) {
 471          update_option( 'siteurl', $url );
 472      }
 473  }
 474  
 475  //Set a cookie now to see if they are supported by the browser.
 476  $secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) );
 477  setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure );
 478  if ( SITECOOKIEPATH != COOKIEPATH ) {
 479      setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure );
 480  }
 481  
 482  /**
 483   * Fires when the login form is initialized.
 484   *
 485   * @since 3.2.0
 486   */
 487  do_action( 'login_init' );
 488  
 489  /**
 490   * Fires before a specified login form action.
 491   *
 492   * The dynamic portion of the hook name, `$action`, refers to the action
 493   * that brought the visitor to the login form. Actions include 'postpass',
 494   * 'logout', 'lostpassword', etc.
 495   *
 496   * @since 2.8.0
 497   */
 498  do_action( "login_form_{$action}" );
 499  
 500  $http_post     = ( 'POST' == $_SERVER['REQUEST_METHOD'] );
 501  $interim_login = isset( $_REQUEST['interim-login'] );
 502  
 503  /**
 504   * Filters the separator used between login form navigation links.
 505   *
 506   * @since 4.9.0
 507   *
 508   * @param string $login_link_separator The separator used between login form navigation links.
 509   */
 510  $login_link_separator = apply_filters( 'login_link_separator', ' | ' );
 511  
 512  switch ( $action ) {
 513  
 514      case 'postpass':
 515          if ( ! array_key_exists( 'post_password', $_POST ) ) {
 516              wp_safe_redirect( wp_get_referer() );
 517              exit();
 518          }
 519  
 520          require_once  ABSPATH . WPINC . '/class-phpass.php';
 521          $hasher = new PasswordHash( 8, true );
 522  
 523          /**
 524           * Filters the life span of the post password cookie.
 525           *
 526           * By default, the cookie expires 10 days from creation. To turn this
 527           * into a session cookie, return 0.
 528           *
 529           * @since 3.7.0
 530           *
 531           * @param int $expires The expiry time, as passed to setcookie().
 532           */
 533          $expire  = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
 534          $referer = wp_get_referer();
 535          if ( $referer ) {
 536              $secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) );
 537          } else {
 538              $secure = false;
 539          }
 540          setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
 541  
 542          wp_safe_redirect( wp_get_referer() );
 543          exit();
 544  
 545      case 'logout':
 546          check_admin_referer( 'log-out' );
 547  
 548          $user = wp_get_current_user();
 549  
 550          wp_logout();
 551  
 552          if ( ! empty( $_REQUEST['redirect_to'] ) ) {
 553              $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
 554          } else {
 555              $redirect_to           = 'wp-login.php?loggedout=true';
 556              $requested_redirect_to = '';
 557          }
 558  
 559          /**
 560           * Filters the log out redirect URL.
 561           *
 562           * @since 4.2.0
 563           *
 564           * @param string  $redirect_to           The redirect destination URL.
 565           * @param string  $requested_redirect_to The requested redirect destination URL passed as a parameter.
 566           * @param WP_User $user                  The WP_User object for the user that's logging out.
 567           */
 568          $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user );
 569          wp_safe_redirect( $redirect_to );
 570          exit();
 571  
 572      case 'lostpassword':
 573      case 'retrievepassword':
 574          if ( $http_post ) {
 575              $errors = retrieve_password();
 576              if ( ! is_wp_error( $errors ) ) {
 577                  $redirect_to = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm';
 578                  wp_safe_redirect( $redirect_to );
 579                  exit();
 580              }
 581          }
 582  
 583          if ( isset( $_GET['error'] ) ) {
 584              if ( 'invalidkey' == $_GET['error'] ) {
 585                  $errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) );
 586              } elseif ( 'expiredkey' == $_GET['error'] ) {
 587                  $errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) );
 588              }
 589          }
 590  
 591          $lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
 592          /**
 593           * Filters the URL redirected to after submitting the lostpassword/retrievepassword form.
 594           *
 595           * @since 3.0.0
 596           *
 597           * @param string $lostpassword_redirect The redirect destination URL.
 598           */
 599          $redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect );
 600  
 601          /**
 602           * Fires before the lost password form.
 603           *
 604           * @since 1.5.1
 605           * @since 5.1.0 Added the `$errors` parameter.
 606           *
 607           * @param WP_Error $errors A `WP_Error` object containing any errors generated by using invalid
 608           *                         credentials. Note that the error object may not contain any errors.
 609           */
 610          do_action( 'lost_password', $errors );
 611  
 612          login_header( __( 'Lost Password' ), '<p class="message">' . __( 'Please enter your username or email address. You will receive a link to create a new password via email.' ) . '</p>', $errors );
 613  
 614          $user_login = '';
 615  
 616          if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) {
 617              $user_login = wp_unslash( $_POST['user_login'] );
 618          }
 619  
 620          ?>
 621  
 622      <form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post">
 623      <p>
 624          <label for="user_login" ><?php _e( 'Username or Email Address' ); ?><br />
 625          <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" /></label>
 626      </p>
 627          <?php
 628          /**
 629           * Fires inside the lostpassword form tags, before the hidden fields.
 630           *
 631           * @since 2.1.0
 632           */
 633          do_action( 'lostpassword_form' );
 634          ?>
 635          <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
 636          <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Get New Password' ); ?>" /></p>
 637      </form>
 638  
 639      <p id="nav">
 640      <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
 641          <?php
 642          if ( get_option( 'users_can_register' ) ) :
 643              $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
 644  
 645              echo esc_html( $login_link_separator );
 646  
 647              /** This filter is documented in wp-includes/general-template.php */
 648              echo apply_filters( 'register', $registration_url );
 649      endif;
 650          ?>
 651      </p>
 652  
 653          <?php
 654          login_footer( 'user_login' );
 655  
 656          break;
 657  
 658      case 'resetpass':
 659      case 'rp':
 660          list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
 661          $rp_cookie       = 'wp-resetpass-' . COOKIEHASH;
 662          if ( isset( $_GET['key'] ) ) {
 663              $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) );
 664              setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
 665              wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) );
 666              exit;
 667          }
 668  
 669          if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
 670              list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
 671              $user                      = check_password_reset_key( $rp_key, $rp_login );
 672              if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
 673                  $user = false;
 674              }
 675          } else {
 676              $user = false;
 677          }
 678  
 679          if ( ! $user || is_wp_error( $user ) ) {
 680              setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
 681              if ( $user && $user->get_error_code() === 'expired_key' ) {
 682                  wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
 683              } else {
 684                  wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );
 685              }
 686              exit;
 687          }
 688  
 689          $errors = new WP_Error();
 690  
 691          if ( isset( $_POST['pass1'] ) && $_POST['pass1'] != $_POST['pass2'] ) {
 692              $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) );
 693          }
 694  
 695          /**
 696           * Fires before the password reset procedure is validated.
 697           *
 698           * @since 3.5.0
 699           *
 700           * @param object           $errors WP Error object.
 701           * @param WP_User|WP_Error $user   WP_User object if the login and reset key match. WP_Error object otherwise.
 702           */
 703          do_action( 'validate_password_reset', $errors, $user );
 704  
 705          if ( ( ! $errors->has_errors() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {
 706              reset_password( $user, $_POST['pass1'] );
 707              setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
 708              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>' );
 709              login_footer();
 710              exit;
 711          }
 712  
 713          wp_enqueue_script( 'utils' );
 714          wp_enqueue_script( 'user-profile' );
 715  
 716          login_header( __( 'Reset Password' ), '<p class="message reset-pass">' . __( 'Enter your new password below.' ) . '</p>', $errors );
 717  
 718          ?>
 719      <form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off">
 720      <input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" />
 721  
 722      <div class="user-pass1-wrap">
 723          <p>
 724              <label for="pass1"><?php _e( 'New password' ); ?></label>
 725          </p>
 726  
 727          <div class="wp-pwd">
 728              <div class="password-input-wrapper">
 729                  <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" />
 730                  <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js">
 731                      <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
 732                  </button>
 733              </div>
 734              <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></div>
 735          </div>
 736          <div class="pw-weak">
 737              <label>
 738                  <input type="checkbox" name="pw_weak" class="pw-checkbox" />
 739                  <?php _e( 'Confirm use of weak password' ); ?>
 740              </label>
 741          </div>
 742      </div>
 743  
 744      <p class="user-pass2-wrap">
 745          <label for="pass2"><?php _e( 'Confirm new password' ); ?></label><br />
 746          <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" />
 747      </p>
 748  
 749      <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
 750      <br class="clear" />
 751  
 752          <?php
 753          /**
 754           * Fires following the 'Strength indicator' meter in the user password reset form.
 755           *
 756           * @since 3.9.0
 757           *
 758           * @param WP_User $user User object of the user whose password is being reset.
 759           */
 760          do_action( 'resetpass_form', $user );
 761          ?>
 762      <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" />
 763      <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Reset Password' ); ?>" /></p>
 764      </form>
 765  
 766      <p id="nav">
 767      <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
 768          <?php
 769          if ( get_option( 'users_can_register' ) ) :
 770              $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
 771  
 772              echo esc_html( $login_link_separator );
 773  
 774              /** This filter is documented in wp-includes/general-template.php */
 775              echo apply_filters( 'register', $registration_url );
 776      endif;
 777          ?>
 778      </p>
 779  
 780          <?php
 781          login_footer( 'user_pass' );
 782  
 783          break;
 784  
 785      case 'register':
 786          if ( is_multisite() ) {
 787              /**
 788               * Filters the Multisite sign up URL.
 789               *
 790               * @since 3.0.0
 791               *
 792               * @param string $sign_up_url The sign up URL.
 793               */
 794              wp_redirect( apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ) );
 795              exit;
 796          }
 797  
 798          if ( ! get_option( 'users_can_register' ) ) {
 799              wp_redirect( site_url( 'wp-login.php?registration=disabled' ) );
 800              exit();
 801          }
 802  
 803          $user_login = '';
 804          $user_email = '';
 805  
 806          if ( $http_post ) {
 807              if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) {
 808                  $user_login = $_POST['user_login'];
 809              }
 810  
 811              if ( isset( $_POST['user_email'] ) && is_string( $_POST['user_email'] ) ) {
 812                  $user_email = wp_unslash( $_POST['user_email'] );
 813              }
 814  
 815              $errors = register_new_user( $user_login, $user_email );
 816              if ( ! is_wp_error( $errors ) ) {
 817                  $redirect_to = ! empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered';
 818                  wp_safe_redirect( $redirect_to );
 819                  exit();
 820              }
 821          }
 822  
 823          $registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
 824          /**
 825           * Filters the registration redirect URL.
 826           *
 827           * @since 3.0.0
 828           *
 829           * @param string $registration_redirect The redirect destination URL.
 830           */
 831          $redirect_to = apply_filters( 'registration_redirect', $registration_redirect );
 832          login_header( __( 'Registration Form' ), '<p class="message register">' . __( 'Register For This Site' ) . '</p>', $errors );
 833          ?>
 834      <form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate">
 835      <p>
 836          <label for="user_login"><?php _e( 'Username' ); ?><br />
 837          <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( wp_unslash( $user_login ) ); ?>" size="20" autocapitalize="off" /></label>
 838      </p>
 839      <p>
 840          <label for="user_email"><?php _e( 'Email' ); ?><br />
 841          <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label>
 842      </p>
 843          <?php
 844          /**
 845           * Fires following the 'Email' field in the user registration form.
 846           *
 847           * @since 2.1.0
 848           */
 849          do_action( 'register_form' );
 850          ?>
 851      <p id="reg_passmail"><?php _e( 'Registration confirmation will be emailed to you.' ); ?></p>
 852      <br class="clear" />
 853      <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
 854      <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Register' ); ?>" /></p>
 855      </form>
 856  
 857      <p id="nav">
 858      <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
 859          <?php echo esc_html( $login_link_separator ); ?>
 860      <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
 861      </p>
 862  
 863          <?php
 864          login_footer( 'user_login' );
 865  
 866          break;
 867  
 868      case 'confirmaction':
 869          if ( ! isset( $_GET['request_id'] ) ) {
 870              wp_die( __( 'Missing request ID.' ) );
 871          }
 872  
 873          if ( ! isset( $_GET['confirm_key'] ) ) {
 874              wp_die( __( 'Missing confirm key.' ) );
 875          }
 876  
 877          $request_id = (int) $_GET['request_id'];
 878          $key        = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) );
 879          $result     = wp_validate_user_request_key( $request_id, $key );
 880  
 881          if ( is_wp_error( $result ) ) {
 882              wp_die( $result );
 883          }
 884  
 885          /**
 886           * Fires an action hook when the account action has been confirmed by the user.
 887           *
 888           * Using this you can assume the user has agreed to perform the action by
 889           * clicking on the link in the confirmation email.
 890           *
 891           * After firing this action hook the page will redirect to wp-login a callback
 892           * redirects or exits first.
 893           *
 894           * @since 4.9.6
 895           *
 896           * @param int $request_id Request ID.
 897           */
 898          do_action( 'user_request_action_confirmed', $request_id );
 899  
 900          $message = _wp_privacy_account_request_confirmed_message( $request_id );
 901  
 902          login_header( __( 'User action confirmed.' ), $message );
 903          login_footer();
 904          exit;
 905  
 906      case 'login':
 907      default:
 908          $secure_cookie   = '';
 909          $customize_login = isset( $_REQUEST['customize-login'] );
 910          if ( $customize_login ) {
 911              wp_enqueue_script( 'customize-base' );
 912          }
 913  
 914          // If the user wants SSL but the session is not SSL, force a secure cookie.
 915          if ( ! empty( $_POST['log'] ) && ! force_ssl_admin() ) {
 916              $user_name = sanitize_user( $_POST['log'] );
 917              $user      = get_user_by( 'login', $user_name );
 918  
 919              if ( ! $user && strpos( $user_name, '@' ) ) {
 920                  $user = get_user_by( 'email', $user_name );
 921              }
 922  
 923              if ( $user ) {
 924                  if ( get_user_option( 'use_ssl', $user->ID ) ) {
 925                      $secure_cookie = true;
 926                      force_ssl_admin( true );
 927                  }
 928              }
 929          }
 930  
 931          if ( isset( $_REQUEST['redirect_to'] ) ) {
 932              $redirect_to = $_REQUEST['redirect_to'];
 933              // Redirect to HTTPS if user wants SSL.
 934              if ( $secure_cookie && false !== strpos( $redirect_to, 'wp-admin' ) ) {
 935                  $redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to );
 936              }
 937          } else {
 938              $redirect_to = admin_url();
 939          }
 940  
 941          $reauth = empty( $_REQUEST['reauth'] ) ? false : true;
 942  
 943          $user = wp_signon( array(), $secure_cookie );
 944  
 945          if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) {
 946              if ( headers_sent() ) {
 947                  $user = new WP_Error(
 948                      'test_cookie',
 949                      sprintf(
 950                          /* translators: 1: Browser cookie documentation URL, 2: Support forums URL */
 951                          __( '<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>.' ),
 952                          __( 'https://wordpress.org/support/article/cookies/' ),
 953                          __( 'https://wordpress.org/support/forums/' )
 954                      )
 955                  );
 956              } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) {
 957                  // If cookies are disabled we can't log in even with a valid user+pass
 958                  $user = new WP_Error(
 959                      'test_cookie',
 960                      sprintf(
 961                          /* translators: %s: Browser cookie documentation URL */
 962                          __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ),
 963                          __( 'https://wordpress.org/support/article/cookies/#enable-cookies-in-your-browser' )
 964                      )
 965                  );
 966              }
 967          }
 968  
 969          $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
 970          /**
 971           * Filters the login redirect URL.
 972           *
 973           * @since 3.0.0
 974           *
 975           * @param string           $redirect_to           The redirect destination URL.
 976           * @param string           $requested_redirect_to The requested redirect destination URL passed as a parameter.
 977           * @param WP_User|WP_Error $user                  WP_User object if login was successful, WP_Error object otherwise.
 978           */
 979          $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user );
 980  
 981          if ( ! is_wp_error( $user ) && ! $reauth ) {
 982              if ( $interim_login ) {
 983                  $message       = '<p class="message">' . __( 'You have logged in successfully.' ) . '</p>';
 984                  $interim_login = 'success';
 985                  login_header( '', $message );
 986                  ?>
 987                  </div>
 988                  <?php
 989                  /** This action is documented in wp-login.php */
 990                  do_action( 'login_footer' );
 991                  ?>
 992                  <?php if ( $customize_login ) : ?>
 993                  <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script>
 994              <?php endif; ?>
 995                  </body></html>
 996                  <?php
 997                  exit;
 998              }
 999  
1000              if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) {
1001                  // 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.
1002                  if ( is_multisite() && ! get_active_blog_for_user( $user->ID ) && ! is_super_admin( $user->ID ) ) {
1003                      $redirect_to = user_admin_url();
1004                  } elseif ( is_multisite() && ! $user->has_cap( 'read' ) ) {
1005                      $redirect_to = get_dashboard_url( $user->ID );
1006                  } elseif ( ! $user->has_cap( 'edit_posts' ) ) {
1007                      $redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url();
1008                  }
1009  
1010                  wp_redirect( $redirect_to );
1011                  exit();
1012              }
1013              wp_safe_redirect( $redirect_to );
1014              exit();
1015          }
1016  
1017          $errors = $user;
1018          // Clear errors if loggedout is set.
1019          if ( ! empty( $_GET['loggedout'] ) || $reauth ) {
1020              $errors = new WP_Error();
1021          }
1022  
1023          if ( empty( $_POST ) && $errors->get_error_codes() === array( 'empty_username', 'empty_password' ) ) {
1024              $errors = new WP_Error( '', '' );
1025          }
1026  
1027          if ( $interim_login ) {
1028              if ( ! $errors->has_errors() ) {
1029                  $errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' );
1030              }
1031          } else {
1032              // Some parts of this script use the main login form to display a message.
1033              if ( isset( $_GET['loggedout'] ) && true == $_GET['loggedout'] ) {
1034                  $errors->add( 'loggedout', __( 'You are now logged out.' ), 'message' );
1035              } elseif ( isset( $_GET['registration'] ) && 'disabled' == $_GET['registration'] ) {
1036                  $errors->add( 'registerdisabled', __( 'User registration is currently not allowed.' ) );
1037              } elseif ( isset( $_GET['checkemail'] ) && 'confirm' == $_GET['checkemail'] ) {
1038                  $errors->add( 'confirm', __( 'Check your email for the confirmation link.' ), 'message' );
1039              } elseif ( isset( $_GET['checkemail'] ) && 'newpass' == $_GET['checkemail'] ) {
1040                  $errors->add( 'newpass', __( 'Check your email for your new password.' ), 'message' );
1041              } elseif ( isset( $_GET['checkemail'] ) && 'registered' == $_GET['checkemail'] ) {
1042                  $errors->add( 'registered', __( 'Registration complete. Please check your email.' ), 'message' );
1043              } elseif ( strpos( $redirect_to, 'about.php?updated' ) ) {
1044                  $errors->add( 'updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what&#8217;s new.' ), 'message' );
1045              } elseif ( WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED === $action ) {
1046                  $errors->add( 'enter_recovery_mode', __( 'Recovery Mode Initialized. Please log in to continue.' ), 'message' );
1047              }
1048          }
1049  
1050          /**
1051           * Filters the login page errors.
1052           *
1053           * @since 3.6.0
1054           *
1055           * @param object $errors      WP Error object.
1056           * @param string $redirect_to Redirect destination URL.
1057           */
1058          $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to );
1059  
1060          // Clear any stale cookies.
1061          if ( $reauth ) {
1062              wp_clear_auth_cookie();
1063          }
1064  
1065          login_header( __( 'Log In' ), '', $errors );
1066  
1067          if ( isset( $_POST['log'] ) ) {
1068              $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr( wp_unslash( $_POST['log'] ) ) : '';
1069          }
1070          $rememberme = ! empty( $_POST['rememberme'] );
1071  
1072          if ( $errors->has_errors() ) {
1073              $aria_describedby_error = ' aria-describedby="login_error"';
1074          } else {
1075              $aria_describedby_error = '';
1076          }
1077          ?>
1078  
1079      <form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
1080      <p>
1081          <label for="user_login"><?php _e( 'Username or Email Address' ); ?><br />
1082          <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" /></label>
1083      </p>
1084      <p>
1085          <label for="user_pass"><?php _e( 'Password' ); ?><br />
1086          <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" size="20" /></label>
1087      </p>
1088          <?php
1089          /**
1090           * Fires following the 'Password' field in the login form.
1091           *
1092           * @since 2.1.0
1093           */
1094          do_action( 'login_form' );
1095          ?>
1096      <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked( $rememberme ); ?> /> <?php esc_html_e( 'Remember Me' ); ?></label></p>
1097      <p class="submit">
1098          <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Log In' ); ?>" />
1099          <?php    if ( $interim_login ) { ?>
1100          <input type="hidden" name="interim-login" value="1" />
1101      <?php    } else { ?>
1102          <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
1103      <?php } ?>
1104          <?php if ( $customize_login ) : ?>
1105          <input type="hidden" name="customize-login" value="1" />
1106      <?php endif; ?>
1107          <input type="hidden" name="testcookie" value="1" />
1108      </p>
1109      </form>
1110  
1111          <?php if ( ! $interim_login ) { ?>
1112      <p id="nav">
1113              <?php
1114              if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) :
1115                  if ( get_option( 'users_can_register' ) ) :
1116                      $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
1117  
1118                      /** This filter is documented in wp-includes/general-template.php */
1119                      echo apply_filters( 'register', $registration_url );
1120  
1121                      echo esc_html( $login_link_separator );
1122                  endif;
1123                  ?>
1124          <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
1125              <?php endif; ?>
1126      </p>
1127      <?php } ?>
1128  
1129      <script type="text/javascript">
1130  	function wp_attempt_focus(){
1131      setTimeout( function(){ try{
1132          <?php if ( $user_login ) { ?>
1133      d = document.getElementById('user_pass');
1134      d.value = '';
1135      <?php } else { ?>
1136      d = document.getElementById('user_login');
1137              <?php if ( 'invalid_username' == $errors->get_error_code() ) { ?>
1138      if( d.value != '' )
1139      d.value = '';
1140                  <?php
1141              }
1142      }
1143      ?>
1144      d.focus();
1145      d.select();
1146      } catch(e){}
1147      }, 200);
1148      }
1149  
1150          <?php
1151          /**
1152           * Filters whether to print the call to `wp_attempt_focus()` on the login screen.
1153           *
1154           * @since 4.8.0
1155           *
1156           * @param bool $print Whether to print the function call. Default true.
1157           */
1158          if ( apply_filters( 'enable_login_autofocus', true ) && ! $error ) {
1159              ?>
1160      wp_attempt_focus();
1161          <?php } ?>
1162      if(typeof wpOnload=='function')wpOnload();
1163          <?php if ( $interim_login ) { ?>
1164      (function(){
1165      try {
1166          var i, links = document.getElementsByTagName('a');
1167          for ( i in links ) {
1168              if ( links[i].href )
1169                  links[i].target = '_blank';
1170          }
1171      } catch(e){}
1172      }());
1173      <?php } ?>
1174      </script>
1175  
1176          <?php
1177          login_footer();
1178  
1179          break;
1180  } // End action switch.


Generated: Sun Jun 16 01:00:07 2019 Cross-referenced by PHPXref 0.7.1