WP_Comments_List_Table
- Since
- 3.1.0
- Source
wp-admin/includes/class-wp-comments-list-table.php:17
Core class used to implement displaying comments in a list table.
Compatibility
- WordPress
- since 3.1.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 10
Every hook that fires from inside WP_Comments_List_Table, in the order it appears in the class, grouped by the method that fires it.
WP_Comments_List_Table::prepare_items()
- apply_filters( comments_list_table_query_args )filter line 163
WP_Comments_List_Table::extra_tablenav()
- do_action( restrict_manage_comments )action line 419
- do_action( manage_comments_nav )action line 446
Properties · 4
$checkboxpublic$pending_countpublic$extra_itemspublic$user_canprivate
Methods · 23
- __construct()Constructor.
- floated_admin_avatar()Adds avatars to comment author names.
- ajax_user_can()
- prepare_items()
- get_per_page()
- no_items()
- get_views()
- get_bulk_actions()
- extra_tablenav()
- current_action()
- get_columns()
- comment_type_dropdown()Displays a comment type drop-down for filtering on the Comments list table.
- get_sortable_columns()
- get_default_primary_column_name()Gets the name of the default primary column.
- display()Displays the comments table.
- single_row()
- handle_row_actions()Generates and displays row actions links.
- column_cb()
- column_comment()
- column_author()
- column_date()
- column_response()
- column_default()
Source code
class WP_Comments_List_Table extends WP_List_Table { public $checkbox = true; public $pending_count = array(); public $extra_items; private $user_can; /** * Constructor. * * @since 3.1.0 * * @see WP_List_Table::__construct() for more information on default arguments. * * @global int $post_id * * @param array $args An associative array of arguments. */ public function __construct( $args = array() ) { global $post_id; $post_id = isset( $_REQUEST['p'] ) ? absint( $_REQUEST['p'] ) : 0; if ( get_option( 'show_avatars' ) ) { add_filter( 'comment_author', array( $this, 'floated_admin_avatar' ), 10, 2 ); } parent::__construct( array( 'plural' => 'comments', 'singular' => 'comment', 'ajax' => true, 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, ) ); } /** * Adds avatars to comment author names. * * @since 3.1.0 * * @param string $name Comment author name. * @param int $comment_id Comment ID. * @return string Avatar with the user name. */ public function floated_admin_avatar( $name, $comment_id ) { $comment = get_comment( $comment_id ); $avatar = get_avatar( $comment, 32, 'mystery' ); return "$avatar $name"; } /** * @return bool */ public function ajax_user_can() { return current_user_can( 'edit_posts' ); } /** * @global string $mode List table view mode. * @global int $post_id * @global string $comment_status * @global string $comment_type * @global string $search */ public function prepare_items() { global $mode, $post_id, $comment_status, $comment_type, $search; if ( ! empty( $_REQUEST['mode'] ) ) { $mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list'; set_user_setting( 'posts_list_mode', $mode ); } else { $mode = get_user_setting( 'posts_list_mode', 'list' ); } $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';Changelog
Introduced in 3.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-admin/includes/class-wp-comments-list-table.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.