Add admin email verification screen. Shown every six months after an admin has logged in.

Also includes WPCS fixes for wp-login.php.

Props andraganescu, boemedia, lessbloat, azaozz.
See #46349.
Built from https://develop.svn.wordpress.org/trunk@45757


git-svn-id: http://core.svn.wordpress.org/trunk@45568 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2019-08-07 00:04:56 +00:00
parent e081194455
commit fff56d219f
8 changed files with 624 additions and 245 deletions

View File

@ -131,6 +131,17 @@ p {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
}
.login-action-confirm_admin_email #login {
width: 60vw;
margin-top: -2vh;
}
@media screen and (max-width: 782px) {
.login-action-confirm_admin_email #login {
width: 100vw;
}
}
.login form .forgetmenot {
font-weight: 400;
float: right;
@ -141,6 +152,36 @@ p {
float: left;
}
.login .admin-email-confirm-form .submit {
text-align: center;
}
.admin-email__later {
text-align: right;
}
.login form p.admin-email__details {
margin: 1.1em 0;
}
.login h1.admin-email__heading {
border-bottom: 1px rgb(241, 241, 241) solid;
color: rgb(95, 95, 95);
font-weight: normal;
padding-bottom: 0.5em;
text-align: right;
}
.admin-email__actions div {
padding-top: 1.5em;
}
.login .admin-email__actions .button-primary {
float: none;
margin-right: 0.25em;
margin-left: 0.25em;
}
#login form p {
margin-bottom: 0;
}

View File

