From 89fe0ff804e7c6497ebacc8b341ac89974f6f255 Mon Sep 17 00:00:00 2001
From: donncha
Date: Mon, 21 May 2007 18:37:58 +0000
Subject: WP Merge to rev 5499, this is a big one! Test it before you put it
live! Test only, not for production use yet
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@972 7be80a69-a1ef-0310-a953-fb0f7c49ff36
---
wp-admin/edit-comments.php | 161 ++++++++++++---------------------------------
1 file changed, 41 insertions(+), 120 deletions(-)
(limited to 'wp-admin/edit-comments.php')
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index 0557270..bbd5e22 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -75,104 +75,53 @@ if ( !empty( $_POST['delete_comments'] ) ) :
echo '
';
endif;
-if (isset($_GET['s'])) {
- $s = $wpdb->escape($_GET['s']);
- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE
- (comment_author LIKE '%$s%' OR
- comment_author_email LIKE '%$s%' OR
- comment_author_url LIKE ('%$s%') OR
- comment_author_IP LIKE ('%$s%') OR
- comment_content LIKE ('%$s%') ) AND
- comment_approved != 'spam'
- ORDER BY comment_date DESC");
-} else {
- if ( isset( $_GET['apage'] ) )
- $page = (int) $_GET['apage'];
- else
- $page = 1;
- $start = $offset = ( $page - 1 ) * 20;
+if ( isset( $_GET['apage'] ) )
+ $page = (int) $_GET['apage'];
+else
+ $page = 1;
- $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, 20" );
- $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1'" );
-}
-?>
- 20 ) {
-$total_pages = ceil( $total / 20 );
-$r = '';
-if ( 1 < $page ) {
- $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1;
- $r .= '« '. __('Previous Page') .'' . "\n";
-}
-if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) {
- for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
- if ( $page == $page_num ) :
- $r .= "$page_num\n";
- else :
- $p = false;
- if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
- $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num;
- $r .= '' . ( $page_num ) . "\n";
- $in = true;
- elseif ( $in == true ) :
- $r .= "...\n";
- $in = false;
- endif;
- endif;
- endfor;
-}
-if ( ( $page ) * 20 < $total || -1 == $total ) {
- $args['apage'] = $page + 1;
- $r .= ''. __('Next Page') .' »' . "\n";
-}
-echo "$r
";
-?>
+$start = $offset = ( $page - 1 ) * 20;
-
+list($_comments, $total) = _wp_get_comment_list( isset($_GET['s']) ? $_GET['s'] : false, $start, 25 ); // Grab a few extra
+
+$comments = array_slice($_comments, 0, 20);
+$extra_comments = array_slice($_comments, 20);
+
+$page_links = paginate_links( array(
+ 'base' => add_query_arg( 'apage', '%_%' ),
+ 'format' => '',
+ 'total' => ceil($total / 20),
+ 'current' => $page
+));
+
+if ( $page_links )
+ echo "$page_links
";
-
-";
+ echo "\n\n";
- — [
+if ( $extra_comments ) : ?>
+
+
@@ -208,7 +157,7 @@ $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
$class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
?>
comment_author_email) { ?>| comment_author_url && 'http://' != $comment->comment_author_url) { ?> | |
- - + foreach ( $comments as $comment ) { + get_comment( $comment ); // Cache it + _wp_comment_list_item( $comment->comment_ID, ++$i ); + } + echo "