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
3908       *
3909       * @param array  $args        Arguments passed to get_avatar_data(), after processing.
3910       * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
3911       *                            user email, WP_User object, WP_Post object, or WP_Comment object.
3912       */
3913      $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
3914
3915      if ( isset( $args['url'] ) && ! is_null( $args['url'] ) ) {
3916           /** This filter is documented in wp-includes/link-template.php */
3917           return apply_filters( 'get_avatar_data', $args, $id_or_email );
3918      }
3919
3920      $email_hash = '';
3921      $user = $email = false;
3922
3923      if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
3924           $id_or_email = get_comment( $id_or_email );
3925      }
3926
 
Line Code
3947            *
3948            * @since 3.0.0
3949            *
3950            * @param array $types An array of content types. Default only contains 'comment'.
3951            */
3952           $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
3953           if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
3954                $args['url'] = false;
3955                /** This filter is documented in wp-includes/link-template.php */
3956                return apply_filters( 'get_avatar_data', $args, $id_or_email );
3957           }
3958
3959           if ( ! empty( $id_or_email->user_id ) ) {
3960                $user = get_user_by( 'id', (int) $id_or_email->user_id );
3961           }
3962           if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
3963                $email = $id_or_email->comment_author_email;
3964           }
3965      }
 
Line Code
4014      /**
4015       * Filters the avatar data.
4016       *
4017       * @since 4.2.0
4018       *
4019       * @param array  $args        Arguments passed to get_avatar_data(), after processing.
4020       * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
4021       *                            user email, WP_User object, WP_Post object, or WP_Comment object.
4022       */
4023      return apply_filters( 'get_avatar_data', $args, $id_or_email );
4024 }
4025
4026 /**
4027  * Retrieves the URL of a file in the theme.
4028  *
4029  * Searches in the stylesheet directory before the template directory so themes
4030  * which inherit from a parent theme can just override one file.
4031  *
4032  * @since 4.7.0