~canonical-sysadmins/wordpress/3.9.x

« back to all changes in this revision

Viewing changes to wp-login.php

  • Committer: Chris Jones
  • Date: 2010-01-19 13:17:33 UTC
  • Revision ID: cmsj@tenshu.net-20100119131733-rf31jv9k1v0xzo2h
[CJ] Import wordpress 2.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 * @param WP_Error $wp_error Optional. WordPress Error Object
40
40
 */
41
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
44
        // Don't index any of these forms
45
45
        add_filter( 'pre_option_blog_public', create_function( '$a', 'return 0;' ) );
53
53
<head>
54
54
        <title><?php bloginfo('name'); ?> &rsaquo; <?php echo $title; ?></title>
55
55
        <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
56
 
        <?php
 
56
<?php
57
57
        wp_admin_css( 'login', true );
58
58
        wp_admin_css( 'colors-fresh', true );
59
59
 
60
 
        if ( $is_iphone ) {
61
 
        ?>
62
 
        <meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" /> 
63
 
        <style type="text/css" media="screen"> 
 
60
        if ( $is_iphone ) { ?>
 
61
        <meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" />
 
62
        <style type="text/css" media="screen">
64
63
        form { margin-left: 0px; }
65
64
        #login { margin-top: 20px; }
66
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
74
        do_action('login_head'); ?>
163
167
        $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
164
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
176
        $title = apply_filters('retrieve_password_title', $title);
169
177
        $message = apply_filters('retrieve_password_message', $message, $key);
208
216
        $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
209
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
225
        $title = apply_filters('password_reset_title', $title);
214
226
        $message = apply_filters('password_reset_message', $message, $new_pass);
254
266
 
255
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
271
        if ( $errors->get_error_code() )
260
272
                return $errors;
282
294
        $action = 'resetpass';
283
295
 
284
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
298
        $action = 'login';
287
299
 
288
300
nocache_headers();
347
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
360
        </p>
349
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
363
</form>
352
364
 
353
365
<p id="nav">
420
432
<?php do_action('register_form'); ?>
421
433
        <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p>
422
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
436
</form>
425
437
 
426
438
<p id="nav">
443
455
case 'login' :
444
456
default:
445
457
        $secure_cookie = '';
 
458
        $interim_login = isset($_REQUEST['interim-login']);
446
459
 
447
460
        // If the user wants ssl but the session is not ssl, force a secure cookie.
448
461
        if ( !empty($_POST['log']) && !force_ssl_admin() ) {
472
485
        $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);
473
486
 
474
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
497
                // If the user can't edit posts, send them to their profile.
476
498
                if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) )
477
499
                        $redirect_to = admin_url('profile.php');
489
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
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');
493
 
        elseif  ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) $errors->add('registerdisabled', __('User registration is currently not allowed.'));
494
 
        elseif  ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] )      $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
495
 
        elseif  ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )      $errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
496
 
        elseif  ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] )   $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
 
514
        if              ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] )
 
515
                $errors->add('loggedout', __('You are now logged out.'), 'message');
 
516
        elseif  ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] )
 
517
                $errors->add('registerdisabled', __('User registration is currently not allowed.'));
 
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
527
        login_header(__('Log In'), '', $errors);
499
528
 
514
543
<?php do_action('login_form'); ?>
515
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
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
550
                <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" />
 
551
<?php   } ?>
519
552
                <input type="hidden" name="testcookie" value="1" />
520
553
        </p>
521
554
</form>
522
555
<?php endif; ?>
523
556
 
 
557
<?php if ( !$interim_login ) { ?>
524
558
<p id="nav">
525
559
<?php if ( isset($_GET['checkemail']) && in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?>
526
560
<?php elseif (get_option('users_can_register')) : ?>
531
565
<?php endif; ?>
532
566
</p>
533
567
 
 
568
<p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('&larr; Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
 
569
<?php } ?>
534
570
</div>
535
571
 
536
 
<p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('&larr; Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
537
 
 
538
572
<script type="text/javascript">
539
 
<?php if ( $user_login ) { ?>
 
573
<?php if ( $user_login || $interim_login ) { ?>
540
574
setTimeout( function(){ try{
541
575
d = document.getElementById('user_pass');
542
576
d.value = '';