Skip to content

Commit

Permalink
Resolved #348
Browse files Browse the repository at this point in the history
  • Loading branch information
desaiuditd committed Mar 20, 2014
1 parent 22ee462 commit 0b0ab32
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions includes/list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 0b0ab32

Please sign in to comment.