wp_initial_nav_menu_meta_boxes

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

Description

wp_initial_nav_menu_meta_boxes(); 

Usage

  1. if ( !function_exists( 'wp_initial_nav_menu_meta_boxes' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/nav-menu.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_initial_nav_menu_meta_boxes(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/nav-menu.php  
  1. function wp_initial_nav_menu_meta_boxes() { 
  2. global $wp_meta_boxes; 
  3.  
  4. if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) 
  5. return; 
  6.  
  7. $initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' ); 
  8. $hidden_meta_boxes = array(); 
  9.  
  10. foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) { 
  11. foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) { 
  12. foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) { 
  13. if ( in_array( $box['id'], $initial_meta_boxes ) ) { 
  14. unset( $box['id'] ); 
  15. } else { 
  16. $hidden_meta_boxes[] = $box['id']; 
  17.  
  18. $user = wp_get_current_user(); 
  19. update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );