Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_avatar_data

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
4071       *
4072       * @param array  $args        Arguments passed to get_avatar_data(), after processing.
4073       * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
4074       *                            user email, WP_User object, WP_Post object, or WP_Comment object.
4075       */
4076      $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
4077
4078      if ( isset( $args['url'] ) ) {
4079           /** This filter is documented in wp-includes/link-template.php */
4080           return apply_filters( 'get_avatar_data', $args, $id_or_email );
4081      }
4082
4083      $email_hash = '';
4084      $user       = $email = false;
4085
4086      if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
4087           $id_or_email = get_comment( $id_or_email );
4088      }
4089
 
Line Code
4102           // User Object
4103           $user = $id_or_email;
4104      } elseif ( $id_or_email instanceof WP_Post ) {
4105           // Post Object
4106           $user = get_user_by( 'id', (int) $id_or_email->post_author );
4107      } elseif ( $id_or_email instanceof WP_Comment ) {
4108           if ( ! is_avatar_comment_type( get_comment_type( $id_or_email ) ) ) {
4109                $args['url'] = false;
4110                /** This filter is documented in wp-includes/link-template.php */
4111                return apply_filters( 'get_avatar_data', $args, $id_or_email );
4112           }
4113
4114           if ( ! empty( $id_or_email->user_id ) ) {
4115                $user = get_user_by( 'id', (int) $id_or_email->user_id );
4116           }
4117           if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
4118                $email = $id_or_email->comment_author_email;
4119           }
4120      }
 
Line Code
4169      /**
4170       * Filters the avatar data.
4171       *
4172       * @since 4.2.0
4173       *
4174       * @param array  $args        Arguments passed to get_avatar_data(), after processing.
4175       * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
4176       *                            user email, WP_User object, WP_Post object, or WP_Comment object.
4177       */
4178      return apply_filters( 'get_avatar_data', $args, $id_or_email );
4179 }
4180
4181 /**
4182  * Retrieves the URL of a file in the theme.
4183  *
4184  * Searches in the stylesheet directory before the template directory so themes
4185  * which inherit from a parent theme can just override one file.
4186  *
4187  * @since 4.7.0