diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index 31ee627..5e1d32a 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -3140,3 +3140,166 @@ function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) {
 		echo $before, $link, $after;
 	}
 }
+
+/**
+ * Retrieve the avatar URL for a user, email address, MD5 hash, comment, or post.
+ *
+ * @uses apply_filters() 'pre_get_avatar_url' to bypass
+ * @uses apply_filters() 'get_avatar_url' filters the result
+ * @uses apply_filters() 'get_avatar_comment_types' filters the comment types for which we can calculate an avatar
+ *
+ * @since 3.8.0
+ * @param mixed $id_or_email The Gravatar to retrieve {
+ *     @type int    {user_id}                   : Use the email address of the corresponding user
+ *     @type string "{hash}@md5.gravatar.com"   : Use the hash directly
+ *     @type string "{email}"
+ *     @type object {User row or WP_User object}: Use the user's email
+ *     @type object {Post row or WP_Post object}: Use the post_author's email
+ *     @type object {Comment row}               : Use the comment's user_id or comment_author_email
+ * }
+ * @param array $args Extra options to apply to the avatar {
+ *     @type int    $size           Size of the avatar image
+ *     @type string $default        URL for the default image or a default type {
+ *             404                    : Return a 404 instead of a default image
+ *             retro                  : 8bit
+ *             monsterid              : Monster
+ *             wavatar                : cartoon face
+ *             identicon              : the "quilt"
+ *             mystery, mm, mysteryman: The Oyster Man
+ *             blank                  : A transparent GIF
+ *             gravatar_default       : Gravatar Logo
+ *     }
+ *     @type bool   $force_default  Always show the default image, never the Gravatar
+ *     @type string $rating         display avatars up to the given rating: G < PG < R < X.
+ *     @type string $scheme         @see set_url_scheme()
+ *     @type array  $processed_args Pass as reference.  When the function returns, the value will be the processed/sanitized $args plus a "found_avatar" guess.
+ * }
+ *
+ * @return bool|string URL false on failure
+ */
+function get_avatar_url( $id_or_email, $args = null ) {
+        $original_args = $args;
+
+        $args = wp_parse_args( $args, array(
+                'size'           => 96,
+                'default'        => get_option( 'avatar_default', 'mystery' ),
+                'force_default'  => false,
+                'rating'         => get_option( 'avatar_rating' ),
+                'scheme'         => null,
+                'processed_args' => null, // if used, should be a reference
+        ) );
+
+        if ( is_numeric( $args['size'] ) ) {
+                $args['size'] = absint( $args['size'] );
+                if ( !$args['size'] ) {
+                        $args['size'] = 96;
+                }
+        } else {
+                $args['size'] = 96;
+        }
+
+        if ( empty( $args['default'] ) ) {
+                $args['default'] = 'mystery';
+        }
+
+        switch ( $args['default'] ) {
+                case 'mm' :
+                case 'mystery' :
+                case 'mysteryman' :
+                        $args['default'] = 'mm';
+                        break;
+                case 'gravatar_default' :
+                        $args['default'] = false;
+                        break;
+        }
+
+        $args['force_default'] = (bool) $args['force_default'];
+
+        $args['rating'] = strtolower( $args['rating'] );
+
+        $args['found_avatar'] = false;
+
+        $url = apply_filters_ref_array( 'pre_get_avatar_url', array( null, $id_or_email, &$args, $original_args ) );
+        if ( !is_null( $url ) ) {
+                $return = apply_filters_ref_array( 'get_avatar_url', array( $url, $id_or_email, &$args, $original_args ) );
+                $args['processed_args'] = $args;
+                unset( $args['processed_args']['processed_args'] );
+                return $return;
+        }
+
+        $email_hash = '';
+        $user = $email = false;
+
+        if ( is_numeric( $id_or_email ) ) {
+                $user = get_user_by( 'id', absint( $id_or_email ) );
+        } elseif ( is_string( $id_or_email ) ) {
+                if ( strpos( $id_or_email, '@md5.gravatar.com' ) ) {
+                        // md5 hash
+                        list( $email_hash ) = explode( '@', $id_or_email );
+                } else {
+                        // email address
+                        $email = $id_or_email;
+                }
+        } elseif ( is_object( $id_or_email ) ) {
+                if ( isset( $id_or_email->comment_ID ) ) {
+                        // Comment Object
+
+                        // 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 ) ) {
+                                $args['processed_args'] = $args;
+                                unset( $args['processed_args']['processed_args'] );
+                                return false;
+                        }
+
+                        if ( ! empty( $id_or_email->user_id ) ) {
+                                $user = get_user_by( 'id', (int) $id_or_email->user_id );
+                        }
+                        if ( ( !$user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
+                                $email = $id_or_email->comment_author_email;
+                        }
+                } elseif ( ! empty( $id_or_email->user_login ) ) {
+                        // User Object
+                        $user = $id_or_email;
+                } elseif ( ! empty( $id_or_email->post_author ) ) {
+                        // Post Object
+                        $user = get_user_by( 'id', (int) $id_or_email->post_author );
+                }
+        }
+
+        if ( !$email_hash ) {
+                if ( $user ) {
+                        $email = $user->user_email;
+                }
+
+                if ( $email ) {
+                        $email_hash = md5( strtolower( trim( $email ) ) );
+                }
+        }
+
+        if ( $email_hash ) {
+                $args['found_avatar'] = true;
+                $gravatar_server = hexdec( $email_hash[0] ) % 3;
+        } else {
+                $gravatar_server = rand( 0, 2 );
+        }
+
+        $url_args = array(
+                's' => $args['size'],
+                'd' => $args['default'],
+                'f' => $args['force_default'] ? 'y' : false,
+                'r' => $args['rating'],
+        );
+
+        $url = sprintf( 'http://%d.gravatar.com/avatar/%s', $gravatar_server, $email_hash );
+
+        $url = add_query_arg(
+                rawurlencode_deep( array_filter( $url_args ) ),
+                set_url_scheme( $url, $args['scheme'] )
+        );
+
+        $return = apply_filters_ref_array( 'get_avatar_url', array( $url, $id_or_email, &$args, $original_args ) );
+        $args['processed_args'] = $args;
+        unset( $args['processed_args']['processed_args'] );
+        return $return;
+}
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index 59d7fd6..355d944 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -2070,122 +2070,107 @@ function wp_set_password( $password, $user_id ) {
 
 if ( !function_exists( 'get_avatar' ) ) :
 /**
- * Retrieve the avatar for a user who provided a user ID or email address.
- *
- * @since 2.5.0
- *
- * @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 Alternative 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
-
-		/**
-		 * Filter the list of allowed comment types for retrieving avatars.
-		 *
-		 * @since 3.0.0
-		 *
-		 * @param array $types An array of content types. Default only contains 'comment'.
-		 */
-		$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;
-		}
-
-		if ( ! $email && ! 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( trim( $email ) ) );
-
-	if ( is_ssl() ) {
-		$host = 'https://secure.gravatar.com';
-	} else {
-		if ( !empty($email) )
-			$host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash[0] ) % 2 ) );
-		else
-			$host = 'http://0.gravatar.com';
-	}
-
-	if ( 'mystery' == $default )
-		$default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
-	elseif ( 'blank' == $default )
-		$default = $email ? 'blank' : includes_url( 'images/blank.gif' );
-	elseif ( !empty($email) && 'gravatar_default' == $default )
-		$default = '';
-	elseif ( 'gravatar_default' == $default )
-		$default = "$host/avatar/?s={$size}";
-	elseif ( empty($email) )
-		$default = "$host/avatar/?d=$default&amp;s={$size}";
-	elseif ( strpos($default, 'http://') === 0 )
-		$default = add_query_arg( 's', $size, $default );
-
-	if ( !empty($email) ) {
-		$out = "$host/avatar/";
-		$out .= $email_hash;
-		$out .= '?s='.$size;
-		$out .= '&amp;d=' . urlencode( $default );
-
-		$rating = get_option('avatar_rating');
-		if ( !empty( $rating ) )
-			$out .= "&amp;r={$rating}";
-
-		$out = str_replace( '&#038;', '&amp;', esc_url( $out ) );
-		$avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
-	} else {
-		$avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
-	}
-
-	/**
-	 * Filter the avatar to retrieve.
-	 *
-	 * @since 2.5.0
-	 *
-	 * @param string            $avatar      Image tag for the user's avatar.
-	 * @param int|object|string $id_or_email A user ID, email address, or comment object.
-	 * @param int               $size        Square avatar width and height in pixels to retrieve.
-	 * @param string            $alt         Alternative text to use in the avatar image tag.
-	 *                                       Default empty.
-	 */
-	return apply_filters( 'get_avatar', $avatar, $id_or_email, $size, $default, $alt );
+ * Retrieve the avatar img tag for a user, email address, MD5 hash, comment, or post.
+ *
+ * @uses apply_filters() 'pre_get_avatar' to bypass
+ * @uses apply_filters() 'get_avatar' filters the result
+ *
+ * @since 2.5
+ * @param mixed  $id_or_email The Gravatar to retrieve {
+ *     @type int    {user_id}                   : Use the email address of the corresponding user
+ *     @type string "{hash}@md5.gravatar.com"   : Use the hash directly
+ *     @type string "{email}"
+ *     @type object {User row or WP_User object}: Use the user's email
+ *     @type object {Post row or WP_Post object}: Use the post_author's email
+ *     @type object {Comment row}               : Use the comment's user_id or comment_author_email
+ * }
+ * @param int    $size        Size of the avatar image
+ * @param string $default     URL for the default image or a default type {
+ *     404                    : Return a 404 instead of a default image
+ *     retro                  : 8bit
+ *     monsterid              : Monster
+ *     wavatar                : cartoon face
+ *     identicon              : the "quilt"
+ *     mystery, mm, mysteryman: The Oyster Man
+ *     blank                  : A transparent GIF
+ *     gravatar_default       : Gravatar Logo
+ * }
+ * @param string $alt         Alternative text to use in image tag. Defaults to blank
+ * @param array  $args        Extra options to apply to the avatar {
+ *     @type bool   $force_default Always show the default image, never the Gravatar
+ *     @type string $rating        display avatars up to the given rating: G < PG < R < X.
+ *     @type string $scheme        @see set_url_scheme()
+ *     @type mixed  $class         array or string of additional classes to add to the img element
+ *     @type bool   $force_display Always show the avatar - ignore the show_avatars option
+ * }
+ *
+ * @return bool|string <img> tag for the user's avatar.  False on failure.
+ */
+function get_avatar( $id_or_email, $size = 96, $default = '', $alt = '', $args = null ) {
+        $defaults = array(
+                // get_avatar_url() args
+                'size'          => 96,
+                'default'       => get_option( 'avatar_default', 'mystery' ),
+                'force_default' => false,
+                'rating'        => get_option( 'avatar_rating' ),
+                'scheme'        => null,
+
+                'alt'           => '',
+                'class'         => null,
+                'force_display' => false,
+        );
+
+        if ( empty( $args ) )
+                $args = array();
+
+        $args['size']    = $size;
+        $args['default'] = $default;
+        $args['alt']     = $alt;
+
+        $original_args = $args;
+
+        $args = wp_parse_args( $args, $defaults );
+
+        $avatar = apply_filters_ref_array( 'pre_get_avatar', array( null, $id_or_email, &$args, $original_args ) );
+        if ( !is_null( $avatar ) ) {
+                return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args, $original_args );
+        }
+
+        if ( !$args['force_display'] && !get_option( 'show_avatars' ) ) {
+                return false;
+        }
+
+        $processed_args = null;
+        $args['processed_args'] =& $processed_args;
+        $url = get_avatar_url( $id_or_email, $args );
+        if ( !$url || is_wp_error( $url ) ) {
+                return false;
+        }
+
+        $class = array( 'avatar', 'avatar-' . (int) $processed_args['size'], 'photo' );
+
+        if ( !$processed_args['found_avatar'] || $processed_args['force_default'] ) {
+                $class[] = ' avatar-default';
+        }
+
+        if ( $args['class'] ) {
+                if ( is_array( $args['class'] ) ) {
+                        $class = array_merge( $class, $args['class'] );
+                } else {
+                        $class[] = $args['class'];
+                }
+        }
+
+        $avatar = sprintf(
+                '<img alt="%s" src="%s" class="%s" height="%d" width="%d" />',
+                esc_attr( $processed_args['alt'] ),
+                esc_url( $url ),
+                esc_attr( join( ' ', $class ) ),
+                (int) $processed_args['size'],
+                (int) $processed_args['size']
+        );
+
+        return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $processed_args, $original_args );
 }
 endif;
 
@@ -2263,4 +2248,3 @@ function wp_text_diff( $left_string, $right_string, $args = null ) {
 	return $r;
 }
 endif;
-
