WPCOM_JSON_API_Menus_List_Menus_Endpoint

The Jetpack by WordPress.com WPCOM JSON API Menus List 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_List_Menus_Endpoint extends WPCOM_JSON_API_Menus_Abstract_Endpoint { 
  2. function callback( $path = '', $site = 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. $menus = wp_get_nav_menus( array( 'orderby' => 'term_id' ) ); 
  9.  
  10. if ( is_wp_error( $menus ) ) { 
  11. return $menus; 
  12.  
  13. foreach ( $menus as $m ) { 
  14. $items = wp_get_nav_menu_items( $m->term_id, array( 'update_post_term_cache' => false ) ); 
  15. if ( is_wp_error( $items ) ) { 
  16. return $items; 
  17. $m->items = $items; 
  18.  
  19. $menus = $this->simplify( $menus ); 
  20.  
  21. if ( is_wp_error( $this->get_locations() ) ) { 
  22. return $this->get_locations(); 
  23.  
  24. return array( 'menus' => $menus, 'locations' => $this->get_locations() );