I am wondering whether anyone knows how to force the dasboard layout to 1 column on a wordpress Multisite install for the Network Admin Dashboard
This is part of the solution but it does not force the number of columns to 1:
function so_screen_layout_columns( $columns ) {
$columns['dashboard-network'] = 1;
return $columns;
}
add_filter( 'screen_layout_columns', 'so_screen_layout_columns' );
The following should force it but it does not work on the Network Admin Dashboard page, Anyone knows of a solution?
function so_screen_layout_dashboard() {
return 1;
}
add_filter( 'get_user_option_screen_layout_dashboard', 'so_screen_layout_dashboard' );
The question is how to overwrite these columns number settings in the Screen Options panel:
Network dashboard
When you change the number of columns in the screen options panel on the network dashboard page, you get the meta value of
screen_layout_dashboard-network
 saved into thewp_usermeta
table:In the
WP_Screen
class the columns number is fetched with:where
$this->id
isdashboard-network
.When user options are fetched with
get_user_option( $option )
they are filtered throughIn our case the user option is
screen_layout_dashboard-network
so the filter we are looking for isget_user_option_screen_layout_dashboard-network
.You should therefore try out:
Site dashboard
Changing the columns number on the site dashboard page, we get the meta value of
screen_layout_dashboard
saved into thewp_usermeta
table:The filter that can be used here is:
ps: The screen layout settings are only saved into the database when they are changed. So for a newly installed WordPress these settings are not in the database.