meta_box_prefs() WordPress Function
The meta_box_prefs() function enables users to hide certain metaboxes on the post editing screen. By default, all metaboxes are visible. However, if a user hides a metabox using this function, it will be hidden for all users on that site.
meta_box_prefs( WP_Screen $screen ) #
Prints the meta box preferences for screen meta.
Parameters
- $screen
- (WP_Screen)(Required) 
Source
File: wp-admin/includes/screen.php
function meta_box_prefs( $screen ) {
	global $wp_meta_boxes;
	if ( is_string( $screen ) ) {
		$screen = convert_to_screen( $screen );
	}
	if ( empty( $wp_meta_boxes[ $screen->id ] ) ) {
		return;
	}
	$hidden = get_hidden_meta_boxes( $screen );
	foreach ( array_keys( $wp_meta_boxes[ $screen->id ] ) as $context ) {
		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
			if ( ! isset( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] ) ) {
				continue;
			}
			foreach ( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] as $box ) {
				if ( false === $box || ! $box['title'] ) {
					continue;
				}
				// Submit box cannot be hidden.
				if ( 'submitdiv' === $box['id'] || 'linksubmitdiv' === $box['id'] ) {
					continue;
				}
				$widget_title = $box['title'];
				if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) {
					$widget_title = $box['args']['__widget_basename'];
				}
				$is_hidden = in_array( $box['id'], $hidden, true );
				printf(
					'<label for="%1$s-hide"><input class="hide-postbox-tog" name="%1$s-hide" type="checkbox" id="%1$s-hide" value="%1$s" %2$s />%3$s</label>',
					esc_attr( $box['id'] ),
					checked( $is_hidden, false, false ),
					$widget_title
				);
			}
		}
	}
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description | 
|---|---|
| 2.7.0 | Introduced. |