- $title = apply_filters('retrieve_password_title', $title);
- $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...') );
-
- return true;
-}
-
-/**
- * Handles resetting the user's password.
- *
- * @uses $wpdb WordPress Database object
- *
- * @param string $key Hash to validate sending user's password
- * @return bool|WP_Error
- */
-function reset_password($key, $login) {
- global $wpdb;
-
- $key = preg_replace('/[^a-z0-9]/i', '', $key);
-
- if ( empty( $key ) || !is_string( $key ) )
- return new WP_Error('invalid_key', __('Invalid key'));
-
- if ( empty($login) || !is_string($login) )
- return new WP_Error('invalid_key', __('Invalid key'));
-
- $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login));
- if ( empty( $user ) )
- return new WP_Error('invalid_key', __('Invalid key'));
-
- // Generate something random for a password...
- $new_pass = wp_generate_password();
-
- do_action('password_reset', $user, $new_pass);
-
- wp_set_password($new_pass, $user->ID);
- update_user_option($user->ID, 'default_password_nag', true, true); //Set up the Password change nag.
- $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
- $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
- $message .= site_url('wp-login.php', 'login') . "\r\n";
-
- if ( is_multisite() )
- $blogname = $GLOBALS['current_site']->site_name;
- else
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
- // we want to reverse this for the plain text arena of emails.
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
-
- $title = sprintf( __('[%s] Your new password'), $blogname );
-
- $title = apply_filters('password_reset_title', $title);
- $message = apply_filters('password_reset_message', $message, $new_pass);
-
- if ( $message && !wp_mail($user->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...') );
-
- wp_password_change_notification($user);
+ /**
+ * Filter the subject of the password reset email.
+ *
+ * @since 2.8.0
+ *
+ * @param string $title Default email title.
+ */
+ $title = apply_filters( 'retrieve_password_title', $title );
+ /**
+ * Filter the message body 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, wp_specialchars_decode( $title ), $message ) )
+ wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') );