Here is an answer how to modify the css classes of metaboxes. I would not remove the postbox class, because it is needed to open and close the metabox. But you can attach your own css class to style the metabox and the following html elements.
But you have to modify every single metabox, there is no general hook for all metaboxes. Use the global $wp_meta_boxes
to find out which metaboxes are available on the current screen.
add_action( 'wp_dashboard_setup', 'close_all_meta_boxes', 999 );
function close_all_meta_boxes() {
global $wp_meta_boxes;
$screen = get_current_screen();
$page = $screen->id;
if ( isset( $wp_meta_boxes[$page] ) ) {
foreach ( $wp_meta_boxes[$page] as $parts ) {
if ( is_array( $parts ) ) {
foreach ( $parts as $part ) {
if ( is_array( $part ) ) {
foreach ( $part as $id => $metabox ) {
add_filter( "postbox_classes_{$page}_{$id}", 'modify_meta_box_css' );
}
}
}
}
}
}
}
function modify_meta_box_css( $classes ) {
if ( is_array( $classes ) ) {
array_push( $classes, 'closed' );
}
return $classes;
}
This code will add the closed
class to all metaboxes on the dashboard, so all metaboxes will be displayed minified.