To show the proper count for the ‘Redacted’ link on the ‘all comments’ table list, you can use the get_comments() function to get the total number of ‘redacted’ comments and then update the link text to include this count. Here is an example of how you can modify the my_comment_link_add() function to do this:
function my_comment_link_add($status_links) {
// Get the total number of redacted comments
$args = array(
'meta_key' => 'redact',
'meta_value' => '1',
'count' => true
);
$redacted_count = get_comments($args);
// Update the link text to include the count
$status_links['redacted']= "<a href="https://wordpress.stackexchange.com/questions/412509/?status=redacted">Redacted ($redacted_count)</a>";
return $status_links;
}
add_filter("comment_status_links","my_comment_link_add");
To show the proper ‘All’ count when only the ‘Redacted’ comments are shown on the table list, you can use the get_comments_count() function to get the total number of comments and then update the link text to include this count. Here is an example of how you can modify the my_comment_redacted_list() function to do this:
function my_comment_redacted_list($query) {
global $pagenow;
// Get the total number of comments
$all_count = get_comments_count();
//
Lemme know if this helps.