WordPress.org

Make WordPress Core

Changeset 11035


Ignore:
Timestamp:
04/21/09 21:12:01 (5 years ago)
Author:
ryan
Message:

Remember last view for comments page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-comments.php

    r10943 r11035  
    8686$mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : attribute_escape($_GET['mode']); 
    8787 
    88 $comment_status = !empty($_GET['comment_status']) ? attribute_escape($_GET['comment_status']) : ''; 
     88$default_status = get_user_option('edit_comments_last_view'); 
     89if ( empty($default_status) ) 
     90    $default_status = 'all'; 
     91$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : $default_status; 
     92if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam')) ) 
     93    $comment_status = 'all'; 
     94if ( $comment_status != $default_status ) 
     95    update_usermeta($current_user->ID, 'edit_comments_last_view', $comment_status); 
    8996 
    9097$comment_type = !empty($_GET['comment_type']) ? attribute_escape($_GET['comment_type']) : ''; 
     
    142149        'spam' => _n_noop('Spam (<span class="spam-count">%s</span>)', 'Spam (<span class="spam-count">%s</span>)') 
    143150    ); 
    144 $class = ( '' === $comment_status ) ? ' class="current"' : ''; 
    145 // $status_links[] = "<li><a href='edit-comments.php'$class>" . __( 'All' ) . '</a>'; 
    146151$link = 'edit-comments.php'; 
    147152if ( !empty($comment_type) && 'all' != $comment_type ) 
     
    150155    $class = ''; 
    151156 
    152     if ( str_replace( 'all', '', $status ) == $comment_status ) 
     157    if ( $status == $comment_status ) 
    153158        $class = ' class="current"'; 
    154159    if ( !isset( $num_comments->$status ) ) 
    155160        $num_comments->$status = 10; 
    156     if ( 'all' != $status ) 
    157         $link = add_query_arg( 'comment_status', $status, $link ); 
     161    $link = add_query_arg( 'comment_status', $status, $link ); 
    158162    if ( $post_id ) 
    159163        $link = add_query_arg( 'p', absint( $post_id ), $link ); 
     
    245249<select name="action"> 
    246250<option value="-1" selected="selected"><?php _e('Bulk Actions') ?></option> 
    247 <?php if ( empty($comment_status) || 'approved' == $comment_status ): ?> 
     251<?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?> 
    248252<option value="unapprove"><?php _e('Unapprove'); ?></option> 
    249253<?php endif; ?> 
    250 <?php if ( empty($comment_status) || 'moderated' == $comment_status || 'spam' == $comment_status ): ?> 
     254<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?> 
    251255<option value="approve"><?php _e('Approve'); ?></option> 
    252256<?php endif; ?> 
     
    259263<?php wp_nonce_field('bulk-comments'); ?> 
    260264 
    261 <?php if ( $comment_status ) echo "<input type='hidden' name='comment_status' value='$comment_status' />\n"; ?> 
     265<?php echo "<input type='hidden' name='comment_status' value='$comment_status' />\n"; ?> 
    262266<select name="comment_type"> 
    263267    <option value="all"><?php _e('Show all comment types'); ?></option> 
     
    333337<select name="action2"> 
    334338<option value="-1" selected="selected"><?php _e('Bulk Actions') ?></option> 
    335 <?php if ( empty($comment_status) || 'approved' == $comment_status ): ?> 
     339<?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?> 
    336340<option value="unapprove"><?php _e('Unapprove'); ?></option> 
    337341<?php endif; ?> 
    338 <?php if ( empty($comment_status) || 'moderated' == $comment_status || 'spam' == $comment_status ): ?> 
     342<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?> 
    339343<option value="approve"><?php _e('Approve'); ?></option> 
    340344<?php endif; ?> 
     
    369373<div id="ajax-response"></div> 
    370374 
    371 <?php } elseif ( isset($_GET['comment_status']) && 'moderated' == $_GET['comment_status'] ) { ?> 
     375<?php } elseif ( 'moderated' == $comment_status ) { ?> 
    372376<p><?php _e('No comments awaiting moderation&hellip; yet.') ?></p> 
    373377</form> 
Note: See TracChangeset for help on using the changeset viewer.