Created
December 3, 2015 16:51
-
-
Save cfg/2181d8d2807afed583b0 to your computer and use it in GitHub Desktop.
Fix expensive comment queries
This file contains 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 | |
if ( defined( 'WPCOM_IS_VIP_ENV' ) && true === WPCOM_IS_VIP_ENV ) { | |
wpcom_vip_load_plugin( 'disable-comments-query' ); | |
// Kill wp_count_comments lookups because they happen too frequently and are super slow. | |
if ( is_admin() ) { | |
add_filter( 'wp_count_comments', function( $counts, $post_id ) { | |
if ( $post_id ) | |
return $counts; | |
return (object) array( | |
'approved' => 0, | |
'spam' => 0, | |
'trash' => 0, | |
'total_comments' => 0, | |
'moderated' => 0, | |
'post-trashed' => 0, | |
); | |
}, 10, 2 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment