Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-login.php

    r19414 r21031  
    4040 */
    4141function login_header($title = 'Log In', $message = '', $wp_error = '') {
    42         global $error, $is_iphone, $interim_login, $current_site;
     42        global $error, $interim_login, $current_site, $customize_login;
    4343
    4444        // Don't index any of these forms
    … …  
    5555                add_action( 'login_head', 'wp_shake_js', 12 );
    5656
    57         ?>
    58 <!DOCTYPE html>
    59 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    60 <head>
     57        ?><!DOCTYPE html>
     58        <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
     59        <head>
    6160        <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    6261        <title><?php bloginfo('name'); ?> &rsaquo; <?php echo $title; ?></title>
    63 <?php
     62        <?php
     63
    6464        wp_admin_css( 'wp-admin', true );
    6565        wp_admin_css( 'colors-fresh', true );
    6666
    67         if ( $is_iphone ) { ?>
    68         <meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" />
    69         <style type="text/css" media="screen">
    70         .login form, .login .message, #login_error { margin-left: 0px; }
    71         .login #nav, .login #backtoblog { margin-left: 8px; }
    72         .login h1 a { width: auto; }
    73         #login { padding: 20px 0; }
    74         </style>
    75 <?php
    76         }
     67        if ( wp_is_mobile() ) { ?>
     68                <meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" /><?php
     69        }
     70
     71        if ( $customize_login )
     72                wp_enqueue_script( 'customize-base' );
    7773
    7874        do_action( 'login_enqueue_scripts' );
    79         do_action( 'login_head' ); ?>
    80 </head>
    81 <body class="login">
    82 <?php   if ( !is_multisite() ) { ?>
    83 <div id="login"><h1><a href="<?php echo esc_url( apply_filters('login_headerurl', 'http://wordpress.org/') ); ?>" title="<?php echo esc_attr( apply_filters('login_headertitle', __( 'Powered by WordPress' ) ) ); ?>"><?php bloginfo('name'); ?></a></h1>
    84 <?php   } else { ?>
    85 <div id="login"><h1><a href="<?php echo esc_url( apply_filters('login_headerurl', network_home_url() ) ); ?>" title="<?php echo esc_attr( apply_filters('login_headertitle', $current_site->site_name ) ); ?>"><span class="hide"><?php bloginfo('name'); ?></span></a></h1>
    86 <?php   }
     75        do_action( 'login_head' );
     76
     77        if ( is_multisite() ) {
     78                $login_header_url   = network_home_url();
     79                $login_header_title = $current_site->site_name;
     80        } else {
     81                $login_header_url   = __( 'http://wordpress.org/' );
     82                $login_header_title = __( 'Powered by WordPress' );
     83        }
     84
     85        $login_header_url   = apply_filters( 'login_headerurl',   $login_header_url   );
     86        $login_header_title = apply_filters( 'login_headertitle', $login_header_title );
     87
     88        // Don't allow interim logins to navigate away from the page.
     89        if ( $interim_login )
     90                $login_header_url = '#';
     91
     92        ?>
     93        </head>
     94        <body class="login<?php if ( wp_is_mobile() ) echo ' mobile'; ?>">
     95        <div id="login">
     96                <h1><a href="<?php echo esc_url( $login_header_url ); ?>" title="<?php echo esc_attr( $login_header_title ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
     97        <?php
     98
     99        unset( $login_header_url, $login_header_title );
    87100
    88101        $message = apply_filters('login_message', $message);
    89         if ( !empty( $message ) ) echo $message . "\n";
     102        if ( !empty( $message ) )
     103                echo $message . "\n";
    90104
    91105        // In case a plugin uses $error rather than the $wp_errors object
    … …  
    120134 */
    121135function login_footer($input_id = '') {
    122         ?>
     136        global $interim_login;
     137
     138        // Don't allow interim logins to navigate away from the page.
     139        if ( ! $interim_login ): ?>
    123140        <p id="backtoblog"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php esc_attr_e( 'Are you lost?' ); ?>"><?php printf( __( '&larr; Back to %s' ), get_bloginfo( 'title', 'display' ) ); ?></a></p>
     141        <?php endif; ?>
     142
    124143        </div>
    125144
    126 <?php if ( !empty($input_id) ) : ?>
    127 <script type="text/javascript">
    128 try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){}
    129 if(typeof wpOnload=='function')wpOnload();
    130 </script>
    131 <?php endif; ?>
    132 
    133 <?php do_action('login_footer'); ?>
    134 <div class="clear"></div>
    135 </body>
    136 </html>
    137 <?php
     145        <?php if ( !empty($input_id) ) : ?>
     146        <script type="text/javascript">
     147        try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){}
     148        if(typeof wpOnload=='function')wpOnload();
     149        </script>
     150        <?php endif; ?>
     151
     152        <?php do_action('login_footer'); ?>
     153        <div class="clear"></div>
     154        </body>
     155        </html>
     156        <?php
    138157}
    139158
    140159function wp_shake_js() {
    141         global $is_iphone;
    142         if ( $is_iphone )
     160        if ( wp_is_mobile() )
    143161                return;
    144162?>
    … …  
    209227        }
    210228        $message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n";
    211         $message .= network_site_url() . "\r\n\r\n";
     229        $message .= network_home_url( '/' ) . "\r\n\r\n";
    212230        $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    213231        $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n";
    … …  
    240258 * @param string $key Hash to validate sending user's password
    241259 * @param string $login The user login
    242  *
    243  * @return object|WP_Error
     260 * @return object|WP_Error User's database row on success, error object for invalid keys
    244261 */
    245262function check_password_reset_key($key, $login) {
    … …  
    265282 * Handles resetting the user's password.
    266283 *
    267  * @uses $wpdb WordPress Database object
    268  *
    269  * @param string $key Hash to validate sending user's password
     284 * @param object $user The user
     285 * @param string $new_pass New password for the user in plaintext
    270286 */
    271287function reset_password($user, $new_pass) {
    … …  
    342358
    343359// validate action so as to default to the login screen
    344 if ( !in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login'), true) && false === has_filter('login_form_' . $action) )
     360if ( !in_array( $action, array( 'postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login' ), true ) && false === has_filter( 'login_form_' . $action ) )
    345361        $action = 'login';
    346362
    … …  
    369385$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
    370386switch ($action) {
     387
     388case 'postpass' :
     389        if ( empty( $wp_hasher ) ) {
     390                require_once( ABSPATH . 'wp-includes/class-phpass.php' );
     391                // By default, use the portable hash from phpass
     392                $wp_hasher = new PasswordHash(8, true);
     393        }
     394
     395        // 10 days
     396        setcookie( 'wp-postpass_' . COOKIEHASH, $wp_hasher->HashPassword( stripslashes( $_POST['post_password'] ) ), time() + 864000, COOKIEPATH );
     397
     398        wp_safe_redirect( wp_get_referer() );
     399        exit();
     400
     401break;
    371402
    372403case 'logout' :
    … …  
    537568        $secure_cookie = '';
    538569        $interim_login = isset($_REQUEST['interim-login']);
     570        $customize_login = isset( $_REQUEST['customize-login'] );
    539571
    540572        // If the user wants ssl but the session is not ssl, force a secure cookie.
    … …  
    561593
    562594        // If the user was redirected to a secure login form from a non-secure admin page, and secure login is required but secure admin is not, then don't use a secure
    563         // cookie and redirect back to the referring non-secure admin page.  This allows logins to always be POSTed over SSL while allowing the user to choose visiting
     595        // cookie and redirect back to the referring non-secure admin page. This allows logins to always be POSTed over SSL while allowing the user to choose visiting
    564596        // the admin via http or https.
    565597        if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
    … …  
    573605                if ( $interim_login ) {
    574606                        $message = '<p class="message">' . __('You have logged in successfully.') . '</p>';
    575                         login_header( '', $message ); ?>
    576                         <script type="text/javascript">setTimeout( function(){window.close()}, 8000);</script>
    577                         <p class="alignright">
    578                         <input type="button" class="button-primary" value="<?php esc_attr_e('Close'); ?>" onclick="window.close()" /></p>
    579                         </div></body></html>
     607                        login_header( '', $message );
     608
     609                        if ( ! $customize_login ) : ?>
     610                                <script type="text/javascript">setTimeout( function(){window.close()}, 8000);</script>
     611                                <p class="alignright">
     612                                <input type="button" class="button-primary" value="<?php esc_attr_e('Close'); ?>" onclick="window.close()" /></p>
     613<?php           endif;
     614
     615                        ?></div><?php
     616
     617                        do_action('login_footer');
     618
     619                        if ( $customize_login ) : ?>
     620                                <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script>
     621<?php           endif; ?>
     622                        </body></html>
    580623<?php           exit;
    581624                }
    … …  
    604647
    605648        // Some parts of this script use the main login form to display a message
    606         if              ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] )
     649        if              ( isset($_GET['loggedout']) && true == $_GET['loggedout'] )
    607650                $errors->add('loggedout', __('You are now logged out.'), 'message');
    608651        elseif  ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] )
    … …  
    616659        elseif  ( $interim_login )
    617660                $errors->add('expired', __('Your session has expired. Please log-in again.'), 'message');
     661        elseif ( strpos( $redirect_to, 'about.php?updated' ) )
     662                $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.' ), 'message' );
    618663
    619664        // Clear any stale cookies.
    … …  
    646691                <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" />
    647692<?php   } ?>
     693<?php   if ( $customize_login ) : ?>
     694                <input type="hidden" name="customize-login" value="1" />
     695<?php   endif; ?>
    648696                <input type="hidden" name="testcookie" value="1" />
    649697        </p>
    … …  
    692740break;
    693741} // end action switch
    694 ?>
Note: See TracChangeset for help on using the changeset viewer.