wp_initial_nav_menu_meta_boxes

Definition:
function wp_initial_nav_menu_meta_boxes() {}

Limit the amount of meta boxes to just links, pages and cats for first time users.

Source code

function wp_initial_nav_menu_meta_boxes() {

	global $wp_meta_boxes;



	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )

		return;



	$initial_meta_boxes = array( 'nav-menu-theme-locations', 'add-custom-links', 'add-page', 'add-category' );

	$hidden_meta_boxes = array();



	foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {

		foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) {

			foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) {

				if ( in_array( $box['id'], $initial_meta_boxes ) ) {

					unset( $box['id'] );

				} else {

					$hidden_meta_boxes[] = $box['id'];

				}

			}

		}

	}



	$user = wp_get_current_user();

	update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );

}

3783

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: