WP_Comments_Table cleanup:

* use column_*() methods
	* remove extra arguments from single_row()
	* introduce derived class WP_Post_Comments_Table for handling the post metabox comments
	* use $pending_count property instead of $_comment_pending_count global
See #14579



git-svn-id: http://svn.automattic.com/wordpress/trunk@15630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-09-18 17:46:29 +00:00
parent a927a1665c
commit ce723858c2
3 changed files with 223 additions and 213 deletions

View File

@ -624,6 +624,8 @@ case 'add-comment' :
die('-1'); die('-1');
$wp_list_table = get_list_table('comments'); $wp_list_table = get_list_table('comments');
$wp_list_table->from_ajax = true;
$wp_list_table->prepare_items(); $wp_list_table->prepare_items();
if ( !$wp_list_table->has_items() ) if ( !$wp_list_table->has_items() )
@ -631,9 +633,8 @@ case 'add-comment' :
$x = new WP_Ajax_Response(); $x = new WP_Ajax_Response();
foreach ( $wp_list_table->items as $comment ) { foreach ( $wp_list_table->items as $comment ) {
get_comment( $comment );
ob_start(); ob_start();
$wp_list_table->single_row( $comment->comment_ID, $mode, $comment_status, true, true ); $wp_list_table->single_row( $comment );
$comment_list_item = ob_get_contents(); $comment_list_item = ob_get_contents();
ob_end_clean(); ob_end_clean();
$x->add( array( $x->add( array(
@ -651,7 +652,8 @@ case 'get-comments' :
if ( !current_user_can( 'edit_post', $post_ID ) ) if ( !current_user_can( 'edit_post', $post_ID ) )
die('-1'); die('-1');
$wp_list_table = get_list_table('comments'); $wp_list_table = get_list_table('post-comments');
$wp_list_table->prepare_items(); $wp_list_table->prepare_items();
if ( !$wp_list_table->has_items() ) if ( !$wp_list_table->has_items() )
@ -662,7 +664,7 @@ case 'get-comments' :
foreach ( $wp_list_table->items as $comment ) { foreach ( $wp_list_table->items as $comment ) {
get_comment( $comment ); get_comment( $comment );
ob_start(); ob_start();
$wp_list_table->single_row( $comment->comment_ID, 'single', false, false ); $wp_list_table->single_row( $comment );
$comment_list_item .= ob_get_contents(); $comment_list_item .= ob_get_contents();
ob_end_clean(); ob_end_clean();
} }
@ -676,6 +678,7 @@ case 'replyto-comment' :
check_ajax_referer( $action, '_ajax_nonce-replyto-comment' ); check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
$wp_list_table = get_list_table('comments'); $wp_list_table = get_list_table('comments');
$wp_list_table->checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
$comment_post_ID = (int) $_POST['comment_post_ID']; $comment_post_ID = (int) $_POST['comment_post_ID'];
if ( !current_user_can( 'edit_post', $comment_post_ID ) ) if ( !current_user_can( 'edit_post', $comment_post_ID ) )
@ -715,16 +718,15 @@ case 'replyto-comment' :
if ( ! $comment ) die('1'); if ( ! $comment ) die('1');
$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
$checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
$x = new WP_Ajax_Response(); $x = new WP_Ajax_Response();
ob_start(); ob_start();
if ( 'dashboard' == $mode ) { if ( 'dashboard' == $mode ) {
require_once( ABSPATH . 'wp-admin/includes/dashboard.php' ); require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
_wp_dashboard_recent_comments_row( $comment, false ); _wp_dashboard_recent_comments_row( $comment );
} else { } else {
$wp_list_table->single_row( $comment->comment_ID, $mode, false, $checkbox ); $wp_list_table->single_row( $comment );
} }
$comment_list_item = ob_get_contents(); $comment_list_item = ob_get_contents();
ob_end_clean(); ob_end_clean();
@ -753,13 +755,13 @@ case 'edit-comment' :
edit_comment(); edit_comment();
$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
$checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0; $comments_status = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : '';
$comments_listing = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : '';
$wp_list_table = get_list_table('comments'); $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
$wp_list_table = get_list_table( $checkbox ? 'comments' : 'post-comments' );
ob_start(); ob_start();
$wp_list_table->single_row( $comment_id, $mode, $comments_listing, $checkbox ); $wp_list_table->single_row( get_comment( $comment_id ) );
$comment_list_item = ob_get_contents(); $comment_list_item = ob_get_contents();
ob_end_clean(); ob_end_clean();

View File

@ -2015,6 +2015,11 @@ class WP_Users_Table extends WP_List_Table {
class WP_Comments_Table extends WP_List_Table { class WP_Comments_Table extends WP_List_Table {
var $checkbox = true;
var $from_ajax = false;
var $pending_count = array();
function WP_Comments_Table() { function WP_Comments_Table() {
global $mode; global $mode;
@ -2091,7 +2096,7 @@ class WP_Comments_Table extends WP_List_Table {
$_comment_post_ids[] = $_c->comment_post_ID; $_comment_post_ids[] = $_c->comment_post_ID;
} }
$_comment_pending_count = get_pending_comments_num( $_comment_post_ids ); $this->pending_count = get_pending_comments_num( $_comment_post_ids );
$this->set_pagination_args( array( $this->set_pagination_args( array(
'total_items' => $total_comments, 'total_items' => $total_comments,
@ -2205,13 +2210,20 @@ class WP_Comments_Table extends WP_List_Table {
} }
function get_columns() { function get_columns() {
return array( global $mode;
'cb' => '<input type="checkbox" />',
'author' => __( 'Author' ), $columns = array();
/* translators: column name */
'comment' => _x( 'Comment', 'column name' ), if ( $this->checkbox )
'response' => __( 'In Response To' ) $columns['cb'] = '<input type="checkbox" />';
);
$columns['author'] = __( 'Author' );
$columns['comment'] = _x( 'Comment', 'column name' );
if ( 'single' !== $mode )
$columns['response'] = _x( 'Comment', 'column name' );
return $columns;
} }
function get_sortable_columns() { function get_sortable_columns() {
@ -2242,11 +2254,11 @@ class WP_Comments_Table extends WP_List_Table {
</tfoot> </tfoot>
<tbody id="the-comment-list" class="list:comment"> <tbody id="the-comment-list" class="list:comment">
<?php $this->display_rows( $this->items ); ?> <?php $this->display_rows(); ?>
</tbody> </tbody>
<tbody id="the-extra-comment-list" class="list:comment" style="display: none;"> <tbody id="the-extra-comment-list" class="list:comment" style="display: none;">
<?php $this->display_rows( $this->extra_items ); ?> <?php $this->items = $this->extra_items; $this->display_rows(); ?>
</tbody> </tbody>
</table> </table>
<?php <?php
@ -2254,30 +2266,32 @@ class WP_Comments_Table extends WP_List_Table {
$this->display_tablenav( 'bottom' ); $this->display_tablenav( 'bottom' );
} }
function display_rows( $items = false ) { function single_row( $a_comment ) {
global $mode, $comment_status; global $post, $comment, $the_comment_status;
if ( false === $items ) $comment = $a_comment;
$items = $this->items; $the_comment_status = wp_get_comment_status( $comment->comment_ID );
foreach ( $items as $comment ) $post = get_post( $comment->comment_post_ID );
$this->single_row( $comment->comment_ID, $mode, $comment_status );
$this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
echo $this->single_row_columns( $comment );
echo "</tr>\n";
} }
function single_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) { function column_cb( $comment ) {
global $comment, $post, $_comment_pending_count; if ( $this->user_can )
$comment = get_comment( $comment_id ); echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
$post = get_post( $comment->comment_post_ID ); }
$the_comment_status = wp_get_comment_status( $comment->comment_ID );
$user_can = current_user_can( 'edit_comment', $comment_id ); function column_comment( $comment ) {
global $post, $comment_status, $the_comment_status;
$user_can = $this->user_can;
$comment_url = esc_url( get_comment_link( $comment->comment_ID ) ); $comment_url = esc_url( get_comment_link( $comment->comment_ID ) );
$author_url = get_comment_author_url();
if ( 'http://' == $author_url )
$author_url = '';
$author_url_display = preg_replace( '|http://(www\.)?|i', '', $author_url );
if ( strlen( $author_url_display ) > 50 )
$author_url_display = substr( $author_url_display, 0, 49 ) . '...';
$ptime = date( 'G', strtotime( $comment->comment_date ) ); $ptime = date( 'G', strtotime( $comment->comment_date ) );
if ( ( abs( time() - $ptime ) ) < 86400 ) if ( ( abs( time() - $ptime ) ) < 86400 )
@ -2300,178 +2314,175 @@ class WP_Comments_Table extends WP_List_Table {
$delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" ); $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
} }
echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>"; echo '<div id="submitted-on">';
/* translators: 2: comment date, 3: comment time */
printf( __( '<a href="%1$s">%2$s at %3$s</a>' ), $comment_url,
/* translators: comment date format. See http://php.net/date */ get_comment_date( __( 'Y/m/d' ) ),
/* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) );
list( $columns, $hidden ) = $this->get_column_headers(); if ( $comment->comment_parent ) {
$parent = get_comment( $comment->comment_parent );
foreach ( $columns as $column_name => $column_display_name ) { $parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
$class = "class=\"$column_name column-$column_name\""; $name = get_comment_author( $parent->comment_ID );
printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );
$style = '';
if ( in_array( $column_name, $hidden ) )
$style = ' style="display:none;"';
$attributes = "$class$style";
switch ( $column_name ) {
case 'cb':
if ( !$checkbox ) break;
echo '<th scope="row" class="check-column">';
if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
echo '</th>';
break;
case 'comment':
echo "<td $attributes>";
echo '<div id="submitted-on">';
/* translators: 2: comment date, 3: comment time */
printf( __( '<a href="%1$s">%2$s at %3$s</a>' ), $comment_url,
/* translators: comment date format. See http://php.net/date */ get_comment_date( __( 'Y/m/d' ) ),
/* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) );
if ( $comment->comment_parent ) {
$parent = get_comment( $comment->comment_parent );
$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
$name = get_comment_author( $parent->comment_ID );
printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );
}
echo '</div>';
comment_text();
if ( $user_can ) { ?>
<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
<textarea class="comment" rows="1" cols="1"><?php echo esc_html( apply_filters( 'comment_edit_pre', $comment->comment_content ) ); ?></textarea>
<div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
<div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
<div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
<div class="comment_status"><?php echo $comment->comment_approved; ?></div>
</div>
<?php
}
if ( $user_can ) {
// preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
$actions = array(
'approve' => '', 'unapprove' => '',
'reply' => '',
'quickedit' => '',
'edit' => '',
'spam' => '', 'unspam' => '',
'trash' => '', 'untrash' => '', 'delete' => ''
);
if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
if ( 'approved' == $the_comment_status )
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
else if ( 'unapproved' == $the_comment_status )
$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
} else {
$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
}
if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
$actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
} elseif ( 'spam' == $the_comment_status ) {
$actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';
} elseif ( 'trash' == $the_comment_status ) {
$actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
}
if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>';
} else {
$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
}
if ( 'trash' != $the_comment_status ) {
$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
$actions['quickedit'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\' );return false;" class="vim-q" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick&nbsp;Edit' ) . '</a>';
if ( 'spam' != $the_comment_status )
$actions['reply'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\' );return false;" class="vim-r" title="'.esc_attr__( 'Reply to this comment' ).'" href="#">' . __( 'Reply' ) . '</a>';
}
$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
$i = 0;
echo '<div class="row-actions">';
foreach ( $actions as $action => $link ) {
++$i;
( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
// Reply and quickedit need a hide-if-no-js span when not added with ajax
if ( ( 'reply' == $action || 'quickedit' == $action ) && ! $from_ajax )
$action .= ' hide-if-no-js';
elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) {
if ( '1' == get_comment_meta( $comment_id, '_wp_trash_meta_status', true ) )
$action .= ' approve';
else
$action .= ' unapprove';
}
echo "<span class='$action'>$sep$link</span>";
}
echo '</div>';
}
echo '</td>';
break;
case 'author':
echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
if ( !empty( $author_url ) )
echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
if ( $user_can ) {
if ( !empty( $comment->comment_author_email ) ) {
comment_author_email_link();
echo '<br />';
}
echo '<a href="edit-comments.php?s=';
comment_author_IP();
echo '&amp;mode=detail';
if ( 'spam' == $comment_status )
echo '&amp;comment_status=spam';
echo '">';
comment_author_IP();
echo '</a>';
} //current_user_can
echo '</td>';
break;
case 'date':
echo "<td $attributes>" . get_comment_date( __( 'Y/m/d \a\t g:ia' ) ) . '</td>';
break;
case 'response':
if ( 'single' !== $mode ) {
if ( isset( $_comment_pending_count[$post->ID] ) ) {
$pending_comments = $_comment_pending_count[$post->ID];
} else {
$_comment_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
$pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
}
if ( $user_can ) {
$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "'>";
$post_link .= get_the_title( $post->ID ) . '</a>';
} else {
$post_link = get_the_title( $post->ID );
}
echo "<td $attributes>\n";
echo '<div class="response-links"><span class="post-com-count-wrapper">';
echo $post_link . '<br />';
$this->comments_bubble( $post->ID, $pending_comments );
echo '</span> ';
echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
echo '</div>';
if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) )
echo $thumb;
echo '</td>';
}
break;
default:
echo "<td $attributes>\n";
do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
echo "</td>\n";
break;
}
} }
echo "</tr>\n";
echo '</div>';
comment_text();
if ( $user_can ) { ?>
<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
<textarea class="comment" rows="1" cols="1"><?php echo esc_html( apply_filters( 'comment_edit_pre', $comment->comment_content ) ); ?></textarea>
<div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
<div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
<div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
<div class="comment_status"><?php echo $comment->comment_approved; ?></div>
</div>
<?php
}
if ( $user_can ) {
// preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
$actions = array(
'approve' => '', 'unapprove' => '',
'reply' => '',
'quickedit' => '',
'edit' => '',
'spam' => '', 'unspam' => '',
'trash' => '', 'untrash' => '', 'delete' => ''
);
if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
if ( 'approved' == $the_comment_status )
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
else if ( 'unapproved' == $the_comment_status )
$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
} else {
$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
}
if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
$actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
} elseif ( 'spam' == $the_comment_status ) {
$actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';
} elseif ( 'trash' == $the_comment_status ) {
$actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
}
if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>';
} else {
$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
}
if ( 'trash' != $the_comment_status ) {
$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
$actions['quickedit'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\' );return false;" class="vim-q" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick&nbsp;Edit' ) . '</a>';
if ( 'spam' != $the_comment_status )
$actions['reply'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\' );return false;" class="vim-r" title="'.esc_attr__( 'Reply to this comment' ).'" href="#">' . __( 'Reply' ) . '</a>';
}
$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
$i = 0;
echo '<div class="row-actions">';
foreach ( $actions as $action => $link ) {
++$i;
( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
// Reply and quickedit need a hide-if-no-js span when not added with ajax
if ( ( 'reply' == $action || 'quickedit' == $action ) && ! $this->from_ajax )
$action .= ' hide-if-no-js';
elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) {
if ( '1' == get_comment_meta( $comment_id, '_wp_trash_meta_status', true ) )
$action .= ' approve';
else
$action .= ' unapprove';
}
echo "<span class='$action'>$sep$link</span>";
}
echo '</div>';
}
}
function column_author( $comment ) {
global $comment_status;
$author_url = get_comment_author_url();
if ( 'http://' == $author_url )
$author_url = '';
$author_url_display = preg_replace( '|http://(www\.)?|i', '', $author_url );
if ( strlen( $author_url_display ) > 50 )
$author_url_display = substr( $author_url_display, 0, 49 ) . '...';
echo "<strong>"; comment_author(); echo '</strong><br />';
if ( !empty( $author_url ) )
echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
if ( $this->user_can ) {
if ( !empty( $comment->comment_author_email ) ) {
comment_author_email_link();
echo '<br />';
}
echo '<a href="edit-comments.php?s=';
comment_author_IP();
echo '&amp;mode=detail';
if ( 'spam' == $comment_status )
echo '&amp;comment_status=spam';
echo '">';
comment_author_IP();
echo '</a>';
}
}
function column_date( $comment ) {
return get_comment_date( __( 'Y/m/d \a\t g:ia' ) );
}
function column_response( $comment ) {
global $post;
if ( isset( $this->pending_count[$post->ID] ) ) {
$pending_comments = $this->pending_count[$post->ID];
} else {
$_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
$pending_comments = $this->pending_count[$post->ID] = $_pending_count_temp[$post->ID];
}
if ( current_user_can( 'edit_post', $post->ID ) ) {
$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "'>";
$post_link .= get_the_title( $post->ID ) . '</a>';
} else {
$post_link = get_the_title( $post->ID );
}
echo '<div class="response-links"><span class="post-com-count-wrapper">';
echo $post_link . '<br />';
$this->comments_bubble( $post->ID, $pending_comments );
echo '</span> ';
echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
echo '</div>';
if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) )
echo $thumb;
}
function column_default( $comment, $column_name ) {
do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
}
}
class WP_Post_Comments_Table extends WP_Comments_Table {
function get_columns() {
return array(
'author' => __( 'Author' ),
'comment' => _x( 'Comment', 'column name' ),
);
}
function get_sortable_columns() {
return array();
} }
} }

View File

@ -459,10 +459,8 @@ function post_comment_meta_box($post) {
} }
wp_nonce_field( 'get-comments', 'add_comment_nonce', false ); wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
add_filter('manage_edit-comments_columns', 'post_comment_meta_box_thead', 8, 1);
add_filter('manage_edit-comments_sortable_columns', '__return_empty_array', 8);
$wp_list_table = get_list_table('comments'); $wp_list_table = get_list_table('post-comments');
?> ?>
<table class="widefat comments-box fixed" cellspacing="0" style="display:none;"> <table class="widefat comments-box fixed" cellspacing="0" style="display:none;">
@ -478,7 +476,6 @@ function post_comment_meta_box($post) {
<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script> <script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
<?php <?php
} }
remove_filter('manage_edit-comments_columns', 'post_comment_meta_box_thead');
wp_comment_trashnotice(); wp_comment_trashnotice();
} }