Index: wp-login.php
===================================================================
--- wp-login.php	(revision 25535)
+++ wp-login.php	(working copy)
@@ -49,6 +49,13 @@
 
 	// Shake it!
 	$shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' );
+	/**
+	 * Filter the error codes array for shaking the login form.
+	 *
+	 * @since 3.0.0
+	 *
+	 * @param array $shake_error_codes Error codes that shake the login form.
+	 */
 	$shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes );
 
 	if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) )
@@ -77,7 +84,19 @@
 		<?php
 	}
 
+	/**
+	 * Fires at the time of enqueueing scripts and styles on the login page.
+	 *
+	 * The proper hook to use when enqueueing scripts and styles that will appear on the login page.
+	 *
+	 * @since 3.1.0
+	 */
 	do_action( 'login_enqueue_scripts' );
+	/**
+	 * Fires before </head> on the login page.
+	 *
+	 * @since 2.1.0
+	 */
 	do_action( 'login_head' );
 
 	if ( is_multisite() ) {
@@ -88,7 +107,21 @@
 		$login_header_title = __( 'Powered by WordPress' );
 	}
 
-	$login_header_url   = apply_filters( 'login_headerurl',   $login_header_url   );
+	/**
+	 * Filter link URL of the header logo above login form.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string $login_header_url Default URL.
+	 */
+	$login_header_url   = apply_filters( 'login_headerurl', $login_header_url );
+	/**
+	 * Filter the title of the header logo above login form.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string $login_header_title Default title.
+	 */
 	$login_header_title = apply_filters( 'login_headertitle', $login_header_title );
 
 	$classes = array( 'login-action-' . $action, 'wp-core-ui' );
@@ -106,6 +139,14 @@
 			$classes[] = 'interim-login-success';
 	}
 
+	/**
+	 * Filter the classes of login page <body> tag.
+	 *
+	 * @since 3.5.0
+	 *
+	 * @param array  $classes Classes to be added to the <body>.
+	 * @param string $action  The action user took before coming to the login page.
+	 */
 	$classes = apply_filters( 'login_body_class', $classes, $action );
 
 	?>
@@ -117,7 +158,14 @@
 
 	unset( $login_header_url, $login_header_title );
 
-	$message = apply_filters('login_message', $message);
+	/**
+	 * Filter the message to display above the login form.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string $message Default message text.
+	 */
+	$message = apply_filters( 'login_message', $message );
 	if ( !empty( $message ) )
 		echo $message . "\n";
 
@@ -140,9 +188,23 @@
 			}
 		}
 		if ( !empty($errors) )
-			echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
+			/**
+			 * Filter the error message above the login form.
+			 *
+			 * @since 2.1.0
+			 *
+			 * @param string $errors Error message.
+			 */
+			echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n";
 		if ( !empty($messages) )
-			echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
+			/**
+			 * Filter the login message above the login form.
+			 *
+			 * @since 2.5.0
+			 *
+			 * @param string $messages Login message.
+			 */
+			echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n";
 	}
 } // End of login_header()
 
@@ -168,7 +230,13 @@
 	</script>
 	<?php endif; ?>
 
-	<?php do_action('login_footer'); ?>
+	<?php
+	/**
+	 * Fires at the end of the login page HTML.
+	 *
+	 * @since 3.1.0
+	 */
+	do_action( 'login_footer' ); ?>
 	<div class="clear"></div>
 	</body>
 	</html>
@@ -194,7 +262,7 @@
  *
  * @uses $wpdb WordPress Database object
  *
- * @return bool|WP_Error True: when finish. WP_Error on error
+ * @return bool|WP_Error True: when finished. WP_Error on error.
  */
 function retrieve_password() {
 	global $wpdb, $current_site;
@@ -212,7 +280,12 @@
 		$user_data = get_user_by('login', $login);
 	}
 
-	do_action('lostpassword_post');
+	/**
+	 * Fires before returning WP Error in password retrieval process.
+	 *
+	 * @since 2.1.0
+	 */
+	do_action( 'lostpassword_post' );
 
 	if ( $errors->get_error_code() )
 		return $errors;
@@ -226,10 +299,34 @@
 	$user_login = $user_data->user_login;
 	$user_email = $user_data->user_email;
 
-	do_action('retreive_password', $user_login);  // Misspelled and deprecated
-	do_action('retrieve_password', $user_login);
+	/**
+	 * Fires within the password retrieval process.
+	 *
+	 * Misspelled and deprecated
+	 * 
+	 * @since 1.5.2
+	 *
+	 * @param string $user_login User name to login.
+	 */
+	do_action( 'retreive_password', $user_login );
+	/**
+	 * Fires within the password retrieval process.
+	 *
+	 * @since 1.5.2
+	 *
+	 * @param string $user_login User name to login.
+	 */
+	do_action( 'retrieve_password', $user_login );
 
