Ticket #25393: wp-login-3.diff
| File wp-login-3.diff, 15.3 KB (added by , 12 years ago) |
|---|
-
src/wp-login.php
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 for shaking the login form. 54 * 55 * @since 3.0.0 56 * 57 * @param array $shake_error_codes Error codes that 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 time of enqueueing scripts and styles on the login page. 89 * 90 * The proper hook to use when enqueueing scripts and styles that will 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() ) { … … 88 107 $login_header_title = __( 'Powered by WordPress' ); 89 108 } 90 109 91 $login_header_url = apply_filters( 'login_headerurl', $login_header_url ); 110 /** 111 * Filter link URL of the header logo above login form. 112 * 113 * @since 2.1.0 114 * 115 * @param string $login_header_url Default URL. 116 */ 117 $login_header_url = apply_filters( 'login_headerurl', $login_header_url ); 118 /** 119 * Filter the title of the header logo above login form. 120 * 121 * @since 2.1.0 122 * 123 * @param string $login_header_title Default title. 124 */ 92 125 $login_header_title = apply_filters( 'login_headertitle', $login_header_title ); 93 126 94 127 $classes = array( 'login-action-' . $action, 'wp-core-ui' ); … … 106 139 $classes[] = 'interim-login-success'; 107 140 } 108 141 142 /** 143 * Filter the login page <body> classes. 144 * 145 * @since 3.5.0 146 * 147 * @param array $classes Classes to be added to the <body>. 148 * @param string $action The action user took before coming to the login page. 149 */ 109 150 $classes = apply_filters( 'login_body_class', $classes, $action ); 110 151 111 152 ?> … … 117 158 118 159 unset( $login_header_url, $login_header_title ); 119 160 120 $message = apply_filters('login_message', $message); 161 /** 162 * Filter the message to display above the login form. 163 * 164 * @since 2.1.0 165 * 166 * @param string $message Default message text. 167 */ 168 $message = apply_filters( 'login_message', $message ); 121 169 if ( !empty( $message ) ) 122 170 echo $message . "\n"; 123 171 … … 140 188 } 141 189 } 142 190 if ( !empty($errors) ) 143 echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n"; 191 /** 192 * Filter the error message above the login form. 193 * 194 * @since 2.1.0 195 * 196 * @param string $errors Error message. 197 */ 198 echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n"; 144 199 if ( !empty($messages) ) 145 echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n"; 200 /** 201 * Filter the login message above the login form. 202 * 203 * @since 2.5.0 204 * 205 * @param string $messages Login message. 206 */ 207 echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n"; 146 208 } 147 209 } // End of login_header() 148 210 … … 168 230 </script> 169 231 <?php endif; ?> 170 232 171 <?php do_action('login_footer'); ?> 233 <?php 234 /** 235 * Fires at the end of the login page HTML. 236 * 237 * @since 3.1.0 238 */ 239 do_action( 'login_footer' ); ?> 172 240 <div class="clear"></div> 173 241 </body> 174 242 </html> … … 194 262 * 195 263 * @uses $wpdb WordPress Database object 196 264 * 197 * @return bool|WP_Error True: when finish . WP_Error on error265 * @return bool|WP_Error True: when finished. WP_Error on error. 198 266 */ 199 267 function retrieve_password() { 200 268 global $wpdb, $current_site; … … 212 280 $user_data = get_user_by('login', $login); 213 281 } 214 282 215 do_action('lostpassword_post'); 283 /** 284 * Fires before returning WP Error in password retrieving process. 285 * 286 * @since 2.1.0 287 */ 288 do_action( 'lostpassword_post' ); 216 289 217 290 if ( $errors->get_error_code() ) 218 291 return $errors; … … 226 299 $user_login = $user_data->user_login; 227 300 $user_email = $user_data->user_email; 228 301 229 do_action('retreive_password', $user_login); // Misspelled and deprecated 230 do_action('retrieve_password', $user_login); 302 // Misspelled and deprecated 303 do_action( 'retreive_password', $user_login ); 304 /** 305 * Fires within the password retrieval process. 306 * 307 * @since 1.5.2 308 * 309 * @param string $user_login User name to login. 310 */ 311 do_action( 'retrieve_password', $user_login ); 231 312 232 $allow = apply_filters('allow_password_reset', true, $user_data->ID); 313 /** 314 * Filter password reset restriction boolean. 315 * 316 * @since 2.7.0 317 * 318 * @param boolean True as default. 319 * @param int $user_data->ID The ID of the user who is retrieving new password. 320 */ 321 $allow = apply_filters( 'allow_password_reset', true, $user_data->ID ); 233 322 234 323 if ( ! $allow ) 235 324 return new WP_Error('no_password_reset', __('Password reset is not allowed for this user')); … … 240 329 if ( empty($key) ) { 241 330 // Generate something random for a key... 242 331 $key = wp_generate_password(20, false); 243 do_action('retrieve_password_key', $user_login, $key); 332 /** 333 * Fires before inserting the new md5 key into database. 334 * 335 * @since 2.5.0 336 * 337 * @param string $user_login User name to login. 338 * @param string $key Activation key. 339 */ 340 do_action( 'retrieve_password_key', $user_login, $key ); 244 341 // Now insert the new md5 key into the db 245 342 $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); 246 343 } … … 260 357 261 358 $title = sprintf( __('[%s] Password Reset'), $blogname ); 262 359 263 $title = apply_filters('retrieve_password_title', $title); 264 $message = apply_filters('retrieve_password_message', $message, $key); 360 /** 361 * Filter title of the password reset email. 362 * 363 * @since 2.8.0 364 * 365 * @param string $title Default email title. 366 */ 367 $title = apply_filters( 'retrieve_password_title', $title ); 368 /** 369 * Filter body message of the password reset mail. 370 * 371 * @since 2.8.0 372 * 373 * @param string $message Default mail message. 374 * @param string $key The activation key. 375 */ 376 $message = apply_filters( 'retrieve_password_message', $message, $key ); 265 377 266 378 if ( $message && !wp_mail($user_email, $title, $message) ) 267 379 wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') ); … … 301 413 if ( SITECOOKIEPATH != COOKIEPATH ) 302 414 setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); 303 415 304 // allow plugins to override the default actions, and to add extra actions if they want 416 /** 417 * Fires before running the main action of wp-login.php. 418 * 419 * Allow plugins to override the default actions, and add extra actions if they want. 420 * 421 * @since 3.2.0 422 * 423 */ 305 424 do_action( 'login_init' ); 425 /** 426 * Fires before running the main action of wp-login.php, depending on the $action. 427 * 428 * @since 2.8.0 429 * 430 */ 306 431 do_action( 'login_form_' . $action ); 307 432 308 433 $http_post = ('POST' == $_SERVER['REQUEST_METHOD']); … … 321 446 * To turn this into a session cookie, return 0. 322 447 * 323 448 * @since 3.7.0 449 * 324 450 * @param int $expires The expiry time, as passed to setcookie(). 325 451 */ 326 452 $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS ); … … 354 480 } 355 481 356 482 if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.')); 483 /** 484 * Filter the redirect URL after submitting the lostpassword/retrievepassword form. 485 * 486 * @since 3.0.0 487 * 488 * @param string The redirect destination URL. 489 */ 357 490 $redirect_to = apply_filters( 'lostpassword_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' ); 358 491 359 do_action('lost_password'); 492 /** 493 * Fires before the lost password and retrieve password form. 494 * 495 * @since 1.5.2 496 */ 497 do_action( 'lost_password' ); 360 498 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); 361 499 362 500 $user_login = isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : ''; … … 368 506 <label for="user_login" ><?php _e('Username or E-mail:') ?><br /> 369 507 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label> 370 508 </p> 371 <?php do_action('lostpassword_form'); ?> 509 <?php 510 /** 511 * Fires in the lostpassword form to add extra hidden input. 512 * 513 * @since 2.1.0 514 */ 515 do_action( 'lostpassword_form' ); ?> 372 516 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> 373 517 <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> 374 518 </form> … … 375 519 376 520 <p id="nav"> 377 521 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a> 378 <?php if ( get_option( 'users_can_register' ) ) : ?> 379 | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> 380 <?php endif; ?> 522 <?php if ( get_option( 'users_can_register' ) ) : 523 /** 524 * Filter the register link text below the login form. 525 * 526 * @since 1.5.2 527 * 528 * @param string Register link text. 529 */ 530 echo ' | ' . apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); 531 endif; ?> 381 532 </p> 382 533 383 534 <?php … … 398 549 if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) 399 550 $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); 400 551 552 /** 553 * Fires before the validation in the password reset procedure. 554 * 555 * @since 3.5.0 556 * 557 * @param object $errors WP Error object. 558 * @param string $user User data. 559 */ 401 560 do_action( 'validate_password_reset', $errors, $user ); 402 561 403 562 if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) { … … 434 593 435 594 <p id="nav"> 436 595 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> 437 <?php if ( get_option( 'users_can_register' ) ) : ?> 438 | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> 439 <?php endif; ?> 596 <?php if ( get_option( 'users_can_register' ) ) : 597 //duplicate_hook 598 echo ' | ' . apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); 599 endif; ?> 440 600 </p> 441 601 442 602 <?php … … 445 605 446 606 case 'register' : 447 607 if ( is_multisite() ) { 448 // Multisite uses wp-signup.php 608 /** 609 * Filter the redirect destination URL for Multisite. 610 * 611 * @since 3.0.0 612 * 613 * @param string Signup URL for Multisite. 614 */ 449 615 wp_redirect( apply_filters( 'wp_signup_location', network_site_url('wp-signup.php') ) ); 450 616 exit; 451 617 } … … 468 634 } 469 635 } 470 636 637 /** 638 * Filter the redirect destination URL after user registration. 639 * 640 * @since 3.0.0 641 * 642 * @param string The redirect destination URL. 643 */ 471 644 $redirect_to = apply_filters( 'registration_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' ); 472 645 login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors); 473 646 ?> … … 481 654 <label for="user_email"><?php _e('E-mail') ?><br /> 482 655 <input type="text" name="user_email" id="user_email" class="input" value="<?php echo esc_attr(wp_unslash($user_email)); ?>" size="25" /></label> 483 656 </p> 484 <?php do_action('register_form'); ?> 657 <?php 658 /** 659 * Fires in the registration form to add extra input. 660 * 661 * @since 2.1.0 662 */ 663 do_action( 'register_form' ); ?> 485 664 <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p> 486 665 <br class="clear" /> 487 666 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> … … 538 717 else 539 718 $user = wp_signon('', $secure_cookie); 540 719 541 $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user); 720 /** 721 * Filtering the redirect URL after login. 722 * 723 * @since 3.0.0 724 * 725 * @param string $redirect_to The redirect destination URL. 726 * @param string The redirect destination URL which was passed as a parameter. 727 * @param object $user User data object. 728 */ 729 $redirect_to = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user ); 542 730 543 731 if ( !is_wp_error($user) && !$reauth ) { 544 732 if ( $interim_login ) { … … 546 734 $interim_login = 'success'; 547 735 login_header( '', $message ); ?> 548 736 </div> 549 <?php do_action( 'login_footer' ); ?> 737 <?php 738 /** 739 * Fires at the end of the login page HTML. 740 * 741 * @since 3.1.0 742 */ 743 do_action( 'login_footer' ); ?> 550 744 <?php if ( $customize_login ) : ?> 551 745 <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> 552 746 <?php endif; ?> … … 591 785 $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.' ), 'message' ); 592 786 } 593 787 788 /** 789 * Filter the WP Error object of the login page. 790 * 791 * @since 3.6.0 792 * 793 * @param object $errors WP Error object. 794 * @param string $redirect_to Redirect destination URL. 795 */ 594 796 $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); 595 797 596 798 // Clear any stale cookies. … … 613 815 <label for="user_pass"><?php _e('Password') ?><br /> 614 816 <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" /></label> 615 817 </p> 616 <?php do_action('login_form'); ?> 818 <?php 819 /** 820 * Fires in the login form to add extra input. 821 * 822 * @since 2.1.0 823 */ 824 do_action( 'login_form' ); ?> 617 825 <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> 618 826 <p class="submit"> 619 827 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Log In'); ?>" /> … … 631 839 632 840 <?php if ( ! $interim_login ) { ?> 633 841 <p id="nav"> 634 <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : ?> 635 <?php if ( get_option( 'users_can_register' ) ) : ?> 636 <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> | 637 <?php endif; ?> 842 <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : 843 if ( get_option( 'users_can_register' ) ) : 844 //duplicate_hook 845 echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ) . ' | '; 846 endif; 847 ?> 638 848 <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a> 639 849 <?php endif; ?> 640 850 </p>