Make WordPress Core


Ignore:
Timestamp:
09/29/2008 09:26:21 AM (16 years ago)
Author:
azaozz
Message:

Add table footers and action selects at the bottom

File:
1 edited

Legend:

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

    r9023 r9028  
    1717if ( isset( $_POST['delete_all_spam'] ) ) {
    1818    check_admin_referer('bulk-spam-delete');
    19    
     19
    2020    $deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'" );
    2121    wp_redirect('edit-comments.php?deleted=' . (int) $deleted_spam);
    2222}
    2323
    24 if ( !empty( $_REQUEST['delete_comments'] ) && isset($_REQUEST['action']) ) {
     24if ( isset($_REQUEST['delete_comments']) && isset($_REQUEST['action']) && ( -1 != $_REQUEST['action'] || -1 != $_REQUEST['action2'] ) ) {
    2525    check_admin_referer('bulk-comments');
    26 
    27     $comments_deleted = $comments_approved = $comments_unapproved = $comments_spammed = 0;
    28     foreach ($_REQUEST['delete_comments'] as $comment) : // Check the permissions on each
    29         $comment = (int) $comment;
    30         $post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment) );
     26    $doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
     27
     28    $deleted = $approved = $unapproved = $spammed = 0;
     29    foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each
     30        $comment_id = (int) $comment_id;
     31        $post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) );
     32
    3133        if ( !current_user_can('edit_post', $post_id) )
    3234            continue;
    33         if ( $_REQUEST['action'] == 'markspam' ) {
    34             wp_set_comment_status($comment, 'spam');
    35             $comments_spammed++;
    36         } elseif ( $_REQUEST['action'] == 'delete' ) {
    37             wp_set_comment_status($comment, 'delete');
    38             $comments_deleted++;
    39         } elseif ( $_REQUEST['action'] == 'approve' ) {
    40             wp_set_comment_status($comment, 'approve');
    41             $comments_approved++;
    42         } elseif ( $_REQUEST['action'] == 'unapprove' ) {
    43             wp_set_comment_status($comment, 'hold');
    44             $comments_unapproved++;
     35
     36        switch( $doaction ) {
     37            case 'markspam' :
     38                wp_set_comment_status($comment_id, 'spam');
     39                $spammed++;
     40                break;
     41            case 'delete' :
     42                wp_set_comment_status($comment_id, 'delete');
     43                $deleted++;
     44                break;
     45            case 'approve' :
     46                wp_set_comment_status($comment_id, 'approve');
     47                $approved++;
     48                break;
     49            case 'unapprove' :
     50                wp_set_comment_status($comment_id, 'hold');
     51                $unapproved++;
     52                break;
    4553        }
    4654    endforeach;
    47     $redirect_to = basename( __FILE__ ) . '?deleted=' . $comments_deleted . '&approved=' . $comments_approved . '&spam=' . $comments_spammed . '&unapproved=' . $comments_unapproved;
     55
     56    $redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved;
    4857    if ( isset($_REQUEST['apage']) )
    4958        $redirect_to = add_query_arg( 'apage', absint($_REQUEST['apage']), $redirect_to );
     
    5564        $redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to);
    5665    wp_redirect( $redirect_to );
    57 } elseif ( !empty($_GET['_wp_http_referer']) ) {
    58      wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
     66} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
     67     wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
    5968     exit;
    6069}
     
    112121}
    113122?>
     123
    114124<div class="wrap">
    115125
     
    144154
    145155<?php
    146 
    147156$comments_per_page = apply_filters('comments_per_page', 20, $comment_status);
    148157
     
    181190<div class="alignleft">
    182191<select name="action">
    183 <option value="" selected="selected"><?php _e('Actions') ?></option>
     192<option value="-1" selected="selected"><?php _e('Actions') ?></option>
    184193<?php if ( empty($comment_status) || 'approved' == $comment_status ): ?>
    185194<option value="unapprove"><?php _e('Unapprove'); ?></option>
     
    199208<?php }
    200209
    201 if ( 'spam' == $comment_status ) { 
     210if ( 'spam' == $comment_status ) {
    202211    wp_nonce_field('bulk-spam-delete'); ?>
    203212<input type="submit" name="delete_all_spam" value="<?php _e('Delete All Spam'); ?>" class="button-secondary apply" />
     
    211220
    212221<br class="clear" />
    213 <?php
    214 if ($comments) {
    215 ?>
     222
     223<?php if ( $comments ) { ?>
    216224<table class="widefat">
    217225<thead>
     
    220228    </tr>
    221229</thead>
     230
     231<tfoot>
     232    <tr>
     233<?php print_column_headers('comment', false); ?>
     234    </tr>
     235</tfoot>
     236
    222237<tbody id="the-comment-list" class="list:comment">
    223238<?php
     
    233248</tbody>
    234249</table>
     250
     251<div class="tablenav">
     252<?php
     253if ( $page_links )
     254    echo "<div class='tablenav-pages'>$page_links</div>";
     255?>
     256
     257<div class="alignleft">
     258<select name="action2">
     259<option value="-1" selected="selected"><?php _e('Actions') ?></option>
     260<?php if ( empty($comment_status) || 'approved' == $comment_status ): ?>
     261<option value="unapprove"><?php _e('Unapprove'); ?></option>
     262<?php endif; ?>
     263<?php if ( empty($comment_status) || 'moderated' == $comment_status ): ?>
     264<option value="approve"><?php _e('Approve'); ?></option>
     265<?php endif; ?>
     266<?php if ( 'spam' != $comment_status ): ?>
     267<option value="markspam"><?php _e('Mark as Spam'); ?></option>
     268<?php endif; ?>
     269<option value="delete"><?php _e('Delete'); ?></option>
     270</select>
     271<input type="submit" name="doaction2" id="doaction2" value="<?php _e('Apply'); ?>" class="button-secondary apply" />
     272
     273<?php if ( 'spam' == $comment_status ) { ?>
     274<input type="submit" name="delete_all_spam2" value="<?php _e('Delete All Spam'); ?>" class="button-secondary apply" />
     275<?php } ?>
     276<?php do_action('manage_comments_nav', $comment_status); ?>
     277</div>
     278
     279<br class="clear" />
     280</div>
    235281
    236282</form>
     
    252298</p>
    253299<?php
    254 } else  {
     300} else {
    255301?>
    256302<p>
     
    260306}
    261307?>
    262 <div class="tablenav">
    263 <?php
    264 if ( $page_links )
    265     echo "<div class='tablenav-pages'>$page_links</div>";
    266 ?>
    267 <br class="clear" />
    268 </div>
    269308
    270309</div>
Note: See TracChangeset for help on using the changeset viewer.