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
3826       *
3827       * @param array  $args        Arguments passed to get_avatar_data(), after processing.
3828       * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
3829       *                            user email, WP_User object, WP_Post object, or WP_Comment object.
3830       */
3831      $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
3832
3833      if ( isset( $args['url'] ) && ! is_null( $args['url'] ) ) {
3834           /** This filter is documented in wp-includes/link-template.php */
3835           return apply_filters( 'get_avatar_data', $args, $id_or_email );
3836      }
3837
3838      $email_hash = '';
3839      $user = $email = false;
3840
3841      if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
3842           $id_or_email = get_comment( $id_or_email );
3843      }
3844
 
Line Code
3865            *
3866            * @since 3.0.0
3867            *
3868            * @param array $types An array of content types. Default only contains 'comment'.
3869            */
3870           $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
3871           if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
3872                $args['url'] = false;
3873                /** This filter is documented in wp-includes/link-template.php */
3874                return apply_filters( 'get_avatar_data', $args, $id_or_email );
3875           }
3876
3877           if ( ! empty( $id_or_email->user_id ) ) {
3878                $user = get_user_by( 'id', (int) $id_or_email->user_id );
3879           }
3880           if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
3881                $email = $id_or_email->comment_author_email;
3882           }
3883      }
 
Line Code
3932      /**
3933       * Filter the avatar data.
3934       *
3935       * @since 4.2.0
3936       *
3937       * @param array  $args        Arguments passed to get_avatar_data(), after processing.
3938       * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
3939       *                            user email, WP_User object, WP_Post object, or WP_Comment object.
3940       */
3941      return apply_filters( 'get_avatar_data', $args, $id_or_email );
3942 }
3943