parent
3ea8162cff
commit
7355fadfdd
|
@ -349,8 +349,14 @@ class WC_Tracker {
|
||||||
*/
|
*/
|
||||||
private static function get_review_counts() {
|
private static function get_review_counts() {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$review_count = array();
|
$review_count = array( 'total' => 0 );
|
||||||
$counts = $wpdb->get_results(
|
$status_map = array(
|
||||||
|
'0' => 'pending',
|
||||||
|
'1' => 'approved',
|
||||||
|
'trash' => 'trash',
|
||||||
|
'spam' => 'spam',
|
||||||
|
);
|
||||||
|
$counts = $wpdb->get_results(
|
||||||
"
|
"
|
||||||
SELECT comment_approved, COUNT(*) AS num_reviews
|
SELECT comment_approved, COUNT(*) AS num_reviews
|
||||||
FROM {$wpdb->comments}
|
FROM {$wpdb->comments}
|
||||||
|
@ -359,15 +365,19 @@ class WC_Tracker {
|
||||||
",
|
",
|
||||||
ARRAY_A
|
ARRAY_A
|
||||||
);
|
);
|
||||||
if ( $counts ) {
|
|
||||||
foreach ( $counts as $count ) {
|
if ( ! $counts ) {
|
||||||
if ( 1 === $count['comment_approved'] ) {
|
return $review_count;
|
||||||
$review_count['approved'] = $count['num_reviews'];
|
|
||||||
} else {
|
|
||||||
$review_count['pending'] = $count['num_reviews'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ( $counts as $count ) {
|
||||||
|
$status = $count['comment_approved'];
|
||||||
|
if ( array_key_exists( $status, $status_map ) ) {
|
||||||
|
$review_count[ $status_map[ $status ] ] = $count['num_reviews'];
|
||||||
|
}
|
||||||
|
$review_count['total'] += $count['num_reviews'];
|
||||||
|
}
|
||||||
|
|
||||||
return $review_count;
|
return $review_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue