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
4335       *
4336       * @param array $args        Arguments passed to get_avatar_data(), after processing.
4337       * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
4338       *                           user email, WP_User object, WP_Post object, or WP_Comment object.
4339       */
4340      $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
4341
4342      if ( isset( $args['url'] ) ) {
4343           /** This filter is documented in wp-includes/link-template.php */
4344           return apply_filters( 'get_avatar_data', $args, $id_or_email );
4345      }
4346
4347      $email_hash = '';
4348      $user       = false;
4349      $email      = false;
4350
4351      if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
4352           $id_or_email = get_comment( $id_or_email );
4353      }
 
Line Code
4367           // User object.
4368           $user = $id_or_email;
4369      } elseif ( $id_or_email instanceof WP_Post ) {
4370           // Post object.
4371           $user = get_user_by( 'id', (int) $id_or_email->post_author );
4372      } elseif ( $id_or_email instanceof WP_Comment ) {
4373           if ( ! is_avatar_comment_type( get_comment_type( $id_or_email ) ) ) {
4374                $args['url'] = false;
4375                /** This filter is documented in wp-includes/link-template.php */
4376                return apply_filters( 'get_avatar_data', $args, $id_or_email );
4377           }
4378
4379           if ( ! empty( $id_or_email->user_id ) ) {
4380                $user = get_user_by( 'id', (int) $id_or_email->user_id );
4381           }
4382           if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
4383                $email = $id_or_email->comment_author_email;
4384           }
4385      }
 
Line Code
4434      /**
4435       * Filters the avatar data.
4436       *
4437       * @since 4.2.0
4438       *
4439       * @param array $args        Arguments passed to get_avatar_data(), after processing.
4440       * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
4441       *                           user email, WP_User object, WP_Post object, or WP_Comment object.
4442       */
4443      return apply_filters( 'get_avatar_data', $args, $id_or_email );
4444 }
4445
4446 /**
4447  * Retrieves the URL of a file in the theme.
4448  *
4449  * Searches in the stylesheet directory before the template directory so themes
4450  * which inherit from a parent theme can just override one file.
4451  *
4452  * @since 4.7.0