wp_ajax_menu_get_metabox

Ajax handler for retrieving menu meta boxes.

Description

wp_ajax_menu_get_metabox(); 

Usage

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

Defined (1)

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

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_menu_get_metabox() { 
  2. if ( ! current_user_can( 'edit_theme_options' ) ) 
  3. wp_die( -1 ); 
  4.  
  5. require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; 
  6.  
  7. if ( isset( $_POST['item-type'] ) && 'post_type' == $_POST['item-type'] ) { 
  8. $type = 'posttype'; 
  9. $items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); 
  10. } elseif ( isset( $_POST['item-type'] ) && 'taxonomy' == $_POST['item-type'] ) { 
  11. $type = 'taxonomy'; 
  12. $items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' ); 
  13.  
  14. if ( ! empty( $_POST['item-object'] ) && isset( $items[$_POST['item-object']] ) ) { 
  15. $menus_meta_box_object = $items[ $_POST['item-object'] ]; 
  16.  
  17. /** This filter is documented in wp-admin/includes/nav-menu.php */ 
  18. $item = apply_filters( 'nav_menu_meta_box_object', $menus_meta_box_object ); 
  19. ob_start(); 
  20. call_user_func_array($callback, array( 
  21. null,  
  22. array( 
  23. 'id' => 'add-' . $item->name,  
  24. 'title' => $item->labels->name,  
  25. 'callback' => $callback,  
  26. 'args' => $item,  
  27. )); 
  28.  
  29. $markup = ob_get_clean(); 
  30.  
  31. echo wp_json_encode(array( 
  32. 'replace-id' => $type . '-' . $item->name,  
  33. 'markup' => $markup,  
  34. )); 
  35.  
  36. wp_die();