raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Edit Comments Administration Panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 $post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
mp-wp_genesis 13
mp-wp_genesis 14 if ( ( isset( $_REQUEST['delete_all_spam'] ) || isset( $_REQUEST['delete_all_spam2'] ) ) && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
mp-wp_genesis 15 check_admin_referer('bulk-spam-delete', '_spam_nonce');
mp-wp_genesis 16
mp-wp_genesis 17 $delete_time = $wpdb->escape( $_REQUEST['pagegen_timestamp'] );
mp-wp_genesis 18 $deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
mp-wp_genesis 19
mp-wp_genesis 20 $redirect_to = 'edit-comments.php?comment_status=spam&deleted=' . (int) $deleted_spam;
mp-wp_genesis 21 if ( $post_id )
mp-wp_genesis 22 $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
mp-wp_genesis 23 wp_redirect( $redirect_to );
mp-wp_remove-all-... 24 } elseif ( isset($_REQUEST['delete_comments']) && isset($_REQUEST['action']) && -1 != $_REQUEST['action'] ) {
mp-wp_genesis 25 check_admin_referer('bulk-comments');
mp-wp_remove-all-... 26 $doaction = $_REQUEST['action'];
mp-wp_genesis 27
mp-wp_genesis 28 $deleted = $approved = $unapproved = $spammed = 0;
mp-wp_genesis 29 foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each
mp-wp_genesis 30 $comment_id = (int) $comment_id;
mp-wp_genesis 31 $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) );
mp-wp_genesis 32
mp-wp_genesis 33 if ( !current_user_can('edit_post', $_post_id) )
mp-wp_genesis 34 continue;
mp-wp_genesis 35
mp-wp_genesis 36 switch( $doaction ) {
mp-wp_genesis 37 case 'markspam' :
mp-wp_genesis 38 wp_set_comment_status($comment_id, 'spam');
mp-wp_genesis 39 $spammed++;
mp-wp_genesis 40 break;
mp-wp_genesis 41 case 'delete' :
mp-wp_genesis 42 wp_set_comment_status($comment_id, 'delete');
mp-wp_genesis 43 $deleted++;
mp-wp_genesis 44 break;
mp-wp_genesis 45 case 'approve' :
mp-wp_genesis 46 wp_set_comment_status($comment_id, 'approve');
mp-wp_genesis 47 $approved++;
mp-wp_genesis 48 break;
mp-wp_genesis 49 case 'unapprove' :
mp-wp_genesis 50 wp_set_comment_status($comment_id, 'hold');
mp-wp_genesis 51 $unapproved++;
mp-wp_genesis 52 break;
mp-wp_genesis 53 }
mp-wp_genesis 54 endforeach;
mp-wp_genesis 55
mp-wp_genesis 56 $redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved;
mp-wp_genesis 57 if ( $post_id )
mp-wp_genesis 58 $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
mp-wp_genesis 59 if ( isset($_REQUEST['apage']) )
mp-wp_genesis 60 $redirect_to = add_query_arg( 'apage', absint($_REQUEST['apage']), $redirect_to );
mp-wp_genesis 61 if ( !empty($_REQUEST['mode']) )
mp-wp_genesis 62 $redirect_to = add_query_arg('mode', $_REQUEST['mode'], $redirect_to);
mp-wp_genesis 63 if ( !empty($_REQUEST['comment_status']) )
mp-wp_genesis 64 $redirect_to = add_query_arg('comment_status', $_REQUEST['comment_status'], $redirect_to);
mp-wp_genesis 65 if ( !empty($_REQUEST['s']) )
mp-wp_genesis 66 $redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to);
mp-wp_genesis 67 wp_redirect( $redirect_to );
mp-wp_genesis 68 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
mp-wp_genesis 69 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
mp-wp_genesis 70 exit;
mp-wp_genesis 71 }
mp-wp_genesis 72
mp-wp_genesis 73 if ( $post_id )
mp-wp_genesis 74 $title = sprintf(__('Edit Comments on &#8220;%s&#8221;'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
mp-wp_genesis 75 else
mp-wp_genesis 76 $title = __('Edit Comments');
mp-wp_genesis 77
mp-wp_genesis 78 require_once('admin-header.php');
mp-wp_genesis 79
mp-wp_genesis 80 $mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : attribute_escape($_GET['mode']);
mp-wp_genesis 81
mp-wp_genesis 82 $comment_status = !empty($_GET['comment_status']) ? attribute_escape($_GET['comment_status']) : '';
mp-wp_genesis 83
mp-wp_genesis 84 $comment_type = !empty($_GET['comment_type']) ? attribute_escape($_GET['comment_type']) : '';
mp-wp_genesis 85
mp-wp_genesis 86 $search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : '';
mp-wp_genesis 87 $search = attribute_escape( $search_dirty ); ?>
mp-wp_genesis 88
mp-wp_genesis 89 <div class="wrap">
mp-wp_genesis 90 <?php screen_icon(); ?>
mp-wp_genesis 91 <h2><?php echo wp_specialchars( $title );
mp-wp_genesis 92 if ( isset($_GET['s']) && $_GET['s'] )
mp-wp_genesis 93 printf( '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( wp_specialchars( stripslashes( $_GET['s'] ) ), 50 ) ) . '</span>' ); ?>
mp-wp_genesis 94 </h2>
mp-wp_genesis 95
mp-wp_genesis 96 <?php
mp-wp_genesis 97 if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) {
mp-wp_genesis 98 $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0;
mp-wp_genesis 99 $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0;
mp-wp_genesis 100 $spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0;
mp-wp_genesis 101
mp-wp_genesis 102 if ( $approved > 0 || $deleted > 0 || $spam > 0 ) {
mp-wp_genesis 103 echo '<div id="moderated" class="updated fade"><p>';
mp-wp_genesis 104
mp-wp_genesis 105 if ( $approved > 0 ) {
mp-wp_genesis 106 printf( __ngettext( '%s comment approved', '%s comments approved', $approved ), $approved );
mp-wp_genesis 107 echo '<br />';
mp-wp_genesis 108 }
mp-wp_genesis 109
mp-wp_genesis 110 if ( $deleted > 0 ) {
mp-wp_genesis 111 printf( __ngettext( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
mp-wp_genesis 112 echo '<br />';
mp-wp_genesis 113 }
mp-wp_genesis 114
mp-wp_genesis 115 if ( $spam > 0 ) {
mp-wp_genesis 116 printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
mp-wp_genesis 117 echo '<br />';
mp-wp_genesis 118 }
mp-wp_genesis 119
mp-wp_genesis 120 echo '</p></div>';
mp-wp_genesis 121 }
mp-wp_genesis 122 }
mp-wp_genesis 123 ?>
mp-wp_genesis 124
mp-wp_genesis 125 <form id="comments-form" action="" method="get">
mp-wp_genesis 126 <ul class="subsubsub">
mp-wp_genesis 127 <?php
mp-wp_genesis 128 $status_links = array();
mp-wp_genesis 129 $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
mp-wp_genesis 130 //, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
mp-wp_genesis 131 //, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
mp-wp_genesis 132 $stati = array(
mp-wp_genesis 133 'all' => __ngettext_noop('All', 'All'), // singular not used
mp-wp_genesis 134 'moderated' => __ngettext_noop('Pending (<span class="pending-count">%s</span>)', 'Pending (<span class="pending-count">%s</span>)'),
mp-wp_genesis 135 'approved' => __ngettext_noop('Approved', 'Approved'), // singular not used
mp-wp_genesis 136 'spam' => __ngettext_noop('Spam (<span class="spam-count">%s</span>)', 'Spam (<span class="spam-count">%s</span>)')
mp-wp_genesis 137 );
mp-wp_genesis 138 $class = ( '' === $comment_status ) ? ' class="current"' : '';
mp-wp_genesis 139 // $status_links[] = "<li><a href='edit-comments.php'$class>" . __( 'All' ) . '</a>';
mp-wp_genesis 140 $link = 'edit-comments.php';
mp-wp_genesis 141 if ( !empty($comment_type) && 'all' != $comment_type )
mp-wp_genesis 142 $link = add_query_arg( 'comment_type', $comment_type, $link );
mp-wp_genesis 143 foreach ( $stati as $status => $label ) {
mp-wp_genesis 144 $class = '';
mp-wp_genesis 145
mp-wp_genesis 146 if ( str_replace( 'all', '', $status ) == $comment_status )
mp-wp_genesis 147 $class = ' class="current"';
mp-wp_genesis 148 if ( !isset( $num_comments->$status ) )
mp-wp_genesis 149 $num_comments->$status = 10;
mp-wp_genesis 150 if ( 'all' != $status )
mp-wp_genesis 151 $link = add_query_arg( 'comment_status', $status, $link );
mp-wp_genesis 152 if ( $post_id )
mp-wp_genesis 153 $link = add_query_arg( 'p', absint( $post_id ), $link );
mp-wp_genesis 154 /*
mp-wp_genesis 155 // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
mp-wp_genesis 156 if ( !empty( $_GET['s'] ) )
mp-wp_genesis 157 $link = add_query_arg( 's', attribute_escape( stripslashes( $_GET['s'] ) ), $link );
mp-wp_genesis 158 */
mp-wp_genesis 159 $status_links[] = "<li class='$status'><a href='$link'$class>" . sprintf(
mp-wp_genesis 160 __ngettext( $label[0], $label[1], $num_comments->$status ),
mp-wp_genesis 161 number_format_i18n( $num_comments->$status )
mp-wp_genesis 162 ) . '</a>';
mp-wp_genesis 163 }
mp-wp_genesis 164
mp-wp_genesis 165 $status_links = apply_filters( 'comment_status_links', $status_links );
mp-wp_genesis 166
mp-wp_genesis 167 echo implode( " |</li>\n", $status_links) . '</li>';
mp-wp_genesis 168 unset($status_links);
mp-wp_genesis 169 ?>
mp-wp_genesis 170 </ul>
mp-wp_genesis 171
mp-wp_genesis 172 <p class="search-box">
mp-wp_genesis 173 <label class="hidden" for="comment-search-input"><?php _e( 'Search Comments' ); ?>:</label>
mp-wp_genesis 174 <input type="text" class="search-input" id="comment-search-input" name="s" value="<?php _admin_search_query(); ?>" />
mp-wp_genesis 175 <input type="submit" value="<?php _e( 'Search Comments' ); ?>" class="button" />
mp-wp_genesis 176 </p>
mp-wp_genesis 177
mp-wp_genesis 178 <?php
mp-wp_genesis 179 $comments_per_page = apply_filters('comments_per_page', 20, $comment_status);
mp-wp_genesis 180
mp-wp_genesis 181 if ( isset( $_GET['apage'] ) )
mp-wp_genesis 182 $page = abs( (int) $_GET['apage'] );
mp-wp_genesis 183 else
mp-wp_genesis 184 $page = 1;
mp-wp_genesis 185
mp-wp_genesis 186 $start = $offset = ( $page - 1 ) * $comments_per_page;
mp-wp_genesis 187
mp-wp_genesis 188 list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5, $post_id, $comment_type ); // Grab a few extra
mp-wp_genesis 189
mp-wp_genesis 190 $_comment_post_ids = array();
mp-wp_genesis 191 foreach ( $_comments as $_c ) {
mp-wp_genesis 192 $_comment_post_ids[] = $_c->comment_post_ID;
mp-wp_genesis 193 }
mp-wp_genesis 194 $_comment_pending_count_temp = (array) get_pending_comments_num($_comment_post_ids);
mp-wp_genesis 195 foreach ( (array) $_comment_post_ids as $_cpid )
mp-wp_genesis 196 $_comment_pending_count[$_cpid] = isset( $_comment_pending_count_temp[$_cpid] ) ? $_comment_pending_count_temp[$_cpid] : 0;
mp-wp_genesis 197 if ( empty($_comment_pending_count) )
mp-wp_genesis 198 $_comment_pending_count = array();
mp-wp_genesis 199
mp-wp_genesis 200 $comments = array_slice($_comments, 0, $comments_per_page);
mp-wp_genesis 201 $extra_comments = array_slice($_comments, $comments_per_page);
mp-wp_genesis 202
mp-wp_genesis 203 $page_links = paginate_links( array(
mp-wp_genesis 204 'base' => add_query_arg( 'apage', '%#%' ),
mp-wp_genesis 205 'format' => '',
mp-wp_genesis 206 'prev_text' => __('&laquo;'),
mp-wp_genesis 207 'next_text' => __('&raquo;'),
mp-wp_genesis 208 'total' => ceil($total / $comments_per_page),
mp-wp_genesis 209 'current' => $page
mp-wp_genesis 210 ));
mp-wp_genesis 211
mp-wp_genesis 212 ?>
mp-wp_genesis 213
mp-wp_genesis 214 <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
mp-wp_genesis 215 <?php if ( $post_id ) : ?>
mp-wp_genesis 216 <input type="hidden" name="p" value="<?php echo intval( $post_id ); ?>" />
mp-wp_genesis 217 <?php endif; ?>
mp-wp_genesis 218 <input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
mp-wp_genesis 219 <input type="hidden" name="pagegen_timestamp" value="<?php echo current_time('mysql', 1); ?>" />
mp-wp_genesis 220
mp-wp_genesis 221 <div class="tablenav">
mp-wp_genesis 222
mp-wp_remove-all-... 223 <?php if ( $page_links ) { ?>
mp-wp_genesis 224 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
mp-wp_genesis 225 number_format_i18n( $start + 1 ),
mp-wp_genesis 226 number_format_i18n( min( $page * $comments_per_page, $total ) ),
mp-wp_genesis 227 number_format_i18n( $total ),
mp-wp_genesis 228 $page_links
mp-wp_genesis 229 ); echo $page_links_text; ?></div>
mp-wp_remove-all-... 230 <?php } ?>
mp-wp_genesis 231
mp-wp_genesis 232 <div class="alignleft actions">
mp-wp_genesis 233 <select name="action">
mp-wp_genesis 234 <option value="-1" selected="selected"><?php _e('Bulk Actions') ?></option>
mp-wp_genesis 235 <?php if ( empty($comment_status) || 'approved' == $comment_status ): ?>
mp-wp_genesis 236 <option value="unapprove"><?php _e('Unapprove'); ?></option>
mp-wp_genesis 237 <?php endif; ?>
mp-wp_genesis 238 <?php if ( empty($comment_status) || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
mp-wp_genesis 239 <option value="approve"><?php _e('Approve'); ?></option>
mp-wp_genesis 240 <?php endif; ?>
mp-wp_genesis 241 <?php if ( 'spam' != $comment_status ): ?>
mp-wp_genesis 242 <option value="markspam"><?php _e('Mark as Spam'); ?></option>
mp-wp_genesis 243 <?php endif; ?>
mp-wp_genesis 244 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 245 </select>
mp-wp_genesis 246 <input type="submit" name="doaction" id="doaction" value="<?php _e('Apply'); ?>" class="button-secondary apply" />
mp-wp_genesis 247 <?php wp_nonce_field('bulk-comments'); ?>
mp-wp_genesis 248
mp-wp_genesis 249 <?php if ( $comment_status ) echo "<input type='hidden' name='comment_status' value='$comment_status' />\n"; ?>
mp-wp_genesis 250 <select name="comment_type">
mp-wp_genesis 251 <option value="all"><?php _e('Show all comment types'); ?></option>
mp-wp_genesis 252 <?php
mp-wp_genesis 253 $comment_types = apply_filters( 'admin_comment_types_dropdown', array(
mp-wp_genesis 254 'comment' => __('Comments'),
mp-wp_genesis 255 'pings' => __('Pings'),
mp-wp_genesis 256 ) );
mp-wp_genesis 257
mp-wp_genesis 258 foreach ( $comment_types as $type => $label ) {
mp-wp_genesis 259 echo " <option value='$type'";
mp-wp_genesis 260 selected( $comment_type, $type );
mp-wp_genesis 261 echo ">$label</option>\n";
mp-wp_genesis 262 }
mp-wp_genesis 263 ?>
mp-wp_genesis 264 </select>
mp-wp_genesis 265 <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
mp-wp_genesis 266
mp-wp_genesis 267 <?php if ( isset($_GET['apage']) ) { ?>
mp-wp_genesis 268 <input type="hidden" name="apage" value="<?php echo absint( $_GET['apage'] ); ?>" />
mp-wp_genesis 269 <?php }
mp-wp_genesis 270
mp-wp_genesis 271 if ( 'spam' == $comment_status ) {
mp-wp_genesis 272 wp_nonce_field('bulk-spam-delete', '_spam_nonce'); ?>
mp-wp_genesis 273 <input type="submit" name="delete_all_spam" value="<?php _e('Delete All Spam'); ?>" class="button-secondary apply" />
mp-wp_genesis 274 <?php } ?>
mp-wp_genesis 275 <?php do_action('manage_comments_nav', $comment_status); ?>
mp-wp_genesis 276 </div>
mp-wp_genesis 277
mp-wp_genesis 278 <br class="clear" />
mp-wp_genesis 279
mp-wp_genesis 280 </div>
mp-wp_genesis 281
mp-wp_genesis 282 <div class="clear"></div>
mp-wp_genesis 283
mp-wp_genesis 284 <?php if ( $comments ) { ?>
mp-wp_genesis 285 <table class="widefat comments fixed" cellspacing="0">
mp-wp_genesis 286 <thead>
mp-wp_genesis 287 <tr>
mp-wp_genesis 288 <?php print_column_headers('edit-comments'); ?>
mp-wp_genesis 289 </tr>
mp-wp_genesis 290 </thead>
mp-wp_genesis 291 <tbody id="the-comment-list" class="list:comment">
mp-wp_genesis 292 <?php
mp-wp_genesis 293 foreach ($comments as $comment)
mp-wp_genesis 294 _wp_comment_row( $comment->comment_ID, $mode, $comment_status );
mp-wp_genesis 295 ?>
mp-wp_genesis 296 </tbody>
mp-wp_genesis 297 <tbody id="the-extra-comment-list" class="list:comment" style="display: none;">
mp-wp_genesis 298 <?php
mp-wp_genesis 299 foreach ($extra_comments as $comment)
mp-wp_genesis 300 _wp_comment_row( $comment->comment_ID, $mode, $comment_status );
mp-wp_genesis 301 ?>
mp-wp_genesis 302 </tbody>
mp-wp_genesis 303 </table>
mp-wp_genesis 304
mp-wp_remove-all-... 305 <?php if ( $page_links ) { ?>
mp-wp_genesis 306 <div class="tablenav">
mp-wp_remove-all-... 307 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
mp-wp_remove-all-... 308 number_format_i18n( $start + 1 ),
mp-wp_remove-all-... 309 number_format_i18n( min( $page * $comments_per_page, $total ) ),
mp-wp_remove-all-... 310 number_format_i18n( $total ),
mp-wp_remove-all-... 311 $page_links
mp-wp_remove-all-... 312 ); echo $page_links_text; ?></div>
mp-wp_genesis 313 </div>
mp-wp_remove-all-... 314 <?php } ?>
mp-wp_genesis 315
mp-wp_genesis 316 </form>
mp-wp_genesis 317
mp-wp_genesis 318 <form id="get-extra-comments" method="post" action="" class="add:the-extra-comment-list:" style="display: none;">
mp-wp_genesis 319 <input type="hidden" name="s" value="<?php echo $search; ?>" />
mp-wp_genesis 320 <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
mp-wp_genesis 321 <input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
mp-wp_genesis 322 <input type="hidden" name="page" value="<?php echo isset($_REQUEST['page']) ? absint( $_REQUEST['page'] ) : 1; ?>" />
mp-wp_genesis 323 <input type="hidden" name="p" value="<?php echo attribute_escape( $post_id ); ?>" />
mp-wp_genesis 324 <input type="hidden" name="comment_type" value="<?php echo attribute_escape( $comment_type ); ?>" />
mp-wp_genesis 325 </form>
mp-wp_genesis 326
mp-wp_genesis 327 <?php } elseif ( 'moderated' == $_GET['comment_status'] ) { ?>
mp-wp_genesis 328 <p><?php _e('No comments awaiting moderation&hellip; yet.') ?></p>
mp-wp_genesis 329 </form>
mp-wp_genesis 330
mp-wp_genesis 331 <?php } else { ?>
mp-wp_genesis 332 <p><?php _e('No results found.') ?></p>
mp-wp_remove-all-... 333
mp-wp_genesis 334 </form>
mp-wp_genesis 335
mp-wp_genesis 336 <?php } ?>
mp-wp_genesis 337 </div>
mp-wp_genesis 338
mp-wp_genesis 339 <?php
mp-wp_genesis 340 wp_comment_reply('-1', true, 'detail');
mp-wp_genesis 341 include('admin-footer.php'); ?>