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
3912       *
3913       * @param array  $args        Arguments passed to get_avatar_data(), after processing.
3914       * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
3915       *                            user email, WP_User object, WP_Post object, or WP_Comment object.
3916       */
3917      $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
3918
3919      if ( isset( $args['url'] ) && ! is_null( $args['url'] ) ) {
3920           /** This filter is documented in wp-includes/link-template.php */
3921           return apply_filters( 'get_avatar_data', $args, $id_or_email );
3922      }
3923
3924      $email_hash = '';
3925      $user = $email = false;
3926
3927      if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
3928           $id_or_email = get_comment( $id_or_email );
3929      }
3930
 
Line Code
3951            *
3952            * @since 3.0.0
3953            *
3954            * @param array $types An array of content types. Default only contains 'comment'.
3955            */
3956           $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
3957           if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
3958                $args['url'] = false;
3959                /** This filter is documented in wp-includes/link-template.php */
3960                return apply_filters( 'get_avatar_data', $args, $id_or_email );
3961           }
3962
3963           if ( ! empty( $id_or_email->user_id ) ) {
3964                $user = get_user_by( 'id', (int) $id_or_email->user_id );
3965           }
3966           if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
3967                $email = $id_or_email->comment_author_email;
3968           }
3969      }
 
Line Code
4018      /**
4019       * Filters the avatar data.
4020       *
4021       * @since 4.2.0
4022       *
4023       * @param array  $args        Arguments passed to get_avatar_data(), after processing.
4024       * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
4025       *                            user email, WP_User object, WP_Post object, or WP_Comment object.
4026       */
4027      return apply_filters( 'get_avatar_data', $args, $id_or_email );
4028 }
4029