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