Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #39 from barryceelen/filter-comments-count
Browse files Browse the repository at this point in the history
Filter 'wp_count_comments'
  • Loading branch information
bueltge committed Aug 29, 2016
2 parents 99a4002 + 96a3b70 commit 62478a2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions remove-comments-absolute.php
Expand Up @@ -113,6 +113,9 @@ public function __construct() {
add_filter( 'comments_rewrite_rules', '__return_empty_array', 99 );
// Remove rewrite rules for the legacy comment feed and post type comment pages.
add_filter( 'rewrite_rules_array', array( $this, 'filter_rewrite_rules_array' ), 99 );

// Return an object with each comment stat set to zero.
add_filter( 'wp_count_comments', array( $this, 'filter_count_comments' ) );
}

/**
Expand Down Expand Up @@ -674,6 +677,19 @@ public function filter_rewrite_rules_array( $rules ) {
return $rules;
}

/**
* Return an object with each comment stat set to zero.
*
* Prevents 'wp_count_comments' form performing a database query.
*
* @since TODO
* @see wp_count_comments
* @return object Comment stats.
*/
public function filter_count_comments() {
return (object) array( 'approved' => 0, 'spam' => 0, 'trash' => 0, 'post-trashed' => 0, 'total_comments' => 0, 'all' => 0, 'moderated' => 0 );
}

} // end class

} // end if class exists

0 comments on commit 62478a2

Please sign in to comment.