@ -1,2 +1,2 @@
/*! This file is auto-generated */
body,html{height:100%;margin:0;padding:0}body{background:#f1f1f1;min-width:0;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:13px;line-height:1.4}a{color:#0073aa;transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out}a{outline:0}a:active,a:hover{color:#00a0d2}a:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 a:focus{outline:#5b9dd9 solid 1px}p{line-height:1.5}.login #login_error,.login .message,.login .success{border-right:4px solid #00a0d2;padding:12px;margin-right:0;margin-bottom:20px;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}.login .success{border-right-color:#46b450}.login #login_error{border-right-color:#dc3232}#loginform p.submit,.login-action-lostpassword p.submit{border:none;margin:-10px 0 20px}.login *{margin:0;padding:0}.login .password-input-wrapper{position:relative}.login .input.password-input{margin:0}.login .input::-ms-clear{display:none}.login .pw-weak{margin-bottom:15px}.login .button.button-secondary{background:0 0;border:1px solid transparent;box-shadow:none;font-size:14px;line-height:2;height:auto;margin:0;padding:5px 9px;position:absolute;left:0;top:0}.login .button.button-secondary:hover{background:0 0}.login .button.button-secondary:focus{background:0 0;border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.login .button.button-secondary:active{background:0 0;box-shadow:none;transform:none}.login form{margin-top:20px;margin-right:0;padding:26px 24px 46px;font-weight:400;overflow:hidden;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.13)}.login form .forgetmenot{font-weight:400;float:right;margin-bottom:0}.login .button-primary{float:left}#login form p{margin-bottom:0}#login form p.submit{margin:0;padding:0}.login label{font-size:14px}.login form .forgetmenot label{font-size:12px;line-height:1.58333333}.login h1{text-align:center}.login h1 a{background-image:url(../images/w-logo-blue.png?ver=20131202);background-image:none,url(../images/wordpress-logo.svg?ver=20131107);background-size:84px;background-position:center top;background-repeat:no-repeat;color:#444;height:84px;font-size:20px;font-weight:400;line-height:1.3;margin:0 auto 25px;padding:0;text-decoration:none;width:84px;text-indent:-9999px;outline:0;overflow:hidden;display:block}#login{width:320px;padding:8% 0 0;margin:auto}.login #backtoblog,.login #nav{font-size:13px;padding:0 24px 0}.login #nav{margin:24px 0 0 0}#backtoblog{margin:16px 0}.login #backtoblog a,.login #nav a{text-decoration:none;color:#555d66}.login #backtoblog a:hover,.login #nav a:hover,.login h1 a:hover{color:#00a0d2}.login #backtoblog a:focus,.login #nav a:focus,.login h1 a:focus{color:#124964}.login .privacy-policy-page-link{text-align:center;width:100%;margin:5em 0 2em}.login form .input,.login input[type=text]{font-size:24px;width:100%;padding:5px;margin:2px 0 16px 6px}.login-action-rp form .input,.login-action-rp input[type=text]{padding:5px 5px 5px 45px}.login form .input,.login form input[type=checkbox],.login input[type=text]{background:#fbfbfb}.ie7 .login form .input,.ie8 .login form .input{font-family:sans-serif}.login-action-rp input[type=text]{box-shadow:none;margin:0}.login #pass-strength-result{font-weight:600;margin:-1px 0 16px 5px;padding:6px 5px;text-align:center;width:100%}body.interim-login{height:auto}.interim-login #login{padding:0;margin:5px auto 20px}.interim-login.login h1 a{width:auto}.interim-login #login_error,.interim-login.login .message{margin:0 0 16px}.interim-login.login form{margin:0}@-ms-viewport{width:device-width}@media screen and (max-height:550px){#login{padding:20px 0}}@media screen and (max-width:782px){.interim-login input[type=checkbox]{height:16px;width:16px}.interim-login input[type=checkbox]:checked:before{width:16px;font:normal 21px/1 dashicons;margin:-3px -4px 0 0}}
body,html{height:100%;margin:0;padding:0}body{background:#f1f1f1;min-width:0;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:13px;line-height:1.4}a{color:#0073aa;transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out}a{outline:0}a:active,a:hover{color:#00a0d2}a:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 a:focus{outline:#5b9dd9 solid 1px}p{line-height:1.5}.login #login_error,.login .message,.login .success{border-right:4px solid #00a0d2;padding:12px;margin-right:0;margin-bottom:20px;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}.login .success{border-right-color:#46b450}.login #login_error{border-right-color:#dc3232}#loginform p.submit,.login-action-lostpassword p.submit{border:none;margin:-10px 0 20px}.login *{margin:0;padding:0}.login .password-input-wrapper{position:relative}.login .input.password-input{margin:0}.login .input::-ms-clear{display:none}.login .pw-weak{margin-bottom:15px}.login .button.button-secondary{background:0 0;border:1px solid transparent;box-shadow:none;font-size:14px;line-height:2;height:auto;margin:0;padding:5px 9px;position:absolute;left:0;top:0}.login .button.button-secondary:hover{background:0 0}.login .button.button-secondary:focus{background:0 0;border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.login .button.button-secondary:active{background:0 0;box-shadow:none;transform:none}.login form{margin-top:20px;margin-right:0;padding:26px 24px 46px;font-weight:400;overflow:hidden;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.13)}.login-action-confirm_admin_email #login{width:60vw;margin-top:-2vh}@media screen and (max-width:782px){.login-action-confirm_admin_email #login{width:100vw}}.login form .forgetmenot{font-weight:400;float:right;margin-bottom:0}.login .button-primary{float:left}.login .admin-email-confirm-form .submit{text-align:center}.admin-email__later{text-align:right}.login form p.admin-email__details{margin:1.1em 0}.login h1.admin-email__heading{border-bottom:1px #f1f1f1 solid;color:#5f5f5f;font-weight:400;padding-bottom:.5em;text-align:right}.admin-email__actions div{padding-top:1.5em}.login .admin-email__actions .button-primary{float:none;margin-right:.25em;margin-left:.25em}#login form p{margin-bottom:0}#login form p.submit{margin:0;padding:0}.login label{font-size:14px}.login form .forgetmenot label{font-size:12px;line-height:1.58333333}.login h1{text-align:center}.login h1 a{background-image:url(../images/w-logo-blue.png?ver=20131202);background-image:none,url(../images/wordpress-logo.svg?ver=20131107);background-size:84px;background-position:center top;background-repeat:no-repeat;color:#444;height:84px;font-size:20px;font-weight:400;line-height:1.3;margin:0 auto 25px;padding:0;text-decoration:none;width:84px;text-indent:-9999px;outline:0;overflow:hidden;display:block}#login{width:320px;padding:8% 0 0;margin:auto}.login #backtoblog,.login #nav{font-size:13px;padding:0 24px 0}.login #nav{margin:24px 0 0 0}#backtoblog{margin:16px 0}.login #backtoblog a,.login #nav a{text-decoration:none;color:#555d66}.login #backtoblog a:hover,.login #nav a:hover,.login h1 a:hover{color:#00a0d2}.login #backtoblog a:focus,.login #nav a:focus,.login h1 a:focus{color:#124964}.login .privacy-policy-page-link{text-align:center;width:100%;margin:5em 0 2em}.login form .input,.login input[type=text]{font-size:24px;width:100%;padding:5px;margin:2px 0 16px 6px}.login-action-rp form .input,.login-action-rp input[type=text]{padding:5px 5px 5px 45px}.login form .input,.login form input[type=checkbox],.login input[type=text]{background:#fbfbfb}.ie7 .login form .input,.ie8 .login form .input{font-family:sans-serif}.login-action-rp input[type=text]{box-shadow:none;margin:0}.login #pass-strength-result{font-weight:600;margin:-1px 0 16px 5px;padding:6px 5px;text-align:center;width:100%}body.interim-login{height:auto}.interim-login #login{padding:0;margin:5px auto 20px}.interim-login.login h1 a{width:auto}.interim-login #login_error,.interim-login.login .message{margin:0 0 16px}.interim-login.login form{margin:0}@-ms-viewport{width:device-width}@media screen and (max-height:550px){#login{padding:20px 0}}@media screen and (max-width:782px){.interim-login input[type=checkbox]{height:16px;width:16px}.interim-login input[type=checkbox]:checked:before{width:16px;font:normal 21px/1 dashicons;margin:-3px -4px 0 0}}

View File

@ -131,6 +131,17 @@ p {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
}
.login-action-confirm_admin_email #login {
width: 60vw;
margin-top: -2vh;
}
@media screen and (max-width: 782px) {
.login-action-confirm_admin_email #login {
width: 100vw;
}
}
.login form .forgetmenot {
font-weight: 400;
float: left;
@ -141,6 +152,36 @@ p {
float: right;
}
.login .admin-email-confirm-form .submit {
text-align: center;
}
.admin-email__later {
text-align: left;
}
.login form p.admin-email__details {
margin: 1.1em 0;
}
.login h1.admin-email__heading {
border-bottom: 1px rgb(241, 241, 241) solid;
color: rgb(95, 95, 95);
font-weight: normal;
padding-bottom: 0.5em;
text-align: left;
}
.admin-email__actions div {
padding-top: 1.5em;
}
.login .admin-email__actions .button-primary {
float: none;
margin-left: 0.25em;
margin-right: 0.25em;
}
#login form p {
margin-bottom: 0;
}

View File

