Administration: Introduce extensibility to posts and comments list table views, for accessibility purposes.

At default, expands the excerpt view to become an extended view. Includes a new `table_view_mode` filter to allow further configuration.

Fixes #49715.
Props joedolson, audrasjb, afercia, whyisjake.



git-svn-id: https://develop.svn.wordpress.org/trunk@48398 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock
2020-07-07 19:10:46 +00:00
parent bfb896ce08
commit 86ffb51a33
4 changed files with 90 additions and 24 deletions
+23 -3
View File
@@ -166,8 +166,8 @@ class WP_List_Table {
if ( empty( $this->modes ) ) {
$this->modes = array(
'list' => __( 'List View' ),
'excerpt' => __( 'Excerpt View' ),
'list' => __( 'Compact View' ),
'extended' => __( 'Extended View' ),
);
}
}
@@ -523,6 +523,11 @@ class WP_List_Table {
return '';
}
$mode = get_user_setting( 'posts_list_mode', 'list' );
if ( 'extended' === $mode ) {
$always_visible = true;
}
$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
foreach ( $actions as $action => $link ) {
++$i;
@@ -1247,7 +1252,22 @@ class WP_List_Table {
* @return string[] Array of CSS classes for the table tag.
*/
protected function get_table_classes() {
return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] );
$mode = get_user_setting( 'posts_list_mode', 'list' );
$mode_class = 'extended' === $mode ? 'table-view-extended' : 'table-view-list';
$mode = get_user_setting( 'posts_list_mode', 'list' );
/**
* Filters the current view mode.
*
* @since 5.5.0
*
* @param string $mode The current selected mode. Default value of
* posts_list_mode user setting.
*/
$mode = apply_filters( 'table_view_mode', $mode );
$mode_class = 'extended' === $mode ? 'table-view-extended' : 'table-view-' . $mode;
return array( 'widefat', 'fixed', 'striped', $mode_class, $this->_args['plural'] );
}
/**