diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index cda3444af8..0e746becb0 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -3937,6 +3937,29 @@ function get_avatar_url( $id_or_email, $args = null ) { return $args['url']; } + +/** + * Check if this comment type allows avatars to be retrieved. + * + * @since 5.1.0 + * + * @param string $comment_type Comment type to check. + * @return bool Whether the comment type is allowed for retrieving avatars. + */ +function is_avatar_comment_type( $comment_type ) { + /** + * Filters the list of allowed comment types for retrieving avatars. + * + * @since 3.0.0 + * + * @param array $types An array of content types. Default only contains 'comment'. + */ + $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); + + return in_array( $comment_type, (array) $allowed_comment_types, true ); +} + + /** * Retrieves default data about the avatar. * @@ -4082,15 +4105,7 @@ function get_avatar_data( $id_or_email, $args = null ) { // Post Object $user = get_user_by( 'id', (int) $id_or_email->post_author ); } elseif ( $id_or_email instanceof WP_Comment ) { - /** - * Filters the list of allowed comment types for retrieving avatars. - * - * @since 3.0.0 - * - * @param array $types An array of content types. Default only contains 'comment'. - */ - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { + if ( ! is_avatar_comment_type( get_comment_type( $id_or_email ) ) ) { $args['url'] = false; /** This filter is documented in wp-includes/link-template.php */ return apply_filters( 'get_avatar_data', $args, $id_or_email ); diff --git a/wp-includes/version.php b/wp-includes/version.php index f3e6997dd5..27a587c9eb 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.1-alpha-44498'; +$wp_version = '5.1-alpha-44499'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.