WordPress.org

Make WordPress Core

Ticket #16774: 16774.diff

File 16774.diff, 963 bytes (added by garyc40, 4 years ago)

remember previous view mode

  • wp-admin/includes/class-wp-posts-list-table.php

    diff --git wp-admin/includes/class-wp-posts-list-table.php wp-admin/includes/class-wp-posts-list-table.php
    index e623ab5..0199f89 100644
    class WP_Posts_List_Table extends WP_List_Table { 
    102102                else 
    103103                        $total_pages = $wp_query->max_num_pages; 
    104104 
    105                 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; 
     105                $screen = get_current_screen(); 
     106                $default_mode = get_user_option( "{$screen->id}_last_view" ); 
     107                if ( empty( $default_mode ) ) 
     108                        $default_mode = 'list'; 
     109                $mode = ( ! empty( $_REQUEST['mode'] ) ) ? $_REQUEST['mode'] : $default_mode; 
     110                if ( $mode !== $default_mode ) 
     111                        update_user_meta( get_current_user_id(), "{$screen->id}_last_view", $mode ); 
     112 
     113//              $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; 
    106114 
    107115                $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash'; 
    108116