问题是如何覆盖屏幕选项面板中的这些列数设置:

网络仪表板当您更改网络仪表板页面上屏幕选项面板中的列数时,您会得到screen_layout_dashboard-network
保存到wp_usermeta
表格:

在WP_Screen
获取列号时使用的类:
get_user_option("screen_layout_$this->id")
在哪里
$this->id
是
dashboard-network
.
使用获取用户选项时get_user_option( $option )
它们被过滤掉了
return apply_filters("get_user_option_{$option}", $result, $option, $user);
在我们的例子中,用户选项是
screen_layout_dashboard-network
所以我们要找的过滤器是
get_user_option_screen_layout_dashboard-network
.
因此,您应该尝试:
add_filter( \'get_user_option_screen_layout_dashboard-network\', \'number_of_columns\' );
function number_of_columns( $nr ) {
return 1;
}
更改站点仪表板页面上的列数,我们可以得到
screen_layout_dashboard
保存到
wp_usermeta
表格:

此处可以使用的过滤器是:
add_filter( \'get_user_option_screen_layout_dashboard\', \'number_of_columns\' );
ps: 屏幕布局设置仅在更改时保存到数据库中。因此,对于新安装的WordPress,这些设置不在数据库中。