WPCOM_JSON_API_List_Post_Formats_Endpoint

The Jetpack by WordPress.com WPCOM JSON API List Post Formats Endpoint class.

Defined (1)

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

/json-endpoints/class.wpcom-json-api-get-site-endpoint.php  
  1. class WPCOM_JSON_API_List_Post_Formats_Endpoint extends WPCOM_JSON_API_Endpoint { 
  2. // /sites/%s/post-formats -> $blog_id 
  3. function callback( $path = '', $blog_id = 0 ) { 
  4. $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); 
  5. if ( is_wp_error( $blog_id ) ) { 
  6. return $blog_id; 
  7.  
  8. if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { 
  9. $this->load_theme_functions(); 
  10.  
  11. // Get a list of supported post formats. 
  12. $all_formats = get_post_format_strings(); 
  13. $supported = get_theme_support( 'post-formats' ); 
  14.  
  15. $supported_formats = $response['formats'] = array(); 
  16.  
  17. if ( isset( $supported[0] ) ) { 
  18. foreach ( $supported[0] as $format ) { 
  19. $supported_formats[ $format ] = $all_formats[ $format ]; 
  20.  
  21. $response['formats'] = (object) $supported_formats; 
  22.  
  23. return $response;