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
3806       *
3807       * @param array  $args        Arguments passed to get_avatar_data(), after processing.
3808       * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
3809       *                            user email, WP_User object, WP_Post object, or WP_Comment object.
3810       */
3811      $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
3812
3813      if ( isset( $args['url'] ) && ! is_null( $args['url'] ) ) {
3814           /** This filter is documented in wp-includes/link-template.php */
3815           return apply_filters( 'get_avatar_data', $args, $id_or_email );
3816      }
3817
3818      $email_hash = '';
3819      $user = $email = false;
3820
3821      if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
3822           $id_or_email = get_comment( $id_or_email );
3823      }
3824
 
Line Code
3845            *
3846            * @since 3.0.0
3847            *
3848            * @param array $types An array of content types. Default only contains 'comment'.
3849            */
3850           $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
3851           if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
3852                $args['url'] = false;
3853                /** This filter is documented in wp-includes/link-template.php */
3854                return apply_filters( 'get_avatar_data', $args, $id_or_email );
3855           }
3856
3857           if ( ! empty( $id_or_email->user_id ) ) {
3858                $user = get_user_by( 'id', (int) $id_or_email->user_id );
3859           }
3860           if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
3861                $email = $id_or_email->comment_author_email;
3862           }
3863      }
 
Line Code
3912      /**
3913       * Filter the avatar data.
3914       *
3915       * @since 4.2.0
3916       *
3917       * @param array  $args        Arguments passed to get_avatar_data(), after processing.
3918       * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
3919       *                            user email, WP_User object, WP_Post object, or WP_Comment object.
3920       */
3921      return apply_filters( 'get_avatar_data', $args, $id_or_email );
3922 }
3923