From a71e3e97ddf79ed5f2f27f4d4a4992ec42d0c3c0 Mon Sep 17 00:00:00 2001 From: Kata Date: Fri, 28 Jul 2023 16:32:50 -0400 Subject: [PATCH] Update co-authors-plus.php --- co-authors-plus.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/co-authors-plus.php b/co-authors-plus.php index f3d6f0d0..948d3b3a 100755 --- a/co-authors-plus.php +++ b/co-authors-plus.php @@ -446,7 +446,11 @@ public function coauthors_meta_box( $post ) { ID ); + $user_type = 'guest-user'; + if ( $coauthor instanceof WP_User ) { + $user_type = 'wp-user'; + } + $avatar_url = get_avatar_url( $coauthor->ID, array( 'user_type' => $user_type ) ); ?>
  • ID, $this->gravatar_size ); ?> @@ -1833,9 +1837,29 @@ public function get_guest_author_post_count( $guest_author ) { * @return string Avatar URL */ public function filter_pre_get_avatar_data_url( $args, $id ) { + global $wp_current_filter; + if ( ! $id || ! $this->is_guest_authors_enabled() || ! is_numeric( $id ) || isset( $args['url'] ) ) { return $args; } + + // Do not filter the icon in the admin bar + if ( doing_filter( 'admin_bar_menu' ) ) { + return $args; + } + + // Do not filter when we have a WordPress user sent from CAP meta box + if ( isset( $args['user_type'] ) && 'wp-user' === $args['user_type'] ) { + return $args; + } + + // Do not filter when on the user screen + $current_screen = get_current_screen(); + if ( isset( $current_screen->parent_base ) && 'users' == $current_screen->parent_base ) { + return $args; + } + + $coauthor = $this->get_coauthor_by( 'id', $id ); if ( false !== $coauthor && isset( $coauthor->type ) && 'guest-author' === $coauthor->type ) { if ( has_post_thumbnail( $id ) ) {