WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/09/2019 05:59:49 AM (10 months ago)
Author:
pento
Message:

Comments: Add a new is_avatar_comment_type() function.

This function splits the get_avatar_comment_types filter out of get_avatar_data().

Props dshanske, birgire.
Fixes #44033.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r44351 r44499  
    39383938}
    39393939
     3940
     3941/**
     3942 * Check if this comment type allows avatars to be retrieved.
     3943 *
     3944 * @since 5.1.0
     3945 *
     3946 * @param string $comment_type Comment type to check.
     3947 * @return bool Whether the comment type is allowed for retrieving avatars.
     3948 */
     3949function is_avatar_comment_type( $comment_type ) {
     3950    /**
     3951     * Filters the list of allowed comment types for retrieving avatars.
     3952     *
     3953     * @since 3.0.0
     3954     *
     3955     * @param array $types An array of content types. Default only contains 'comment'.
     3956     */
     3957    $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
     3958
     3959    return in_array( $comment_type, (array) $allowed_comment_types, true );
     3960}
     3961
     3962
    39403963/**
    39413964 * Retrieves default data about the avatar.
     
    40834106        $user = get_user_by( 'id', (int) $id_or_email->post_author );
    40844107    } elseif ( $id_or_email instanceof WP_Comment ) {
    4085         /**
    4086          * Filters the list of allowed comment types for retrieving avatars.
    4087          *
    4088          * @since 3.0.0
    4089          *
    4090          * @param array $types An array of content types. Default only contains 'comment'.
    4091          */
    4092         $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
    4093         if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
     4108        if ( ! is_avatar_comment_type( get_comment_type( $id_or_email ) ) ) {
    40944109            $args['url'] = false;
    40954110            /** This filter is documented in wp-includes/link-template.php */
Note: See TracChangeset for help on using the changeset viewer.