Last active
April 13, 2023 16:48
-
-
Save pmgarman/d64c768754dbc0ff5f49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Plugin Name: Remove crazy counts slowing down my dashboard | |
* Plugin URI: https://pmgarman.me | |
* Description: Those comment counts are such a pain when you have a lot of comments | |
* Author: Patrick Garman | |
* Author URI: https://pmgarman.me | |
* Version: 1.0.0 | |
* License: GPLv2 | |
*/ | |
// Remove unmoderated comment counts from the admin menu | |
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 ); | |
// Remove order count from admin menu | |
add_filter( 'woocommerce_include_processing_order_count_in_menu', '__return_false' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@tnorthcutt finally pulled in your change :D