Ticket #25393: wp-login.diff
| File wp-login.diff, 16.7 KB (added by , 12 years ago) |
|---|
-
.php
old new 49 49 50 50 // Shake it! 51 51 $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' ); 52 /** 53 * Filter the error codes array that are to shake the login form. 54 * 55 * @since 3.0.0 56 * 57 * @param array $shake_error_codes Error codes that will shake the login form. 58 */ 52 59 $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes ); 53 60 54 61 if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) … … 77 84 <?php 78 85 } 79 86 87 /** 88 * Fires at the timig of enqueing scripts and styles on the login page. 89 * 90 * The proper hook to use when enqueuing scripts and styles that are meant to appear on the login page. 91 * 92 * @since 3.1.0 93 */ 80 94 do_action( 'login_enqueue_scripts' ); 95 /** 96 * Fires before </head> on the login page. 97 * 98 * @since 2.1.0 99 */ 81 100 do_action( 'login_head' ); 82 101 83 102 if ( is_multisite() ) { … … 87 106 $login_header_url = __( 'http://wordpress.org/' ); 88 107 $login_header_title = __( 'Powered by WordPress' ); 89 108 } 90 109 /** 110 * Filter the link url of the header logo above login form. 111 * 112 * @since 2.1.0 113 * 114 * @param string $login_header_url Default url. 115 */ 91 116 $login_header_url = apply_filters( 'login_headerurl', $login_header_url ); 117 /** 118 * Filter the title of the header logo above login form. 119 * 120 * @since 2.1.0 121 * 122 * @param string $login_header_title Default title. 123 */ 92 124 $login_header_title = apply_filters( 'login_headertitle', $login_header_title ); 93 125 94 126 $classes = array( 'login-action-' . $action, 'wp-core-ui' ); … … 105 137 if ( 'success' === $interim_login ) 106 138 $classes[] = 'interim-login-success'; 107 139 } 108 140 /** 141 * Filter the classes of login page <body>. 142 * 143 * @since 3.5.0 144 * 145 * @param array $classes Classes to be added to the <body>. 146 * @param string $action The action user took before coming to the login page. 147 */ 109 148 $classes = apply_filters( 'login_body_class', $classes, $action ); 110 149 111 150 ?> … … 116 155 <?php 117 156 118 157 unset( $login_header_url, $login_header_title ); 119 120 $message = apply_filters('login_message', $message); 158 /** 159 * Filter the message to display in header above login form. 160 * 161 * @since 2.1.0 162 * 163 * @param string $message Message text. 164 */ 165 $message = apply_filters( 'login_message', $message ); 121 166 if ( !empty( $message ) ) 122 167 echo $message . "\n"; 123 168 … … 140 185 } 141 186 } 142 187 if ( !empty($errors) ) 143 echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n"; 188 /** 189 * Filter the error message above the login form. 190 * 191 * @since 2.1.0 192 * 193 * @param string $errors Error message. 194 */ 195 echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n"; 144 196 if ( !empty($messages) ) 145 echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n"; 197 /** 198 * Filter the message above the login form. 199 * 200 * @since 2.5.0 201 * 202 * @param string $messages Login message. 203 */ 204 echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n"; 146 205 } 147 206 } // End of login_header() 148 207 … … 168 227 </script> 169 228 <?php endif; ?> 170 229 171 <?php do_action('login_footer'); ?> 230 <?php 231 /** 232 * Fires at the end of the html on the login page. 233 * 234 * @since 3.1.0 235 */ 236 do_action( 'login_footer' ); ?> 172 237 <div class="clear"></div> 173 238 </body> 174 239 </html> … … 212 277 $user_data = get_user_by('login', $login); 213 278 } 214 279 215 do_action('lostpassword_post'); 280 /** 281 * Fires before returning WP Error in password retrieving process. 282 * 283 * @since 2.1.0 284 */ 285 do_action( 'lostpassword_post' ); 216 286 217 287 if ( $errors->get_error_code() ) 218 288 return $errors; … … 226 296 $user_login = $user_data->user_login; 227 297 $user_email = $user_data->user_email; 228 298 229 do_action('retreive_password', $user_login); // Misspelled and deprecated 299 // Misspelled and deprecated 300 do_action( 'retreive_password', $user_login ); 301 /** 302 * Fires after redefing user login from the user data object. 303 * 304 * @since 1.5.2 305 * 306 * @param string $user_login User name to login. 307 */ 230 308 do_action('retrieve_password', $user_login); 231 232 $allow = apply_filters('allow_password_reset', true, $user_data->ID); 309 /** 310 * Filter password reset restriction boolean. 311 * 312 * @since 2.7.0 313 * 314 * @param boolean True as default. 315 * @param int $user_data->ID The ID of the user who is retrieving new password. 316 */ 317 $allow = apply_filters( 'allow_password_reset', true, $user_data->ID ); 233 318 234 319 if ( ! $allow ) 235 320 return new WP_Error('no_password_reset', __('Password reset is not allowed for this user')); … … 240 325 if ( empty($key) ) { 241 326 // Generate something random for a key... 242 327 $key = wp_generate_password(20, false); 243 do_action('retrieve_password_key', $user_login, $key); 328 /** 329 * Fires before inserting the new md5 key into database. 330 * 331 * @since 2.5.0 332 * 333 * @param string $user_login User name to login. 334 * @param string $key Activation key. 335 */ 336 do_action( 'retrieve_password_key', $user_login, $key ); 244 337 // Now insert the new md5 key into the db 245 338 $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); 246 339 } … … 259 352 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 260 353 261 354 $title = sprintf( __('[%s] Password Reset'), $blogname ); 262 263 $title = apply_filters('retrieve_password_title', $title); 264 $message = apply_filters('retrieve_password_message', $message, $key); 355 /** 356 * Filter the title of the password reset mail. 357 * 358 * @since 2.8.0 359 * 360 * @param string $title Default mail title. 361 */ 362 $title = apply_filters( 'retrieve_password_title', $title ); 363 /** 364 * Filter the body message of the password reset mail. 365 * 366 * @since 2.8.0 367 * 368 * @param string $message Default mail message. 369 * @param string $key The activation key. 370 */ 371 $message = apply_filters( 'retrieve_password_message', $message, $key ); 265 372 266 373 if ( $message && !wp_mail($user_email, $title, $message) ) 267 374 wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') ); … … 304 411 * @param string $new_pass New password for the user in plaintext 305 412 */ 306 413 function reset_password($user, $new_pass) { 307 do_action('password_reset', $user, $new_pass); 414 /** 415 * Runs before the user's password is reset to a random new password. 416 * 417 * @since 1.5.2 418 * 419 * @param string $user The user. 420 * @param string $new_pass New password for the user in plaintext. 421 */ 422 do_action( 'password_reset', $user, $new_pass ); 308 423 309 424 wp_set_password($new_pass, $user->ID); 310 425 … … 322 437 $errors = new WP_Error(); 323 438 324 439 $sanitized_user_login = sanitize_user( $user_login ); 440 /** 441 * Filter the user email address on user registration. 442 * 443 * @since 2.1.0 444 * 445 * @param string $user_email User's email address to send password and add. 446 */ 325 447 $user_email = apply_filters( 'user_registration_email', $user_email ); 326 448 327 449 // Check the username … … 344 466 $errors->add( 'email_exists', __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ) ); 345 467 } 346 468 469 /** 470 * Fires before registering a new user. 471 * 472 * @since 2.1.0 473 * 474 * @param string $sanitized_user_login Sanitized user's username for logging in. 475 * @param string $user_email New user email. 476 * @param object $errors WP Error object. 477 */ 347 478 do_action( 'register_post', $sanitized_user_login, $user_email, $errors ); 348 479 /** 480 * Filter the errors of register validation. 481 * 482 * @since 2.1.0 483 * 484 * @param array $errors WP Error object. 485 * @param string $sanitized_user_login Sanitized user's username for logging in. 486 * @param string $user_email New user email. 487 */ 349 488 $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email ); 350 489 351 490 if ( $errors->get_error_code() ) … … 397 536 if ( SITECOOKIEPATH != COOKIEPATH ) 398 537 setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); 399 538 400 // allow plugins to override the default actions, and to add extra actions if they want 539 /** 540 * Fires before running the main action of wp-login.php. 541 * 542 * Allow plugins to override the default actions, and to add extra actions if they want. 543 * 544 * @since 3.2.0 545 * 546 */ 401 547 do_action( 'login_init' ); 548 /** 549 * Fires before running the main action of wp-login.php depending on the $action. 550 * 551 * @since Unknown 552 * 553 */ 402 554 do_action( 'login_form_' . $action ); 403 555 404 556 $http_post = ('POST' == $_SERVER['REQUEST_METHOD']); … … 441 593 } 442 594 443 595 if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.')); 596 /** 597 * Filtering the redirect url after submitting the lostpassword/retrievepassword form. 598 * 599 * @since 3.0.0 600 * 601 * @param string The redirect destination url. 602 */ 444 603 $redirect_to = apply_filters( 'lostpassword_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' ); 445 604 446 do_action('lost_password'); 605 /** 606 * Fires before the lost password and retrieving password form 607 * 608 * @since 1.5.2 609 * 610 */ 611 do_action( 'lost_password' ); 447 612 login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or email address. You will receive a link to create a new password via email.') . '</p>', $errors); 448 613 449 614 $user_login = isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : ''; … … 455 620 <label for="user_login" ><?php _e('Username or E-mail:') ?><br /> 456 621 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label> 457 622 </p> 458 <?php do_action('lostpassword_form'); ?> 623 <?php 624 /** 625 * Fires in the lostpassword form. 626 * 627 * @since 2.1.0 628 * 629 */ 630 do_action( 'lostpassword_form' ); ?> 459 631 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> 460 632 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Get New Password'); ?>" /></p> 461 633 </form> 462 634 463 635 <p id="nav"> 464 636 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a> 465 <?php if ( get_option( 'users_can_register' ) ) : ?> 466 | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> 467 <?php endif; ?> 468 </p> 637 <?php 638 if ( get_option( 'users_can_register' ) ) : 639 /** 640 * Filter the Register link text below the login form. 641 * 642 * @since 1.5.2 643 * 644 * @param string Register ink text. 645 */ 646 echo ' | ' . apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); 647 endif; 648 ?></p> 469 649 470 650 <?php 471 651 login_footer('user_login'); … … 485 665 if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) 486 666 $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); 487 667 668 /** 669 * Fires before the validation in the reset password precedure. 670 * 671 * @since 3.5.0 672 * 673 * @param object $errors WP Error object. 674 * @param string $user User data. 675 */ 488 676 do_action( 'validate_password_reset', $errors, $user ); 489 677 490 678 if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) { … … 521 709 522 710 <p id="nav"> 523 711 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> 524 <?php if ( get_option( 'users_can_register' ) ) : ?> 525 | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> 526 <?php endif; ?> 527 </p> 712 <?php 713 if ( get_option( 'users_can_register' ) ) : 714 //duplicate_hook 715 echo ' | ' . apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); 716 endif; 717 ?></p> 718 528 719 529 720 <?php 530 721 login_footer('user_pass'); … … 532 723 533 724 case 'register' : 534 725 if ( is_multisite() ) { 535 // Multisite uses wp-signup.php 726 /** 727 * Filter the redirect destination url for the Multi Site installation. 728 * 729 * @since 3.0.0 730 * 731 * @param string Signup url of the multisite. 732 */ 536 733 wp_redirect( apply_filters( 'wp_signup_location', network_site_url('wp-signup.php') ) ); 537 734 exit; 538 735 } … … 554 751 exit(); 555 752 } 556 753 } 557 754 /** 755 * Filter the redirect destination url after user registration. 756 * 757 * @since 3.0.0 758 * 759 * @param string The redirect destination url. 760 */ 558 761 $redirect_to = apply_filters( 'registration_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' ); 559 762 login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors); 560 763 ?> … … 568 771 <label for="user_email"><?php _e('E-mail') ?><br /> 569 772 <input type="text" name="user_email" id="user_email" class="input" value="<?php echo esc_attr(wp_unslash($user_email)); ?>" size="25" /></label> 570 773 </p> 571 <?php do_action('register_form'); ?> 774 <?php 775 /** 776 * Fires in the registration form. 777 * 778 * @since 2.1.0 779 * 780 */ 781 do_action( 'register_form' ); ?> 572 782 <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p> 573 783 <br class="clear" /> 574 784 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> … … 621 831 622 832 $user = wp_signon('', $secure_cookie); 623 833 624 $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user); 834 /** 835 * Filtering the redirect url after login. 836 * 837 * @since 3.0.0 838 * 839 * @param string $redirect_to The redirect destination url. 840 * @param string The redirect destination url which was passed as a parameter. 841 * @param object $user User data object. 842 */ 843 $redirect_to = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user ); 625 844 626 845 if ( !is_wp_error($user) && !$reauth ) { 627 846 if ( $interim_login ) { … … 629 848 $interim_login = 'success'; 630 849 login_header( '', $message ); ?> 631 850 </div> 632 <?php do_action( 'login_footer' ); ?> 851 <?php 852 /** 853 * Fires at the end of the html on the login page. 854 * 855 * @since 3.5.0 856 * 857 * @param object $errors WP Error object. 858 * @param string $user User data. 859 */ 860 do_action( 'login_footer' ); ?> 633 861 <?php if ( $customize_login ) : ?> 634 862 <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> 635 863 <?php endif; ?> … … 677 905 elseif ( strpos( $redirect_to, 'about.php?updated' ) ) 678 906 $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.' ), 'message' ); 679 907 } 680 908 /** 909 * Filter the WP Error object. 910 * 911 * @since 3.6.0 912 * 913 * @param object $errors WP Error object. 914 * @param string $redirect_to Redirect destination url. 915 */ 681 916 $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); 682 917 683 918 // Clear any stale cookies. … … 700 935 <label for="user_pass"><?php _e('Password') ?><br /> 701 936 <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" /></label> 702 937 </p> 703 <?php do_action('login_form'); ?> 938 <?php 939 /** 940 * Fires in the login form. 941 * 942 * @since 2.1.0 943 * 944 */ 945 do_action( 'login_form' ); ?> 704 946 <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked( $rememberme ); ?> /> <?php esc_attr_e('Remember Me'); ?></label></p> 705 947 <p class="submit"> 706 948 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Log In'); ?>" /> … … 718 960 719 961 <?php if ( ! $interim_login ) { ?> 720 962 <p id="nav"> 721 <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : ?> 722 <?php if ( get_option( 'users_can_register' ) ) : ?> 723 <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> | 724 <?php endif; ?> 963 <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : 964 if ( get_option( 'users_can_register' ) ) : 965 //duplicate_hook 966 echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ) . ' | '; 967 endif; 968 ?> 725 969 <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a> 726 970 <?php endif; ?> 727 971 </p>