@ -1,2 +1,2 @@
/*! This file is auto-generated */
body,html{height:100%;margin:0;padding:0}body{background:#f1f1f1;min-width:0;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:13px;line-height:1.4}a{color:#0073aa;transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out}a{outline:0}a:active,a:hover{color:#00a0d2}a:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 a:focus{outline:#5b9dd9 solid 1px}p{line-height:1.5}.login #login_error,.login .message,.login .success{border-left:4px solid #00a0d2;padding:12px;margin-left:0;margin-bottom:20px;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}.login .success{border-left-color:#46b450}.login #login_error{border-left-color:#dc3232}#loginform p.submit,.login-action-lostpassword p.submit{border:none;margin:-10px 0 20px}.login *{margin:0;padding:0}.login .password-input-wrapper{position:relative}.login .input.password-input{margin:0}.login .input::-ms-clear{display:none}.login .pw-weak{margin-bottom:15px}.login .button.button-secondary{background:0 0;border:1px solid transparent;box-shadow:none;font-size:14px;line-height:2;height:auto;margin:0;padding:5px 9px;position:absolute;right:0;top:0}.login .button.button-secondary:hover{background:0 0}.login .button.button-secondary:focus{background:0 0;border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.login .button.button-secondary:active{background:0 0;box-shadow:none;transform:none}.login form{margin-top:20px;margin-left:0;padding:26px 24px 46px;font-weight:400;overflow:hidden;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.13)}.login form .forgetmenot{font-weight:400;float:left;margin-bottom:0}.login .button-primary{float:right}#login form p{margin-bottom:0}#login form p.submit{margin:0;padding:0}.login label{font-size:14px}.login form .forgetmenot label{font-size:12px;line-height:1.58333333}.login h1{text-align:center}.login h1 a{background-image:url(../images/w-logo-blue.png?ver=20131202);background-image:none,url(../images/wordpress-logo.svg?ver=20131107);background-size:84px;background-position:center top;background-repeat:no-repeat;color:#444;height:84px;font-size:20px;font-weight:400;line-height:1.3;margin:0 auto 25px;padding:0;text-decoration:none;width:84px;text-indent:-9999px;outline:0;overflow:hidden;display:block}#login{width:320px;padding:8% 0 0;margin:auto}.login #backtoblog,.login #nav{font-size:13px;padding:0 24px 0}.login #nav{margin:24px 0 0 0}#backtoblog{margin:16px 0}.login #backtoblog a,.login #nav a{text-decoration:none;color:#555d66}.login #backtoblog a:hover,.login #nav a:hover,.login h1 a:hover{color:#00a0d2}.login #backtoblog a:focus,.login #nav a:focus,.login h1 a:focus{color:#124964}.login .privacy-policy-page-link{text-align:center;width:100%;margin:5em 0 2em}.login form .input,.login input[type=text]{font-size:24px;width:100%;padding:5px;margin:2px 6px 16px 0}.login-action-rp form .input,.login-action-rp input[type=text]{padding:5px 45px 5px 5px}.login form .input,.login form input[type=checkbox],.login input[type=text]{background:#fbfbfb}.ie7 .login form .input,.ie8 .login form .input{font-family:sans-serif}.login-action-rp input[type=text]{box-shadow:none;margin:0}.login #pass-strength-result{font-weight:600;margin:-1px 5px 16px 0;padding:6px 5px;text-align:center;width:100%}body.interim-login{height:auto}.interim-login #login{padding:0;margin:5px auto 20px}.interim-login.login h1 a{width:auto}.interim-login #login_error,.interim-login.login .message{margin:0 0 16px}.interim-login.login form{margin:0}@-ms-viewport{width:device-width}@media screen and (max-height:550px){#login{padding:20px 0}}@media screen and (max-width:782px){.interim-login input[type=checkbox]{height:16px;width:16px}.interim-login input[type=checkbox]:checked:before{width:16px;font:normal 21px/1 dashicons;margin:-3px 0 0 -4px}}
body,html{height:100%;margin:0;padding:0}body{background:#f1f1f1;min-width:0;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:13px;line-height:1.4}a{color:#0073aa;transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out}a{outline:0}a:active,a:hover{color:#00a0d2}a:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 a:focus{outline:#5b9dd9 solid 1px}p{line-height:1.5}.login #login_error,.login .message,.login .success{border-left:4px solid #00a0d2;padding:12px;margin-left:0;margin-bottom:20px;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}.login .success{border-left-color:#46b450}.login #login_error{border-left-color:#dc3232}#loginform p.submit,.login-action-lostpassword p.submit{border:none;margin:-10px 0 20px}.login *{margin:0;padding:0}.login .password-input-wrapper{position:relative}.login .input.password-input{margin:0}.login .input::-ms-clear{display:none}.login .pw-weak{margin-bottom:15px}.login .button.button-secondary{background:0 0;border:1px solid transparent;box-shadow:none;font-size:14px;line-height:2;height:auto;margin:0;padding:5px 9px;position:absolute;right:0;top:0}.login .button.button-secondary:hover{background:0 0}.login .button.button-secondary:focus{background:0 0;border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.login .button.button-secondary:active{background:0 0;box-shadow:none;transform:none}.login form{margin-top:20px;margin-left:0;padding:26px 24px 46px;font-weight:400;overflow:hidden;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.13)}.login-action-confirm_admin_email #login{width:60vw;margin-top:-2vh}@media screen and (max-width:782px){.login-action-confirm_admin_email #login{width:100vw}}.login form .forgetmenot{font-weight:400;float:left;margin-bottom:0}.login .button-primary{float:right}.login .admin-email-confirm-form .submit{text-align:center}.admin-email__later{text-align:left}.login form p.admin-email__details{margin:1.1em 0}.login h1.admin-email__heading{border-bottom:1px #f1f1f1 solid;color:#5f5f5f;font-weight:400;padding-bottom:.5em;text-align:left}.admin-email__actions div{padding-top:1.5em}.login .admin-email__actions .button-primary{float:none;margin-left:.25em;margin-right:.25em}#login form p{margin-bottom:0}#login form p.submit{margin:0;padding:0}.login label{font-size:14px}.login form .forgetmenot label{font-size:12px;line-height:1.58333333}.login h1{text-align:center}.login h1 a{background-image:url(../images/w-logo-blue.png?ver=20131202);background-image:none,url(../images/wordpress-logo.svg?ver=20131107);background-size:84px;background-position:center top;background-repeat:no-repeat;color:#444;height:84px;font-size:20px;font-weight:400;line-height:1.3;margin:0 auto 25px;padding:0;text-decoration:none;width:84px;text-indent:-9999px;outline:0;overflow:hidden;display:block}#login{width:320px;padding:8% 0 0;margin:auto}.login #backtoblog,.login #nav{font-size:13px;padding:0 24px 0}.login #nav{margin:24px 0 0 0}#backtoblog{margin:16px 0}.login #backtoblog a,.login #nav a{text-decoration:none;color:#555d66}.login #backtoblog a:hover,.login #nav a:hover,.login h1 a:hover{color:#00a0d2}.login #backtoblog a:focus,.login #nav a:focus,.login h1 a:focus{color:#124964}.login .privacy-policy-page-link{text-align:center;width:100%;margin:5em 0 2em}.login form .input,.login input[type=text]{font-size:24px;width:100%;padding:5px;margin:2px 6px 16px 0}.login-action-rp form .input,.login-action-rp input[type=text]{padding:5px 45px 5px 5px}.login form .input,.login form input[type=checkbox],.login input[type=text]{background:#fbfbfb}.ie7 .login form .input,.ie8 .login form .input{font-family:sans-serif}.login-action-rp input[type=text]{box-shadow:none;margin:0}.login #pass-strength-result{font-weight:600;margin:-1px 5px 16px 0;padding:6px 5px;text-align:center;width:100%}body.interim-login{height:auto}.interim-login #login{padding:0;margin:5px auto 20px}.interim-login.login h1 a{width:auto}.interim-login #login_error,.interim-login.login .message{margin:0 0 16px}.interim-login.login form{margin:0}@-ms-viewport{width:device-width}@media screen and (max-height:550px){#login{padding:20px 0}}@media screen and (max-width:782px){.interim-login input[type=checkbox]{height:16px;width:16px}.interim-login input[type=checkbox]:checked:before{width:16px;font:normal 21px/1 dashicons;margin:-3px 0 0 -4px}}

View File

@ -815,6 +815,10 @@ function upgrade_all() {
upgrade_510();
}
if ( $wp_current_db_version < 45744 ) {
upgrade_530();
}
maybe_disable_link_manager();
maybe_disable_automattic_widgets();
@ -2114,6 +2118,19 @@ function upgrade_510() {
delete_site_option( 'upgrade_500_was_gutenberg_active' );
}
/**
* Executes changes made in WordPress 5.3.0.
*
* @ignore
* @since 5.3.0
*/
function upgrade_530() {
// Do `add_option()` rather than overwriting with `update_option()` as this may run
// after an admin was redirected to the email verification screen,
// and the option was updated.
add_option( 'admin_email_lifespan', 0 );
}
/**
* Executes network-level upgrade routines.
*

View File

@ -108,7 +108,7 @@ if ( ! is_multisite() ) {
<?php } ?>
<tr>
<th scope="row"><label for="new_admin_email"><?php _e( 'Email Address' ); ?></label></th>
<th scope="row"><label for="new_admin_email"><?php _e( 'Administration Email Address' ); ?></label></th>
<td><input name="new_admin_email" type="email" id="new_admin_email" aria-describedby="new-admin-email-description" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" />
<p class="description" id="new-admin-email-description"><?php _e( 'This address is used for admin purposes. If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?></p>
<?php

View File

@ -13,14 +13,14 @@
*
* @global string $wp_version
*/
$wp_version = '5.3-alpha-45756';
$wp_version = '5.3-alpha-45757';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
*
* @global int $wp_db_version
*/
$wp_db_version = 44719;
$wp_db_version = 45744;
/**
* Holds the TinyMCE version

View File

@ -55,7 +55,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
*/
$shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes );
if ( $shake_error_codes && $wp_error->has_errors() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) {
if ( $shake_error_codes && $wp_error->has_errors() && in_array( $wp_error->get_error_code(), $shake_error_codes, true ) ) {
add_action( 'login_head', 'wp_shake_js', 12 );
}
@ -98,7 +98,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
* This could be added by add_action('login_head'...) like wp_shake_js(),
* but maybe better if it's not removable by plugins.
*/
if ( 'loggedout' == $wp_error->get_error_code() ) {
if ( 'loggedout' === $wp_error->get_error_code() ) {
?>
<script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script>
<?php
@ -159,11 +159,14 @@ function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
$login_header_text = apply_filters( 'login_headertext', $login_header_text );
$classes = array( 'login-action-' . $action, 'wp-core-ui' );
if ( is_rtl() ) {
$classes[] = 'rtl';
}
if ( $interim_login ) {
$classes[] = 'interim-login';
?>
<style type="text/css">html{background-color: transparent;}</style>
<?php
@ -172,6 +175,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
$classes[] = 'interim-login-success';
}
}
$classes[] = ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
/**
@ -194,6 +198,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
* @since 4.6.0
*/
do_action( 'login_header' );
?>
<div id="login">
<h1><a href="<?php echo esc_url( $login_header_url ); ?>"><?php echo $login_header_text; ?></a></h1>
@ -206,6 +211,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
* @param string $message Login message text.
*/
$message = apply_filters( 'login_message', $message );
if ( ! empty( $message ) ) {
echo $message . "\n";
}
@ -219,16 +225,18 @@ function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
if ( $wp_error->has_errors() ) {
$errors = '';
$messages = '';
foreach ( $wp_error->get_error_codes() as $code ) {
$severity = $wp_error->get_error_data( $code );
foreach ( $wp_error->get_error_messages( $code ) as $error_message ) {
if ( 'message' == $severity ) {
if ( 'message' === $severity ) {
$messages .= ' ' . $error_message . "<br />\n";
} else {
$errors .= ' ' . $error_message . "<br />\n";
}
}
}
if ( ! empty( $errors ) ) {
/**
* Filters the error messages displayed above the login form.
@ -239,6 +247,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
*/
echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n";
}
if ( ! empty( $messages ) ) {
/**
* Filters instructional messages displayed above the login form.
@ -263,33 +272,42 @@ function login_footer( $input_id = '' ) {
global $interim_login;
// Don't allow interim logins to navigate away from the page.
if ( ! $interim_login ) :
if ( ! $interim_login ) {
?>
<p id="backtoblog"><a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php
/* translators: %s: site title */
printf( _x( '&larr; Back to %s', 'site' ), get_bloginfo( 'title', 'display' ) );
?>
</a></p>
<?php the_privacy_policy_link( '<div class="privacy-policy-page-link">', '</div>' ); ?>
<?php endif; ?>
<?php
</div>
the_privacy_policy_link( '<div class="privacy-policy-page-link">', '</div>' );
}
<?php if ( ! empty( $input_id ) ) : ?>
?>
</div><?php // End of <div id="login"> ?>
<?php
if ( ! empty( $input_id ) ) {
?>
<script type="text/javascript">
try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){}
if(typeof wpOnload=='function')wpOnload();
</script>
<?php endif; ?>
<?php
}
/**
* Fires in the login page footer.
*
* @since 3.1.0
*/
do_action( 'login_footer' );
?>
<div class="clear"></div>
</body>
@ -452,8 +470,22 @@ if ( isset( $_GET['key'] ) ) {
$action = 'resetpass';
}
$default_actions = array(
'confirm_admin_email',
'postpass',
'logout',
'lostpassword',
'retrievepassword',
'resetpass',
'rp',
'register',
'login',
'confirmaction',
WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED,
);
// Validate action so as to default to the login screen.
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 ) ) {
if ( ! in_array( $action, $default_actions, true ) && false === has_filter( 'login_form_' . $action ) ) {
$action = 'login';
}
@ -462,12 +494,13 @@ nocache_headers();
header( 'Content-Type: ' . get_bloginfo( 'html_type' ) . '; charset=' . get_bloginfo( 'charset' ) );
if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set
if ( isset( $_SERVER['PATH_INFO'] ) && ( $_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'] ) ) {
if ( isset( $_SERVER['PATH_INFO'] ) && ( $_SERVER['PATH_INFO'] !== $_SERVER['PHP_SELF'] ) ) {
$_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
}
$url = dirname( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ) );
if ( $url != get_option( 'siteurl' ) ) {
if ( $url !== get_option( 'siteurl' ) ) {
update_option( 'siteurl', $url );
}
}
@ -475,6 +508,7 @@ if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set
//Set a cookie now to see if they are supported by the browser.
$secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) );
setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure );
if ( SITECOOKIEPATH != COOKIEPATH ) {
setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure );
}
@ -497,7 +531,7 @@ do_action( 'login_init' );
*/
do_action( "login_form_{$action}" );
$http_post = ( 'POST' == $_SERVER['REQUEST_METHOD'] );
$http_post = ( 'POST' === $_SERVER['REQUEST_METHOD'] );
$interim_login = isset( $_REQUEST['interim-login'] );
/**
@ -511,10 +545,171 @@ $login_link_separator = apply_filters( 'login_link_separator', ' | ' );
switch ( $action ) {
case 'confirm_admin_email':
// Note that `is_user_logged_in()` will return false immediately after logging in
// as the current user is not set, see wp-includes/pluggable.php.
// However this action runs on a redirect after logging in.
if ( ! is_user_logged_in() ) {
wp_safe_redirect( wp_login_url() );
exit;
}
if ( ! empty( $_REQUEST['redirect_to'] ) ) {
$redirect_to = $_REQUEST['redirect_to'];
} else {
$redirect_to = admin_url();
}
if ( current_user_can( 'manage_options' ) ) {
$admin_email = get_option( 'admin_email' );
} else {
wp_safe_redirect( $redirect_to );
exit;
}
if ( ! empty( $_GET['remind_me_later'] ) ) {
if ( ! wp_verify_nonce( $_GET['remind_me_later'], 'remind_me_later_nonce' ) ) {
wp_safe_redirect( wp_login_url() );
exit;
}
// "Remind me later" is a bit ambiguous. Three days later?
update_option( 'admin_email_lifespan', time() + 3 * DAY_IN_SECONDS );
wp_safe_redirect( $redirect_to );
exit;
}
if ( ! empty( $_POST['correct-admin-email'] ) ) {
if ( ! check_admin_referer( 'confirm_admin_email', 'confirm_admin_email_nonce' ) ) {
wp_safe_redirect( wp_login_url() );
exit;
}
/**
* Filters the interval for redirecting the user to the admin email confirmation screen.
* If `0` (zero) is returned, the user will not be redirected.
*
* @since 5.3.0
*
* @param int Interval time (in seconds).
*/
$admin_email_check_interval = (int) apply_filters( 'admin_email_check_interval', 180 * DAY_IN_SECONDS );
if ( $admin_email_check_interval > 0 ) {
update_option( 'admin_email_lifespan', time() + $admin_email_check_interval );
}
wp_safe_redirect( $redirect_to );
exit;
}
login_header( __( 'Confirm your admin email' ), '', $errors );
/**
* Fires before the admin email confirm form.
*
* @since 5.3.0
*
* @param WP_Error $errors A `WP_Error` object containing any errors generated by using invalid credentials. Note that the error object may not contain any errors.
*/
do_action( 'admin_email_confirm', $errors );
?>
<form class="admin-email-confirm-form" name="admin-email-confirm-form" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=confirm_admin_email', 'login_post' ) ); ?>" method="post">
<?php
/**
* Fires inside the admin-email-confirm-form form tags, before the hidden fields.
*
* @since 5.3.0
*/
do_action( 'admin_email_confirm_form' );
wp_nonce_field( 'confirm_admin_email', 'confirm_admin_email_nonce' );
?>
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
<h1 class="admin-email__heading">
<?php _e( 'Administration email verification' ); ?>
</h1>
<p class="admin-email__details">
<?php _e( 'Please verify that the <strong>administration email</strong> for this website is still correct.' ); ?>
<?php
/* translators: URL to the WordPress help section about admin email. */
$admin_email_help_url = __( 'https://wordpress.org/support/article/settings-general-screen/#email-address' );
printf(
'<a href="%s" rel="noopener noreferrer" target="_blank">%s</a>',
esc_url( $admin_email_help_url ),
__( 'Why is this important?' )
);
?>
</p>
<p class="admin-email__details">
<?php
printf(
__( 'Current administration email: <strong>%s</strong>' ),
esc_html( $admin_email )
);
?>
</p>
<p class="admin-email__details">
<?php _e( 'This email may be different from your personal email address.' ); ?>
<?php
printf(
'<a href="%s" rel="noopener noreferrer" target="_blank">%s</a>',
esc_url( $admin_email_help_url ),
__( 'Learn more.' )
);
?>
</p>
<div class="admin-email__actions">
<div class="admin-email__actions-primary">
<?php
$change_link = admin_url( 'options-general.php' );
$change_link = add_query_arg( 'highlight', 'confirm_admin_email', $change_link );
?>
<a class="button button-large" href="<?php echo esc_url( $change_link ); ?>"><?php _e( 'Update' ); ?></a>
<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' ); ?>" />
</div>
<div class="admin-email__actions-secondary">
<?php
$remind_me_link = wp_login_url( $redirect_to );
$remind_me_link = add_query_arg(
array(
'action' => 'confirm_admin_email',
'remind_me_later' => wp_create_nonce( 'remind_me_later_nonce' ),
),
$remind_me_link
);
?>
<a href="<?php echo esc_url( $remind_me_link ); ?>"><?php _e( 'Remind me later' ); ?></a>
</div>
</div>
</form>
<?php
login_footer();
break;
case 'postpass':
if ( ! array_key_exists( 'post_password', $_POST ) ) {
wp_safe_redirect( wp_get_referer() );
exit();
exit;
}
require_once ABSPATH . WPINC . '/class-phpass.php';
@ -532,11 +727,13 @@ switch ( $action ) {
*/
$expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
$referer = wp_get_referer();
if ( $referer ) {
$secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) );
} else {
$secure = false;
}
setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
wp_safe_redirect( wp_get_referer() );
@ -560,6 +757,7 @@ switch ( $action ) {
),
wp_login_url()
);
$requested_redirect_to = '';
}
@ -573,6 +771,7 @@ switch ( $action ) {
* @param WP_User $user The WP_User object for the user that's logging out.
*/
$redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user );
wp_safe_redirect( $redirect_to );
exit();
@ -580,6 +779,7 @@ switch ( $action ) {
case 'retrievepassword':
if ( $http_post ) {
$errors = retrieve_password();
if ( ! is_wp_error( $errors ) ) {
$redirect_to = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm';
wp_safe_redirect( $redirect_to );
@ -588,9 +788,9 @@ switch ( $action ) {
}
if ( isset( $_GET['error'] ) ) {
if ( 'invalidkey' == $_GET['error'] ) {
if ( 'invalidkey' === $_GET['error'] ) {
$errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) );
} elseif ( 'expiredkey' == $_GET['error'] ) {
} elseif ( 'expiredkey' === $_GET['error'] ) {
$errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) );
}
}
@ -632,50 +832,59 @@ switch ( $action ) {
<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" /></label>
</p>
<?php
/**
* Fires inside the lostpassword form tags, before the hidden fields.
*
* @since 2.1.0
*/
do_action( 'lostpassword_form' );
?>
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
<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>
<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>
</form>
<p id="nav">
<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
<?php
if ( get_option( 'users_can_register' ) ) :
if ( get_option( 'users_can_register' ) ) {
$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
echo esc_html( $login_link_separator );
/** This filter is documented in wp-includes/general-template.php */
echo apply_filters( 'register', $registration_url );
endif;
}
?>
</p>
<?php
login_footer( 'user_login' );
login_footer( 'user_login' );
break;
case 'resetpass':
case 'rp':
list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
if ( isset( $_GET['key'] ) ) {
$value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) );
setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) );
exit;
}
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
$user = check_password_reset_key( $rp_key, $rp_login );
if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
$user = false;
}
@ -685,11 +894,13 @@ switch ( $action ) {
if ( ! $user || is_wp_error( $user ) ) {
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
if ( $user && $user->get_error_code() === 'expired_key' ) {
wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
} else {
wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );
}
exit;
}
@ -757,6 +968,7 @@ switch ( $action ) {
<br class="clear" />
<?php
/**
* Fires following the 'Strength indicator' meter in the user password reset form.
*
@ -765,28 +977,32 @@ switch ( $action ) {
* @param WP_User $user User object of the user whose password is being reset.
*/
do_action( 'resetpass_form', $user );
?>
<input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" />
<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>
<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>
</form>
<p id="nav">
<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
<?php
if ( get_option( 'users_can_register' ) ) :
if ( get_option( 'users_can_register' ) ) {
$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
echo esc_html( $login_link_separator );
/** This filter is documented in wp-includes/general-template.php */
echo apply_filters( 'register', $registration_url );
endif;
}
?>
</p>
<?php
login_footer( 'user_pass' );
login_footer( 'user_pass' );
break;
case 'register':
@ -820,6 +1036,7 @@ switch ( $action ) {
}
$errors = register_new_user( $user_login, $user_email );
if ( ! is_wp_error( $errors ) ) {
$redirect_to = ! empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered';
wp_safe_redirect( $redirect_to );
@ -828,6 +1045,7 @@ switch ( $action ) {
}
$registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
/**
* Filters the registration redirect URL.
*
@ -836,7 +1054,9 @@ switch ( $action ) {
* @param string $registration_redirect The redirect destination URL.
*/
$redirect_to = apply_filters( 'registration_redirect', $registration_redirect );
login_header( __( 'Registration Form' ), '<p class="message register">' . __( 'Register For This Site' ) . '</p>', $errors );
?>
<form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate">
<p>
@ -848,17 +1068,23 @@ switch ( $action ) {
<input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label>
</p>
<?php
/**
* Fires following the 'Email' field in the user registration form.
*
* @since 2.1.0
*/
do_action( 'register_form' );
?>
<p id="reg_passmail"><?php _e( 'Registration confirmation will be emailed to you.' ); ?></p>
<p id="reg_passmail">
<?php _e( 'Registration confirmation will be emailed to you.' ); ?>
</p>
<br class="clear" />
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
<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>
<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>
</form>
<p id="nav">
@ -866,10 +1092,9 @@ switch ( $action ) {
<?php echo esc_html( $login_link_separator ); ?>
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
</p>
<?php
login_footer( 'user_login' );
login_footer( 'user_login' );
break;
case 'confirmaction':
@ -914,6 +1139,7 @@ switch ( $action ) {
default:
$secure_cookie = '';
$customize_login = isset( $_REQUEST['customize-login'] );
if ( $customize_login ) {
wp_enqueue_script( 'customize-base' );
}
@ -990,21 +1216,42 @@ switch ( $action ) {
$message = '<p class="message">' . __( 'You have logged in successfully.' ) . '</p>';
$interim_login = 'success';
login_header( '', $message );
?>
</div>
<?php
/** This action is documented in wp-login.php */
do_action( 'login_footer' );
if ( $customize_login ) {
?>
<?php if ( $customize_login ) : ?>
<script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script>
<?php endif; ?>
<?php
}
?>
</body></html>
<?php
exit;
}
if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) {
// Check if it is time to add a redirect to the admin email confirmation screen.
if ( is_a( $user, 'WP_User' ) && $user->exists() && $user->has_cap( 'manage_options' ) ) {
$admin_email_lifespan = (int) get_option( 'admin_email_lifespan' );
// If `0` (or anything "falsey" as it is cast to int) is returned, the user will not be redirected
// to the admin email confirmation screen.
/** This filter is documented in wp-login.php */
$admin_email_check_interval = (int) apply_filters( 'admin_email_check_interval', 180 * DAY_IN_SECONDS );
if ( $admin_email_check_interval > 0 && time() > $admin_email_lifespan ) {
$redirect_to = add_query_arg( 'action', 'confirm_admin_email', wp_login_url( $redirect_to ) );
}
}
if ( ( empty( $redirect_to ) || $redirect_to === 'wp-admin/' || $redirect_to == admin_url() ) ) {
// 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.
if ( is_multisite() && ! get_active_blog_for_user( $user->ID ) && ! is_super_admin( $user->ID ) ) {
$redirect_to = user_admin_url();
@ -1015,10 +1262,11 @@ switch ( $action ) {
}
wp_redirect( $redirect_to );
exit();
exit;
}
wp_safe_redirect( $redirect_to );
exit();
exit;
}
$errors = $user;
@ -1037,15 +1285,15 @@ switch ( $action ) {
}
} else {
// Some parts of this script use the main login form to display a message.
if ( isset( $_GET['loggedout'] ) && true == $_GET['loggedout'] ) {
if ( isset( $_GET['loggedout'] ) && $_GET['loggedout'] ) {
$errors->add( 'loggedout', __( 'You are now logged out.' ), 'message' );
} elseif ( isset( $_GET['registration'] ) && 'disabled' == $_GET['registration'] ) {
} elseif ( isset( $_GET['registration'] ) && 'disabled' === $_GET['registration'] ) {
$errors->add( 'registerdisabled', __( 'User registration is currently not allowed.' ) );
} elseif ( isset( $_GET['checkemail'] ) && 'confirm' == $_GET['checkemail'] ) {
} elseif ( isset( $_GET['checkemail'] ) && 'confirm' === $_GET['checkemail'] ) {
$errors->add( 'confirm', __( 'Check your email for the confirmation link.' ), 'message' );
} elseif ( isset( $_GET['checkemail'] ) && 'newpass' == $_GET['checkemail'] ) {
} elseif ( isset( $_GET['checkemail'] ) && 'newpass' === $_GET['checkemail'] ) {
$errors->add( 'newpass', __( 'Check your email for your new password.' ), 'message' );
} elseif ( isset( $_GET['checkemail'] ) && 'registered' == $_GET['checkemail'] ) {
} elseif ( isset( $_GET['checkemail'] ) && 'registered' === $_GET['checkemail'] ) {
$errors->add( 'registered', __( 'Registration complete. Please check your email.' ), 'message' );
} elseif ( strpos( $redirect_to, 'about.php?updated' ) ) {
$errors->add( 'updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what&#8217;s new.' ), 'message' );
@ -1072,8 +1320,9 @@ switch ( $action ) {
login_header( __( 'Log In' ), '', $errors );
if ( isset( $_POST['log'] ) ) {
$user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr( wp_unslash( $_POST['log'] ) ) : '';
$user_login = ( 'incorrect_password' === $errors->get_error_code() || 'empty_password' === $errors->get_error_code() ) ? esc_attr( wp_unslash( $_POST['log'] ) ) : '';
}
$rememberme = ! empty( $_POST['rememberme'] );
if ( $errors->has_errors() ) {
@ -1081,6 +1330,7 @@ switch ( $action ) {
} else {
$aria_describedby_error = '';
}
?>
<form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
@ -1093,68 +1343,87 @@ switch ( $action ) {
<input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" size="20" /></label>
</p>
<?php
/**
* Fires following the 'Password' field in the login form.
*
* @since 2.1.0
*/
do_action( 'login_form' );
?>
<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>
<p class="submit">
<input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Log In' ); ?>" />
<?php if ( $interim_login ) { ?>
<?php
if ( $interim_login ) {
?>
<input type="hidden" name="interim-login" value="1" />
<?php } else { ?>
<?php
} else {
?>
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
<?php } ?>
<?php if ( $customize_login ) : ?>
<?php
}
if ( $customize_login ) {
?>
<input type="hidden" name="customize-login" value="1" />
<?php endif; ?>
<?php
}
?>
<input type="hidden" name="testcookie" value="1" />
</p>
</form>
<?php if ( ! $interim_login ) { ?>
<?php
if ( ! $interim_login ) {
?>
<p id="nav">
<?php
if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) :
if ( get_option( 'users_can_register' ) ) :
if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ), true ) ) {
if ( get_option( 'users_can_register' ) ) {
$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
/** This filter is documented in wp-includes/general-template.php */
echo apply_filters( 'register', $registration_url );
echo esc_html( $login_link_separator );
endif;
}
?>
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
<?php endif; ?>
</p>
<?php } ?>
<script type="text/javascript">
function wp_attempt_focus(){
setTimeout( function(){ try{
<?php if ( $user_login ) { ?>
d = document.getElementById('user_pass');
d.value = '';
<?php } else { ?>
d = document.getElementById('user_login');
<?php if ( 'invalid_username' == $errors->get_error_code() ) { ?>
if( d.value != '' )
d.value = '';
<?php
}
}
?>
d.focus();
d.select();
} catch(e){}
}, 200);
</p>
<?php
}
<?php
$login_script = 'function wp_attempt_focus() {';
$login_script .= 'setTimeout( function() {';
$login_script .= 'try {';
if ( $user_login ) {
$login_script .= 'd = document.getElementById( "user_pass" ); d.value = "";';
} else {
$login_script .= 'd = document.getElementById( "user_login" );';
if ( $errors->get_error_code() === 'invalid_username' ) {
$login_script .= 'd.value = "";';
}
}
$login_script .= 'd.focus(); d.select();';
$login_script .= '} catch( er ) {}';
$login_script .= '}, 200);';
$login_script .= "}\n"; // End of wp_attempt_focus().
/**
* Filters whether to print the call to `wp_attempt_focus()` on the login screen.
*
@ -1163,25 +1432,36 @@ switch ( $action ) {
* @param bool $print Whether to print the function call. Default true.
*/
if ( apply_filters( 'enable_login_autofocus', true ) && ! $error ) {
$login_script .= "wp_attempt_focus();\n";
}
// Run `wpOnload()` if defined.
$login_script .= "if ( typeof wpOnload === 'function' ) { wpOnload() }";
?>
wp_attempt_focus();
<?php } ?>
if(typeof wpOnload=='function')wpOnload();
<?php if ( $interim_login ) { ?>
<script type="text/javascript">
<?php echo $login_script; ?>
</script>
<?php
if ( $interim_login ) {
?>
<script type="text/javascript">
( function() {
try {
var i, links = document.getElementsByTagName( 'a' );
for ( i in links ) {
if ( links[i].href )
if ( links[i].href ) {
links[i].target = '_blank';
links[i].rel = 'noreferrer noopener';
}
} catch(e){}
}
} catch( er ) {}
}());
<?php } ?>
</script>
<?php
login_footer();
}
login_footer();
break;
} // End action switch.