Ticket #25393: 25393.diff
| File 25393.diff, 16.5 KB (added by , 13 years ago) |
|---|
-
src/wp-login.php
25 25 /** 26 26 * Outputs the header for the login page. 27 27 * 28 * @uses do_action() Calls the 'login_head' for outputting HTML in the Log In29 * header.30 * @uses apply_filters() Calls 'login_headerurl' for the top login link.31 * @uses apply_filters() Calls 'login_headertitle' for the top login title.32 * @uses apply_filters() Calls 'login_message' on the message to display in the33 * header.34 * @uses $error The error global, which is checked for displaying errors.35 *36 28 * @param string $title Optional. WordPress Log In Page title to display in 37 29 * <title/> element. 38 30 * @param string $message Optional. Message to display in header. … … 52 44 53 45 // Shake it! 54 46 $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' ); 47 /** 48 * Filter the error codes array for shaking the login form. 49 * 50 * @since 3.0.0 51 * 52 * @param array $shake_error_codes Error codes that shake the login form. 53 */ 55 54 $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes ); 56 55 57 56 if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) … … 76 75 <?php 77 76 } 78 77 78 /** 79 * Enqueue scripts and styles for the login page. 80 * 81 * @since 3.1.0 82 */ 79 83 do_action( 'login_enqueue_scripts' ); 84 /** 85 * Fires in the login page header after scripts are enqueued. 86 * 87 * @since 2.1.0 88 */ 80 89 do_action( 'login_head' ); 81 90 82 91 if ( is_multisite() ) { … … 87 96 $login_header_title = __( 'Powered by WordPress' ); 88 97 } 89 98 90 $login_header_url = apply_filters( 'login_headerurl', $login_header_url ); 99 /** 100 * Filter link URL of the header logo above login form. 101 * 102 * @since 2.1.0 103 * 104 * @param string $login_header_url Default URL. 105 */ 106 $login_header_url = apply_filters( 'login_headerurl', $login_header_url ); 107 /** 108 * Filter the title attribute of the header logo above login form. 109 * 110 * @since 2.1.0 111 * 112 * @param string $login_header_title Default title. 113 */ 91 114 $login_header_title = apply_filters( 'login_headertitle', $login_header_title ); 92 115 93 116 $classes = array( 'login-action-' . $action, 'wp-core-ui' ); … … 105 128 $classes[] = 'interim-login-success'; 106 129 } 107 130 131 /** 132 * Filter the login page body classes. 133 * 134 * @since 3.5.0 135 * 136 * @param array $classes An array of body classes. 137 * @param string $action The action that brought the visitor to the login page. 138 */ 108 139 $classes = apply_filters( 'login_body_class', $classes, $action ); 109 140 110 141 ?> … … 116 147 117 148 unset( $login_header_url, $login_header_title ); 118 149 119 $message = apply_filters('login_message', $message); 150 /** 151 * Filter the message to display above the login form. 152 * 153 * @since 2.1.0 154 * 155 * @param string $message Default message text. 156 */ 157 $message = apply_filters( 'login_message', $message ); 120 158 if ( !empty( $message ) ) 121 159 echo $message . "\n"; 122 160 … … 138 176 $errors .= ' ' . $error . "<br />\n"; 139 177 } 140 178 } 141 if ( !empty($errors) ) 142 echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n"; 143 if ( !empty($messages) ) 144 echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n"; 179 if ( ! empty( $errors ) ) { 180 /** 181 * Filter the error messages displayed above the login. 182 * 183 * @since 2.1.0 184 * 185 * @param string $errors Error message. 186 */ 187 echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n"; 188 } 189 if ( ! empty( $messages ) ) { 190 /** 191 * Filter instructional messages displayed above the login form. 192 * 193 * @since 2.5.0 194 * 195 * @param string $messages Login message. 196 */ 197 echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n"; 198 } 145 199 } 146 200 } // End of login_header() 147 201 … … 167 221 </script> 168 222 <?php endif; ?> 169 223 170 <?php do_action('login_footer'); ?> 224 <?php 225 /** 226 * Fires in the login page footer. 227 * 228 * @since 3.1.0 229 */ 230 do_action( 'login_footer' ); ?> 171 231 <div class="clear"></div> 172 232 </body> 173 233 </html> … … 217 277 $user_data = get_user_by('login', $login); 218 278 } 219 279 220 do_action('lostpassword_post'); 280 /** 281 * Fires before errors are returned from a password reset request. 282 * 283 * @since 2.1.0 284 */ 285 do_action( 'lostpassword_post' ); 221 286 222 287 if ( $errors->get_error_code() ) 223 288 return $errors; … … 231 296 $user_login = $user_data->user_login; 232 297 $user_email = $user_data->user_email; 233 298 234 do_action('retreive_password', $user_login); // Misspelled and deprecated 235 do_action('retrieve_password', $user_login); 299 /** 300 * Fires before a new password is retrieved. 301 * 302 * Misspelled and deprecated 303 * 304 * @since 1.5.2 305 * 306 * @param string $user_login The user login name. 307 */ 308 do_action( 'retreive_password', $user_login ); 309 /** 310 * Fires before a new password is retrieved. 311 * 312 * @since 1.5.2 313 * 314 * @param string $user_login The user login name 315 */ 316 do_action( 'retrieve_password', $user_login ); 236 317 237 $allow = apply_filters('allow_password_reset', true, $user_data->ID); 318 /** 319 * Filter whether to allow a password to be reset. 320 * 321 * @since 2.7.0 322 * 323 * @param bool true Whether to allow the password to be reset. Default true. 324 * @param int $user_data->ID The ID of the user attempting to reset a password. 325 */ 326 $allow = apply_filters( 'allow_password_reset', true, $user_data->ID ); 238 327 239 328 if ( ! $allow ) 240 329 return new WP_Error('no_password_reset', __('Password reset is not allowed for this user')); … … 245 334 if ( empty($key) ) { 246 335 // Generate something random for a key... 247 336 $key = wp_generate_password(20, false); 248 do_action('retrieve_password_key', $user_login, $key); 337 /** 338 * Fires before inserting the activation key into the database. 339 * 340 * @since 2.5.0 341 * 342 * @param string $user_login User username to log in. 343 * @param string $key Activation key. 344 */ 345 do_action( 'retrieve_password_key', $user_login, $key ); 249 346 // Now insert the new md5 key into the db 250 347 $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); 251 348 } … … 265 362 266 363 $title = sprintf( __('[%s] Password Reset'), $blogname ); 267 364 268 $title = apply_filters('retrieve_password_title', $title); 269 $message = apply_filters('retrieve_password_message', $message, $key); 365 /** 366 * Filter the subject of the password reset email. 367 * 368 * @since 2.8.0 369 * 370 * @param string $title Default email title. 371 */ 372 $title = apply_filters( 'retrieve_password_title', $title ); 373 /** 374 * Filter the message body of the password reset mail. 375 * 376 * @since 2.8.0 377 * 378 * @param string $message Default mail message. 379 * @param string $key The activation key. 380 */ 381 $message = apply_filters( 'retrieve_password_message', $message, $key ); 270 382 271 383 if ( $message && !wp_mail($user_email, $title, $message) ) 272 384 wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') ); … … 306 418 if ( SITECOOKIEPATH != COOKIEPATH ) 307 419 setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); 308 420 309 // allow plugins to override the default actions, and to add extra actions if they want 421 /** 422 * Fires when the login form is initialized. 423 * 424 * @since 3.2.0 425 * 426 */ 310 427 do_action( 'login_init' ); 428 /** 429 * Fires before a specified login form action. 430 * 431 * The dynamic portion of the hook name, $action, refers to the action that brought the visitor 432 * to the login form. Actions include 'postpass', 'logout', 'lostpassword', etc. 433 * 434 * @since 2.8.0 435 * 436 */ 311 437 do_action( 'login_form_' . $action ); 312 438 313 439 $http_post = ('POST' == $_SERVER['REQUEST_METHOD']); … … 322 448 /** 323 449 * Filter the life of the post password cookie. 324 450 * 325 * By default, the cookie expires 10 days from now.451 * By default, the cookie expires 10 days from creation. 326 452 * To turn this into a session cookie, return 0. 327 453 * 328 454 * @since 3.7.0 455 * 329 456 * @param int $expires The expiry time, as passed to setcookie(). 330 457 */ 331 458 $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS ); … … 359 486 } 360 487 361 488 if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.')); 362 $redirect_to = apply_filters( 'lostpassword_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' ); 489 490 $lostpassword_redirect = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; 491 /** 492 * Filter the URL redirected to after submitting the lostpassword/retrievepassword form. 493 * 494 * @since 3.0.0 495 * 496 * @param string $lostpassword_redirect The redirect destination URL. 497 */ 498 $redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect ); 363 499 364 do_action('lost_password'); 500 /** 501 * Fires before the lost password form. 502 * 503 * @since 1.5.2 504 */ 505 do_action( 'lost_password' ); 365 506 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); 366 507 367 508 $user_login = isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : ''; … … 373 514 <label for="user_login" ><?php _e('Username or E-mail:') ?><br /> 374 515 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label> 375 516 </p> 376 <?php do_action('lostpassword_form'); ?> 517 <?php 518 /** 519 * Fires inside the lostpassword <form> tags, before the hidden fields. 520 * 521 * @since 2.1.0 522 */ 523 do_action( 'lostpassword_form' ); ?> 377 524 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> 378 525 <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> 379 526 </form> 380 527 381 528 <p id="nav"> 382 529 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a> 383 <?php if ( get_option( 'users_can_register' ) ) : ?> 384 | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> 385 <?php endif; ?> 530 <?php if ( get_option( 'users_can_register' ) ) : 531 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); 532 /** 533 * Filter the registration URL below the login form. 534 * 535 * @since 1.5.2 536 * 537 * @param string $registration_url Register link text. 538 */ 539 echo ' | ' . apply_filters( 'register', $registration_url ); 540 endif; ?> 386 541 </p> 387 542 388 543 <?php … … 403 558 if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) 404 559 $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); 405 560 561 /** 562 * Fires before the validation in the password reset procedure. 563 * 564 * @since 3.5.0 565 * 566 * @param object $errors WP Error object. 567 * @param string $user User data. 568 */ 406 569 do_action( 'validate_password_reset', $errors, $user ); 407 570 408 571 if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) { … … 439 602 440 603 <p id="nav"> 441 604 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> 442 <?php if ( get_option( 'users_can_register' ) ) : ?> 443 | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> 444 <?php endif; ?> 605 <?php if ( get_option( 'users_can_register' ) ) : 606 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); 607 //duplicate_hook 608 echo ' | ' . apply_filters( 'register', $registration_url ); 609 endif; ?> 445 610 </p> 446 611 447 612 <?php … … 450 615 451 616 case 'register' : 452 617 if ( is_multisite() ) { 453 // Multisite uses wp-signup.php 454 wp_redirect( apply_filters( 'wp_signup_location', network_site_url('wp-signup.php') ) ); 618 $sign_up_url = network_site_url( 'wp-signup.php' ); 619 /** 620 * Filter the Multisite sign up redirect URL. 621 * 622 * @since 3.0.0 623 * 624 * @param string $sign_up_url The sign up URL for Multisite. 625 */ 626 wp_redirect( apply_filters( 'wp_signup_location', $sign_up_url ) ); 455 627 exit; 456 628 } 457 629 … … 473 645 } 474 646 } 475 647 648 /** 649 * Filter the registration redirect URL. 650 * 651 * @since 3.0.0 652 * 653 * @param string The redirect destination URL. 654 */ 476 655 $redirect_to = apply_filters( 'registration_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' ); 477 656 login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors); 478 657 ?> … … 486 665 <label for="user_email"><?php _e('E-mail') ?><br /> 487 666 <input type="text" name="user_email" id="user_email" class="input" value="<?php echo esc_attr(wp_unslash($user_email)); ?>" size="25" /></label> 488 667 </p> 489 <?php do_action('register_form'); ?> 668 <?php 669 /** 670 * Fires following the 'E-mail' field in the user registration form. 671 * 672 * @since 2.1.0 673 */ 674 do_action( 'register_form' ); ?> 490 675 <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p> 491 676 <br class="clear" /> 492 677 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> … … 543 728 else 544 729 $user = wp_signon('', $secure_cookie); 545 730 546 $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user); 731 $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; 732 /** 733 * Filter the login redirect URL. 734 * 735 * @since 3.0.0 736 * 737 * @param string $redirect_to The redirect destination URL. 738 * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. 739 * @param object $user User data object. 740 */ 741 $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user ); 547 742 548 743 if ( !is_wp_error($user) && !$reauth ) { 549 744 if ( $interim_login ) { … … 551 746 $interim_login = 'success'; 552 747 login_header( '', $message ); ?> 553 748 </div> 554 <?php do_action( 'login_footer' ); ?> 749 <?php 750 //duplicate_hook 751 do_action( 'login_footer' ); ?> 555 752 <?php if ( $customize_login ) : ?> 556 753 <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> 557 754 <?php endif; ?> … … 596 793 $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.' ), 'message' ); 597 794 } 598 795 796 /** 797 * Filter the login page errors. 798 * 799 * @since 3.6.0 800 * 801 * @param object $errors WP Error object. 802 * @param string $redirect_to Redirect destination URL. 803 */ 599 804 $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); 600 805 601 806 // Clear any stale cookies. … … 618 823 <label for="user_pass"><?php _e('Password') ?><br /> 619 824 <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" /></label> 620 825 </p> 621 <?php do_action('login_form'); ?> 826 <?php 827 /** 828 * Fires following the 'Password' field in the login form. 829 * 830 * @since 2.1.0 831 */ 832 do_action( 'login_form' ); ?> 622 833 <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> 623 834 <p class="submit"> 624 835 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Log In'); ?>" /> … … 636 847 637 848 <?php if ( ! $interim_login ) { ?> 638 849 <p id="nav"> 639 <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : ?> 640 <?php if ( get_option( 'users_can_register' ) ) : ?> 641 <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> | 642 <?php endif; ?> 850 <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : 851 if ( get_option( 'users_can_register' ) ) : 852 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); 853 //duplicate_hook 854 echo apply_filters( 'register', $registration_url ) . ' | '; 855 endif; 856 ?> 643 857 <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a> 644 858 <?php endif; ?> 645 859 </p>