From fff56d219f13b5bec5a657d4a210954e0da7cebf Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 7 Aug 2019 00:04:56 +0000 Subject: [PATCH] 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 --- wp-admin/css/login-rtl.css | 41 ++ wp-admin/css/login-rtl.min.css | 2 +- wp-admin/css/login.css | 41 ++ wp-admin/css/login.min.css | 2 +- wp-admin/includes/upgrade.php | 17 + wp-admin/options-general.php | 2 +- wp-includes/version.php | 4 +- wp-login.php | 760 ++++++++++++++++++++++----------- 8 files changed, 624 insertions(+), 245 deletions(-) diff --git a/wp-admin/css/login-rtl.css b/wp-admin/css/login-rtl.css index 1b07589c67..dfe5943eff 100644 --- a/wp-admin/css/login-rtl.css +++ b/wp-admin/css/login-rtl.css @@ -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; } diff --git a/wp-admin/css/login-rtl.min.css b/wp-admin/css/login-rtl.min.css index a44f5d058c..4d56a5661e 100644 --- a/wp-admin/css/login-rtl.min.css +++ b/wp-admin/css/login-rtl.min.css @@ -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}} \ No newline at end of file +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}} \ No newline at end of file diff --git a/wp-admin/css/login.css b/wp-admin/css/login.css index fc139f579c..12590f27f4 100644 --- a/wp-admin/css/login.css +++ b/wp-admin/css/login.css @@ -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; } diff --git a/wp-admin/css/login.min.css b/wp-admin/css/login.min.css index 0759227b90..b1d01e1dcf 100644 --- a/wp-admin/css/login.min.css +++ b/wp-admin/css/login.min.css @@ -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}} \ No newline at end of file +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}} \ No newline at end of file diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 281aa68b86..90e10d2f4b 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -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. * diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index 633aa92dc2..fe882b83f7 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -108,7 +108,7 @@ if ( ! is_multisite() ) { - +

The new address will not become active until confirmed.' ); ?>

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() ) { ?>

@@ -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 . "
\n"; } else { $errors .= ' ' . $error_message . "
\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 '
' . apply_filters( 'login_errors', $errors ) . "
\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 ) { ?> -

+

-

- ', '
' ); ?> - +

+ + the_privacy_policy_link( '' ); + } - - - + ?> + ?> + +
@@ -304,13 +322,13 @@ function login_footer( $input_id = '' ) { */ function wp_shake_js() { ?> - + 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 ); + + ?> + +
+ + + +

+ +

+

+ administration email for this website is still correct.' ); ?> + %s', + esc_url( $admin_email_help_url ), + __( 'Why is this important?' ) + ); + + ?> +

+

+ %s' ), + esc_html( $admin_email ) + ); + + ?> +

+

+ + %s', + esc_url( $admin_email_help_url ), + __( 'Learn more.' ) + ); + + ?> +

+ +
+
+ + + +
+
+ 'confirm_admin_email', + 'remind_me_later' => wp_create_nonce( 'remind_me_later_nonce' ), + ), + $remind_me_link + ); + + ?> + +
+
+
+ + HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure ); wp_safe_redirect( wp_get_referer() ); @@ -553,13 +750,14 @@ switch ( $action ) { $redirect_to = $_REQUEST['redirect_to']; $requested_redirect_to = $redirect_to; } else { - $redirect_to = add_query_arg( + $redirect_to = add_query_arg( array( 'loggedout' => 'true', 'wp_lang' => get_user_locale( $user ), ), 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.' ) ); } } @@ -626,56 +826,65 @@ switch ( $action ) { ?> -
-

- -

+ +

+ +

+ + +

+ +

+
+ + - -

- - - - 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; } @@ -723,70 +934,75 @@ switch ( $action ) { login_header( __( 'Reset Password' ), '

' . __( 'Enter your new password below.' ) . '

', $errors ); ?> -
- + + -
-

- -

+
+

+ +

-
-
- - +
+
+ + +
+
+
+
+ +
-
-
-
- -
-
-

-
- -

+

+
+ +

-

-
+

+
+ + +

+ +

+ + + - -

- - - - ' . __( 'Register For This Site' ) . '

', $errors ); - ?> -
-

- -

-

- -

- -

-
- -

-
- + ?> +
+

+ +

+

+ +

+ +

+ +

+
+ +

+ +

+
+ + ' . __( 'You have logged in successfully.' ) . '

'; $interim_login = 'success'; login_header( '', $message ); + ?>
+ + - - - 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', __( 'You have successfully updated WordPress! Please log back in to see what’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,80 +1330,100 @@ switch ( $action ) { } else { $aria_describedby_error = ''; } + ?> -
-

- -

-

- -

- -

-

- - - - - - - - - - -

-
- - -
+

+ +

+

+ +

%s', esc_url( wp_registration_url() ), __( 'Register' ) ); - /** This filter is documented in wp-includes/general-template.php */ - echo apply_filters( 'register', $registration_url ); + /** + * Fires following the 'Password' field in the login form. + * + * @since 2.1.0 + */ + do_action( 'login_form' ); - echo esc_html( $login_link_separator ); - endif; - ?> - - -

- - - + // Run `wpOnload()` if defined. + $login_script .= "if ( typeof wpOnload === 'function' ) { wpOnload() }"; + + ?> + + +