WordPress.org

Make WordPress Core

Ticket #4478: 4478.diff

File 4478.diff, 4.6 KB (added by ryan, 11 years ago)

Use locate_template() and fix login_error()

  • wp-login.php

     
    1111/** Make sure that the WordPress bootstrap has ran before continuing. */
    1212require( dirname(__FILE__) . '/wp-load.php' );
    1313
     14// load login theme template if present
     15locate_template(array('login.php'), true);
     16
    1417// Redirect to https login if forced to use SSL
    1518if ( force_ssl_admin() && !is_ssl() ) {
    1619        if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
     
    2225        }
    2326}
    2427
     28if ( !function_exists('login_header') ) :
    2529/**
    2630 * Outputs the header for the login page.
    2731 *
     
    3842 * @param string $message Optional. Message to display in header.
    3943 * @param WP_Error $wp_error Optional. WordPress Error Object
    4044 */
    41 function login_header($title = 'Log In', $message = '', $wp_error = '') {
     45function login_header($title = 'Log In') {
    4246        global $error;
    43 
    44         if ( empty($wp_error) )
    45                 $wp_error = new WP_Error();
    4647        ?>
    4748<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    4849<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
     
    5859
    5960<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', __('Powered by WordPress')); ?>"><?php bloginfo('name'); ?></a></h1>
    6061<?php
     62        login_error($message = '', $wp_error = '');
     63} // End of login_header()
     64
     65endif; // End of login_header function check
     66
     67// Default login_footer if not defined by the Theme
     68if ( !function_exists('login_footer') ) :
     69function login_footer() {
     70?>
     71</body>
     72</html>
     73<?php   
     74}
     75endif;
     76
     77function login_error($message, $wp_error) {
     78        global $error;
     79
    6180        if ( !empty( $message ) ) echo apply_filters('login_message', $message) . "\n";
    6281
     82        if ( empty($wp_error) )
     83                $wp_error = new WP_Error();
     84
    6385        // Incase a plugin uses $error rather than the $errors object
    6486        if ( !empty( $error ) ) {
    6587                $wp_error->add('error', $error);
     
    83105                if ( !empty($messages) )
    84106                        echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
    85107        }
    86 } // End of login_header()
     108} // End of login_header_error()
    87109
    88110/**
    89111 * Handles sending password retrieval email to user.
     
    297319        if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.'));
    298320
    299321        do_action('lost_password');
    300         login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or e-mail address. You will receive a new password via e-mail.') . '</p>', $errors);
     322        login_header(__('Lost Password'));
     323        login_error('<p class="message">' . __('Please enter your username or e-mail address. You will receive a new password via e-mail.') . '</p>', $errors);
    301324
    302325        $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
    303326
     
    328351<script type="text/javascript">
    329352try{document.getElementById('user_login').focus();}catch(e){}
    330353</script>
    331 </body>
    332 </html>
    333354<?php
     355login_footer();
    334356break;
    335357
    336358case 'resetpass' :
     
    367389                }
    368390        }
    369391
    370         login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors);
     392        login_header(__('Registration Form'));
     393        login_error('<p class="message register">' . __('Register For This Site') . '</p>', $errors);
    371394?>
    372395
    373396<form name="registerform" id="registerform" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
     
    396419<script type="text/javascript">
    397420try{document.getElementById('user_login').focus();}catch(e){}
    398421</script>
    399 </body>
    400 </html>
    401422<?php
     423login_footer();
    402424break;
    403425
    404426case 'login' :
     
    456478        elseif  ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )      $errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
    457479        elseif  ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] )   $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
    458480
    459         login_header(__('Log In'), '', $errors);
     481        login_header(__('Log In'));
     482        login_error('', $errors);
    460483
    461484        if ( isset($_POST['log']) )
    462485                $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? attribute_escape(stripslashes($_POST['log'])) : '';
     
    508531try{document.getElementById('user_login').focus();}catch(e){}
    509532<?php } ?>
    510533</script>
    511 </body>
    512 </html>
    513534<?php
    514535
     536login_footer();
    515537break;
    516538} // end action switch
    517539?>