+ // random_password filter was previously in random_password function which was deprecated
+ return apply_filters('random_password', $password);
+}
+endif;
+
+if ( !function_exists('wp_rand') ) :
+ /**
+ * Generates a random number
+ *
+ * @since 2.6.2
+ *
+ * @param int $min Lower limit for the generated number (optional, default is 0)
+ * @param int $max Upper limit for the generated number (optional, default is 4294967295)
+ * @return int A random number between min and max
+ */
+function wp_rand( $min = 0, $max = 0 ) {
+ global $rnd_value;
+
+ // Reset $rnd_value after 14 uses
+ // 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value
+ if ( strlen($rnd_value) < 8 ) {
+ if ( defined( 'WP_SETUP_CONFIG' ) )
+ static $seed = '';
+ else
+ $seed = get_transient('random_seed');
+ $rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
+ $rnd_value .= sha1($rnd_value);
+ $rnd_value .= sha1($rnd_value . $seed);
+ $seed = md5($seed . $rnd_value);
+ if ( ! defined( 'WP_SETUP_CONFIG' ) )
+ set_transient('random_seed', $seed);
+ }
+
+ // Take the first 8 digits for our value
+ $value = substr($rnd_value, 0, 8);
+
+ // Strip the first eight, leaving the remainder for the next call to wp_rand().
+ $rnd_value = substr($rnd_value, 8);
+
+ $value = abs(hexdec($value));
+
+ // Reduce the value to be within the min - max range
+ // 4294967295 = 0xffffffff = max random number
+ if ( $max != 0 )
+ $value = $min + (($max - $min + 1) * ($value / (4294967295 + 1)));
+
+ return abs(intval($value));
+}
+endif;
+
+if ( !function_exists('wp_set_password') ) :
+/**
+ * Updates the user's password with a new encrypted one.
+ *
+ * For integration with other applications, this function can be overwritten to
+ * instead use the other package password checking algorithm.
+ *
+ * @since 2.5
+ * @uses $wpdb WordPress database object for queries
+ * @uses wp_hash_password() Used to encrypt the user's password before passing to the database
+ *
+ * @param string $password The plaintext new user password
+ * @param int $user_id User ID
+ */
+function wp_set_password( $password, $user_id ) {
+ global $wpdb;
+
+ $hash = wp_hash_password($password);
+ $wpdb->update($wpdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id) );
+
+ wp_cache_delete($user_id, 'users');
+}
+endif;
+
+if ( !function_exists( 'get_avatar' ) ) :
+/**
+ * Retrieve the avatar for a user who provided a user ID or email address.
+ *
+ * @since 2.5
+ * @param int|string|object $id_or_email A user ID, email address, or comment object
+ * @param int $size Size of the avatar image
+ * @param string $default URL to a default image to use if no avatar is available
+ * @param string $alt Alternate text to use in image tag. Defaults to blank
+ * @return string <img> tag for the user's avatar
+*/
+function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) {
+ if ( ! get_option('show_avatars') )
+ return false;
+
+ if ( false === $alt)
+ $safe_alt = '';
+ else
+ $safe_alt = esc_attr( $alt );
+
+ if ( !is_numeric($size) )
+ $size = '96';
+
+ $email = '';
+ if ( is_numeric($id_or_email) ) {
+ $id = (int) $id_or_email;
+ $user = get_userdata($id);
+ if ( $user )
+ $email = $user->user_email;
+ } elseif ( is_object($id_or_email) ) {
+ // No avatar for pingbacks or trackbacks
+ $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
+ if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) )
+ return false;
+
+ if ( !empty($id_or_email->user_id) ) {
+ $id = (int) $id_or_email->user_id;
+ $user = get_userdata($id);
+ if ( $user)
+ $email = $user->user_email;
+ } elseif ( !empty($id_or_email->comment_author_email) ) {
+ $email = $id_or_email->comment_author_email;
+ }
+ } else {
+ $email = $id_or_email;
+ }
+
+ if ( empty($default) ) {
+ $avatar_default = get_option('avatar_default');
+ if ( empty($avatar_default) )
+ $default = 'mystery';
+ else
+ $default = $avatar_default;
+ }
+
+ if ( !empty($email) )
+ $email_hash = md5( strtolower( $email ) );
+
+ if ( is_ssl() ) {
+ $host = 'https://secure.gravatar.com';