comment_type ) || $id_or_email->user_id ) { return $args; } /** * Filter allowed comment types for avatars. * * @param array $allowed_comment_types Array of allowed comment types. */ $allowed_comment_types = \apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); if ( ! \in_array( $id_or_email->comment_type ?: 'comment', $allowed_comment_types, true ) ) { return $args; } // Respect WordPress "show avatars" setting. if ( ! \get_option( 'show_avatars' ) ) { return $args; } $avatar = null; // First, try to get avatar from remote actor. $remote_actor_id = \get_comment_meta( $id_or_email->comment_ID, '_activitypub_remote_actor_id', true ); if ( $remote_actor_id ) { $avatar = Remote_Actors::get_avatar_url( $remote_actor_id ); } // Fall back to avatar_url comment meta for backward compatibility. if ( ! $avatar ) { $avatar = \get_comment_meta( $id_or_email->comment_ID, 'avatar_url', true ); } if ( $avatar ) { if ( empty( $args['class'] ) ) { $args['class'] = array(); } elseif ( \is_string( $args['class'] ) ) { $args['class'] = \explode( ' ', $args['class'] ); } /** This filter is documented in wp-includes/link-template.php */ $args['url'] = \apply_filters( 'get_avatar_url', $avatar, $id_or_email, $args ); $args['class'][] = 'avatar'; $args['class'][] = 'avatar-activitypub'; $args['class'][] = 'avatar-' . (int) $args['size']; $args['class'][] = 'photo'; $args['class'][] = 'u-photo'; $args['class'] = \array_unique( $args['class'] ); } return $args; } }