Skip to content

Commit 94423ed

Browse files
committed
Show comment count for Fediverse filter in admin
Adds a comment count badge to the 'Fediverse' filter in the admin comments view and updates the query logic to better handle post type filtering for federated comments.
1 parent 71faff1 commit 94423ed

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

includes/class-comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ public static function comment_query( $query ) {
705705
// Handle admin comment queries.
706706
if ( \is_admin() ) {
707707
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
708-
if ( isset( $_GET['comment_status'] ) && 'federated' === $_GET['comment_status'] && empty( $query->query_vars['count'] ) ) {
708+
if ( ( isset( $_GET['comment_status'] ) && 'federated' === $_GET['comment_status'] && empty( $query->query_vars['count'] ) ) || $query->query_vars['post_type'] ) {
709709
// Show only comments from hidden post types (Fediverse view).
710710
$query->query_vars['post_type'] = self::hide_for();
711711
$query->query_vars['status'] = 'all';

includes/wp-admin/class-admin.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,20 @@ public static function comment_views( $views ) {
573573
$views['all'] = \str_replace( 'current', '', $views['all'] );
574574
}
575575

576+
// Count comments from hidden post types.
577+
$count = \get_comments(
578+
array(
579+
'post_type' => $post_types,
580+
'count' => true,
581+
)
582+
);
583+
576584
$views['federated'] = \sprintf(
577-
'<a href="%s" class="%s">%s</a>',
585+
'<a href="%s" class="%s">%s <span class="count">(%s)</span></a>',
578586
\esc_url( \admin_url( 'edit-comments.php?comment_status=federated' ) ),
579587
\esc_attr( $current ),
580-
\esc_html__( 'Fediverse', 'activitypub' )
588+
\esc_html__( 'Fediverse', 'activitypub' ),
589+
\esc_html( \number_format_i18n( $count ) )
581590
);
582591

583592
return $views;

0 commit comments

Comments
 (0)