@@ -45,6 +45,7 @@ public static function init() {
4545 \add_filter ( 'manage_edit-comments_columns ' , array ( static ::class, 'manage_comment_columns ' ) );
4646 \add_action ( 'manage_comments_custom_column ' , array ( static ::class, 'manage_comments_custom_column ' ), 9 , 2 );
4747 \add_filter ( 'admin_comment_types_dropdown ' , array ( static ::class, 'comment_types_dropdown ' ) );
48+ \add_filter ( 'views_edit-comments ' , array ( static ::class, 'comment_views ' ) );
4849
4950 \add_filter ( 'manage_posts_columns ' , array ( static ::class, 'manage_post_columns ' ), 10 , 2 );
5051 \add_action ( 'manage_posts_custom_column ' , array ( self ::class, 'manage_posts_custom_column ' ), 10 , 2 );
@@ -547,6 +548,41 @@ public static function comment_types_dropdown( $types ) {
547548 return $ types ;
548549 }
549550
551+ /**
552+ * Add "Fediverse" view to the comment views.
553+ *
554+ * This allows users to see comments from hidden post types like ap_post.
555+ *
556+ * @param array $views The existing comment views.
557+ *
558+ * @return array The extended comment views.
559+ */
560+ public static function comment_views ( $ views ) {
561+ $ post_types = Comment::hide_for ();
562+
563+ if ( empty ( $ post_types ) ) {
564+ return $ views ;
565+ }
566+
567+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
568+ $ is_fediverse_view = isset ( $ _GET ['comment_status ' ] ) && 'federated ' === $ _GET ['comment_status ' ];
569+ $ current = $ is_fediverse_view ? 'current ' : '' ;
570+
571+ // Remove "current" class from "All" when in Fediverse view.
572+ if ( $ is_fediverse_view && isset ( $ views ['all ' ] ) ) {
573+ $ views ['all ' ] = \str_replace ( 'current ' , '' , $ views ['all ' ] );
574+ }
575+
576+ $ views ['federated ' ] = \sprintf (
577+ '<a href="%s" class="%s">%s</a> ' ,
578+ \esc_url ( \admin_url ( 'edit-comments.php?comment_status=federated ' ) ),
579+ \esc_attr ( $ current ),
580+ \esc_html__ ( 'Fediverse ' , 'activitypub ' )
581+ );
582+
583+ return $ views ;
584+ }
585+
550586 /**
551587 * Return the results for the activitypub column.
552588 *
0 commit comments