362 | | $totals = (array) $wpdb->get_results(" |
363 | | SELECT comment_approved, COUNT( * ) AS total |
364 | | FROM {$wpdb->comments} |
365 | | {$where} |
366 | | GROUP BY comment_approved |
367 | | ", ARRAY_A); |
368 | | |
369 | | $comment_count = array( |
370 | | 'approved' => 0, |
371 | | 'awaiting_moderation' => 0, |
372 | | 'spam' => 0, |
373 | | 'trash' => 0, |
374 | | 'post-trashed' => 0, |
375 | | 'total_comments' => 0, |
376 | | 'all' => 0, |
377 | | ); |
378 | | |
379 | | foreach ( $totals as $row ) { |
380 | | switch ( $row['comment_approved'] ) { |
381 | | case 'trash': |
382 | | $comment_count['trash'] = $row['total']; |
383 | | break; |
384 | | case 'post-trashed': |
385 | | $comment_count['post-trashed'] = $row['total']; |
386 | | break; |
387 | | case 'spam': |
388 | | $comment_count['spam'] = $row['total']; |
389 | | $comment_count['total_comments'] += $row['total']; |
390 | | break; |
391 | | case '1': |
392 | | $comment_count['approved'] = $row['total']; |
393 | | $comment_count['total_comments'] += $row['total']; |
394 | | $comment_count['all'] += $row['total']; |
395 | | break; |
396 | | case '0': |
397 | | $comment_count['awaiting_moderation'] = $row['total']; |
398 | | $comment_count['total_comments'] += $row['total']; |
399 | | $comment_count['all'] += $row['total']; |
400 | | break; |
401 | | default: |
402 | | break; |
| 361 | $totals = (array) $wpdb->get_results(" |
| 362 | SELECT comment_approved, COUNT( * ) AS total |
| 363 | FROM {$wpdb->comments} |
| 364 | {$where} |
| 365 | GROUP BY comment_approved |
| 366 | ", ARRAY_A); |
| 367 | |
| 368 | $comment_count = array( |
| 369 | 'approved' => 0, |
| 370 | 'awaiting_moderation' => 0, |
| 371 | 'spam' => 0, |
| 372 | 'trash' => 0, |
| 373 | 'post-trashed' => 0, |
| 374 | 'total_comments' => 0, |
| 375 | 'all' => 0, |
| 376 | ); |
| 377 | |
| 378 | foreach ( $totals as $row ) { |
| 379 | switch ( $row['comment_approved'] ) { |
| 380 | case 'trash': |
| 381 | $comment_count['trash'] = $row['total']; |
| 382 | break; |
| 383 | case 'post-trashed': |
| 384 | $comment_count['post-trashed'] = $row['total']; |
| 385 | break; |
| 386 | case 'spam': |
| 387 | $comment_count['spam'] = $row['total']; |
| 388 | $comment_count['total_comments'] += $row['total']; |
| 389 | break; |
| 390 | case '1': |
| 391 | $comment_count['approved'] = $row['total']; |
| 392 | $comment_count['total_comments'] += $row['total']; |
| 393 | $comment_count['all'] += $row['total']; |
| 394 | break; |
| 395 | case '0': |
| 396 | $comment_count['awaiting_moderation'] = $row['total']; |
| 397 | $comment_count['total_comments'] += $row['total']; |
| 398 | $comment_count['all'] += $row['total']; |
| 399 | break; |
| 400 | default: |
| 401 | break; |
| 402 | } |
| 404 | } else { |
| 405 | $comment_count = array( |
| 406 | 'approved' => 0, |
| 407 | 'awaiting_moderation' => $wpdb->get_var("SELECT COUNT( * ) FROM {$wpdb->comments} WHERE comment_approved = '0' "), |
| 408 | 'spam' => $spam = $wpdb->get_var("SELECT COUNT( * ) FROM {$wpdb->comments} WHERE comment_approved = 'spam' "), |
| 409 | 'trash' => $wpdb->get_var("SELECT COUNT( * ) FROM {$wpdb->comments} WHERE comment_approved = 'trash' "), |
| 410 | 'post-trashed' => $wpdb->get_var("SELECT COUNT( * ) FROM {$wpdb->comments} WHERE comment_approved = 'post-trashed' "), |
| 411 | 'all' => 0, |
| 412 | ); |
| 413 | |
| 414 | $comment_count['total_comments'] = $wpdb->get_var("SELECT COUNT( * ) FROM {$wpdb->comments} "); |
| 415 | $comment_count['all'] = $comment_count['total_comments']; |
| 416 | $comment_count['approved'] = $comment_count['total_comments'] - $comment_count['spam'] - $comment_count['post-trashed'] - $comment_count['trash'] - $comment_count['awaiting_moderation']; |