From 561146621f5367c034592ab7c01b2ee7df591779 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 21 Apr 2009 21:12:01 +0000 Subject: [PATCH] Remember last view for comments page git-svn-id: http://svn.automattic.com/wordpress/trunk@11035 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-comments.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index c9686e9dbf..179af5580b 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -85,7 +85,14 @@ require_once('admin-header.php'); $mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : attribute_escape($_GET['mode']); -$comment_status = !empty($_GET['comment_status']) ? attribute_escape($_GET['comment_status']) : ''; +$default_status = get_user_option('edit_comments_last_view'); +if ( empty($default_status) ) + $default_status = 'all'; +$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : $default_status; +if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam')) ) + $comment_status = 'all'; +if ( $comment_status != $default_status ) + update_usermeta($current_user->ID, 'edit_comments_last_view', $comment_status); $comment_type = !empty($_GET['comment_type']) ? attribute_escape($_GET['comment_type']) : ''; @@ -141,20 +148,17 @@ $stati = array( 'approved' => _n_noop('Approved', 'Approved'), // singular not used 'spam' => _n_noop('Spam (%s)', 'Spam (%s)') ); -$class = ( '' === $comment_status ) ? ' class="current"' : ''; -// $status_links[] = "
  • " . __( 'All' ) . ''; $link = 'edit-comments.php'; if ( !empty($comment_type) && 'all' != $comment_type ) $link = add_query_arg( 'comment_type', $comment_type, $link ); foreach ( $stati as $status => $label ) { $class = ''; - if ( str_replace( 'all', '', $status ) == $comment_status ) + if ( $status == $comment_status ) $class = ' class="current"'; if ( !isset( $num_comments->$status ) ) $num_comments->$status = 10; - if ( 'all' != $status ) - $link = add_query_arg( 'comment_status', $status, $link ); + $link = add_query_arg( 'comment_status', $status, $link ); if ( $post_id ) $link = add_query_arg( 'p', absint( $post_id ), $link ); /* @@ -244,10 +248,10 @@ $page_links = paginate_links( array(
    -\n"; ?> +\n"; ?> - + - + @@ -368,7 +372,7 @@ if ( $page_links )
    - +