_wp_comment_row($comment->comment_ID, $mode, $status, true, true); $comment_list_item = ob_get_contents(); ob_end_clean(); $x->add(array('what' => 'comment', 'id' => $comment->comment_ID, 'data' => $comment_list_item)); } $x->send(); break; case 'get-comments': check_ajax_referer($action); $post_ID = (int) $_POST['post_ID']; if (!current_user_can('edit_post', $post_ID)) { die('-1'); } $start = isset($_POST['start']) ? intval($_POST['start']) : 0; $num = isset($_POST['num']) ? intval($_POST['num']) : 10; list($comments, $total) = _wp_get_comment_list(false, false, $start, $num, $post_ID); if (!$comments) { die('1'); } $comment_list_item = ''; $x = new WP_Ajax_Response(); foreach ((array) $comments as $comment) { get_comment($comment); ob_start(); _wp_comment_row($comment->comment_ID, 'single', false, false); $comment_list_item .= ob_get_contents(); ob_end_clean(); } $x->add(array('what' => 'comments', 'data' => $comment_list_item)); $x->send(); break;
<li <?php if ( 'detail' == $mode ) echo "class='current'" ?>><a href="<?php echo clean_url(add_query_arg('mode', 'detail', $_SERVER['REQUEST_URI'])) ?>"><?php _e('Detail View') ?></a></li> <li <?php if ( 'list' == $mode ) echo "class='current'" ?>><a href="<?php echo clean_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>"><?php _e('List View') ?></a></li> </ul> <?php $comments_per_page = apply_filters('comments_per_page', 20, $comment_status); if ( isset( $_GET['apage'] ) ) $page = abs( (int) $_GET['apage'] ); else $page = 1; $start = $offset = ( $page - 1 ) * $comments_per_page; list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5 ); // Grab a few extra $comments = array_slice($_comments, 0, $comments_per_page); $extra_comments = array_slice($_comments, $comments_per_page); $page_links = paginate_links( array( 'base' => add_query_arg( 'apage', '%#%' ), 'format' => '', 'total' => ceil($total / $comments_per_page), 'current' => $page )); ?> <form id="comments-form" action="" method="post">
" class="button" /> </p> <?php $comments_per_page = (int) get_user_option('edit_comments_per_page'); if (empty($comments_per_page) || $comments_per_page < 1) { $comments_per_page = 20; } $comments_per_page = apply_filters('comments_per_page', $comments_per_page, $comment_status); if (isset($_GET['apage'])) { $page = abs((int) $_GET['apage']); } else { $page = 1; } $start = $offset = ($page - 1) * $comments_per_page; list($_comments, $total) = _wp_get_comment_list($comment_status, $search_dirty, $start, $comments_per_page + 8, $post_id, $comment_type); // Grab a few extra $_comment_post_ids = array(); foreach ($_comments as $_c) { $_comment_post_ids[] = $_c->comment_post_ID; } $_comment_pending_count = get_pending_comments_num($_comment_post_ids); $comments = array_slice($_comments, 0, $comments_per_page); $extra_comments = array_slice($_comments, $comments_per_page); $page_links = paginate_links(array('base' => add_query_arg('apage', '%#%'), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => ceil($total / $comments_per_page), 'current' => $page)); ?> <input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?> " />
echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>'; if ( !empty( $_POST['spam_button'] ) ) { printf(__ngettext('%s comment marked as spam', '%s comments marked as spam.', $i), $i); } else { printf(__ngettext('%s comment deleted.', '%s comments deleted.', $i), $i); } echo '</p></div>'; endif; if ( isset( $_GET['apage'] ) ) $page = (int) $_GET['apage']; else $page = 1; $start = $offset = ( $page - 1 ) * 20; list($_comments, $total) = _wp_get_comment_list( isset($_GET['s']) ? $_GET['s'] : false, $start, 25 ); // Grab a few extra $comments = array_slice($_comments, 0, 20); $extra_comments = array_slice($_comments, 20); $page_links = paginate_links( array( 'base' => 'edit-comments.php?%_%', 'format' => 'apage=%#%', 'total' => ceil($total / 20), 'current' => $page )); if ( $page_links ) echo "<p class='pagenav'>$page_links</p>"; if ('view' == $mode) {
$x = new WP_Ajax_Response( array( 'what' => 'cat', 'id' => $cat->cat_ID, 'data' => _cat_row( $cat, $level, $cat_full_name ), 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->cat_ID", $cat_full_name)) ) ); $x->send(); break; case 'add-comment' : if ( !current_user_can( 'edit_post', $id ) ) die('-1'); $search = isset($_POST['s']) ? $_POST['s'] : false; $start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25; list($comments, $total) = _wp_get_comment_list( $search, $start, 1 ); if ( !$comments ) die('1'); $x = new WP_Ajax_Response(); foreach ( (array) $comments as $comment ) { get_comment( $comment ); ob_start(); _wp_comment_list_item( $comment->comment_ID ); $comment_list_item = ob_get_contents(); ob_end_clean(); $x->add( array( 'what' => 'comment', 'id' => $comment->comment_ID, 'data' => $comment_list_item ) );
echo clean_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])); ?> "><?php _e('List View'); ?> </a></li> </ul> <?php if (isset($_GET['apage'])) { $page = abs((int) $_GET['apage']); } else { $page = 1; } $start = $offset = ($page - 1) * 20; list($_comments, $total) = _wp_get_comment_list($comment_status, $search_dirty, $start, 25); // Grab a few extra $comments = array_slice($_comments, 0, 20); $extra_comments = array_slice($_comments, 20); $page_links = paginate_links(array('base' => add_query_arg('apage', '%#%'), 'format' => '', 'total' => ceil($total / 20), 'current' => $page)); ?> <form id="comments-form" action="" method="post"> <div class="tablenav"> <?php if ($page_links) { echo "<div class='tablenav-pages'>{$page_links}</div>"; } ?>
private function output() { global $title, $parent_file, $wpdb; if ($this->post_id > 0) { $title = sprintf(__('Comments for %s', 'ktai_style'), wp_html_excerpt($this->get_post_title($this->post_id), 50)); $this->post_status = $wpdb->get_var($wpdb->prepare("SELECT post_status FROM {$wpdb->posts} WHERE ID = %d", $this->post_id)); } else { $title = __('Edit Comment'); $this->post_status = NULL; } $parent_file = 'edit-comments.php'; include dirname(__FILE__) . '/admin-header.php'; $mode = !isset($_GET['mode']) || empty($_GET['mode']) ? 'detail' : esc_attr($_GET['mode']); $comment_status = !empty($_GET['comment_status']) ? esc_attr($_GET['comment_status']) : ''; $comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : ''; $search_dirty = isset($_GET['s']) ? $_GET['s'] : ''; $search = stripslashes($search_dirty); if ($search_dirty) { printf('<h2>' . __('Search results for “%s”', 'ktai_style') . '</h2>', esc_attr($search)); } if (isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed'])) { $approved = isset($_GET['approved']) ? (int) $_GET['approved'] : 0; $deleted = isset($_GET['deleted']) ? (int) $_GET['deleted'] : 0; $trashed = isset($_GET['trashed']) ? (int) $_GET['trashed'] : 0; $untrashed = isset($_GET['untrashed']) ? (int) $_GET['untrashed'] : 0; $spammed = isset($_GET['spammed']) ? (int) $_GET['spammed'] : 0; $unspammed = isset($_GET['unspammed']) ? (int) $_GET['unspammed'] : 0; if ($approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0) { echo '<p><font color="olive">'; if ($approved > 0) { printf(_n('%s comment approved.', '%s comments approved.', $approved, 'ktai_style'), $approved); echo '<br />'; } if ($spammed > 0) { printf(_n('%s comment marked as spam.', '%s comments marked as spam.', $spammed, 'ktai_style'), $spammed); if (isset($_GET['ids']) && function_exists('wp_unspam_comment')) { $undo_url = 'edit-comments.php?doaction=undo&action=unspam&ids=' . $_GET['ids']; $undo_url = wp_nonce_url($undo_url, 'bulk-comments'); // does html escape printf(' <a href="%s">%s</a><br />', $undo_url, __('Undo')); } } if ($unspammed > 0) { printf(_n('%s comment restored from the spam', '%s comments restored from the spam', $unspammed, 'ktai_style'), $unspammed); echo '<br />'; } if ($trashed > 0) { printf(_n('%s comment moved to the trash.', '%s comments moved to the trash.', $trashed, 'ktai_style'), $trashed); if (isset($_GET['ids']) && function_exists('wp_untrash_comment')) { $undo_url = 'edit-comments.php?doaction=undo&action=untrash&ids=' . $_GET['ids']; $undo_url = wp_nonce_url($undo_url, 'bulk-comments'); // does html escape printf('<a href="%s">%s</a><br />', $undo_url, __('Undo')); } } if ($untrashed > 0) { printf(_n('%s comment restored from the trash.', '%s comments restored from the trash.', $untrashed, 'ktai_style'), $untrashed); echo '<br />'; } if ($deleted > 0) { printf(_n('%s comment deleted.', '%s comments deleted.', $deleted, 'ktai_style'), $deleted); echo '<br />'; } echo '</font></p>'; } } if (!$this->base->admin_available_wp_upper()) { return; } if ($this->post_id > 0) { $num_comments = wp_count_comments($this->post_id); } else { $num_comments = wp_count_comments(); } $this->comments_stati($num_comments, $comment_status, $comment_type); $comments_per_page = intval(($this->base->get('page_size') - self::HEADER_FOOTER_SIZE) / (self::COMMENT_EXCERPT_SIZE + self::COMMENT_NAV_SIZE)); $comments_per_page = apply_filters('comments_per_page', $comments_per_page, $comment_status); if ($comments_per_page < 1) { $comments_per_page = 1; } elseif ($comments_per_page > self::COMMENTS_PER_PAGE) { $comments_per_page = self::COMMENTS_PER_PAGE; } if (isset($_GET['filter'])) { $page = 1; } else { $page = isset($_GET['apage']) ? abs((int) $_GET['apage']) : 1; } $start = $offset = ($page - 1) * $comments_per_page; list($_comments, $total) = _wp_get_comment_list($comment_status, $search_dirty, $start, $comments_per_page + 8, $this->post_id, $comment_type); // Grab a few extra $_comment_post_ids = array(); foreach ($_comments as $_c) { $_comment_post_ids[] = $_c->comment_post_ID; } $_comment_pending_count_temp = (array) get_pending_comments_num($_comment_post_ids); foreach ((array) $_comment_post_ids as $_cpid) { $_comment_pending_count[$_cpid] = isset($_comment_pending_count_temp[$_cpid]) ? $_comment_pending_count_temp[$_cpid] : 0; } if (empty($_comment_pending_count)) { $_comment_pending_count = array(); } $comments = array_slice($_comments, 0, $comments_per_page); $extra_comments = array_slice($_comments, $comments_per_page); $max_pages = ceil($total / $comments_per_page); $this->admin->nav_dropdown($page, $max_pages, 'apage'); ?> <form action="" method="get"><div> <?php $this->admin->sid_field(); _e('Search'); ?> <input type="text" name="ks" value="<?php echo esc_attr($search); ?> " size="20" /> <input type="hidden" name="mode" value="<?php echo $mode; ?> " /> <?php if ($this->post_id) { echo '<input type="hidden" name="p" value="' . intval($this->post_id) . '" />'; } if ($comment_status) { echo '<input type="hidden" name="comment_status" value="' . $comment_status . '" />'; } ?> <input type="hidden" name="pagegen_timestamp" value="<?php echo current_time('mysql', 1); ?> " /> <select name="comment_type"> <option value="all"><?php _e('All comment types', 'ktai_style'); ?> </option> <?php $comment_types = apply_filters('admin_comment_types_dropdown', array('comment' => __('Comments'), 'pings' => __('Pings', 'ktai_style'))); foreach ($comment_types as $type => $label) { echo '<option value="' . esc_attr($type) . '"'; selected($comment_type, $type); echo '>' . esc_attr($label) . '</option>'; } ?> </select> <input type="submit" name="filter" value="<?php _e('Filter'); ?> " /> <?php // do_action('manage_comments_nav', $comment_status); ?> </div> <?php if ($comments) { echo '<dl>'; foreach ($comments as $c) { $this->comment_list_item($c); echo '</dd>'; } echo '</dl>'; ?> <select name="action"> <option value="-1" selected="selected"><?php _e('Bulk Actions', 'ktai_style'); ?> </option><?php if (empty($comment_status) || 'approved' == $comment_status) { ?> <option value="unapprove"><?php _e('Unapprove'); ?> </option><?php } if (empty($comment_status) || 'unapproved' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status) { ?> <option value="approve"><?php _e('Approve'); ?> </option><?php } if ('spam' != $comment_status) { ?> <option value="markspam"><?php _e('Mark as Spam', 'ktai_style'); ?> </option><?php } if ('trash' == $comment_status || 'spam' == $comment_status || !function_exists('wp_trash_comment') || !EMPTY_TRASH_DAYS) { ?> <option value="delete"><?php _e('Delete'); ?> </option><?php } else { ?> <option value="trash"><?php _e('Move to Trash'); ?> </option><?php } ?> </select> <input type="submit" name="doaction" value="<?php _e('Apply'); ?> " /><?php wp_nonce_field('bulk-comments'); if (('spam' == $comment_status || 'trash' == $comment_status) && current_user_can('moderate_comments')) { if ($this->base->check_wp_version('2.9')) { wp_nonce_field('bulk-destroy', '_destroy_nonce'); } else { wp_nonce_field('bulk-spam-delete', '_spam_nonce'); } if ('spam' == $comment_status) { ?> <input type="submit" name="delete_all" value="<?php _e('Empty Spam', 'ktai_style'); ?> " /><?php } else { ?> <input type="submit" name="delete_all" value="<?php _e('Empty Trash'); ?> " /><?php } } } elseif ('moderated' == $_GET['comment_status']) { ?> <p><?php _e('No comments awaiting moderation… yet.'); ?> </p><?php } else { ?> <p><?php _e('No results found.'); ?> </p><?php } ?> </form><?php $this->admin->nav_link($page, $max_pages, 'apage'); if ($this->post_id > 0 && preg_match('!/(edit|post)\\.php($|\\?)!', $referer = $this->admin->get_referer())) { echo '<div>' . sprintf(__('<a href="%s">Back to lists</a>', 'ktai_style'), $referer) . '</div>'; } }