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. Built from https://develop.svn.wordpress.org/trunk@44499 git-svn-id: http://core.svn.wordpress.org/trunk@44330 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
05c1030151
commit
eeac928d3b
|
@ -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 );
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue