Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/wp-admin/css/list-tables.css
Original file line number Diff line number Diff line change
Expand Up @@ -736,11 +736,29 @@ th.sorted a span {
}

.tablenav .actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 5px 6px;
padding: 0 8px 0 0;
margin-bottom: 5px;
}

.wp-filter .actions {
display: inline-block;
.wp-core-ui .tablenav .actions select {
margin-right: 0;
}

.tablenav-filter {
display: flex;
align-items: center;
gap: 6px;
margin-right: 6px;
}

.wp-filter .actions,
.wp-filter .tablenav-filter {
display: inline-flex;
align-items: center;
vertical-align: middle;
}

Expand Down Expand Up @@ -1893,6 +1911,10 @@ div.action-links,
margin-bottom: 5px;
}

.tablenav .actions {
margin-bottom: 0;
}

.tablenav.bottom .actions.alignleft + .actions.alignleft {
clear: left;
margin-top: 10px;
Expand Down
5 changes: 3 additions & 2 deletions src/wp-admin/includes/class-wp-comments-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,9 @@ protected function comment_type_dropdown( $comment_type ) {
);

if ( $comment_types && is_array( $comment_types ) ) {
echo '<div class="tablenav-filter">';
printf(
'<label class="screen-reader-text" for="filter-by-comment-type">%s</label>',
/* translators: Hidden accessibility text. */
'<label for="filter-by-comment-type">%s</label>',
__( 'Filter by comment type' )
);

Expand All @@ -565,6 +565,7 @@ protected function comment_type_dropdown( $comment_type ) {
}

echo '</select>';
echo '</div>';
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/wp-admin/includes/class-wp-links-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ protected function extra_tablenav( $which ) {
'orderby' => 'name',
);

echo '<label class="screen-reader-text" for="cat_id">' . get_taxonomy( 'link_category' )->labels->filter_by_item . '</label>';
echo '<div class="tablenav-filter">';
echo '<label for="cat_id">' . get_taxonomy( 'link_category' )->labels->filter_by_item . '</label>';

wp_dropdown_categories( $dropdown_options );
echo '</div>';

submit_button( __( 'Filter' ), 'compact', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
?>
Expand Down
9 changes: 4 additions & 5 deletions src/wp-admin/includes/class-wp-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,7 @@ protected function bulk_actions( $which = '' ) {
return;
}

echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' .
/* translators: Hidden accessibility text. */
__( 'Select bulk action' ) .
'</label>';
echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '">' . __( 'Bulk actions' ) . '</label>';
echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
echo '<option value="-1">' . __( 'Bulk actions' ) . "</option>\n";

Expand Down Expand Up @@ -795,7 +792,8 @@ protected function months_dropdown( $post_type ) {

$selected_month = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
?>
<label for="filter-by-date" class="screen-reader-text"><?php echo get_post_type_object( $post_type )->labels->filter_by_date; ?></label>
<div class="tablenav-filter">
<label for="filter-by-date"><?php echo get_post_type_object( $post_type )->labels->filter_by_date; ?></label>
<select name="m" id="filter-by-date">
<option<?php selected( $selected_month, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
<?php
Expand All @@ -817,6 +815,7 @@ protected function months_dropdown( $post_type ) {
}
?>
</select>
</div>
<?php
}

Expand Down
5 changes: 3 additions & 2 deletions src/wp-admin/includes/class-wp-media-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ public function views() {
<div class="filter-items">
<?php $this->view_switcher( $mode ); ?>

<label for="attachment-filter" class="screen-reader-text">
<div class="tablenav-filter">
<label for="attachment-filter">
<?php
/* translators: Hidden accessibility text. */
_e( 'Filter by type' );
?>
</label>
Expand All @@ -324,6 +324,7 @@ public function views() {
}
?>
</select>
</div>

<?php
$this->extra_tablenav( 'bar' );
Expand Down
9 changes: 6 additions & 3 deletions src/wp-admin/includes/class-wp-posts-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,11 @@ protected function categories_dropdown( $post_type ) {
'selected' => $cat,
);

echo '<label class="screen-reader-text" for="cat">' . get_taxonomy( 'category' )->labels->filter_by_item . '</label>';
echo '<div class="tablenav-filter">';
echo '<label for="cat">' . get_taxonomy( 'category' )->labels->filter_by_item . '</label>';

wp_dropdown_categories( $dropdown_options );
echo '</div>';
}
}

Expand Down Expand Up @@ -533,9 +535,9 @@ protected function formats_dropdown( $post_type ) {

$displayed_post_format = $_GET['post_format'] ?? '';
?>
<label for="filter-by-format" class="screen-reader-text">
<div class="tablenav-filter">
<label for="filter-by-format">
<?php
/* translators: Hidden accessibility text. */
_e( 'Filter by post format' );
?>
</label>
Expand All @@ -558,6 +560,7 @@ protected function formats_dropdown( $post_type ) {
}
?>
</select>
</div>
<?php
}

Expand Down
5 changes: 3 additions & 2 deletions src/wp-admin/includes/class-wp-users-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ protected function extra_tablenav( $which ) {
?>
<div class="alignleft actions">
<?php if ( current_user_can( 'promote_users' ) && $this->has_items() ) : ?>
<label class="screen-reader-text" for="<?php echo $id; ?>">
<div class="tablenav-filter">
<label for="<?php echo $id; ?>">
<?php
/* translators: Hidden accessibility text. */
_e( 'Change role to&hellip;' );
?>
</label>
Expand All @@ -314,6 +314,7 @@ protected function extra_tablenav( $which ) {
<?php wp_dropdown_roles(); ?>
<option value="none"><?php _e( '&mdash; No role for this site &mdash;' ); ?></option>
</select>
</div>
<?php
submit_button( __( 'Change' ), '', $button_id, false );
endif;
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function create_initial_taxonomies() {
'separate_items_with_commas' => null,
'add_or_remove_items' => null,
'choose_from_most_used' => null,
'filter_by_item' => __( 'Filter by category' ),
'back_to_items' => __( '&larr; Go to Link Categories' ),
),
'capabilities' => array(
Expand Down
17 changes: 17 additions & 0 deletions tests/phpunit/tests/admin/wpCommentsListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,21 @@ public function data_comment_type(): array {
'all type requested' => array( 'all' ),
);
}

/**
* @ticket 63971
*
* @covers WP_Comments_List_Table::comment_type_dropdown
*/
public function test_comment_type_filter_label_is_visible() {
self::factory()->comment->create( array( 'comment_post_ID' => self::factory()->post->create() ) );

$this->table->prepare_items();

ob_start();
$this->table->extra_tablenav( 'top' );
$output = ob_get_clean();

$this->assertMatchesRegularExpression( '#<div class="tablenav-filter"><label for="filter-by-comment-type">Filter by comment type</label><select id="filter-by-comment-type"#', $output );
}
}
24 changes: 24 additions & 0 deletions tests/phpunit/tests/admin/wpLinksListTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/**
* @group admin
*
* @covers WP_Links_List_Table
*/
class Tests_Admin_wpLinksListTable extends WP_UnitTestCase {

/**
* @ticket 63971
*
* @covers WP_Links_List_Table::extra_tablenav
*/
public function test_link_category_filter_label_is_visible() {
$table = _get_list_table( 'WP_Links_List_Table', array( 'screen' => 'link-manager' ) );

ob_start();
$table->extra_tablenav( 'top' );
$output = ob_get_clean();

$this->assertMatchesRegularExpression( '#<div class="tablenav-filter"><label for="cat_id">Filter by category</label><select\s+name=\'cat_id\' id=\'cat_id\'#', $output );
}
}
14 changes: 14 additions & 0 deletions tests/phpunit/tests/admin/wpMediaListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,4 +512,18 @@ private static function set_detached( $detached ) {
self::$detached->setAccessible( false );
}
}

/**
* @ticket 63971
*
* @covers WP_Media_List_Table::views
*/
public function test_type_filter_label_is_visible() {
$GLOBALS['mode'] = 'list';
list( $GLOBALS['post_mime_types'], $GLOBALS['avail_post_mime_types'] ) = wp_edit_attachments_query();

$output = get_echo( array( self::$list_table, 'views' ) );

$this->assertMatchesRegularExpression( '#<div class="tablenav-filter">\s*<label for="attachment-filter">\s*Filter by type\s*</label>\s*<select class="attachment-filters" name="attachment-filter" id="attachment-filter">#', $output );
}
}
36 changes: 36 additions & 0 deletions tests/phpunit/tests/admin/wpPostsListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,4 +596,40 @@ public function test_checkbox_label_includes_no_title_excerpt() {

$this->assertStringContainsString( 'Select (no title) Hello world example excerpt.', $output );
}

/**
* @ticket 63971
*
* @covers WP_Posts_List_Table::extra_tablenav
*/
public function test_filter_labels_are_visible() {
$post_id = self::factory()->post->create();
set_post_format( $post_id, 'aside' );

$table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => 'edit-post' ) );

ob_start();
$table->extra_tablenav( 'top' );
$output = ob_get_clean();

$this->assertMatchesRegularExpression( '#<div class="tablenav-filter">\s*<label for="filter-by-date">Filter by date</label>\s*<select name="m" id="filter-by-date">#', $output );
$this->assertMatchesRegularExpression( '#<div class="tablenav-filter">\s*<label for="cat">Filter by category</label>\s*<select\s+name=\'cat\' id=\'cat\'#', $output );
$this->assertMatchesRegularExpression( '#<div class="tablenav-filter">\s*<label for="filter-by-format">\s*Filter by post format\s*</label>\s*<select name="post_format" id="filter-by-format">#', $output );
$this->assertSame( 3, substr_count( $output, '<div class="tablenav-filter">' ), 'Each filter should have its own wrapper.' );
$this->assertStringNotContainsString( 'screen-reader-text', $output );
}

/**
* @ticket 63971
*
* @covers WP_List_Table::bulk_actions
*/
public function test_bulk_actions_label_is_visible() {
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );

$table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => 'edit-post' ) );
$output = get_echo( array( $table, 'bulk_actions' ), array( 'top' ) );

$this->assertStringContainsString( '<label for="bulk-action-selector-top">Bulk actions</label>', $output );
}
}
20 changes: 20 additions & 0 deletions tests/phpunit/tests/admin/wpUsersListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,24 @@ public function test_get_views_should_return_views_by_default() {

$this->assertSame( $expected, $this->table->get_views() );
}

/**
* @ticket 63971
*
* @covers WP_Users_List_Table::extra_tablenav
*/
public function test_change_role_label_is_visible() {
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
if ( is_multisite() ) {
grant_super_admin( get_current_user_id() );
}

$this->table->prepare_items();

ob_start();
$this->table->extra_tablenav( 'top' );
$output = ob_get_clean();

$this->assertMatchesRegularExpression( '#<div class="tablenav-filter">\s*<label for="new_role">\s*Change role to&hellip;\s*</label>\s*<select name="new_role" id="new_role">#', $output );
}
}
Loading