-	$allow = apply_filters('allow_password_reset', true, $user_data->ID);
+	/**
+	 * Filter password reset restriction condition boolean to disallow password reset.
+	 *
+	 * @since 2.7.0
+	 *
+	 * @param boolean            Allow/Disallow user to reset password, true as default.
+	 * @param int $user_data->ID The ID of the user who is retrieving new password.
+	 */
+	$allow = apply_filters( 'allow_password_reset', true, $user_data->ID );
 
 	if ( ! $allow )
 		return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
@@ -240,7 +337,15 @@
 	if ( empty($key) ) {
 		// Generate something random for a key...
 		$key = wp_generate_password(20, false);
-		do_action('retrieve_password_key', $user_login, $key);
+		/**
+		 * Fires before inserting the activation key into database.
+		 *
+		 * @since 2.5.0
+		 *
+		 * @param string $user_login User name to login.
+		 * @param string $key        Activation key.
+		 */
+		do_action( 'retrieve_password_key', $user_login, $key );
 		// Now insert the new md5 key into the db
 		$wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
 	}
@@ -260,8 +365,23 @@
 
 	$title = sprintf( __('[%s] Password Reset'), $blogname );
 
-	$title = apply_filters('retrieve_password_title', $title);
-	$message = apply_filters('retrieve_password_message', $message, $key);
+	/**
+	 * Filter title of the password reset email.
+	 *
+	 * @since 2.8.0
+	 *
+	 * @param string $title Default email title.
+	 */
+	$title = apply_filters( 'retrieve_password_title', $title );
+	/**
+	 * Filter body message of the password reset mail.
+	 *
+	 * @since 2.8.0
+	 *
+	 * @param string $message Default mail message.
+	 * @param string $key     The activation key.
+	 */
+	$message = apply_filters( 'retrieve_password_message', $message, $key );
 
 	if ( $message && !wp_mail($user_email, $title, $message) )
 		wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') );
@@ -301,8 +421,21 @@
 if ( SITECOOKIEPATH != COOKIEPATH )
 	setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
 
-// allow plugins to override the default actions, and to add extra actions if they want
+/**
+ * Fires before running the actions such as showing forms and logout etc.
+ * 
+ * Allow plugins to override the default actions, and add extra actions if they want.
+ *
+ * @since 3.2.0
+ *
+ */
 do_action( 'login_init' );
+/**
+ * Fires before running the actions such as showing forms and logout etc. depending on the $action.
+ * 
+ * @since 2.8.0
+ *
+ */
 do_action( 'login_form_' . $action );
 
 $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
@@ -321,6 +454,7 @@
 	 * To turn this into a session cookie, return 0.
 	 *
 	 * @since 3.7.0
+	 *
 	 * @param int $expires The expiry time, as passed to setcookie().
 	 */
 	$expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
@@ -354,9 +488,23 @@
 	}
 
 	if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.'));
-	$redirect_to = apply_filters( 'lostpassword_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' );
+	
+	$lostpassword_redirect = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
+	/**
+	 * Filter the redirect URL after submitting the lostpassword/retrievepassword form.
+	 *
+	 * @since 3.0.0
+	 *
+	 * @param string $lostpassword_redirect The redirect destination URL.
+	 */
+	$redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect );
 
-	do_action('lost_password');
+	/**
+	 * Fires before the lost password and retrieve password form.
+	 *
+	 * @since 1.5.2
+	 */
+	do_action( 'lost_password' );
 	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);
 
 	$user_login = isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : '';
@@ -368,7 +516,13 @@
 		<label for="user_login" ><?php _e('Username or E-mail:') ?><br />
 		<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label>
 	</p>
-<?php do_action('lostpassword_form'); ?>
+<?php 
+/**
+ * Fires in the lostpassword form before the hidden fields.
+ * 
+ * @since 2.1.0
+ */
+do_action( 'lostpassword_form' ); ?>
 	<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
 	<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>
 </form>
@@ -375,9 +529,17 @@
 
 <p id="nav">
 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a>
-<?php if ( get_option( 'users_can_register' ) ) : ?>
- | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?>
-<?php endif; ?>
+<?php if ( get_option( 'users_can_register' ) ) :
+	$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
+	/**
+	 * Filter the register link text below the login form.
+	 *
+	 * @since 1.5.2
+	 *
+	 * @param string $registration_url Register link text.
+	 */
+	echo ' | ' . apply_filters( 'register', $registration_url );
+endif; ?>
 </p>
 
 <?php
