WordPress.org

Make WordPress Core

Ticket #10878: bulk-comments.diff

File bulk-comments.diff, 3.1 KB (added by beaulebens, 9 years ago)

Initial patch for review.

  • wp-admin/edit.php

     
    9595                                $sendback = add_query_arg( $done, $sendback );
    9696                        }
    9797                        break;
     98                case 'enable-comments':
     99                        $comms = 0;
     100                        foreach( (array) $post_ids as $post_id ) {
     101                                if ( !wp_update_post( array( 'ID' => $post_id, 'comment_status' => 'open' ) ) )
     102                                        wp_die( __( 'Error in changing comment status...' ) );
     103                                $comms++;
     104                        }
     105                        $sendback = add_query_arg( 'comments-enabled', $comms, $sendback );
     106                        break;
     107                case 'disable-comments':
     108                        $comms = 0;
     109                        foreach( (array) $post_ids as $post_id ) {
     110                                if ( !wp_update_post( array( 'ID' => $post_id, 'comment_status' => 'closed' ) ) )
     111                                        wp_die( __( 'Error in changing comment status...' ) );
     112                                $comms++;
     113                        }
     114                        $sendback = add_query_arg( 'comments-disabled', $comms, $sendback );
     115                        break;
    98116        }
    99117
    100118        if ( isset($_GET['action']) )
     
    145163<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
    146164endif; ?>
    147165
    148 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?>
     166<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['comments-enabled']) || isset($_GET['comments-disabled']) ) { ?>
    149167<div id="message" class="updated fade"><p>
    150168<?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
    151169        printf( _n( '%s post updated.', '%s posts updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
     
    176194        unset($_GET['undeleted']);
    177195}
    178196
    179 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] );
     197if ( isset($_GET['comments-enabled']) && (int) $_GET['comments-enabled'] ) {
     198        printf( _n( 'Comments enabled on that post.', 'Comments enabled on %s posts.', $_GET['comments-enabled'] ), number_format_i18n( $_GET['comments-enabled'] ) );
     199        unset($_GET['comments-enabled']);
     200}
     201
     202if ( isset($_GET['comments-disabled']) && (int) $_GET['comments-disabled'] ) {
     203        printf( _n( 'Comments disabled on that post.', 'Comments disabled on %s posts.', $_GET['comments-disabled'] ), number_format_i18n( $_GET['comments-disabled'] ) );
     204        unset($_GET['comments-disabled']);
     205}
     206
     207$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed', 'comments-enabled', 'comments-disabled'), $_SERVER['REQUEST_URI'] );
    180208?>
    181209</p></div>
    182210<?php } ?>
     
    257285<?php } else { ?>
    258286<option value="edit"><?php _e('Edit'); ?></option>
    259287<option value="trash"><?php _e('Move to Trash'); ?></option>
     288<option value="enable-comments"><?php _e('Enable Comments'); ?></option>
     289<option value="disable-comments"><?php _e('Disable Comments'); ?></option>
    260290<?php } ?>
    261291</select>
    262292<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />