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