From d3614d49fec38a35258eb3535ee13591fda8e526 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 28 Jul 2020 16:53:03 +0000 Subject: [PATCH] Administration: Don't override the `$mode` global in `WP_Screen::render_view_mode()` if it's already set. Follow-up to [48398], [48423], [48424], [48450]. See #49715. git-svn-id: https://develop.svn.wordpress.org/trunk@48670 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-comments-list-table.php | 5 ++++- src/wp-admin/includes/class-wp-screen.php | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index c7ffb4d9f2..91b29c5c1f 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -78,17 +78,20 @@ class WP_Comments_List_Table extends WP_List_Table { } /** + * @global string $mode List table view mode. * @global int $post_id * @global string $comment_status * @global string $comment_type * @global string $search */ public function prepare_items() { - global $post_id, $comment_status, $comment_type, $search; + 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 { + $mode = get_user_setting( 'posts_list_mode', 'list' ); } $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php index ce98c2c840..440527f249 100644 --- a/src/wp-admin/includes/class-wp-screen.php +++ b/src/wp-admin/includes/class-wp-screen.php @@ -1313,7 +1313,9 @@ final class WP_Screen { return; } - $mode = get_user_setting( 'posts_list_mode', 'list' ); + if ( ! isset( $mode ) ) { + $mode = get_user_setting( 'posts_list_mode', 'list' ); + } // This needs a submit button. add_filter( 'screen_options_show_submit', '__return_true' );