'comments' ) ); } function check_permissions() { if ( !current_user_can('edit_posts') ) wp_die(__('Cheatin’ uh?')); } function prepare_items() { global $post_id, $comment_status, $search; if ( isset( $_REQUEST['p'] ) ) $post_id = absint( $_REQUEST['p'] ); elseif ( isset( $_REQUEST['post'] ) ) $post_id = absint( $_REQUEST['post'] ); elseif ( isset( $_REQUEST['post_ID'] ) ) $post_id = absint( $_REQUEST['post_ID'] ); else $post_id = 0; $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) ) $comment_status = 'all'; $comment_type = !empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : ''; $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : ''; $user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : ''; $comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' ); $comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status ); if ( isset( $_POST['number'] ) ) $number = (int) $_POST['number']; else $number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra $page = $this->get_pagenum(); $start = $offset = ( $page - 1 ) * $comments_per_page; $status_map = array( 'moderated' => 'hold', 'approved' => 'approve' ); $args = array( 'status' => isset( $status_map[$comment_status] ) ? $status_map[$comment_status] : $comment_status, 'search' => $search, 'user_id' => $user_id, 'offset' => $start, 'number' => $number, 'post_id' => $post_id, 'type' => $comment_type, 'orderby' => @$_REQUEST['orderby'], 'order' => @$_REQUEST['order'], ); $_comments = get_comments( $args ); update_comment_cache( $_comments ); $this->items = array_slice( $_comments, 0, $comments_per_page ); $this->extra_items = array_slice( $_comments, $comments_per_page ); $total_comments = get_comments( array_merge( $args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); $_comment_post_ids = array(); foreach ( $_comments as $_c ) { $_comment_post_ids[] = $_c->comment_post_ID; } $this->pending_count = get_pending_comments_num( $_comment_post_ids ); $this->set_pagination_args( array( 'total_items' => $total_comments, 'per_page' => $comments_per_page, ) ); } function no_items() { global $comment_status; if ( 'moderated' == $comment_status ) _e( 'No comments awaiting moderation… yet.' ); else _e( 'No comments found.' ); } function get_views() { global $post_id, $comment_status; $status_links = array(); $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments(); //, number_format_i18n($num_comments->moderated) ), "" . number_format_i18n($num_comments->moderated) . ""), //, number_format_i18n($num_comments->spam) ), "" . number_format_i18n($num_comments->spam) . "") $stati = array( 'all' => _nx_noop('All', 'All', 'comments'), // singular not used 'moderated' => _n_noop('Pending (%s)', 'Pending (%s)'), 'approved' => _n_noop('Approved', 'Approved'), // singular not used 'spam' => _n_noop('Spam (%s)', 'Spam (%s)'), 'trash' => _n_noop('Trash (%s)', 'Trash (%s)') ); if ( !EMPTY_TRASH_DAYS ) unset($stati['trash']); $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 = ( $status == $comment_status ) ? ' class="current"' : ''; if ( !isset( $num_comments->$status ) ) $num_comments->$status = 10; $link = add_query_arg( 'comment_status', $status, $link ); if ( $post_id ) $link = add_query_arg( 'p', absint( $post_id ), $link ); /* // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark if ( !empty( $_REQUEST['s'] ) ) $link = add_query_arg( 's', esc_attr( stripslashes( $_REQUEST['s'] ) ), $link ); */ $status_links[$status] = "