Skip to content

Commit

Permalink
Issue #15 - don't count spam posts
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Mar 27, 2018
1 parent 85ad272 commit 05a0ba0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Binary file modified converter/estimate.ods
Binary file not shown.
17 changes: 14 additions & 3 deletions shortcodes/oik-content.php
Expand Up @@ -109,12 +109,22 @@ function oik_block_post_type_compatible( $post_type, $post_type_object ) {
}

/**
* Returns the sum total of all posts for a post type
* Returns the sum total of all posts worth processing for a post type
*
* This includes all different statuses, including 'trash' and 'auto-draft'
* wp_count_posts includes all different statuses, including 'trash', 'auto-draft' and 'spam'.
* Althought the user may undelete the content from Trash we don't need to worry about them.
* There really shouldn't be that many Auto-drafts!
*
* And we don't care about spam.
*
* Post statuses that are worth considering include
* `
[publish] => 10
[future] => 0
[draft] => 0
[pending] => 0
[private] => 0
[inherit] => 0
* `
* @param string $post_type
* @return integer total number of posts
*/
Expand All @@ -123,6 +133,7 @@ function oik_block_count_posts( $post_type ) {
$counts = (array) wp_count_posts( $post_type );
unset( $counts['auto-draft'] );
unset( $counts['trash'] );
unset( $counts['spam'] );
bw_trace2( $counts, "counts" );
//$counts = implode( " ", $counts );
$total = array_sum( $counts );
Expand Down

0 comments on commit 05a0ba0

Please sign in to comment.