WordPress/wp-admin/includes/class-wp-post-comments-list-table.php
Peter Wilson 566caa07ae Administration: Remove private delegation from list tables.
Remove the private delegation from the following classes and function:

* `WP_List_Table`
* `WP_Application_Passwords_List_Table`
* `WP_Comments_List_Table`
* `WP_Links_List_Table`
* `WP_Media_List_Table`
* `WP_MS_Sites_List_Table`
* `WP_MS_Themes_List_Table`
* `WP_MS_Users_List_Table`
* `WP_Plugin_Install_List_Table`
* `WP_Plugins_List_Table`
* `WP_Post_Comments_List_Table`
* `WP_Posts_List_Table`
* `WP_Terms_List_Table`
* `WP_Theme_Install_List_Table`
* `WP_Themes_List_Table`
* `WP_Users_List_Table`
* `_get_list_table()`

This change is to reflect the reality that list tables are very, very, very widely used by extenders and backward compatibility therefore needs to be maintained.

Introduces the filter `wp_list_table_class_name` within `_get_list_table()` to allow extenders to modify the list table returned for custom screens.

Props audrasjb, birgire, costdev, desrosj, faison, johnbillion, jrbeilke, kurtpayne, milana_cap, miqrogroove, nacin, peterwilsoncc, scribu, sergeybiryukov, sirzooro, westonruter, wonderboymusic.
Fixes #18449.

Built from https://develop.svn.wordpress.org/trunk@54378


git-svn-id: http://core.svn.wordpress.org/trunk@53937 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-04 03:47:15 +00:00

78 lines
1.4 KiB
PHP

<?php
/**
* List Table API: WP_Post_Comments_List_Table class
*
* @package WordPress
* @subpackage Administration
* @since 4.4.0
*/
/**
* Core class used to implement displaying post comments in a list table.
*
* @since 3.1.0
*
* @see WP_Comments_List_Table
*/
class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
/**
* @return array
*/
protected function get_column_info() {
return array(
array(
'author' => __( 'Author' ),
'comment' => _x( 'Comment', 'column name' ),
),
array(),
array(),
'comment',
);
}
/**
* @return array
*/
protected function get_table_classes() {
$classes = parent::get_table_classes();
$classes[] = 'wp-list-table';
$classes[] = 'comments-box';
return $classes;
}
/**
* @param bool $output_empty
*/
public function display( $output_empty = false ) {
$singular = $this->_args['singular'];
wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
?>
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" style="display:none;">
<tbody id="the-comment-list"
<?php
if ( $singular ) {
echo " data-wp-lists='list:$singular'";
}
?>
>
<?php
if ( ! $output_empty ) {
$this->display_rows_or_placeholder();
}
?>
</tbody>
</table>
<?php
}
/**
* @param bool $comment_status
* @return int
*/
public function get_per_page( $comment_status = false ) {
return 10;
}
}