author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
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 |
* |
|
19 | 61 |
* @param string[] $shake_error_codes Error codes that shake the login form. |
0 | 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 |
* |
|
19 | 188 |
* @param string[] $classes An array of body classes. |
189 |
* @param string $action The action that brought the visitor to the login page. |
|
0 | 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 |
|
19 | 315 |
if ( |
316 |
! $interim_login && |
|
317 |
/** |
|
318 |
* Filters the Languages select input activation on the login screen. |
|
319 |
* |
|
320 |
* @since 5.9.0 |
|
321 |
* |
|
322 |
* @param bool Whether to display the Languages select input on the login screen. |
|
323 |
*/ |
|
324 |
apply_filters( 'login_display_language_dropdown', true ) |
|
325 |
) { |
|
326 |
$languages = get_available_languages(); |
|
327 |
||
328 |
if ( ! empty( $languages ) ) { |
|
329 |
?> |
|
330 |
<div class="language-switcher"> |
|
331 |
<form id="language-switcher" action="" method="get"> |
|
332 |
||
333 |
<label for="language-switcher-locales"> |
|
334 |
<span class="dashicons dashicons-translation" aria-hidden="true"></span> |
|
335 |
<span class="screen-reader-text"><?php _e( 'Language' ); ?></span> |
|
336 |
</label> |
|
337 |
||
338 |
<?php |
|
339 |
$args = array( |
|
340 |
'id' => 'language-switcher-locales', |
|
341 |
'name' => 'wp_lang', |
|
342 |
'selected' => determine_locale(), |
|
343 |
'show_available_translations' => false, |
|
344 |
'explicit_option_en_us' => true, |
|
345 |
'languages' => $languages, |
|
346 |
); |
|
347 |
||
348 |
/** |
|
349 |
* Filters default arguments for the Languages select input on the login screen. |
|
350 |
* |
|
351 |
* @since 5.9.0 |
|
352 |
* |
|
353 |
* @param array $args Arguments for the Languages select input on the login screen. |
|
354 |
*/ |
|
355 |
wp_dropdown_languages( apply_filters( 'login_language_dropdown_args', $args ) ); |
|
356 |
?> |
|
357 |
||
358 |
<?php if ( $interim_login ) { ?> |
|
359 |
<input type="hidden" name="interim-login" value="1" /> |
|
360 |
<?php } ?> |
|
361 |
||
362 |
<?php if ( isset( $_GET['redirect_to'] ) && '' !== $_GET['redirect_to'] ) { ?> |
|
363 |
<input type="hidden" name="redirect_to" value="<?php echo esc_url_raw( $_GET['redirect_to'] ); ?>" /> |
|
364 |
<?php } ?> |
|
365 |
||
366 |
<?php if ( isset( $_GET['action'] ) && '' !== $_GET['action'] ) { ?> |
|
367 |
<input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action'] ); ?>" /> |
|
368 |
<?php } ?> |
|
369 |
||
370 |
<input type="submit" class="button" value="<?php esc_attr_e( 'Change' ); ?>"> |
|
371 |
||
372 |
</form> |
|
373 |
</div> |
|
374 |
<?php } ?> |
|
375 |
<?php } ?> |
|
376 |
<?php |
|
16 | 377 |
|
378 |
if ( ! empty( $input_id ) ) { |
|
379 |
?> |
|
380 |
<script type="text/javascript"> |
|
381 |
try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){} |
|
18 | 382 |
if(typeof wpOnload==='function')wpOnload(); |
16 | 383 |
</script> |
384 |
<?php |
|
385 |
} |
|
386 |
||
0 | 387 |
/** |
388 |
* Fires in the login page footer. |
|
389 |
* |
|
390 |
* @since 3.1.0 |
|
391 |
*/ |
|
9 | 392 |
do_action( 'login_footer' ); |
16 | 393 |
|
9 | 394 |
?> |
0 | 395 |
<div class="clear"></div> |
396 |
</body> |
|
397 |
</html> |
|
398 |
<?php |
|
399 |
} |
|
400 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
/** |
18 | 402 |
* Outputs the JavaScript to handle the form shaking on the login page. |
9 | 403 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
* @since 3.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
*/ |
0 | 406 |
function wp_shake_js() { |
9 | 407 |
?> |
16 | 408 |
<script type="text/javascript"> |
409 |
document.querySelector('form').classList.add('shake'); |
|
410 |
</script> |
|
9 | 411 |
<?php |
0 | 412 |
} |
413 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
/** |
18 | 415 |
* Outputs the viewport meta tag for the login page. |
9 | 416 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
* @since 3.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
*/ |
0 | 419 |
function wp_login_viewport_meta() { |
420 |
?> |
|
421 |
<meta name="viewport" content="width=device-width" /> |
|
422 |
<?php |
|
423 |
} |
|
424 |
||
19 | 425 |
/* |
426 |
* Main part: check the request and redirect or display a form based on the current action. |
|
427 |
*/ |
|
0 | 428 |
|
9 | 429 |
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login'; |
0 | 430 |
$errors = new WP_Error(); |
431 |
||
9 | 432 |
if ( isset( $_GET['key'] ) ) { |
0 | 433 |
$action = 'resetpass'; |
9 | 434 |
} |
0 | 435 |
|
16 | 436 |
if ( isset( $_GET['checkemail'] ) ) { |
437 |
$action = 'checkemail'; |
|
438 |
} |
|
439 |
||
440 |
$default_actions = array( |
|
441 |
'confirm_admin_email', |
|
442 |
'postpass', |
|
443 |
'logout', |
|
444 |
'lostpassword', |
|
445 |
'retrievepassword', |
|
446 |
'resetpass', |
|
447 |
'rp', |
|
448 |
'register', |
|
449 |
'checkemail', |
|
450 |
'confirmaction', |
|
451 |
'login', |
|
452 |
WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED, |
|
453 |
); |
|
454 |
||
9 | 455 |
// Validate action so as to default to the login screen. |
16 | 456 |
if ( ! in_array( $action, $default_actions, true ) && false === has_filter( 'login_form_' . $action ) ) { |
0 | 457 |
$action = 'login'; |
9 | 458 |
} |
0 | 459 |
|
460 |
nocache_headers(); |
|
461 |
||
9 | 462 |
header( 'Content-Type: ' . get_bloginfo( 'html_type' ) . '; charset=' . get_bloginfo( 'charset' ) ); |
0 | 463 |
|
16 | 464 |
if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set. |
465 |
if ( isset( $_SERVER['PATH_INFO'] ) && ( $_SERVER['PATH_INFO'] !== $_SERVER['PHP_SELF'] ) ) { |
|
0 | 466 |
$_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] ); |
9 | 467 |
} |
0 | 468 |
|
9 | 469 |
$url = dirname( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ) ); |
16 | 470 |
|
471 |
if ( get_option( 'siteurl' ) !== $url ) { |
|
0 | 472 |
update_option( 'siteurl', $url ); |
9 | 473 |
} |
0 | 474 |
} |
475 |
||
16 | 476 |
// 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
|
477 |
$secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) ); |
5 | 478 |
setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
16 | 479 |
|
480 |
if ( SITECOOKIEPATH !== COOKIEPATH ) { |
|
5 | 481 |
setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure ); |
9 | 482 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
|
19 | 484 |
if ( isset( $_GET['wp_lang'] ) ) { |
485 |
setcookie( 'wp_lang', sanitize_text_field( $_GET['wp_lang'] ), 0, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
486 |
} |
|
487 |
||
0 | 488 |
/** |
489 |
* Fires when the login form is initialized. |
|
490 |
* |
|
491 |
* @since 3.2.0 |
|
492 |
*/ |
|
493 |
do_action( 'login_init' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
494 |
|
0 | 495 |
/** |
496 |
* Fires before a specified login form action. |
|
497 |
* |
|
5 | 498 |
* The dynamic portion of the hook name, `$action`, refers to the action |
18 | 499 |
* that brought the visitor to the login form. |
500 |
* |
|
501 |
* Possible hook names include: |
|
502 |
* |
|
19 | 503 |
* - `login_form_checkemail` |
504 |
* - `login_form_confirm_admin_email` |
|
505 |
* - `login_form_confirmaction` |
|
506 |
* - `login_form_entered_recovery_mode` |
|
507 |
* - `login_form_login` |
|
508 |
* - `login_form_logout` |
|
509 |
* - `login_form_lostpassword` |
|
510 |
* - `login_form_postpass` |
|
511 |
* - `login_form_register` |
|
512 |
* - `login_form_resetpass` |
|
513 |
* - `login_form_retrievepassword` |
|
514 |
* - `login_form_rp` |
|
0 | 515 |
* |
516 |
* @since 2.8.0 |
|
517 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
do_action( "login_form_{$action}" ); |
0 | 519 |
|
16 | 520 |
$http_post = ( 'POST' === $_SERVER['REQUEST_METHOD'] ); |
9 | 521 |
$interim_login = isset( $_REQUEST['interim-login'] ); |
0 | 522 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
523 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
524 |
* Filters the separator used between login form navigation links. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
525 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
526 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
527 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
528 |
* @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
|
529 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
530 |
$login_link_separator = apply_filters( 'login_link_separator', ' | ' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
531 |
|
9 | 532 |
switch ( $action ) { |
0 | 533 |
|
16 | 534 |
case 'confirm_admin_email': |
535 |
/* |
|
536 |
* Note that `is_user_logged_in()` will return false immediately after logging in |
|
537 |
* as the current user is not set, see wp-includes/pluggable.php. |
|
538 |
* However this action runs on a redirect after logging in. |
|
539 |
*/ |
|
540 |
if ( ! is_user_logged_in() ) { |
|
541 |
wp_safe_redirect( wp_login_url() ); |
|
542 |
exit; |
|
543 |
} |
|
544 |
||
545 |
if ( ! empty( $_REQUEST['redirect_to'] ) ) { |
|
546 |
$redirect_to = $_REQUEST['redirect_to']; |
|
547 |
} else { |
|
548 |
$redirect_to = admin_url(); |
|
549 |
} |
|
550 |
||
551 |
if ( current_user_can( 'manage_options' ) ) { |
|
552 |
$admin_email = get_option( 'admin_email' ); |
|
553 |
} else { |
|
554 |
wp_safe_redirect( $redirect_to ); |
|
555 |
exit; |
|
556 |
} |
|
557 |
||
558 |
/** |
|
559 |
* Filters the interval for dismissing the admin email confirmation screen. |
|
560 |
* |
|
561 |
* If `0` (zero) is returned, the "Remind me later" link will not be displayed. |
|
562 |
* |
|
563 |
* @since 5.3.1 |
|
564 |
* |
|
565 |
* @param int $interval Interval time (in seconds). Default is 3 days. |
|
566 |
*/ |
|
567 |
$remind_interval = (int) apply_filters( 'admin_email_remind_interval', 3 * DAY_IN_SECONDS ); |
|
568 |
||
569 |
if ( ! empty( $_GET['remind_me_later'] ) ) { |
|
570 |
if ( ! wp_verify_nonce( $_GET['remind_me_later'], 'remind_me_later_nonce' ) ) { |
|
571 |
wp_safe_redirect( wp_login_url() ); |
|
572 |
exit; |
|
573 |
} |
|
574 |
||
575 |
if ( $remind_interval > 0 ) { |
|
576 |
update_option( 'admin_email_lifespan', time() + $remind_interval ); |
|
577 |
} |
|
578 |
||
579 |
$redirect_to = add_query_arg( 'admin_email_remind_later', 1, $redirect_to ); |
|
580 |
wp_safe_redirect( $redirect_to ); |
|
581 |
exit; |
|
582 |
} |
|
583 |
||
584 |
if ( ! empty( $_POST['correct-admin-email'] ) ) { |
|
585 |
if ( ! check_admin_referer( 'confirm_admin_email', 'confirm_admin_email_nonce' ) ) { |
|
586 |
wp_safe_redirect( wp_login_url() ); |
|
587 |
exit; |
|
588 |
} |
|
589 |
||
590 |
/** |
|
591 |
* Filters the interval for redirecting the user to the admin email confirmation screen. |
|
592 |
* |
|
593 |
* If `0` (zero) is returned, the user will not be redirected. |
|
594 |
* |
|
595 |
* @since 5.3.0 |
|
596 |
* |
|
597 |
* @param int $interval Interval time (in seconds). Default is 6 months. |
|
598 |
*/ |
|
599 |
$admin_email_check_interval = (int) apply_filters( 'admin_email_check_interval', 6 * MONTH_IN_SECONDS ); |
|
600 |
||
601 |
if ( $admin_email_check_interval > 0 ) { |
|
602 |
update_option( 'admin_email_lifespan', time() + $admin_email_check_interval ); |
|
603 |
} |
|
604 |
||
605 |
wp_safe_redirect( $redirect_to ); |
|
606 |
exit; |
|
607 |
} |
|
608 |
||
609 |
login_header( __( 'Confirm your administration email' ), '', $errors ); |
|
610 |
||
611 |
/** |
|
612 |
* Fires before the admin email confirm form. |
|
613 |
* |
|
614 |
* @since 5.3.0 |
|
615 |
* |
|
616 |
* @param WP_Error $errors A `WP_Error` object containing any errors generated by using invalid |
|
617 |
* credentials. Note that the error object may not contain any errors. |
|
618 |
*/ |
|
619 |
do_action( 'admin_email_confirm', $errors ); |
|
620 |
||
621 |
?> |
|
622 |
||
623 |
<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"> |
|
624 |
<?php |
|
625 |
/** |
|
626 |
* Fires inside the admin-email-confirm-form form tags, before the hidden fields. |
|
627 |
* |
|
628 |
* @since 5.3.0 |
|
629 |
*/ |
|
630 |
do_action( 'admin_email_confirm_form' ); |
|
631 |
||
632 |
wp_nonce_field( 'confirm_admin_email', 'confirm_admin_email_nonce' ); |
|
633 |
||
634 |
?> |
|
635 |
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
|
636 |
||
637 |
<h1 class="admin-email__heading"> |
|
638 |
<?php _e( 'Administration email verification' ); ?> |
|
639 |
</h1> |
|
640 |
<p class="admin-email__details"> |
|
641 |
<?php _e( 'Please verify that the <strong>administration email</strong> for this website is still correct.' ); ?> |
|
642 |
<?php |
|
643 |
||
644 |
/* translators: URL to the WordPress help section about admin email. */ |
|
645 |
$admin_email_help_url = __( 'https://wordpress.org/support/article/settings-general-screen/#email-address' ); |
|
646 |
||
18 | 647 |
/* translators: Accessibility text. */ |
16 | 648 |
$accessibility_text = sprintf( '<span class="screen-reader-text"> %s</span>', __( '(opens in a new tab)' ) ); |
649 |
||
650 |
printf( |
|
18 | 651 |
'<a href="%s" rel="noopener" target="_blank">%s%s</a>', |
16 | 652 |
esc_url( $admin_email_help_url ), |
653 |
__( 'Why is this important?' ), |
|
654 |
$accessibility_text |
|
655 |
); |
|
656 |
||
657 |
?> |
|
658 |
</p> |
|
659 |
<p class="admin-email__details"> |
|
660 |
<?php |
|
661 |
||
662 |
printf( |
|
663 |
/* translators: %s: Admin email address. */ |
|
664 |
__( 'Current administration email: %s' ), |
|
665 |
'<strong>' . esc_html( $admin_email ) . '</strong>' |
|
666 |
); |
|
667 |
||
668 |
?> |
|
669 |
</p> |
|
670 |
<p class="admin-email__details"> |
|
671 |
<?php _e( 'This email may be different from your personal email address.' ); ?> |
|
672 |
</p> |
|
673 |
||
674 |
<div class="admin-email__actions"> |
|
675 |
<div class="admin-email__actions-primary"> |
|
676 |
<?php |
|
677 |
||
678 |
$change_link = admin_url( 'options-general.php' ); |
|
679 |
$change_link = add_query_arg( 'highlight', 'confirm_admin_email', $change_link ); |
|
680 |
||
681 |
?> |
|
682 |
<a class="button button-large" href="<?php echo esc_url( $change_link ); ?>"><?php _e( 'Update' ); ?></a> |
|
683 |
<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' ); ?>" /> |
|
684 |
</div> |
|
685 |
<?php if ( $remind_interval > 0 ) : ?> |
|
686 |
<div class="admin-email__actions-secondary"> |
|
687 |
<?php |
|
688 |
||
689 |
$remind_me_link = wp_login_url( $redirect_to ); |
|
690 |
$remind_me_link = add_query_arg( |
|
691 |
array( |
|
692 |
'action' => 'confirm_admin_email', |
|
693 |
'remind_me_later' => wp_create_nonce( 'remind_me_later_nonce' ), |
|
694 |
), |
|
695 |
$remind_me_link |
|
696 |
); |
|
697 |
||
698 |
?> |
|
699 |
<a href="<?php echo esc_url( $remind_me_link ); ?>"><?php _e( 'Remind me later' ); ?></a> |
|
700 |
</div> |
|
701 |
<?php endif; ?> |
|
702 |
</div> |
|
703 |
</form> |
|
704 |
||
705 |
<?php |
|
706 |
||
707 |
login_footer(); |
|
708 |
break; |
|
709 |
||
9 | 710 |
case 'postpass': |
711 |
if ( ! array_key_exists( 'post_password', $_POST ) ) { |
|
712 |
wp_safe_redirect( wp_get_referer() ); |
|
16 | 713 |
exit; |
0 | 714 |
} |
9 | 715 |
|
716 |
require_once ABSPATH . WPINC . '/class-phpass.php'; |
|
717 |
$hasher = new PasswordHash( 8, true ); |
|
0 | 718 |
|
9 | 719 |
/** |
720 |
* Filters the life span of the post password cookie. |
|
721 |
* |
|
722 |
* By default, the cookie expires 10 days from creation. To turn this |
|
723 |
* into a session cookie, return 0. |
|
724 |
* |
|
725 |
* @since 3.7.0 |
|
726 |
* |
|
727 |
* @param int $expires The expiry time, as passed to setcookie(). |
|
728 |
*/ |
|
729 |
$expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS ); |
|
730 |
$referer = wp_get_referer(); |
|
16 | 731 |
|
9 | 732 |
if ( $referer ) { |
733 |
$secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) ); |
|
734 |
} else { |
|
735 |
$secure = false; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
736 |
} |
16 | 737 |
|
9 | 738 |
setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
739 |
||
740 |
wp_safe_redirect( wp_get_referer() ); |
|
16 | 741 |
exit; |
9 | 742 |
|
743 |
case 'logout': |
|
744 |
check_admin_referer( 'log-out' ); |
|
745 |
||
746 |
$user = wp_get_current_user(); |
|
747 |
||
748 |
wp_logout(); |
|
749 |
||
750 |
if ( ! empty( $_REQUEST['redirect_to'] ) ) { |
|
16 | 751 |
$redirect_to = $_REQUEST['redirect_to']; |
752 |
$requested_redirect_to = $redirect_to; |
|
9 | 753 |
} else { |
16 | 754 |
$redirect_to = add_query_arg( |
755 |
array( |
|
756 |
'loggedout' => 'true', |
|
757 |
'wp_lang' => get_user_locale( $user ), |
|
758 |
), |
|
759 |
wp_login_url() |
|
760 |
); |
|
761 |
||
9 | 762 |
$requested_redirect_to = ''; |
763 |
} |
|
0 | 764 |
|
9 | 765 |
/** |
766 |
* Filters the log out redirect URL. |
|
767 |
* |
|
768 |
* @since 4.2.0 |
|
769 |
* |
|
770 |
* @param string $redirect_to The redirect destination URL. |
|
771 |
* @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
|
772 |
* @param WP_User $user The WP_User object for the user that's logging out. |
|
773 |
*/ |
|
774 |
$redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user ); |
|
16 | 775 |
|
9 | 776 |
wp_safe_redirect( $redirect_to ); |
16 | 777 |
exit; |
9 | 778 |
|
779 |
case 'lostpassword': |
|
780 |
case 'retrievepassword': |
|
781 |
if ( $http_post ) { |
|
782 |
$errors = retrieve_password(); |
|
16 | 783 |
|
9 | 784 |
if ( ! is_wp_error( $errors ) ) { |
785 |
$redirect_to = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; |
|
786 |
wp_safe_redirect( $redirect_to ); |
|
16 | 787 |
exit; |
9 | 788 |
} |
789 |
} |
|
790 |
||
791 |
if ( isset( $_GET['error'] ) ) { |
|
16 | 792 |
if ( 'invalidkey' === $_GET['error'] ) { |
18 | 793 |
$errors->add( 'invalidkey', __( '<strong>Error</strong>: Your password reset link appears to be invalid. Please request a new link below.' ) ); |
16 | 794 |
} elseif ( 'expiredkey' === $_GET['error'] ) { |
18 | 795 |
$errors->add( 'expiredkey', __( '<strong>Error</strong>: Your password reset link has expired. Please request a new link below.' ) ); |
9 | 796 |
} |
797 |
} |
|
0 | 798 |
|
9 | 799 |
$lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
800 |
/** |
|
801 |
* Filters the URL redirected to after submitting the lostpassword/retrievepassword form. |
|
802 |
* |
|
803 |
* @since 3.0.0 |
|
804 |
* |
|
805 |
* @param string $lostpassword_redirect The redirect destination URL. |
|
806 |
*/ |
|
807 |
$redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect ); |
|
0 | 808 |
|
9 | 809 |
/** |
810 |
* Fires before the lost password form. |
|
811 |
* |
|
812 |
* @since 1.5.1 |
|
813 |
* @since 5.1.0 Added the `$errors` parameter. |
|
814 |
* |
|
815 |
* @param WP_Error $errors A `WP_Error` object containing any errors generated by using invalid |
|
816 |
* credentials. Note that the error object may not contain any errors. |
|
817 |
*/ |
|
818 |
do_action( 'lost_password', $errors ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
819 |
|
16 | 820 |
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 | 821 |
|
822 |
$user_login = ''; |
|
0 | 823 |
|
9 | 824 |
if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) { |
825 |
$user_login = wp_unslash( $_POST['user_login'] ); |
|
826 |
} |
|
0 | 827 |
|
9 | 828 |
?> |
829 |
||
16 | 830 |
<form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post"> |
831 |
<p> |
|
832 |
<label for="user_login"><?php _e( 'Username or Email Address' ); ?></label> |
|
19 | 833 |
<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" autocomplete="username" /> |
16 | 834 |
</p> |
835 |
<?php |
|
836 |
||
837 |
/** |
|
838 |
* Fires inside the lostpassword form tags, before the hidden fields. |
|
839 |
* |
|
840 |
* @since 2.1.0 |
|
841 |
*/ |
|
842 |
do_action( 'lostpassword_form' ); |
|
0 | 843 |
|
16 | 844 |
?> |
845 |
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
|
846 |
<p class="submit"> |
|
847 |
<input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Get New Password' ); ?>" /> |
|
848 |
</p> |
|
849 |
</form> |
|
5 | 850 |
|
16 | 851 |
<p id="nav"> |
852 |
<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
|
853 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
854 |
|
16 | 855 |
if ( get_option( 'users_can_register' ) ) { |
856 |
$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
|
857 |
||
858 |
echo esc_html( $login_link_separator ); |
|
0 | 859 |
|
16 | 860 |
/** This filter is documented in wp-includes/general-template.php */ |
861 |
echo apply_filters( 'register', $registration_url ); |
|
862 |
} |
|
863 |
||
864 |
?> |
|
865 |
</p> |
|
9 | 866 |
<?php |
16 | 867 |
|
9 | 868 |
login_footer( 'user_login' ); |
869 |
break; |
|
0 | 870 |
|
9 | 871 |
case 'resetpass': |
872 |
case 'rp': |
|
873 |
list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ); |
|
874 |
$rp_cookie = 'wp-resetpass-' . COOKIEHASH; |
|
16 | 875 |
|
18 | 876 |
if ( isset( $_GET['key'] ) && isset( $_GET['login'] ) ) { |
9 | 877 |
$value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) ); |
878 |
setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
16 | 879 |
|
9 | 880 |
wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) ); |
881 |
exit; |
|
882 |
} |
|
0 | 883 |
|
9 | 884 |
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) { |
885 |
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 ); |
|
16 | 886 |
|
887 |
$user = check_password_reset_key( $rp_key, $rp_login ); |
|
888 |
||
9 | 889 |
if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) { |
890 |
$user = false; |
|
891 |
} |
|
892 |
} else { |
|
5 | 893 |
$user = false; |
894 |
} |
|
895 |
||
9 | 896 |
if ( ! $user || is_wp_error( $user ) ) { |
897 |
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
16 | 898 |
|
9 | 899 |
if ( $user && $user->get_error_code() === 'expired_key' ) { |
900 |
wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); |
|
901 |
} else { |
|
902 |
wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); |
|
903 |
} |
|
16 | 904 |
|
9 | 905 |
exit; |
906 |
} |
|
0 | 907 |
|
9 | 908 |
$errors = new WP_Error(); |
0 | 909 |
|
19 | 910 |
// Check if password is one or all empty spaces. |
911 |
if ( ! empty( $_POST['pass1'] ) ) { |
|
912 |
$_POST['pass1'] = trim( $_POST['pass1'] ); |
|
913 |
||
914 |
if ( empty( $_POST['pass1'] ) ) { |
|
915 |
$errors->add( 'password_reset_empty_space', __( 'The password cannot be a space or all spaces.' ) ); |
|
916 |
} |
|
917 |
} |
|
918 |
||
919 |
// Check if password fields do not match. |
|
920 |
if ( ! empty( $_POST['pass1'] ) && trim( $_POST['pass2'] ) !== $_POST['pass1'] ) { |
|
18 | 921 |
$errors->add( 'password_reset_mismatch', __( '<strong>Error</strong>: The passwords do not match.' ) ); |
9 | 922 |
} |
0 | 923 |
|
9 | 924 |
/** |
925 |
* Fires before the password reset procedure is validated. |
|
926 |
* |
|
927 |
* @since 3.5.0 |
|
928 |
* |
|
16 | 929 |
* @param WP_Error $errors WP Error object. |
9 | 930 |
* @param WP_User|WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise. |
931 |
*/ |
|
932 |
do_action( 'validate_password_reset', $errors, $user ); |
|
0 | 933 |
|
9 | 934 |
if ( ( ! $errors->has_errors() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) { |
935 |
reset_password( $user, $_POST['pass1'] ); |
|
936 |
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
937 |
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>' ); |
|
938 |
login_footer(); |
|
939 |
exit; |
|
940 |
} |
|
0 | 941 |
|
9 | 942 |
wp_enqueue_script( 'utils' ); |
943 |
wp_enqueue_script( 'user-profile' ); |
|
0 | 944 |
|
18 | 945 |
login_header( __( 'Reset Password' ), '<p class="message reset-pass">' . __( 'Enter your new password below or generate one.' ) . '</p>', $errors ); |
0 | 946 |
|
9 | 947 |
?> |
16 | 948 |
<form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off"> |
949 |
<input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" /> |
|
950 |
||
951 |
<div class="user-pass1-wrap"> |
|
952 |
<p> |
|
953 |
<label for="pass1"><?php _e( 'New password' ); ?></label> |
|
954 |
</p> |
|
0 | 955 |
|
16 | 956 |
<div class="wp-pwd"> |
19 | 957 |
<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="new-password" aria-describedby="pass-strength-result" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
958 |
|
16 | 959 |
<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' ); ?>"> |
960 |
<span class="dashicons dashicons-hidden" aria-hidden="true"></span> |
|
961 |
</button> |
|
962 |
<div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></div> |
|
963 |
</div> |
|
964 |
<div class="pw-weak"> |
|
965 |
<input type="checkbox" name="pw_weak" id="pw-weak" class="pw-checkbox" /> |
|
966 |
<label for="pw-weak"><?php _e( 'Confirm use of weak password' ); ?></label> |
|
967 |
</div> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
968 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
969 |
|
16 | 970 |
<p class="user-pass2-wrap"> |
971 |
<label for="pass2"><?php _e( 'Confirm new password' ); ?></label> |
|
19 | 972 |
<input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="new-password" /> |
16 | 973 |
</p> |
974 |
||
975 |
<p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p> |
|
976 |
<br class="clear" /> |
|
977 |
||
978 |
<?php |
|
0 | 979 |
|
16 | 980 |
/** |
981 |
* Fires following the 'Strength indicator' meter in the user password reset form. |
|
982 |
* |
|
983 |
* @since 3.9.0 |
|
984 |
* |
|
985 |
* @param WP_User $user User object of the user whose password is being reset. |
|
986 |
*/ |
|
987 |
do_action( 'resetpass_form', $user ); |
|
0 | 988 |
|
16 | 989 |
?> |
990 |
<input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" /> |
|
18 | 991 |
<p class="submit reset-pass-submit"> |
19 | 992 |
<button type="button" class="button wp-generate-pw hide-if-no-js skip-aria-expanded"><?php _e( 'Generate Password' ); ?></button> |
18 | 993 |
<input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Save Password' ); ?>" /> |
16 | 994 |
</p> |
995 |
</form> |
|
9 | 996 |
|
16 | 997 |
<p id="nav"> |
998 |
<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
|
999 |
<?php |
|
9 | 1000 |
|
16 | 1001 |
if ( get_option( 'users_can_register' ) ) { |
1002 |
$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
|
1003 |
||
1004 |
echo esc_html( $login_link_separator ); |
|
0 | 1005 |
|
16 | 1006 |
/** This filter is documented in wp-includes/general-template.php */ |
1007 |
echo apply_filters( 'register', $registration_url ); |
|
1008 |
} |
|
9 | 1009 |
|
16 | 1010 |
?> |
1011 |
</p> |
|
9 | 1012 |
<?php |
16 | 1013 |
|
19 | 1014 |
login_footer( 'pass1' ); |
9 | 1015 |
break; |
5 | 1016 |
|
9 | 1017 |
case 'register': |
1018 |
if ( is_multisite() ) { |
|
1019 |
/** |
|
1020 |
* Filters the Multisite sign up URL. |
|
1021 |
* |
|
1022 |
* @since 3.0.0 |
|
1023 |
* |
|
1024 |
* @param string $sign_up_url The sign up URL. |
|
1025 |
*/ |
|
1026 |
wp_redirect( apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ) ); |
|
1027 |
exit; |
|
1028 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1029 |
|
9 | 1030 |
if ( ! get_option( 'users_can_register' ) ) { |
1031 |
wp_redirect( site_url( 'wp-login.php?registration=disabled' ) ); |
|
16 | 1032 |
exit; |
9 | 1033 |
} |
0 | 1034 |
|
9 | 1035 |
$user_login = ''; |
1036 |
$user_email = ''; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1037 |
|
9 | 1038 |
if ( $http_post ) { |
1039 |
if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) { |
|
16 | 1040 |
$user_login = wp_unslash( $_POST['user_login'] ); |
9 | 1041 |
} |
1042 |
||
1043 |
if ( isset( $_POST['user_email'] ) && is_string( $_POST['user_email'] ) ) { |
|
1044 |
$user_email = wp_unslash( $_POST['user_email'] ); |
|
1045 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1046 |
|
9 | 1047 |
$errors = register_new_user( $user_login, $user_email ); |
16 | 1048 |
|
9 | 1049 |
if ( ! is_wp_error( $errors ) ) { |
1050 |
$redirect_to = ! empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered'; |
|
1051 |
wp_safe_redirect( $redirect_to ); |
|
16 | 1052 |
exit; |
9 | 1053 |
} |
1054 |
} |
|
0 | 1055 |
|
9 | 1056 |
$registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
16 | 1057 |
|
0 | 1058 |
/** |
9 | 1059 |
* Filters the registration redirect URL. |
0 | 1060 |
* |
1061 |
* @since 3.0.0 |
|
19 | 1062 |
* @since 5.9.0 Added the `$errors` parameter. |
0 | 1063 |
* |
19 | 1064 |
* @param string $registration_redirect The redirect destination URL. |
1065 |
* @param int|WP_Error $errors User id if registration was successful, |
|
1066 |
* WP_Error object otherwise. |
|
0 | 1067 |
*/ |
19 | 1068 |
$redirect_to = apply_filters( 'registration_redirect', $registration_redirect, $errors ); |
16 | 1069 |
|
9 | 1070 |
login_header( __( 'Registration Form' ), '<p class="message register">' . __( 'Register For This Site' ) . '</p>', $errors ); |
16 | 1071 |
|
9 | 1072 |
?> |
16 | 1073 |
<form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate"> |
1074 |
<p> |
|
1075 |
<label for="user_login"><?php _e( 'Username' ); ?></label> |
|
19 | 1076 |
<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( wp_unslash( $user_login ) ); ?>" size="20" autocapitalize="off" autocomplete="username" /> |
16 | 1077 |
</p> |
1078 |
<p> |
|
1079 |
<label for="user_email"><?php _e( 'Email' ); ?></label> |
|
19 | 1080 |
<input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" autocomplete="email" /> |
16 | 1081 |
</p> |
1082 |
<?php |
|
1083 |
||
1084 |
/** |
|
1085 |
* Fires following the 'Email' field in the user registration form. |
|
1086 |
* |
|
1087 |
* @since 2.1.0 |
|
1088 |
*/ |
|
1089 |
do_action( 'register_form' ); |
|
1090 |
||
1091 |
?> |
|
1092 |
<p id="reg_passmail"> |
|
1093 |
<?php _e( 'Registration confirmation will be emailed to you.' ); ?> |
|
1094 |
</p> |
|
1095 |
<br class="clear" /> |
|
1096 |
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
|
1097 |
<p class="submit"> |
|
1098 |
<input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Register' ); ?>" /> |
|
1099 |
</p> |
|
1100 |
</form> |
|
1101 |
||
1102 |
<p id="nav"> |
|
1103 |
<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
|
1104 |
<?php echo esc_html( $login_link_separator ); ?> |
|
1105 |
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a> |
|
1106 |
</p> |
|
9 | 1107 |
<?php |
16 | 1108 |
|
1109 |
login_footer( 'user_login' ); |
|
1110 |
break; |
|
1111 |
||
1112 |
case 'checkemail': |
|
1113 |
$redirect_to = admin_url(); |
|
1114 |
$errors = new WP_Error(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1115 |
|
16 | 1116 |
if ( 'confirm' === $_GET['checkemail'] ) { |
1117 |
$errors->add( |
|
1118 |
'confirm', |
|
1119 |
sprintf( |
|
1120 |
/* translators: %s: Link to the login page. */ |
|
1121 |
__( 'Check your email for the confirmation link, then visit the <a href="%s">login page</a>.' ), |
|
1122 |
wp_login_url() |
|
1123 |
), |
|
1124 |
'message' |
|
1125 |
); |
|
1126 |
} elseif ( 'registered' === $_GET['checkemail'] ) { |
|
1127 |
$errors->add( |
|
1128 |
'registered', |
|
1129 |
sprintf( |
|
1130 |
/* translators: %s: Link to the login page. */ |
|
1131 |
__( 'Registration complete. Please check your email, then visit the <a href="%s">login page</a>.' ), |
|
1132 |
wp_login_url() |
|
1133 |
), |
|
1134 |
'message' |
|
1135 |
); |
|
1136 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1137 |
|
16 | 1138 |
/** This action is documented in wp-login.php */ |
1139 |
$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
|
1140 |
|
16 | 1141 |
login_header( __( 'Check your email' ), '', $errors ); |
1142 |
login_footer(); |
|
9 | 1143 |
break; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1144 |
|
9 | 1145 |
case 'confirmaction': |
1146 |
if ( ! isset( $_GET['request_id'] ) ) { |
|
1147 |
wp_die( __( 'Missing request ID.' ) ); |
|
1148 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1149 |
|
9 | 1150 |
if ( ! isset( $_GET['confirm_key'] ) ) { |
1151 |
wp_die( __( 'Missing confirm key.' ) ); |
|
1152 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1153 |
|
9 | 1154 |
$request_id = (int) $_GET['request_id']; |
1155 |
$key = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) ); |
|
1156 |
$result = wp_validate_user_request_key( $request_id, $key ); |
|
0 | 1157 |
|
9 | 1158 |
if ( is_wp_error( $result ) ) { |
1159 |
wp_die( $result ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1160 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1161 |
|
9 | 1162 |
/** |
1163 |
* Fires an action hook when the account action has been confirmed by the user. |
|
1164 |
* |
|
1165 |
* Using this you can assume the user has agreed to perform the action by |
|
1166 |
* clicking on the link in the confirmation email. |
|
1167 |
* |
|
1168 |
* After firing this action hook the page will redirect to wp-login a callback |
|
1169 |
* redirects or exits first. |
|
1170 |
* |
|
1171 |
* @since 4.9.6 |
|
1172 |
* |
|
1173 |
* @param int $request_id Request ID. |
|
1174 |
*/ |
|
1175 |
do_action( 'user_request_action_confirmed', $request_id ); |
|
1176 |
||
1177 |
$message = _wp_privacy_account_request_confirmed_message( $request_id ); |
|
1178 |
||
1179 |
login_header( __( 'User action confirmed.' ), $message ); |
|
1180 |
login_footer(); |
|
1181 |
exit; |
|
1182 |
||
1183 |
case 'login': |
|
1184 |
default: |
|
1185 |
$secure_cookie = ''; |
|
1186 |
$customize_login = isset( $_REQUEST['customize-login'] ); |
|
16 | 1187 |
|
9 | 1188 |
if ( $customize_login ) { |
1189 |
wp_enqueue_script( 'customize-base' ); |
|
1190 |
} |
|
1191 |
||
1192 |
// If the user wants SSL but the session is not SSL, force a secure cookie. |
|
1193 |
if ( ! empty( $_POST['log'] ) && ! force_ssl_admin() ) { |
|
16 | 1194 |
$user_name = sanitize_user( wp_unslash( $_POST['log'] ) ); |
9 | 1195 |
$user = get_user_by( 'login', $user_name ); |
1196 |
||
1197 |
if ( ! $user && strpos( $user_name, '@' ) ) { |
|
1198 |
$user = get_user_by( 'email', $user_name ); |
|
1199 |
} |
|
1200 |
||
1201 |
if ( $user ) { |
|
1202 |
if ( get_user_option( 'use_ssl', $user->ID ) ) { |
|
1203 |
$secure_cookie = true; |
|
1204 |
force_ssl_admin( true ); |
|
1205 |
} |
|
1206 |
} |
|
1207 |
} |
|
1208 |
||
1209 |
if ( isset( $_REQUEST['redirect_to'] ) ) { |
|
1210 |
$redirect_to = $_REQUEST['redirect_to']; |
|
1211 |
// Redirect to HTTPS if user wants SSL. |
|
1212 |
if ( $secure_cookie && false !== strpos( $redirect_to, 'wp-admin' ) ) { |
|
1213 |
$redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to ); |
|
1214 |
} |
|
1215 |
} else { |
|
1216 |
$redirect_to = admin_url(); |
|
1217 |
} |
|
1218 |
||
1219 |
$reauth = empty( $_REQUEST['reauth'] ) ? false : true; |
|
1220 |
||
1221 |
$user = wp_signon( array(), $secure_cookie ); |
|
1222 |
||
1223 |
if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) { |
|
1224 |
if ( headers_sent() ) { |
|
1225 |
$user = new WP_Error( |
|
1226 |
'test_cookie', |
|
1227 |
sprintf( |
|
16 | 1228 |
/* translators: 1: Browser cookie documentation URL, 2: Support forums URL. */ |
1229 |
__( '<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 | 1230 |
__( 'https://wordpress.org/support/article/cookies/' ), |
16 | 1231 |
__( 'https://wordpress.org/support/forums/' ) |
9 | 1232 |
) |
1233 |
); |
|
1234 |
} elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { |
|
16 | 1235 |
// If cookies are disabled, we can't log in even with a valid user and password. |
9 | 1236 |
$user = new WP_Error( |
1237 |
'test_cookie', |
|
1238 |
sprintf( |
|
16 | 1239 |
/* translators: %s: Browser cookie documentation URL. */ |
1240 |
__( '<strong>Error</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ), |
|
9 | 1241 |
__( 'https://wordpress.org/support/article/cookies/#enable-cookies-in-your-browser' ) |
1242 |
) |
|
1243 |
); |
|
0 | 1244 |
} |
1245 |
} |
|
1246 |
||
9 | 1247 |
$requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
1248 |
/** |
|
1249 |
* Filters the login redirect URL. |
|
1250 |
* |
|
1251 |
* @since 3.0.0 |
|
1252 |
* |
|
1253 |
* @param string $redirect_to The redirect destination URL. |
|
1254 |
* @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
|
1255 |
* @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
|
1256 |
*/ |
|
1257 |
$redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user ); |
|
0 | 1258 |
|
9 | 1259 |
if ( ! is_wp_error( $user ) && ! $reauth ) { |
1260 |
if ( $interim_login ) { |
|
1261 |
$message = '<p class="message">' . __( 'You have logged in successfully.' ) . '</p>'; |
|
1262 |
$interim_login = 'success'; |
|
1263 |
login_header( '', $message ); |
|
16 | 1264 |
|
9 | 1265 |
?> |
1266 |
</div> |
|
1267 |
<?php |
|
16 | 1268 |
|
9 | 1269 |
/** This action is documented in wp-login.php */ |
1270 |
do_action( 'login_footer' ); |
|
16 | 1271 |
|
1272 |
if ( $customize_login ) { |
|
1273 |
?> |
|
1274 |
<script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> |
|
1275 |
<?php |
|
1276 |
} |
|
1277 |
||
9 | 1278 |
?> |
1279 |
</body></html> |
|
1280 |
<?php |
|
16 | 1281 |
|
9 | 1282 |
exit; |
1283 |
} |
|
1284 |
||
16 | 1285 |
// Check if it is time to add a redirect to the admin email confirmation screen. |
1286 |
if ( is_a( $user, 'WP_User' ) && $user->exists() && $user->has_cap( 'manage_options' ) ) { |
|
1287 |
$admin_email_lifespan = (int) get_option( 'admin_email_lifespan' ); |
|
1288 |
||
19 | 1289 |
/* |
1290 |
* If `0` (or anything "falsey" as it is cast to int) is returned, the user will not be redirected |
|
1291 |
* to the admin email confirmation screen. |
|
1292 |
*/ |
|
16 | 1293 |
/** This filter is documented in wp-login.php */ |
1294 |
$admin_email_check_interval = (int) apply_filters( 'admin_email_check_interval', 6 * MONTH_IN_SECONDS ); |
|
1295 |
||
1296 |
if ( $admin_email_check_interval > 0 && time() > $admin_email_lifespan ) { |
|
1297 |
$redirect_to = add_query_arg( |
|
1298 |
array( |
|
1299 |
'action' => 'confirm_admin_email', |
|
1300 |
'wp_lang' => get_user_locale( $user ), |
|
1301 |
), |
|
1302 |
wp_login_url( $redirect_to ) |
|
1303 |
); |
|
1304 |
} |
|
1305 |
} |
|
1306 |
||
1307 |
if ( ( empty( $redirect_to ) || 'wp-admin/' === $redirect_to || admin_url() === $redirect_to ) ) { |
|
9 | 1308 |
// 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. |
1309 |
if ( is_multisite() && ! get_active_blog_for_user( $user->ID ) && ! is_super_admin( $user->ID ) ) { |
|
1310 |
$redirect_to = user_admin_url(); |
|
1311 |
} elseif ( is_multisite() && ! $user->has_cap( 'read' ) ) { |
|
1312 |
$redirect_to = get_dashboard_url( $user->ID ); |
|
1313 |
} elseif ( ! $user->has_cap( 'edit_posts' ) ) { |
|
1314 |
$redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url(); |
|
1315 |
} |
|
1316 |
||
1317 |
wp_redirect( $redirect_to ); |
|
16 | 1318 |
exit; |
9 | 1319 |
} |
16 | 1320 |
|
9 | 1321 |
wp_safe_redirect( $redirect_to ); |
16 | 1322 |
exit; |
9 | 1323 |
} |
1324 |
||
1325 |
$errors = $user; |
|
1326 |
// Clear errors if loggedout is set. |
|
1327 |
if ( ! empty( $_GET['loggedout'] ) || $reauth ) { |
|
1328 |
$errors = new WP_Error(); |
|
0 | 1329 |
} |
1330 |
||
9 | 1331 |
if ( empty( $_POST ) && $errors->get_error_codes() === array( 'empty_username', 'empty_password' ) ) { |
1332 |
$errors = new WP_Error( '', '' ); |
|
1333 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1334 |
|
9 | 1335 |
if ( $interim_login ) { |
1336 |
if ( ! $errors->has_errors() ) { |
|
1337 |
$errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' ); |
|
1338 |
} |
|
1339 |
} else { |
|
1340 |
// Some parts of this script use the main login form to display a message. |
|
16 | 1341 |
if ( isset( $_GET['loggedout'] ) && $_GET['loggedout'] ) { |
9 | 1342 |
$errors->add( 'loggedout', __( 'You are now logged out.' ), 'message' ); |
16 | 1343 |
} elseif ( isset( $_GET['registration'] ) && 'disabled' === $_GET['registration'] ) { |
18 | 1344 |
$errors->add( 'registerdisabled', __( '<strong>Error</strong>: User registration is currently not allowed.' ) ); |
9 | 1345 |
} elseif ( strpos( $redirect_to, 'about.php?updated' ) ) { |
1346 |
$errors->add( 'updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); |
|
1347 |
} elseif ( WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED === $action ) { |
|
1348 |
$errors->add( 'enter_recovery_mode', __( 'Recovery Mode Initialized. Please log in to continue.' ), 'message' ); |
|
18 | 1349 |
} elseif ( isset( $_GET['redirect_to'] ) && false !== strpos( $_GET['redirect_to'], 'wp-admin/authorize-application.php' ) ) { |
1350 |
$query_component = wp_parse_url( $_GET['redirect_to'], PHP_URL_QUERY ); |
|
19 | 1351 |
$query = array(); |
1352 |
if ( $query_component ) { |
|
1353 |
parse_str( $query_component, $query ); |
|
1354 |
} |
|
18 | 1355 |
|
1356 |
if ( ! empty( $query['app_name'] ) ) { |
|
1357 |
/* translators: 1: Website name, 2: Application name. */ |
|
1358 |
$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>' ); |
|
1359 |
} else { |
|
1360 |
/* translators: %s: Website name. */ |
|
1361 |
$message = sprintf( 'Please log in to %s to proceed with authorization.', get_bloginfo( 'name', 'display' ) ); |
|
1362 |
} |
|
1363 |
||
1364 |
$errors->add( 'authorize_application', $message, 'message' ); |
|
9 | 1365 |
} |
0 | 1366 |
} |
1367 |
||
9 | 1368 |
/** |
1369 |
* Filters the login page errors. |
|
1370 |
* |
|
1371 |
* @since 3.6.0 |
|
1372 |
* |
|
16 | 1373 |
* @param WP_Error $errors WP Error object. |
1374 |
* @param string $redirect_to Redirect destination URL. |
|
9 | 1375 |
*/ |
1376 |
$errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); |
|
1377 |
||
1378 |
// Clear any stale cookies. |
|
1379 |
if ( $reauth ) { |
|
1380 |
wp_clear_auth_cookie(); |
|
1381 |
} |
|
0 | 1382 |
|
9 | 1383 |
login_header( __( 'Log In' ), '', $errors ); |
0 | 1384 |
|
9 | 1385 |
if ( isset( $_POST['log'] ) ) { |
16 | 1386 |
$user_login = ( 'incorrect_password' === $errors->get_error_code() || 'empty_password' === $errors->get_error_code() ) ? esc_attr( wp_unslash( $_POST['log'] ) ) : ''; |
9 | 1387 |
} |
16 | 1388 |
|
9 | 1389 |
$rememberme = ! empty( $_POST['rememberme'] ); |
0 | 1390 |
|
9 | 1391 |
if ( $errors->has_errors() ) { |
1392 |
$aria_describedby_error = ' aria-describedby="login_error"'; |
|
1393 |
} else { |
|
1394 |
$aria_describedby_error = ''; |
|
1395 |
} |
|
16 | 1396 |
|
1397 |
wp_enqueue_script( 'user-profile' ); |
|
9 | 1398 |
?> |
5 | 1399 |
|
16 | 1400 |
<form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post"> |
1401 |
<p> |
|
1402 |
<label for="user_login"><?php _e( 'Username or Email Address' ); ?></label> |
|
19 | 1403 |
<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" autocomplete="username" /> |
16 | 1404 |
</p> |
1405 |
||
1406 |
<div class="user-pass-wrap"> |
|
1407 |
<label for="user_pass"><?php _e( 'Password' ); ?></label> |
|
1408 |
<div class="wp-pwd"> |
|
19 | 1409 |
<input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input password-input" value="" size="20" autocomplete="current-password" /> |
16 | 1410 |
<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' ); ?>"> |
1411 |
<span class="dashicons dashicons-visibility" aria-hidden="true"></span> |
|
1412 |
</button> |
|
1413 |
</div> |
|
1414 |
</div> |
|
1415 |
<?php |
|
1416 |
||
1417 |
/** |
|
1418 |
* Fires following the 'Password' field in the login form. |
|
1419 |
* |
|
1420 |
* @since 2.1.0 |
|
1421 |
*/ |
|
1422 |
do_action( 'login_form' ); |
|
1423 |
||
1424 |
?> |
|
1425 |
<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> |
|
1426 |
<p class="submit"> |
|
1427 |
<input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Log In' ); ?>" /> |
|
1428 |
<?php |
|
1429 |
||
1430 |
if ( $interim_login ) { |
|
1431 |
?> |
|
1432 |
<input type="hidden" name="interim-login" value="1" /> |
|
1433 |
<?php |
|
1434 |
} else { |
|
1435 |
?> |
|
1436 |
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
|
1437 |
<?php |
|
1438 |
} |
|
1439 |
||
1440 |
if ( $customize_login ) { |
|
1441 |
?> |
|
1442 |
<input type="hidden" name="customize-login" value="1" /> |
|
1443 |
<?php |
|
1444 |
} |
|
1445 |
||
1446 |
?> |
|
1447 |
<input type="hidden" name="testcookie" value="1" /> |
|
1448 |
</p> |
|
1449 |
</form> |
|
1450 |
||
9 | 1451 |
<?php |
0 | 1452 |
|
16 | 1453 |
if ( ! $interim_login ) { |
1454 |
?> |
|
1455 |
<p id="nav"> |
|
1456 |
<?php |
|
1457 |
||
1458 |
if ( get_option( 'users_can_register' ) ) { |
|
9 | 1459 |
$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
5 | 1460 |
|
9 | 1461 |
/** This filter is documented in wp-includes/general-template.php */ |
1462 |
echo apply_filters( 'register', $registration_url ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1463 |
|
9 | 1464 |
echo esc_html( $login_link_separator ); |
16 | 1465 |
} |
1466 |
||
9 | 1467 |
?> |
16 | 1468 |
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a> |
1469 |
</p> |
|
1470 |
<?php |
|
1471 |
} |
|
1472 |
||
1473 |
$login_script = 'function wp_attempt_focus() {'; |
|
1474 |
$login_script .= 'setTimeout( function() {'; |
|
1475 |
$login_script .= 'try {'; |
|
0 | 1476 |
|
16 | 1477 |
if ( $user_login ) { |
1478 |
$login_script .= 'd = document.getElementById( "user_pass" ); d.value = "";'; |
|
1479 |
} else { |
|
1480 |
$login_script .= 'd = document.getElementById( "user_login" );'; |
|
1481 |
||
1482 |
if ( $errors->get_error_code() === 'invalid_username' ) { |
|
1483 |
$login_script .= 'd.value = "";'; |
|
9 | 1484 |
} |
16 | 1485 |
} |
0 | 1486 |
|
16 | 1487 |
$login_script .= 'd.focus(); d.select();'; |
1488 |
$login_script .= '} catch( er ) {}'; |
|
1489 |
$login_script .= '}, 200);'; |
|
1490 |
$login_script .= "}\n"; // End of wp_attempt_focus(). |
|
1491 |
||
9 | 1492 |
/** |
1493 |
* Filters whether to print the call to `wp_attempt_focus()` on the login screen. |
|
1494 |
* |
|
1495 |
* @since 4.8.0 |
|
1496 |
* |
|
1497 |
* @param bool $print Whether to print the function call. Default true. |
|
1498 |
*/ |
|
1499 |
if ( apply_filters( 'enable_login_autofocus', true ) && ! $error ) { |
|
16 | 1500 |
$login_script .= "wp_attempt_focus();\n"; |
1501 |
} |
|
1502 |
||
1503 |
// Run `wpOnload()` if defined. |
|
1504 |
$login_script .= "if ( typeof wpOnload === 'function' ) { wpOnload() }"; |
|
1505 |
||
1506 |
?> |
|
1507 |
<script type="text/javascript"> |
|
1508 |
<?php echo $login_script; ?> |
|
1509 |
</script> |
|
1510 |
<?php |
|
1511 |
||
1512 |
if ( $interim_login ) { |
|
9 | 1513 |
?> |
16 | 1514 |
<script type="text/javascript"> |
1515 |
( function() { |
|
1516 |
try { |
|
1517 |
var i, links = document.getElementsByTagName( 'a' ); |
|
1518 |
for ( i in links ) { |
|
1519 |
if ( links[i].href ) { |
|
1520 |
links[i].target = '_blank'; |
|
18 | 1521 |
links[i].rel = 'noopener'; |
16 | 1522 |
} |
1523 |
} |
|
1524 |
} catch( er ) {} |
|
1525 |
}()); |
|
1526 |
</script> |
|
1527 |
<?php |
|
9 | 1528 |
} |
0 | 1529 |
|
9 | 1530 |
login_footer(); |
1531 |
break; |
|
1532 |
} // End action switch. |