WordPress.org

Make WordPress Core

Ticket #4478: wp-login.php-2.7.1.diff

File wp-login.php-2.7.1.diff, 4.3 KB (added by stealthdave, 5 years ago)

2.7.1 compatible patch, moves login_error out of the template so that it is always displayed.

  • wp-login.php

    old new  
    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 
     15if (function_exists('get_template_directory')){ 
     16        $templatedir = get_template_directory(); 
     17        if ( file_exists($templatedir.'/login.php') ){ 
     18                include($templatedir.'/login.php'); 
     19        } 
     20} 
     21 
    1422// Redirect to https login if forced to use SSL 
    1523if ( force_ssl_admin() && !is_ssl() ) { 
    1624        if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) { 
     
    2230        } 
    2331} 
    2432 
     33if (!function_exists('login_header')){ 
    2534/** 
    2635 * Outputs the header for the login page. 
    2736 * 
     
    3847 * @param string $message Optional. Message to display in header. 
    3948 * @param WP_Error $wp_error Optional. WordPress Error Object 
    4049 */ 
    41 function login_header($title = 'Log In', $message = '', $wp_error = '') { 
     50function login_header($title = 'Log In') { 
    4251        global $error; 
    4352 
    4453        if ( empty($wp_error) ) 
     
    5867 
    5968<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> 
    6069<?php 
     70        login_error($message = '', $wp_error = ''); 
     71} // End of login_header() 
     72 
     73} // End of login_header function check 
     74 
     75// Default login_footer if not defined by the Theme 
     76if (!function_exists('login_footer')){ 
     77        function login_footer() { 
     78?> 
     79</body> 
     80</html> 
     81<?php    
     82        } 
     83} 
     84 
     85function login_error($message, $wp_error) { 
    6186        if ( !empty( $message ) ) echo apply_filters('login_message', $message) . "\n"; 
    6287 
    6388        // Incase a plugin uses $error rather than the $errors object 
     
    83108                if ( !empty($messages) ) 
    84109                        echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n"; 
    85110        } 
    86 } // End of login_header() 
     111} // End of login_header_error() 
    87112 
    88113/** 
    89114 * Handles sending password retrieval email to user. 
     
    297322        if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.')); 
    298323 
    299324        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); 
     325        login_header(__('Lost Password')); 
     326        login_error('<p class="message">' . __('Please enter your username or e-mail address. You will receive a new password via e-mail.') . '</p>', $errors); 
    301327 
    302328        $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; 
    303329 
     
    328354<script type="text/javascript"> 
    329355try{document.getElementById('user_login').focus();}catch(e){} 
    330356</script> 
    331 </body> 
    332 </html> 
    333357<?php 
     358login_footer(); 
    334359break; 
    335360 
    336361case 'resetpass' : 
     
    367392                } 
    368393        } 
    369394 
    370         login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors); 
     395        login_header(__('Registration Form')); 
     396        login_error('<p class="message register">' . __('Register For This Site') . '</p>', $errors); 
    371397?> 
    372398 
    373399<form name="registerform" id="registerform" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post"> 
     
    396422<script type="text/javascript"> 
    397423try{document.getElementById('user_login').focus();}catch(e){} 
    398424</script> 
    399 </body> 
    400 </html> 
    401425<?php 
     426login_footer(); 
    402427break; 
    403428 
    404429case 'login' : 
     
    456481        elseif  ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )      $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); 
    457482        elseif  ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] )   $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); 
    458483 
    459         login_header(__('Log In'), '', $errors); 
     484        login_header(__('Log In')); 
     485        login_error('', $errors); 
    460486 
    461487        if ( isset($_POST['log']) ) 
    462488                $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? attribute_escape(stripslashes($_POST['log'])) : ''; 
     
    508534try{document.getElementById('user_login').focus();}catch(e){} 
    509535<?php } ?> 
    510536</script> 
    511 </body> 
    512 </html> 
    513537<?php 
    514538 
     539login_footer(); 
    515540break; 
    516541} // end action switch 
    517542?>