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
4406       *
4407       * @param array $args        Arguments passed to get_avatar_data(), after processing.
4408       * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
4409       *                           user email, WP_User object, WP_Post object, or WP_Comment object.
4410       */
4411      $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
4412
4413      if ( isset( $args['url'] ) ) {
4414           /** This filter is documented in wp-includes/link-template.php */
4415           return apply_filters( 'get_avatar_data', $args, $id_or_email );
4416      }
4417
4418      $email_hash = '';
4419      $user       = false;
4420      $email      = false;
4421
4422      if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
4423           $id_or_email = get_comment( $id_or_email );
4424      }
 
Line Code
4438           // User object.
4439           $user = $id_or_email;
4440      } elseif ( $id_or_email instanceof WP_Post ) {
4441           // Post object.
4442           $user = get_user_by( 'id', (int) $id_or_email->post_author );
4443      } elseif ( $id_or_email instanceof WP_Comment ) {
4444           if ( ! is_avatar_comment_type( get_comment_type( $id_or_email ) ) ) {
4445                $args['url'] = false;
4446                /** This filter is documented in wp-includes/link-template.php */
4447                return apply_filters( 'get_avatar_data', $args, $id_or_email );
4448           }
4449
4450           if ( ! empty( $id_or_email->user_id ) ) {
4451                $user = get_user_by( 'id', (int) $id_or_email->user_id );
4452           }
4453           if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
4454                $email = $id_or_email->comment_author_email;
4455           }
4456      }
 
Line Code
4505      /**
4506       * Filters the avatar data.
4507       *
4508       * @since 4.2.0
4509       *
4510       * @param array $args        Arguments passed to get_avatar_data(), after processing.
4511       * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
4512       *                           user email, WP_User object, WP_Post object, or WP_Comment object.
4513       */
4514      return apply_filters( 'get_avatar_data', $args, $id_or_email );
4515 }
4516
4517 /**
4518  * Retrieves the URL of a file in the theme.
4519  *
4520  * Searches in the stylesheet directory before the template directory so themes
4521  * which inherit from a parent theme can just override one file.
4522  *
4523  * @since 4.7.0