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 172
WP_Comments_List_Table::extra_tablenav()
- do_action( restrict_manage_comments )action line 439
- do_action( manage_comments_nav )action line 466
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()Checks if the user can edit posts.
- prepare_items()Prepares the comments list items.
- get_per_page()Gets the number of comments to display per page.
- no_items()Displays a message when no comments are found.
- get_views()Returns an array of comment status links.
- get_bulk_actions()Gets the available bulk actions for the comments list.
- extra_tablenav()Displays extra controls between bulk actions and pagination.
- current_action()Gets the current action selected from the bulk actions dropdown.
- get_columns()Gets the list of columns.
- comment_type_dropdown()Displays a comment type drop-down for filtering on the Comments list table.
- get_sortable_columns()Gets a list of sortable columns.
- get_default_primary_column_name()Gets the name of the default primary column.
- display()Displays the comments table.
- single_row()Generates content for a single row of the table.
- handle_row_actions()Generates and displays row actions links.
- column_cb()Outputs the checkbox column.
- column_comment()Outputs the comment column.
- column_author()Outputs the author column.
- column_date()Outputs the date column.
- column_response()Outputs the response column.
- column_default()Outputs the default column.
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 The ID of the post to show comments for. * * @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' => $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"; } /** * Checks if the user can edit posts. * * @return bool Whether the user can edit posts. */ public function ajax_user_can() { return current_user_can( 'edit_posts' ); } /** * Prepares the comments list items. * * @global string $mode Current list table display mode. * @global int $post_id Current post ID filter. * @global string $comment_status Comment status filter. * @global string $comment_type Comment type filter. * @global string $search Search term. */ 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 {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 7.1.0 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.