WPCOM_JSON_API_Menus_Get_Menu_Endpoint

The Jetpack by WordPress.com WPCOM JSON API Menus Get Menu Endpoint class.

Defined (1)

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

/json-endpoints/class.wpcom-json-api-menus-v1-1-endpoint.php  
  1. class WPCOM_JSON_API_Menus_Get_Menu_Endpoint extends WPCOM_JSON_API_Menus_Abstract_Endpoint { 
  2. function callback( $path = '', $site = 0, $menu_id = 0 ) { 
  3. $site_id = $this->switch_to_blog_and_validate_user( $this->api->get_blog_id( $site ) ); 
  4.  
  5. if ( is_wp_error( $site_id ) ) { 
  6. return $site_id; 
  7.  
  8. if ( $menu_id <= 0 ) { 
  9. return new WP_Error( 'menu-id', 'Menu ID must be greater than 0.', 400 ); 
  10.  
  11. $menu = get_term( $menu_id, 'nav_menu' ); 
  12.  
  13. if ( is_wp_error( $menu ) ) { 
  14. return $menu; 
  15.  
  16. $items = wp_get_nav_menu_items( $menu_id, array( 'update_post_term_cache' => false ) ); 
  17.  
  18. if ( is_wp_error( $items ) ) { 
  19. return $items; 
  20.  
  21. $menu->items = $items; 
  22.  
  23. return $this->simplify( $menu );