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
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-links-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function get_sortable_columns() {
'name' => array( 'name', false, _x( 'Name', 'link name' ), __( 'Table ordered by Name.' ), 'asc' ),
'url' => array( 'url', false, __( 'URL' ), __( 'Table ordered by URL.' ) ),
'visible' => array( 'visible', false, __( 'Visible' ), __( 'Table ordered by Visibility.' ) ),
'rating' => array( 'rating', false, __( 'Rating' ), __( 'Table ordered by Rating.' ) ),
'rating' => array( 'rating', true, __( 'Rating' ), __( 'Table ordered by Rating.' ) ),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-media-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ protected function get_sortable_columns() {
'title' => array( 'title', false, _x( 'File', 'column name' ), __( 'Table ordered by File Name.' ) ),
'author' => array( 'author', false, __( 'Author' ), __( 'Table ordered by Author.' ) ),
'parent' => array( 'parent', false, _x( 'Uploaded to', 'column name' ), __( 'Table ordered by Uploaded To.' ) ),
'comments' => array( 'comment_count', __( 'Comments' ), false, __( 'Table ordered by Comments.' ) ),
'comments' => array( 'comment_count', true, __( 'Comments' ), __( 'Table ordered by Comments.' ) ),
'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ),
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-ms-users-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected function get_sortable_columns() {
'username' => array( 'login', false, __( 'Username' ), __( 'Table ordered by Username.' ), 'asc' ),
'name' => array( 'name', false, __( 'Name' ), __( 'Table ordered by Name.' ) ),
'email' => array( 'email', false, __( 'E-mail' ), __( 'Table ordered by E-mail.' ) ),
'registered' => array( 'id', false, _x( 'Registered', 'user' ), __( 'Table ordered by User Registered Date.' ) ),
'registered' => array( 'id', true, _x( 'Registered', 'user' ), __( 'Table ordered by User Registered Date.' ) ),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/includes/class-wp-posts-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,14 +772,14 @@ protected function get_sortable_columns() {
$sortables = array(
'title' => array( 'title', false, __( 'Title' ), $title_orderby_text, 'asc' ),
'parent' => array( 'parent', false ),
'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ),
'comments' => array( 'comment_count', true, __( 'Comments' ), __( 'Table ordered by Comments.' ) ),
'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ) ),
);
} else {
$sortables = array(
'title' => array( 'title', false, __( 'Title' ), __( 'Table ordered by Title.' ) ),
'parent' => array( 'parent', false ),
'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ),
'comments' => array( 'comment_count', true, __( 'Comments' ), __( 'Table ordered by Comments.' ) ),
'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ),
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/includes/class-wp-terms-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ protected function get_sortable_columns() {
'name' => array( 'name', false, _x( 'Name', 'term name' ), $name_orderby_text, 'asc' ),
'description' => array( 'description', false, __( 'Description' ), __( 'Table ordered by Description.' ) ),
'slug' => array( 'slug', false, __( 'Slug' ), __( 'Table ordered by Slug.' ) ),
'posts' => array( 'count', false, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Posts Count.' ) ),
'links' => array( 'count', false, __( 'Links' ), __( 'Table ordered by Links.' ) ),
'posts' => array( 'count', true, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Posts Count.' ) ),
'links' => array( 'count', true, __( 'Links' ), __( 'Table ordered by Links.' ) ),
);
}

Expand Down
26 changes: 26 additions & 0 deletions tests/phpunit/tests/admin/wpLinksListTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* @group admin
*/
class Tests_Admin_wpLinksListTable extends WP_UnitTestCase {
/**
* @var WP_Links_List_Table
*/
private $table;

public function set_up() {
parent::set_up();
$this->table = _get_list_table( 'WP_Links_List_Table', array( 'screen' => 'link-manager' ) );
}

/**
* @covers WP_Links_List_Table::print_column_headers
*/
public function test_sortable_columns_set_rating_descending_by_default() {
$output = get_echo( array( $this->table, 'print_column_headers' ) );

$this->assertStringContainsString( '?orderby=rating&#038;order=desc', $output, 'Mismatch of the default link ordering for rating column. Should be desc.' );
$this->assertStringContainsString( 'column-rating sortable asc', $output, 'Mismatch of CSS classes for the rating column.' );
}
}
21 changes: 21 additions & 0 deletions tests/phpunit/tests/admin/wpMediaListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,27 @@ public function test_get_row_actions_should_not_include_download_without_an_atta
$this->assertArrayNotHasKey( 'download', $actions, '"download" was included in the actions.' );
}

/**
* @covers WP_Media_List_Table::print_column_headers
*/
public function test_sortable_columns_set_comments_descending_by_default() {
$attachment_pages_enabled = get_option( 'wp_attachment_pages_enabled' );

add_post_type_support( 'attachment', 'comments' );
update_option( 'wp_attachment_pages_enabled', 1 );

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

if ( false === $attachment_pages_enabled ) {
delete_option( 'wp_attachment_pages_enabled' );
} else {
update_option( 'wp_attachment_pages_enabled', $attachment_pages_enabled );
}

$this->assertStringContainsString( '?orderby=comment_count&#038;order=desc', $output, 'Mismatch of the default link ordering for comments column. Should be desc.' );
$this->assertMatchesRegularExpression( '/column-comments[^"\\n]*sortable asc/', $output, 'Mismatch of CSS classes for the comments column.' );
}

/**
* Sets the `$is_trash` property.
*
Expand Down
10 changes: 10 additions & 0 deletions tests/phpunit/tests/admin/wpPostsListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,14 @@ public function test_get_views_should_return_views_by_default() {

$this->assertSame( $expected, $actual );
}

/**
* @covers WP_Posts_List_Table::print_column_headers
*/
public function test_sortable_columns_set_comments_descending_by_default() {
$output = get_echo( array( $this->table, 'print_column_headers' ) );

$this->assertStringContainsString( '?orderby=comment_count&#038;order=desc', $output, 'Mismatch of the default link ordering for comments column. Should be desc.' );
$this->assertMatchesRegularExpression( '/column-comments[^"\\n]*sortable asc/', $output, 'Mismatch of CSS classes for the comments column.' );
}
}
10 changes: 10 additions & 0 deletions tests/phpunit/tests/admin/wpTermsListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,14 @@ public function test_handle_row_actions_as_admin() {
$this->assertStringContainsString( 'Delete', $actions, 'Delete action should be displayed to the admin.' );
$this->assertStringContainsString( admin_url( 'term.php' ), $actions, 'Edit term link should be displayed to the admin.' );
}

/**
* @covers WP_Terms_List_Table::print_column_headers
*/
public function test_sortable_columns_set_count_columns_descending_by_default() {
$category_output = get_echo( array( $this->terms_list_table, 'print_column_headers' ) );

$this->assertStringContainsString( '?orderby=count&#038;order=desc', $category_output, 'Mismatch of the default link ordering for posts count column. Should be desc.' );
$this->assertStringContainsString( 'column-posts sortable asc', $category_output, 'Mismatch of CSS classes for the posts count column.' );
}
}
10 changes: 10 additions & 0 deletions tests/phpunit/tests/multisite/wpMsUsersListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,14 @@ public function test_get_views_should_return_views_by_default() {

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

/**
* @covers WP_MS_Users_List_Table::print_column_headers
*/
public function test_sortable_columns_set_registered_descending_by_default() {
$output = get_echo( array( $this->table, 'print_column_headers' ) );

$this->assertStringContainsString( '?orderby=id&#038;order=desc', $output, 'Mismatch of the default link ordering for registered column. Should be desc.' );
$this->assertStringContainsString( 'column-registered sortable asc', $output, 'Mismatch of CSS classes for the registered column.' );
}
}
Loading