You appear to be a bot. Output may be restricted
Description
Remove EDD Comments from the wp_count_comments function
Usage
$array = edd_remove_payment_notes_in_comment_counts( $stats, $post_id );
Parameters
- $stats
- ( array ) required – (empty from core filter)
- $post_id
- ( int ) required – Post ID
Returns
array Array of comment counts
Source
File name: easy-digital-downloads/includes/payments/functions.php
Lines:
1 to 46 of 46
function edd_remove_payment_notes_in_comment_counts( $stats, $post_id ) { global $wpdb, $pagenow; $array_excluded_pages = array( 'index.php', 'edit-comments.php' ); if( ! in_array( $pagenow, $array_excluded_pages ) ) { return $stats; } $post_id = (int) $post_id; if ( apply_filters( 'edd_count_payment_notes_in_comments', false ) ) return $stats; $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); if ( false !== $stats ) return $stats; $where = 'WHERE comment_type != "edd_payment_note"'; if ( $post_id > 0 ) $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); $total = 0; $approved = array( '0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed' ); foreach ( (array) $count as $row ) { // Don't count post-trashed toward totals if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) $total += $row['num_comments']; if ( isset( $approved[$row['comment_approved']] ) ) $stats[$approved[$row['comment_approved']]] = $row['num_comments']; } $stats['total_comments'] = $total; foreach ( $approved as $key ) { if ( empty($stats[$key]) ) $stats[$key] = 0; } $stats = (object) $stats; wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); return $stats; }