- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT $start, $end");
- $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam'" );
+ $where = '';
+ if ( isset( $_GET['ctype'] ) ) {
+ $type = preg_replace( '|[^a-z]|', '', $_GET['ctype'] );
+ if ( 'comments' == $type )
+ $type = '';
+ $where = " AND comment_type = '$type' ";
+ }
+
+ $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' $where ORDER BY comment_date DESC LIMIT $start, $end");
+ $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam' $where" );
+
+ $totals = $wpdb->get_results( "SELECT comment_type, COUNT(*) AS cc FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_type" );
+?>
+<ul class="akismet-tabs">
+<li <?php if ( !isset( $_GET['ctype'] ) ) echo ' class="active"'; ?>><a href="edit-comments.php?page=akismet-admin"><?php _e('All'); ?></a></li>
+<?php
+foreach ( $totals as $type ) {
+ if ( '' == $type->comment_type ) $type->comment_type = 'comments';
+ $show = ucwords( $type->comment_type );
+ $type->cc = number_format( $type->cc );
+ $extra = ( $_GET['ctype'] == $type->comment_type ) ? ' class="active"' : '';
+ echo "<li $extra><a href='edit-comments.php?page=akismet-admin&ctype=$type->comment_type'>$show ($type->cc)</a></li>";
+}
+do_action( 'akismet_tabs' ); // so plugins can add more tabs easily
+?>
+</ul>
+<?php