Changeset 25701
- Timestamp:
- 10/06/2013 04:23:39 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-login.php
r25696 r25701 24 24 25 25 /** 26 * Output s the header for the login page.26 * Output the login page header. 27 27 * 28 * @uses do_action() Calls the 'login_head' for outputting HTML in the Log In 29 * 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 the 33 * header. 34 * @uses $error The error global, which is checked for displaying errors. 35 * 36 * @param string $title Optional. WordPress Log In Page title to display in 37 * <title/> element. 38 * @param string $message Optional. Message to display in header. 28 * @param string $title Optional. WordPress Log In Page title to display in <title/> element. Default 'Log In'. 29 * @param string $message Optional. Message to display in header. Default empty. 30 * @param string $wp_error Optional. The error to pass. Default empty. 39 31 * @param WP_Error $wp_error Optional. WordPress Error Object 40 32 */ … … 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 … … 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 … … 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 Login header logo 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 Login header logo title attribute. 113 */ 91 114 $login_header_title = apply_filters( 'login_headertitle', $login_header_title ); 92 115 … … 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 … … 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 Login message text. 156 */ 157 $message = apply_filters( 'login_message', $message ); 120 158 if ( !empty( $message ) ) 121 159 echo $message . "\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 form. 182 * 183 * @since 2.1.0 184 * 185 * @param string $errors Login 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 messages. 196 */ 197 echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n"; 198 } 145 199 } 146 200 } // End of login_header() … … 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> … … 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() ) … … 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); 236 237 $allow = apply_filters('allow_password_reset', true, $user_data->ID); 299 /** 300 * Fires before a new password is retrieved. 301 * 302 * @since 1.5.2 303 * @deprecated 1.5.2 Misspelled. Use 'retrieve_password' hook instead. 304 * 305 * @param string $user_login The user login name. 306 */ 307 do_action( 'retreive_password', $user_login ); 308 /** 309 * Fires before a new password is retrieved. 310 * 311 * @since 1.5.2 312 * 313 * @param string $user_login The user login name. 314 */ 315 do_action( 'retrieve_password', $user_login ); 316 317 /** 318 * Filter whether to allow a password to be reset. 319 * 320 * @since 2.7.0 321 * 322 * @param bool true Whether to allow the password to be reset. Default true. 323 * @param int $user_data->ID The ID of the user attempting to reset a password. 324 */ 325 $allow = apply_filters( 'allow_password_reset', true, $user_data->ID ); 238 326 239 327 if ( ! $allow ) … … 279 367 $title = sprintf( __('[%s] Password Reset'), $blogname ); 280 368 281 $title = apply_filters('retrieve_password_title', $title); 282 $message = apply_filters('retrieve_password_message', $message, $key); 369 /** 370 * Filter the subject of the password reset email. 371 * 372 * @since 2.8.0 373 * 374 * @param string $title Default email title. 375 */ 376 $title = apply_filters( 'retrieve_password_title', $title ); 377 /** 378 * Filter the message body of the password reset mail. 379 * 380 * @since 2.8.0 381 * 382 * @param string $message Default mail message. 383 * @param string $key The activation key. 384 */ 385 $message = apply_filters( 'retrieve_password_message', $message, $key ); 283 386 284 387 if ( $message && !wp_mail($user_email, $title, $message) ) … … 320 423 setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); 321 424 322 // allow plugins to override the default actions, and to add extra actions if they want 425 /** 426 * Fires when the login form is initialized. 427 * 428 * @since 3.2.0 429 */ 323 430 do_action( 'login_init' ); 431 /** 432 * Fires before a specified login form action. 433 * 434 * The dynamic portion of the hook name, $action, refers to the action 435 * that brought the visitor to the login form. Actions include 'postpass', 436 * 'logout', 'lostpassword', etc. 437 * 438 * @since 2.8.0 439 */ 324 440 do_action( 'login_form_' . $action ); 325 441 … … 334 450 335 451 /** 336 * Filter the life of the post password cookie.337 * 338 * By default, the cookie expires 10 days from now.339 * To turn thisinto a session cookie, return 0.452 * Filter the life span of the post password cookie. 453 * 454 * By default, the cookie expires 10 days from creation. To turn this 455 * into a session cookie, return 0. 340 456 * 341 457 * @since 3.7.0 458 * 342 459 * @param int $expires The expiry time, as passed to setcookie(). 343 460 */ … … 379 496 } 380 497 381 $redirect_to = apply_filters( 'lostpassword_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' ); 382 383 do_action('lost_password'); 498 $lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; 499 /** 500 * Filter the URL redirected to after submitting the lostpassword/retrievepassword form. 501 * 502 * @since 3.0.0 503 * 504 * @param string $lostpassword_redirect The redirect destination URL. 505 */ 506 $redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect ); 507 508 /** 509 * Fires before the lost password form. 510 * 511 * @since 1.5.2 512 */ 513 do_action( 'lost_password' ); 514 384 515 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); 385 516 … … 393 524 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label> 394 525 </p> 395 <?php do_action('lostpassword_form'); ?> 526 <?php 527 /** 528 * Fires inside the lostpassword <form> tags, before the hidden fields. 529 * 530 * @since 2.1.0 531 */ 532 do_action( 'lostpassword_form' ); ?> 396 533 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> 397 534 <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> … … 400 537 <p id="nav"> 401 538 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a> 402 <?php if ( get_option( 'users_can_register' ) ) : ?> 403 | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> 404 <?php endif; ?> 539 <?php 540 if ( get_option( 'users_can_register' ) ) : 541 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); 542 /** 543 * Filter the registration URL below the login form. 544 * 545 * @since 1.5.2 546 * 547 * @param string $registration_url Registration URL. 548 */ 549 echo ' | ' . apply_filters( 'register', $registration_url ); 550 endif; 551 ?> 405 552 </p> 406 553 … … 426 573 $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); 427 574 575 /** 576 * Fires before the password reset procedure is validated. 577 * 578 * @since 3.5.0 579 * 580 * @param object $errors WP Error object. 581 * @param WP_User|WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise. 582 */ 428 583 do_action( 'validate_password_reset', $errors, $user ); 429 584 … … 462 617 <p id="nav"> 463 618 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> 464 <?php if ( get_option( 'users_can_register' ) ) : ?> 465 | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> 466 <?php endif; ?> 619 <?php 620 if ( get_option( 'users_can_register' ) ) : 621 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); 622 //duplicate_hook 623 echo ' | ' . apply_filters( 'register', $registration_url ); 624 endif; 625 ?> 467 626 </p> 468 627 … … 473 632 case 'register' : 474 633 if ( is_multisite() ) { 475 // Multisite uses wp-signup.php 476 wp_redirect( apply_filters( 'wp_signup_location', network_site_url('wp-signup.php') ) ); 634 $sign_up_url = network_site_url( 'wp-signup.php' ); 635 /** 636 * Filter the Multisite sign up URL. 637 * 638 * @since 3.0.0 639 * 640 * @param string $sign_up_url The sign up URL. 641 */ 642 wp_redirect( apply_filters( 'wp_signup_location', $sign_up_url ) ); 477 643 exit; 478 644 } … … 496 662 } 497 663 498 $redirect_to = apply_filters( 'registration_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' ); 664 $registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; 665 /** 666 * Filter the registration redirect URL. 667 * 668 * @since 3.0.0 669 * 670 * @param string $registration_redirect The redirect destination URL. 671 */ 672 $redirect_to = apply_filters( 'registration_redirect', $registration_redirect ); 499 673 login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors); 500 674 ?> … … 509 683 <input type="text" name="user_email" id="user_email" class="input" value="<?php echo esc_attr(wp_unslash($user_email)); ?>" size="25" /></label> 510 684 </p> 511 <?php do_action('register_form'); ?> 685 <?php 686 /** 687 * Fires following the 'E-mail' field in the user registration form. 688 * 689 * @since 2.1.0 690 */ 691 do_action( 'register_form' ); 692 ?> 512 693 <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p> 513 694 <br class="clear" /> … … 566 747 $user = wp_signon('', $secure_cookie); 567 748 568 $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user); 749 $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; 750 /** 751 * Filter the login redirect URL. 752 * 753 * @since 3.0.0 754 * 755 * @param string $redirect_to The redirect destination URL. 756 * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. 757 * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. 758 */ 759 $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user ); 569 760 570 761 if ( !is_wp_error($user) && !$reauth ) { … … 574 765 login_header( '', $message ); ?> 575 766 </div> 576 <?php do_action( 'login_footer' ); ?> 767 <?php 768 //duplicate_hook 769 do_action( 'login_footer' ); ?> 577 770 <?php if ( $customize_login ) : ?> 578 771 <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> … … 619 812 } 620 813 814 /** 815 * Filter the login page errors. 816 * 817 * @since 3.6.0 818 * 819 * @param object $errors WP Error object. 820 * @param string $redirect_to Redirect destination URL. 821 */ 621 822 $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); 622 823 … … 641 842 <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" /></label> 642 843 </p> 643 <?php do_action('login_form'); ?> 844 <?php 845 /** 846 * Fires following the 'Password' field in the login form. 847 * 848 * @since 2.1.0 849 */ 850 do_action( 'login_form' ); 851 ?> 644 852 <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> 645 853 <p class="submit"> … … 659 867 <?php if ( ! $interim_login ) { ?> 660 868 <p id="nav"> 661 <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : ?> 662 <?php if ( get_option( 'users_can_register' ) ) : ?> 663 <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> | 664 <?php endif; ?> 869 <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : 870 if ( get_option( 'users_can_register' ) ) : 871 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); 872 //duplicate_hook 873 echo apply_filters( 'register', $registration_url ) . ' | '; 874 endif; 875 ?> 665 876 <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a> 666 877 <?php endif; ?>
Note: See TracChangeset
for help on using the changeset viewer.