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
4178       *
4179       * @param array $args        Arguments passed to get_avatar_data(), after processing.
4180       * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
4181       *                           user email, WP_User object, WP_Post object, or WP_Comment object.
4182       */
4183      $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
4184
4185      if ( isset( $args['url'] ) ) {
4186           /** This filter is documented in wp-includes/link-template.php */
4187           return apply_filters( 'get_avatar_data', $args, $id_or_email );
4188      }
4189
4190      $email_hash = '';
4191      $user       = false;
4192      $email      = false;
4193
4194      if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
4195           $id_or_email = get_comment( $id_or_email );
4196      }
 
Line Code
4210           // User object.
4211           $user = $id_or_email;
4212      } elseif ( $id_or_email instanceof WP_Post ) {
4213           // Post object.
4214           $user = get_user_by( 'id', (int) $id_or_email->post_author );
4215      } elseif ( $id_or_email instanceof WP_Comment ) {
4216           if ( ! is_avatar_comment_type( get_comment_type( $id_or_email ) ) ) {
4217                $args['url'] = false;
4218                /** This filter is documented in wp-includes/link-template.php */
4219                return apply_filters( 'get_avatar_data', $args, $id_or_email );
4220           }
4221
4222           if ( ! empty( $id_or_email->user_id ) ) {
4223                $user = get_user_by( 'id', (int) $id_or_email->user_id );
4224           }
4225           if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
4226                $email = $id_or_email->comment_author_email;
4227           }
4228      }
 
Line Code
4277      /**
4278       * Filters the avatar data.
4279       *
4280       * @since 4.2.0
4281       *
4282       * @param array $args        Arguments passed to get_avatar_data(), after processing.
4283       * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
4284       *                           user email, WP_User object, WP_Post object, or WP_Comment object.
4285       */
4286      return apply_filters( 'get_avatar_data', $args, $id_or_email );
4287 }
4288
4289 /**
4290  * Retrieves the URL of a file in the theme.
4291  *
4292  * Searches in the stylesheet directory before the template directory so themes
4293  * which inherit from a parent theme can just override one file.
4294  *
4295  * @since 4.7.0