webimpian
5/5/2018 - 2:07 PM

Remove unmoderated comment counts from the admin menu

<?php

function pmgarman_unmoderated_comment_counts( $stats, $post_id ) {
  global $wpdb;

  if ( 0 === $post_id ) {
	$stats = json_decode( json_encode( array(
	  'moderated'      => 0,
	  'approved'       => 0,
	  'post-trashed'   => 0,
	  'trash'          => 0,
	  'total_comments' => 0
	) ) );
  }

  return $stats;
}
add_filter( 'wp_count_comments', 'pmgarman_unmoderated_comment_counts', 10, 2 );

// If running WooCommerce, remove their filter so that nothing funky goes down
remove_filter( 'wp_count_comments', array( 'WC_Comments', 'wp_count_comments' ), 10 );