web/wp-admin/includes/class-wp-comments-list-table.php
changeset 194 32102edaa81b
child 204 09a1c134465b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
       
     1 <?php
       
     2 /**
       
     3  * Comments and Post Comments List Table classes.
       
     4  *
       
     5  * @package WordPress
       
     6  * @subpackage List_Table
       
     7  * @since 3.1.0
       
     8  */
       
     9 
       
    10 /**
       
    11  * Comments List Table class.
       
    12  *
       
    13  * @package WordPress
       
    14  * @subpackage List_Table
       
    15  * @since 3.1.0
       
    16  * @access private
       
    17  */
       
    18 class WP_Comments_List_Table extends WP_List_Table {
       
    19 
       
    20 	var $checkbox = true;
       
    21 
       
    22 	var $pending_count = array();
       
    23 
       
    24 	function __construct() {
       
    25 		global $post_id;
       
    26 
       
    27 		$post_id = isset( $_REQUEST['p'] ) ? absint( $_REQUEST['p'] ) : 0;
       
    28 
       
    29 		if ( get_option('show_avatars') )
       
    30 			add_filter( 'comment_author', 'floated_admin_avatar' );
       
    31 
       
    32 		parent::__construct( array(
       
    33 			'plural' => 'comments',
       
    34 			'singular' => 'comment',
       
    35 			'ajax' => true,
       
    36 		) );
       
    37 	}
       
    38 
       
    39 	function ajax_user_can() {
       
    40 		return current_user_can('edit_posts');
       
    41 	}
       
    42 
       
    43 	function prepare_items() {
       
    44 		global $post_id, $comment_status, $search, $comment_type;
       
    45 
       
    46 		$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
       
    47 		if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) )
       
    48 			$comment_status = 'all';
       
    49 
       
    50 		$comment_type = !empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
       
    51 
       
    52 		$search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : '';
       
    53 
       
    54 		$user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : '';
       
    55 
       
    56 		$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : '';
       
    57 		$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : '';
       
    58 
       
    59 		$comments_per_page = $this->get_per_page( $comment_status );
       
    60 
       
    61 		$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
       
    62 
       
    63 		if ( isset( $_REQUEST['number'] ) ) {
       
    64 			$number = (int) $_REQUEST['number'];
       
    65 		}
       
    66 		else {
       
    67 			$number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra
       
    68 		}
       
    69 
       
    70 		$page = $this->get_pagenum();
       
    71 
       
    72 		if ( isset( $_REQUEST['start'] ) ) {
       
    73 			$start = $_REQUEST['start'];
       
    74 		} else {
       
    75 			$start = ( $page - 1 ) * $comments_per_page;
       
    76 		}
       
    77 
       
    78 		if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) {
       
    79 			$start += $_REQUEST['offset'];
       
    80 		}
       
    81 
       
    82 		$status_map = array(
       
    83 			'moderated' => 'hold',
       
    84 			'approved' => 'approve'
       
    85 		);
       
    86 
       
    87 		$args = array(
       
    88 			'status' => isset( $status_map[$comment_status] ) ? $status_map[$comment_status] : $comment_status,
       
    89 			'search' => $search,
       
    90 			'user_id' => $user_id,
       
    91 			'offset' => $start,
       
    92 			'number' => $number,
       
    93 			'post_id' => $post_id,
       
    94 			'type' => $comment_type,
       
    95 			'orderby' => $orderby,
       
    96 			'order' => $order,
       
    97 		);
       
    98 
       
    99 		$_comments = get_comments( $args );
       
   100 
       
   101 		update_comment_cache( $_comments );
       
   102 
       
   103 		$this->items = array_slice( $_comments, 0, $comments_per_page );
       
   104 		$this->extra_items = array_slice( $_comments, $comments_per_page );
       
   105 
       
   106 		$total_comments = get_comments( array_merge( $args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
       
   107 
       
   108 		$_comment_post_ids = array();
       
   109 		foreach ( $_comments as $_c ) {
       
   110 			$_comment_post_ids[] = $_c->comment_post_ID;
       
   111 		}
       
   112 
       
   113 		$_comment_post_ids = array_unique( $_comment_post_ids );
       
   114 
       
   115 		$this->pending_count = get_pending_comments_num( $_comment_post_ids );
       
   116 
       
   117 		$this->set_pagination_args( array(
       
   118 			'total_items' => $total_comments,
       
   119 			'per_page' => $comments_per_page,
       
   120 		) );
       
   121 	}
       
   122 
       
   123 	function get_per_page( $comment_status = 'all' ) {
       
   124 		$comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' );
       
   125 		$comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
       
   126 		return $comments_per_page;
       
   127 	}
       
   128 
       
   129 	function no_items() {
       
   130 		global $comment_status;
       
   131 
       
   132 		if ( 'moderated' == $comment_status )
       
   133 			_e( 'No comments awaiting moderation.' );
       
   134 		else
       
   135 			_e( 'No comments found.' );
       
   136 	}
       
   137 
       
   138 	function get_views() {
       
   139 		global $post_id, $comment_status, $comment_type;
       
   140 
       
   141 		$status_links = array();
       
   142 		$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
       
   143 		//, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
       
   144 		//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
       
   145 		$stati = array(
       
   146 				'all' => _nx_noop('All', 'All', 'comments'), // singular not used
       
   147 				'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'),
       
   148 				'approved' => _n_noop('Approved', 'Approved'), // singular not used
       
   149 				'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'),
       
   150 				'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>')
       
   151 			);
       
   152 
       
   153 		if ( !EMPTY_TRASH_DAYS )
       
   154 			unset($stati['trash']);
       
   155 
       
   156 		$link = 'edit-comments.php';
       
   157 		if ( !empty($comment_type) && 'all' != $comment_type )
       
   158 			$link = add_query_arg( 'comment_type', $comment_type, $link );
       
   159 
       
   160 		foreach ( $stati as $status => $label ) {
       
   161 			$class = ( $status == $comment_status ) ? ' class="current"' : '';
       
   162 
       
   163 			if ( !isset( $num_comments->$status ) )
       
   164 				$num_comments->$status = 10;
       
   165 			$link = add_query_arg( 'comment_status', $status, $link );
       
   166 			if ( $post_id )
       
   167 				$link = add_query_arg( 'p', absint( $post_id ), $link );
       
   168 			/*
       
   169 			// I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
       
   170 			if ( !empty( $_REQUEST['s'] ) )
       
   171 				$link = add_query_arg( 's', esc_attr( stripslashes( $_REQUEST['s'] ) ), $link );
       
   172 			*/
       
   173 			$status_links[$status] = "<a href='$link'$class>" . sprintf(
       
   174 				translate_nooped_plural( $label, $num_comments->$status ),
       
   175 				number_format_i18n( $num_comments->$status )
       
   176 			) . '</a>';
       
   177 		}
       
   178 
       
   179 		$status_links = apply_filters( 'comment_status_links', $status_links );
       
   180 		return $status_links;
       
   181 	}
       
   182 
       
   183 	function get_bulk_actions() {
       
   184 		global $comment_status;
       
   185 
       
   186 		$actions = array();
       
   187 		if ( in_array( $comment_status, array( 'all', 'approved' ) ) )
       
   188 			$actions['unapprove'] = __( 'Unapprove' );
       
   189 		if ( in_array( $comment_status, array( 'all', 'moderated' ) ) )
       
   190 			$actions['approve'] = __( 'Approve' );
       
   191 		if ( in_array( $comment_status, array( 'all', 'moderated', 'approved' ) ) )
       
   192 			$actions['spam'] = _x( 'Mark as Spam', 'comment' );
       
   193 
       
   194 		if ( 'trash' == $comment_status )
       
   195 			$actions['untrash'] = __( 'Restore' );
       
   196 		elseif ( 'spam' == $comment_status )
       
   197 			$actions['unspam'] = _x( 'Not Spam', 'comment' );
       
   198 
       
   199 		if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || !EMPTY_TRASH_DAYS )
       
   200 			$actions['delete'] = __( 'Delete Permanently' );
       
   201 		else
       
   202 			$actions['trash'] = __( 'Move to Trash' );
       
   203 
       
   204 		return $actions;
       
   205 	}
       
   206 
       
   207 	function extra_tablenav( $which ) {
       
   208 		global $comment_status, $comment_type;
       
   209 ?>
       
   210 		<div class="alignleft actions">
       
   211 <?php
       
   212 		if ( 'top' == $which ) {
       
   213 ?>
       
   214 			<select name="comment_type">
       
   215 				<option value=""><?php _e( 'Show all comment types' ); ?></option>
       
   216 <?php
       
   217 				$comment_types = apply_filters( 'admin_comment_types_dropdown', array(
       
   218 					'comment' => __( 'Comments' ),
       
   219 					'pings' => __( 'Pings' ),
       
   220 				) );
       
   221 
       
   222 				foreach ( $comment_types as $type => $label )
       
   223 					echo "\t<option value='" . esc_attr( $type ) . "'" . selected( $comment_type, $type, false ) . ">$label</option>\n";
       
   224 			?>
       
   225 			</select>
       
   226 <?php
       
   227 			submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
       
   228 		}
       
   229 
       
   230 		if ( ( 'spam' == $comment_status || 'trash' == $comment_status ) && current_user_can( 'moderate_comments' ) ) {
       
   231 			wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
       
   232 			$title = ( 'spam' == $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
       
   233 			submit_button( $title, 'button-secondary apply', 'delete_all', false );
       
   234 		}
       
   235 		do_action( 'manage_comments_nav', $comment_status );
       
   236 		echo '</div>';
       
   237 	}
       
   238 
       
   239 	function current_action() {
       
   240 		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
       
   241 			return 'delete_all';
       
   242 
       
   243 		return parent::current_action();
       
   244 	}
       
   245 
       
   246 	function get_columns() {
       
   247 		global $post_id;
       
   248 
       
   249 		$columns = array();
       
   250 
       
   251 		if ( $this->checkbox )
       
   252 			$columns['cb'] = '<input type="checkbox" />';
       
   253 
       
   254 		$columns['author'] = __( 'Author' );
       
   255 		$columns['comment'] = _x( 'Comment', 'column name' );
       
   256 
       
   257 		if ( !$post_id )
       
   258 			$columns['response'] = _x( 'In Response To', 'column name' );
       
   259 
       
   260 		return $columns;
       
   261 	}
       
   262 
       
   263 	function get_sortable_columns() {
       
   264 		return array(
       
   265 			'author'   => 'comment_author',
       
   266 			'response' => 'comment_post_ID'
       
   267 		);
       
   268 	}
       
   269 
       
   270 	function display() {
       
   271 		extract( $this->_args );
       
   272 
       
   273 		wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
       
   274 
       
   275 		$this->display_tablenav( 'top' );
       
   276 
       
   277 ?>
       
   278 <table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
       
   279 	<thead>
       
   280 	<tr>
       
   281 		<?php $this->print_column_headers(); ?>
       
   282 	</tr>
       
   283 	</thead>
       
   284 
       
   285 	<tfoot>
       
   286 	<tr>
       
   287 		<?php $this->print_column_headers( false ); ?>
       
   288 	</tr>
       
   289 	</tfoot>
       
   290 
       
   291 	<tbody id="the-comment-list" class="list:comment">
       
   292 		<?php $this->display_rows_or_placeholder(); ?>
       
   293 	</tbody>
       
   294 
       
   295 	<tbody id="the-extra-comment-list" class="list:comment" style="display: none;">
       
   296 		<?php $this->items = $this->extra_items; $this->display_rows(); ?>
       
   297 	</tbody>
       
   298 </table>
       
   299 <?php
       
   300 
       
   301 		$this->display_tablenav( 'bottom' );
       
   302 	}
       
   303 
       
   304 	function single_row( $a_comment ) {
       
   305 		global $post, $comment;
       
   306 
       
   307 		$comment = $a_comment;
       
   308 		$the_comment_class = join( ' ', get_comment_class( wp_get_comment_status( $comment->comment_ID ) ) );
       
   309 
       
   310 		$post = get_post( $comment->comment_post_ID );
       
   311 
       
   312 		$this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
       
   313 
       
   314 		echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
       
   315 		echo $this->single_row_columns( $comment );
       
   316 		echo "</tr>\n";
       
   317 	}
       
   318 
       
   319 	function column_cb( $comment ) {
       
   320 		if ( $this->user_can )
       
   321 			echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
       
   322 	}
       
   323 
       
   324 	function column_comment( $comment ) {
       
   325 		global $post, $comment_status;
       
   326 
       
   327 		$user_can = $this->user_can;
       
   328 
       
   329 		$comment_url = esc_url( get_comment_link( $comment->comment_ID ) );
       
   330 		$the_comment_status = wp_get_comment_status( $comment->comment_ID );
       
   331 
       
   332 		$ptime = date( 'G', strtotime( $comment->comment_date ) );
       
   333 		if ( ( abs( time() - $ptime ) ) < 86400 )
       
   334 			$ptime = sprintf( __( '%s ago' ), human_time_diff( $ptime ) );
       
   335 		else
       
   336 			$ptime = mysql2date( __( 'Y/m/d \a\t g:i A' ), $comment->comment_date );
       
   337 
       
   338 		if ( $user_can ) {
       
   339 			$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
       
   340 			$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
       
   341 
       
   342 			$url = "comment.php?c=$comment->comment_ID";
       
   343 
       
   344 			$approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );
       
   345 			$unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );
       
   346 			$spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );
       
   347 			$unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );
       
   348 			$trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );
       
   349 			$untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );
       
   350 			$delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
       
   351 		}
       
   352 
       
   353 		echo '<div class="submitted-on">';
       
   354 		/* translators: 2: comment date, 3: comment time */
       
   355 		printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), $comment_url,
       
   356 			/* translators: comment date format. See http://php.net/date */ get_comment_date( __( 'Y/m/d' ) ),
       
   357 			/* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) );
       
   358 
       
   359 		if ( $comment->comment_parent ) {
       
   360 			$parent = get_comment( $comment->comment_parent );
       
   361 			$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
       
   362 			$name = get_comment_author( $parent->comment_ID );
       
   363 			printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );
       
   364 		}
       
   365 
       
   366 		echo '</div>';
       
   367 		comment_text();
       
   368 		if ( $user_can ) { ?>
       
   369 		<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
       
   370 		<textarea class="comment" rows="1" cols="1"><?php echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) ); ?></textarea>
       
   371 		<div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
       
   372 		<div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
       
   373 		<div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
       
   374 		<div class="comment_status"><?php echo $comment->comment_approved; ?></div>
       
   375 		</div>
       
   376 		<?php
       
   377 		}
       
   378 
       
   379 		if ( $user_can ) {
       
   380 			// preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
       
   381 			$actions = array(
       
   382 				'approve' => '', 'unapprove' => '',
       
   383 				'reply' => '',
       
   384 				'quickedit' => '',
       
   385 				'edit' => '',
       
   386 				'spam' => '', 'unspam' => '',
       
   387 				'trash' => '', 'untrash' => '', 'delete' => ''
       
   388 			);
       
   389 
       
   390 			if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
       
   391 				if ( 'approved' == $the_comment_status )
       
   392 					$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>';
       
   393 				else if ( 'unapproved' == $the_comment_status )
       
   394 					$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>';
       
   395 			} else {
       
   396 				$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>';
       
   397 				$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>';
       
   398 			}
       
   399 
       
   400 			if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
       
   401 				$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>';
       
   402 			} elseif ( 'spam' == $the_comment_status ) {
       
   403 				$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>';
       
   404 			} elseif ( 'trash' == $the_comment_status ) {
       
   405 				$actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
       
   406 			}
       
   407 
       
   408 			if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
       
   409 				$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>';
       
   410 			} else {
       
   411 				$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>';
       
   412 			}
       
   413 
       
   414 			if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
       
   415 				$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
       
   416 				$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>';
       
   417 				$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>';
       
   418 			}
       
   419 
       
   420 			$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
       
   421 
       
   422 			$i = 0;
       
   423 			echo '<div class="row-actions">';
       
   424 			foreach ( $actions as $action => $link ) {
       
   425 				++$i;
       
   426 				( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
       
   427 
       
   428 				// Reply and quickedit need a hide-if-no-js span when not added with ajax
       
   429 				if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') )
       
   430 					$action .= ' hide-if-no-js';
       
   431 				elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) {
       
   432 					if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
       
   433 						$action .= ' approve';
       
   434 					else
       
   435 						$action .= ' unapprove';
       
   436 				}
       
   437 
       
   438 				echo "<span class='$action'>$sep$link</span>";
       
   439 			}
       
   440 			echo '</div>';
       
   441 		}
       
   442 	}
       
   443 
       
   444 	function column_author( $comment ) {
       
   445 		global $comment_status;
       
   446 
       
   447 		$author_url = get_comment_author_url();
       
   448 		if ( 'http://' == $author_url )
       
   449 			$author_url = '';
       
   450 		$author_url_display = preg_replace( '|http://(www\.)?|i', '', $author_url );
       
   451 		if ( strlen( $author_url_display ) > 50 )
       
   452 			$author_url_display = substr( $author_url_display, 0, 49 ) . '...';
       
   453 
       
   454 		echo "<strong>"; comment_author(); echo '</strong><br />';
       
   455 		if ( !empty( $author_url ) )
       
   456 			echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
       
   457 
       
   458 		if ( $this->user_can ) {
       
   459 			if ( !empty( $comment->comment_author_email ) ) {
       
   460 				comment_author_email_link();
       
   461 				echo '<br />';
       
   462 			}
       
   463 			echo '<a href="edit-comments.php?s=';
       
   464 			comment_author_IP();
       
   465 			echo '&amp;mode=detail';
       
   466 			if ( 'spam' == $comment_status )
       
   467 				echo '&amp;comment_status=spam';
       
   468 			echo '">';
       
   469 			comment_author_IP();
       
   470 			echo '</a>';
       
   471 		}
       
   472 	}
       
   473 
       
   474 	function column_date( $comment ) {
       
   475 		return get_comment_date( __( 'Y/m/d \a\t g:ia' ) );
       
   476 	}
       
   477 
       
   478 	function column_response( $comment ) {
       
   479 		global $post;
       
   480 
       
   481 		if ( isset( $this->pending_count[$post->ID] ) ) {
       
   482 			$pending_comments = $this->pending_count[$post->ID];
       
   483 		} else {
       
   484 			$_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
       
   485 			$pending_comments = $this->pending_count[$post->ID] = $_pending_count_temp[$post->ID];
       
   486 		}
       
   487 
       
   488 		if ( current_user_can( 'edit_post', $post->ID ) ) {
       
   489 			$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "'>";
       
   490 			$post_link .= get_the_title( $post->ID ) . '</a>';
       
   491 		} else {
       
   492 			$post_link = get_the_title( $post->ID );
       
   493 		}
       
   494 
       
   495 		echo '<div class="response-links"><span class="post-com-count-wrapper">';
       
   496 		echo $post_link . '<br />';
       
   497 		$this->comments_bubble( $post->ID, $pending_comments );
       
   498 		echo '</span> ';
       
   499 		$post_type_object = get_post_type_object( $post->post_type );
       
   500 		echo "<a href='" . get_permalink( $post->ID ) . "'>" . $post_type_object->labels->view_item . '</a>';
       
   501 		echo '</div>';
       
   502 		if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) )
       
   503 			echo $thumb;
       
   504 	}
       
   505 
       
   506 	function column_default( $comment, $column_name ) {
       
   507 		do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
       
   508 	}
       
   509 }
       
   510 
       
   511 /**
       
   512  * Post Comments List Table class.
       
   513  *
       
   514  * @package WordPress
       
   515  * @subpackage List_Table
       
   516  * @since 3.1.0
       
   517  * @access private
       
   518  *
       
   519  * @see WP_Comments_Table
       
   520  */
       
   521 class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
       
   522 
       
   523 	function get_column_info() {
       
   524 		$this->_column_headers = array(
       
   525 			array(
       
   526 			'author'   => __( 'Author' ),
       
   527 			'comment'  => _x( 'Comment', 'column name' ),
       
   528 			),
       
   529 			array(),
       
   530 			array(),
       
   531 		);
       
   532 
       
   533 		return $this->_column_headers;
       
   534 	}
       
   535 
       
   536 	function get_table_classes() {
       
   537 		$classes = parent::get_table_classes();
       
   538 		$classes[] = 'comments-box';
       
   539 		return $classes;
       
   540 	}
       
   541 
       
   542 	function display( $output_empty = false ) {
       
   543 		extract( $this->_args );
       
   544 
       
   545 		wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
       
   546 ?>
       
   547 <table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0" style="display:none;">
       
   548 	<tbody id="the-comment-list"<?php if ( $singular ) echo " class='list:$singular'"; ?>>
       
   549 		<?php if ( ! $output_empty ) $this->display_rows_or_placeholder(); ?>
       
   550 	</tbody>
       
   551 </table>
       
   552 <?php
       
   553 	}
       
   554 
       
   555 	function get_per_page( $comment_status = false ) {
       
   556 		return 10;
       
   557 	}
       
   558 }