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
4487       *
4488       * @param array $args        Arguments passed to get_avatar_data(), after processing.
4489       * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar SHA-256 or MD5 hash,
4490       *                           user email, WP_User object, WP_Post object, or WP_Comment object.
4491       */
4492      $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
4493
4494      if ( isset( $args['url'] ) ) {
4495           /** This filter is documented in wp-includes/link-template.php */
4496           return apply_filters( 'get_avatar_data', $args, $id_or_email );
4497      }
4498
4499      $email_hash = '';
4500      $user       = false;
4501      $email      = false;
4502
4503      if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
4504           $id_or_email = get_comment( $id_or_email );
4505      }
 
Line Code
4522           // User object.
4523           $user = $id_or_email;
4524      } elseif ( $id_or_email instanceof WP_Post ) {
4525           // Post object.
4526           $user = get_user_by( 'id', (int) $id_or_email->post_author );
4527      } elseif ( $id_or_email instanceof WP_Comment ) {
4528           if ( ! is_avatar_comment_type( get_comment_type( $id_or_email ) ) ) {
4529                $args['url'] = false;
4530                /** This filter is documented in wp-includes/link-template.php */
4531                return apply_filters( 'get_avatar_data', $args, $id_or_email );
4532           }
4533
4534           if ( ! empty( $id_or_email->user_id ) ) {
4535                $user = get_user_by( 'id', (int) $id_or_email->user_id );
4536           }
4537           if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
4538                $email = $id_or_email->comment_author_email;
4539           }
4540      }
 
Line Code
4624      /**
4625       * Filters the avatar data.
4626       *
4627       * @since 4.2.0
4628       *
4629       * @param array $args        Arguments passed to get_avatar_data(), after processing.
4630       * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar SHA-256 or MD5 hash,
4631       *                           user email, WP_User object, WP_Post object, or WP_Comment object.
4632       */
4633      return apply_filters( 'get_avatar_data', $args, $id_or_email );
4634 }
4635
4636 /**
4637  * Retrieves the URL of a file in the theme.
4638  *
4639  * Searches in the stylesheet directory before the template directory so themes
4640  * which inherit from a parent theme can just override one file.
4641  *
4642  * @since 4.7.0