WPCOM_JSON_API_Menus_Abstract_Endpoint

The Jetpack by WordPress.com WPCOM JSON API Menus Abstract 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. abstract class WPCOM_JSON_API_Menus_Abstract_Endpoint extends WPCOM_JSON_API_Endpoint { 
  2.  
  3. protected function switch_to_blog_and_validate_user( $site ) { 
  4. $site_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $site ) ); 
  5. if ( is_wp_error( $site_id ) ) { 
  6. return $site_id; 
  7.  
  8. if ( ! current_user_can( 'edit_theme_options' ) ) { 
  9. return new WP_Error( 'unauthorised', 'User cannot edit theme options on this site.', 403 ); 
  10.  
  11. if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { 
  12. $this->load_theme_functions(); 
  13.  
  14. return $site_id; 
  15.  
  16.  
  17. protected function get_locations() { 
  18. $locations = array(); 
  19. $menus = get_registered_nav_menus(); 
  20. if ( !empty( $menus ) ) { 
  21. foreach( $menus as $name => $description ) { 
  22. $locations[] = array( 'name' => $name, 'description' => $description ); 
  23.  
  24. $locations = array_merge( $locations, WPCOM_JSON_API_Menus_Widgets::get() ); 
  25.  
  26. // Primary (first) location should have defaultState -> default,  
  27. // all other locations (including widgets) should have defaultState -> empty. 
  28. for ( $i = 0; $i < count( $locations ); $i++ ) { 
  29. $locations[ $i ]['defaultState'] = $i ? 'empty' : 'default'; 
  30. return $locations; 
  31.  
  32. protected function simplify( $data ) { 
  33. $simplifier = new WPCOM_JSON_API_Menus_Simplifier( $data ); 
  34. return $simplifier->translate(); 
  35.  
  36. protected function complexify( $data ) { 
  37. $complexifier = new WPCOM_JSON_API_Menus_Complexify( $data ); 
  38. return $complexifier->translate();