37 * <title/> element. |
37 * <title/> element. |
38 * @param string $message Optional. Message to display in header. |
38 * @param string $message Optional. Message to display in header. |
39 * @param WP_Error $wp_error Optional. WordPress Error Object |
39 * @param WP_Error $wp_error Optional. WordPress Error Object |
40 */ |
40 */ |
41 function login_header($title = 'Log In', $message = '', $wp_error = '') { |
41 function login_header($title = 'Log In', $message = '', $wp_error = '') { |
42 global $error, $is_iphone; |
42 global $error, $is_iphone, $interim_login; |
43 |
43 |
44 // Don't index any of these forms |
44 // Don't index any of these forms |
45 add_filter( 'pre_option_blog_public', create_function( '$a', 'return 0;' ) ); |
45 add_filter( 'pre_option_blog_public', create_function( '$a', 'return 0;' ) ); |
46 add_action( 'login_head', 'noindex' ); |
46 add_action( 'login_head', 'noindex' ); |
47 |
47 |
51 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
51 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
52 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> |
52 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> |
53 <head> |
53 <head> |
54 <title><?php bloginfo('name'); ?> › <?php echo $title; ?></title> |
54 <title><?php bloginfo('name'); ?> › <?php echo $title; ?></title> |
55 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> |
55 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> |
56 <?php |
56 <?php |
57 wp_admin_css( 'login', true ); |
57 wp_admin_css( 'login', true ); |
58 wp_admin_css( 'colors-fresh', true ); |
58 wp_admin_css( 'colors-fresh', true ); |
59 |
59 |
60 if ( $is_iphone ) { |
60 if ( $is_iphone ) { ?> |
61 ?> |
61 <meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" /> |
62 <meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" /> |
62 <style type="text/css" media="screen"> |
63 <style type="text/css" media="screen"> |
|
64 form { margin-left: 0px; } |
63 form { margin-left: 0px; } |
65 #login { margin-top: 20px; } |
64 #login { margin-top: 20px; } |
66 </style> |
65 </style> |
67 <?php |
66 <?php |
|
67 } elseif ( isset($interim_login) && $interim_login ) { ?> |
|
68 <style type="text/css" media="all"> |
|
69 .login #login { margin: 20px auto; } |
|
70 </style> |
|
71 <?php |
68 } |
72 } |
69 |
73 |
70 do_action('login_head'); ?> |
74 do_action('login_head'); ?> |
71 </head> |
75 </head> |
72 <body class="login"> |
76 <body class="login"> |
161 $message .= get_option('siteurl') . "\r\n\r\n"; |
165 $message .= get_option('siteurl') . "\r\n\r\n"; |
162 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; |
166 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; |
163 $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n"; |
167 $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n"; |
164 $message .= site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n"; |
168 $message .= site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n"; |
165 |
169 |
166 $title = sprintf(__('[%s] Password Reset'), get_option('blogname')); |
170 // The blogname option is escaped with esc_html on the way into the database in sanitize_option |
|
171 // we want to reverse this for the plain text arena of emails. |
|
172 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
173 |
|
174 $title = sprintf(__('[%s] Password Reset'), $blogname); |
167 |
175 |
168 $title = apply_filters('retrieve_password_title', $title); |
176 $title = apply_filters('retrieve_password_title', $title); |
169 $message = apply_filters('retrieve_password_message', $message, $key); |
177 $message = apply_filters('retrieve_password_message', $message, $key); |
170 |
178 |
171 if ( $message && !wp_mail($user_email, $title, $message) ) |
179 if ( $message && !wp_mail($user_email, $title, $message) ) |
206 update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag. |
214 update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag. |
207 $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n"; |
215 $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n"; |
208 $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n"; |
216 $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n"; |
209 $message .= site_url('wp-login.php', 'login') . "\r\n"; |
217 $message .= site_url('wp-login.php', 'login') . "\r\n"; |
210 |
218 |
211 $title = sprintf(__('[%s] Your new password'), get_option('blogname')); |
219 // The blogname option is escaped with esc_html on the way into the database in sanitize_option |
|
220 // we want to reverse this for the plain text arena of emails. |
|
221 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
222 |
|
223 $title = sprintf(__('[%s] Your new password'), $blogname); |
212 |
224 |
213 $title = apply_filters('password_reset_title', $title); |
225 $title = apply_filters('password_reset_title', $title); |
214 $message = apply_filters('password_reset_message', $message, $new_pass); |
226 $message = apply_filters('password_reset_message', $message, $new_pass); |
215 |
227 |
216 if ( $message && !wp_mail($user->user_email, $title, $message) ) |
228 if ( $message && !wp_mail($user->user_email, $title, $message) ) |
252 } elseif ( email_exists( $user_email ) ) |
264 } elseif ( email_exists( $user_email ) ) |
253 $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.')); |
265 $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.')); |
254 |
266 |
255 do_action('register_post', $user_login, $user_email, $errors); |
267 do_action('register_post', $user_login, $user_email, $errors); |
256 |
268 |
257 $errors = apply_filters( 'registration_errors', $errors ); |
269 $errors = apply_filters( 'registration_errors', $errors, $user_login, $user_email ); |
258 |
270 |
259 if ( $errors->get_error_code() ) |
271 if ( $errors->get_error_code() ) |
260 return $errors; |
272 return $errors; |
261 |
273 |
262 $user_pass = wp_generate_password(); |
274 $user_pass = wp_generate_password(); |
280 |
292 |
281 if ( isset($_GET['key']) ) |
293 if ( isset($_GET['key']) ) |
282 $action = 'resetpass'; |
294 $action = 'resetpass'; |
283 |
295 |
284 // validate action so as to default to the login screen |
296 // validate action so as to default to the login screen |
285 if ( !in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action) ) |
297 if ( !in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login'), true) && false === has_filter('login_form_' . $action) ) |
286 $action = 'login'; |
298 $action = 'login'; |
287 |
299 |
288 nocache_headers(); |
300 nocache_headers(); |
289 |
301 |
290 header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset')); |
302 header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset')); |
345 <p> |
357 <p> |
346 <label><?php _e('Username or E-mail:') ?><br /> |
358 <label><?php _e('Username or E-mail:') ?><br /> |
347 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" tabindex="10" /></label> |
359 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" tabindex="10" /></label> |
348 </p> |
360 </p> |
349 <?php do_action('lostpassword_form'); ?> |
361 <?php do_action('lostpassword_form'); ?> |
350 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php esc_attr_e('Get New Password'); ?>" tabindex="100" /></p> |
362 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Get New Password'); ?>" tabindex="100" /></p> |
351 </form> |
363 </form> |
352 |
364 |
353 <p id="nav"> |
365 <p id="nav"> |
354 <?php if (get_option('users_can_register')) : ?> |
366 <?php if (get_option('users_can_register')) : ?> |
355 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> | |
367 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> | |
418 <input type="text" name="user_email" id="user_email" class="input" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="25" tabindex="20" /></label> |
430 <input type="text" name="user_email" id="user_email" class="input" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="25" tabindex="20" /></label> |
419 </p> |
431 </p> |
420 <?php do_action('register_form'); ?> |
432 <?php do_action('register_form'); ?> |
421 <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p> |
433 <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p> |
422 <br class="clear" /> |
434 <br class="clear" /> |
423 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php esc_attr_e('Register'); ?>" tabindex="100" /></p> |
435 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Register'); ?>" tabindex="100" /></p> |
424 </form> |
436 </form> |
425 |
437 |
426 <p id="nav"> |
438 <p id="nav"> |
427 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> | |
439 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> | |
428 <a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a> |
440 <a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a> |
470 $user = wp_signon('', $secure_cookie); |
483 $user = wp_signon('', $secure_cookie); |
471 |
484 |
472 $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user); |
485 $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user); |
473 |
486 |
474 if ( !is_wp_error($user) ) { |
487 if ( !is_wp_error($user) ) { |
|
488 if ( $interim_login ) { |
|
489 $message = '<p class="message">' . __('You have logged in successfully.') . '</p>'; |
|
490 login_header( '', $message ); ?> |
|
491 <script type="text/javascript">setTimeout( function(){window.close()}, 8000);</script> |
|
492 <p class="alignright"> |
|
493 <input type="button" class="button-primary" value="<?php esc_attr_e('Close'); ?>" onclick="window.close()" /></p> |
|
494 </div></body></html> |
|
495 <?php exit; |
|
496 } |
475 // If the user can't edit posts, send them to their profile. |
497 // If the user can't edit posts, send them to their profile. |
476 if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) |
498 if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) |
477 $redirect_to = admin_url('profile.php'); |
499 $redirect_to = admin_url('profile.php'); |
478 wp_safe_redirect($redirect_to); |
500 wp_safe_redirect($redirect_to); |
479 exit(); |
501 exit(); |
487 // If cookies are disabled we can't log in even with a valid user+pass |
509 // If cookies are disabled we can't log in even with a valid user+pass |
488 if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) ) |
510 if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) ) |
489 $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.")); |
511 $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.")); |
490 |
512 |
491 // Some parts of this script use the main login form to display a message |
513 // Some parts of this script use the main login form to display a message |
492 if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] ) $errors->add('loggedout', __('You are now logged out.'), 'message'); |
514 if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] ) |
493 elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) $errors->add('registerdisabled', __('User registration is currently not allowed.')); |
515 $errors->add('loggedout', __('You are now logged out.'), 'message'); |
494 elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message'); |
516 elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) |
495 elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); |
517 $errors->add('registerdisabled', __('User registration is currently not allowed.')); |
496 elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); |
518 elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) |
|
519 $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message'); |
|
520 elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) |
|
521 $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); |
|
522 elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) |
|
523 $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); |
|
524 elseif ( $interim_login ) |
|
525 $errors->add('expired', __('Your session has expired. Please log-in again.'), 'message'); |
497 |
526 |
498 login_header(__('Log In'), '', $errors); |
527 login_header(__('Log In'), '', $errors); |
499 |
528 |
500 if ( isset($_POST['log']) ) |
529 if ( isset($_POST['log']) ) |
501 $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(stripslashes($_POST['log'])) : ''; |
530 $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(stripslashes($_POST['log'])) : ''; |
512 <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label> |
541 <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label> |
513 </p> |
542 </p> |
514 <?php do_action('login_form'); ?> |
543 <?php do_action('login_form'); ?> |
515 <p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> <?php esc_attr_e('Remember Me'); ?></label></p> |
544 <p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> <?php esc_attr_e('Remember Me'); ?></label></p> |
516 <p class="submit"> |
545 <p class="submit"> |
517 <input type="submit" name="wp-submit" id="wp-submit" value="<?php esc_attr_e('Log In'); ?>" tabindex="100" /> |
546 <input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Log In'); ?>" tabindex="100" /> |
|
547 <?php if ( $interim_login ) { ?> |
|
548 <input type="hidden" name="interim-login" value="1" /> |
|
549 <?php } else { ?> |
518 <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" /> |
550 <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" /> |
|
551 <?php } ?> |
519 <input type="hidden" name="testcookie" value="1" /> |
552 <input type="hidden" name="testcookie" value="1" /> |
520 </p> |
553 </p> |
521 </form> |
554 </form> |
522 <?php endif; ?> |
555 <?php endif; ?> |
523 |
556 |
|
557 <?php if ( !$interim_login ) { ?> |
524 <p id="nav"> |
558 <p id="nav"> |
525 <?php if ( isset($_GET['checkemail']) && in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?> |
559 <?php if ( isset($_GET['checkemail']) && in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?> |
526 <?php elseif (get_option('users_can_register')) : ?> |
560 <?php elseif (get_option('users_can_register')) : ?> |
527 <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a> | |
561 <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a> | |
528 <a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a> |
562 <a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a> |
529 <?php else : ?> |
563 <?php else : ?> |
530 <a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a> |
564 <a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a> |
531 <?php endif; ?> |
565 <?php endif; ?> |
532 </p> |
566 </p> |
533 |
567 |
|
568 <p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display' )); ?></a></p> |
|
569 <?php } ?> |
534 </div> |
570 </div> |
535 |
571 |
536 <p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display' )); ?></a></p> |
|
537 |
|
538 <script type="text/javascript"> |
572 <script type="text/javascript"> |
539 <?php if ( $user_login ) { ?> |
573 <?php if ( $user_login || $interim_login ) { ?> |
540 setTimeout( function(){ try{ |
574 setTimeout( function(){ try{ |
541 d = document.getElementById('user_pass'); |
575 d = document.getElementById('user_pass'); |
542 d.value = ''; |
576 d.value = ''; |
543 d.focus(); |
577 d.focus(); |
544 } catch(e){} |
578 } catch(e){} |