@@ -398,6 +560,14 @@
 	if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] )
 		$errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) );
 
+	/**
+	 * Fires before the validation in the password reset procedure.
+	 * 
+	 * @since 3.5.0
+	 *
+	 * @param object $errors WP Error object.
+	 * @param string $user   User data.
+	 */
 	do_action( 'validate_password_reset', $errors, $user );
 
 	if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) {
@@ -434,9 +604,11 @@
 
 <p id="nav">
 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
-<?php if ( get_option( 'users_can_register' ) ) : ?>
- | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?>
-<?php endif; ?>
+<?php if ( get_option( 'users_can_register' ) ) :
+	$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
+	//duplicate_hook
+	echo ' | ' . apply_filters( 'register', $registration_url );
+endif; ?>
 </p>
 
 <?php
@@ -445,7 +617,13 @@
 
 case 'register' :
 	if ( is_multisite() ) {
-		// Multisite uses wp-signup.php
+		/**
+		 * Filter the redirect destination URL for Multisite.
+		 *
+		 * @since 3.0.0
+		 *
+		 * @param string Signup URL for Multisite.
+		 */
 		wp_redirect( apply_filters( 'wp_signup_location', network_site_url('wp-signup.php') ) );
 		exit;
 	}
@@ -468,6 +646,13 @@
 		}
 	}
 
+	/**
+	 * Filter the redirect destination URL after user registration.
+	 *
+	 * @since 3.0.0
+	 *
+	 * @param string The redirect destination URL.
+	 */
 	$redirect_to = apply_filters( 'registration_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' );
 	login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors);
 ?>
@@ -481,7 +666,13 @@
 		<label for="user_email"><?php _e('E-mail') ?><br />
 		<input type="text" name="user_email" id="user_email" class="input" value="<?php echo esc_attr(wp_unslash($user_email)); ?>" size="25" /></label>
 	</p>
-<?php do_action('register_form'); ?>
+<?php 
+/**
+ * Fires in the registration form to add extra inputs.
+ * 
+ * @since 2.1.0
+ */
+do_action( 'register_form' ); ?>
 	<p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p>
 	<br class="clear" />
 	<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
@@ -538,7 +729,17 @@
 	else
 		$user = wp_signon('', $secure_cookie);
 
-	$redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);
+	$requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
+	/**
+	 * Filtering the redirect URL after login.
+	 *
+	 * @since 3.0.0
+	 *
+	 * @param string $redirect_to 			The redirect destination URL.
+	 * @param string $requested_redirect_to	The redirect destination URL passed as a parameter.
+	 * @param object $user					User data object. 
+	 */
+	$redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user );
 
 	if ( !is_wp_error($user) && !$reauth ) {
 		if ( $interim_login ) {
@@ -546,7 +747,13 @@
 			$interim_login = 'success';
 			login_header( '', $message ); ?>
 			</div>
-			<?php do_action( 'login_footer' ); ?>
+			<?php
+			/**
+			 * Fires at the end of the login page HTML.
+			 * 
+			 * @since 3.1.0
+			 */
+			do_action( 'login_footer' ); ?>
 			<?php if ( $customize_login ) : ?>
 				<script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script>
 			<?php endif; ?>
@@ -591,6 +798,14 @@
 			$errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.' ), 'message' );
 	}
 
+	/**
+	 * Filter the WP Error object of the login page.
+	 *
+	 * @since 3.6.0
+	 *
+	 * @param object $errors      WP Error object.
+	 * @param string $redirect_to Redirect destination URL.
+	 */
 	$errors = apply_filters( 'wp_login_errors', $errors, $redirect_to );
 
 	// Clear any stale cookies.
@@ -613,7 +828,13 @@
 		<label for="user_pass"><?php _e('Password') ?><br />
 		<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" /></label>
 	</p>
-<?php do_action('login_form'); ?>
+<?php
+/**
+ * Fires in the login form to add extra input.
+ * 
+ * @since 2.1.0
+ */
+do_action( 'login_form' ); ?>
 	<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>
 	<p class="submit">
 		<input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Log In'); ?>" />
@@ -631,10 +852,13 @@
 
 <?php if ( ! $interim_login ) { ?>
 <p id="nav">
-<?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : ?>
-	<?php if ( get_option( 'users_can_register' ) ) : ?>
-		<?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> |
-	<?php endif; ?>
+<?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) :
+	if ( get_option( 'users_can_register' ) ) :
+		$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
+		//duplicate_hook
+		echo apply_filters( 'register', $registration_url ) . ' | ';
+	endif;
+?>
 	<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a>
 <?php endif; ?>
 </p>
