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