PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/APP/wp-admin/includes/class-wp-comments-list-table.php

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