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
4149       *
4150       * @param array $args        Arguments passed to get_avatar_data(), after processing.
4151       * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
4152       *                           user email, WP_User object, WP_Post object, or WP_Comment object.
4153       */
4154      $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
4155
4156      if ( isset( $args['url'] ) ) {
4157           /** This filter is documented in wp-includes/link-template.php */
4158           return apply_filters( 'get_avatar_data', $args, $id_or_email );
4159      }
4160
4161      $email_hash = '';
4162      $user       = false;
4163      $email      = false;
4164
4165      if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
4166           $id_or_email = get_comment( $id_or_email );
4167      }
 
Line Code
4181           // User Object
4182           $user = $id_or_email;
4183      } elseif ( $id_or_email instanceof WP_Post ) {
4184           // Post Object
4185           $user = get_user_by( 'id', (int) $id_or_email->post_author );
4186      } elseif ( $id_or_email instanceof WP_Comment ) {
4187           if ( ! is_avatar_comment_type( get_comment_type( $id_or_email ) ) ) {
4188                $args['url'] = false;
4189                /** This filter is documented in wp-includes/link-template.php */
4190                return apply_filters( 'get_avatar_data', $args, $id_or_email );
4191           }
4192
4193           if ( ! empty( $id_or_email->user_id ) ) {
4194                $user = get_user_by( 'id', (int) $id_or_email->user_id );
4195           }
4196           if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
4197                $email = $id_or_email->comment_author_email;
4198           }
4199      }
 
Line Code
4248      /**
4249       * Filters the avatar data.
4250       *
4251       * @since 4.2.0
4252       *
4253       * @param array $args        Arguments passed to get_avatar_data(), after processing.
4254       * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
4255       *                           user email, WP_User object, WP_Post object, or WP_Comment object.
4256       */
4257      return apply_filters( 'get_avatar_data', $args, $id_or_email );
4258 }
4259
4260 /**
4261  * Retrieves the URL of a file in the theme.
4262  *
4263  * Searches in the stylesheet directory before the template directory so themes
4264  * which inherit from a parent theme can just override one file.
4265  *
4266  * @since 4.7.0