- if ( $message && !wp_mail($user_email, $title, $message) )
- die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
-
- 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_usermeta($user->ID, 'default_password_nag', 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";
-
- $title = sprintf(__('[%s] Your new password'), get_option('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) )
- die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
-
- wp_password_change_notification($user);
+ $message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n";
+ $message .= network_home_url( '/' ) . "\r\n\r\n";
+ $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
+ $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n";
+ $message .= __('To reset your password, visit the following address:') . "\r\n\r\n";
+ $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), '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] Password Reset'), $blogname );
+
+ /**
+ * 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
+ * @since 4.1.0 Added `$user_login` and `$user_data` parameters.
+ *
+ * @param string $message Default mail message.
+ * @param string $key The activation key.
+ * @param string $user_login The username for the user.
+ * @param WP_User $user_data WP_User object.
+ */
+ $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );
+
+ 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.') );