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