From 0b0ab3256334fb6cdec8ca5b4d77c0489a565fef Mon Sep 17 00:00:00 2001 From: Udit Desai Date: Fri, 21 Mar 2014 01:17:35 +0530 Subject: [PATCH] Resolved #348 --- includes/list-table.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/includes/list-table.php b/includes/list-table.php index 8f0d785a9..4fc096249 100644 --- a/includes/list-table.php +++ b/includes/list-table.php @@ -20,6 +20,9 @@ function __construct( $args = array() ) { ) ); + // Check for default hidden columns + $this->get_hidden_columns(); + add_filter( 'set-screen-option', array( __CLASS__, 'set_screen_option' ), 10, 3 ); add_filter( 'screen_settings', array( __CLASS__, 'live_update_checkbox' ), 10, 2 ); add_action( 'wp_ajax_wp_stream_filters', array( __CLASS__, 'ajax_filters' ) ); @@ -77,6 +80,24 @@ function get_sortable_columns() { ); } + function get_hidden_columns() { + + if ( ! $user = wp_get_current_user() ) { + return array(); + } + + // Directly checking the user meta; to check whether user has changed screen option or not + $hidden = get_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', true ); + + // If user meta is not found; add the default hidden column 'id' + if ( false == $hidden ) { + $hidden = array( 'id' ); + update_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', $hidden ); + } + + return $hidden; + } + function prepare_items() { $columns = $this->get_columns(); $sortable = $this->get_sortable_columns();