WPCOM_JSON_API_Get_Media_Endpoint

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

Defined (1)

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

/json-endpoints/class.wpcom-json-api-get-media-endpoint.php  
  1. class WPCOM_JSON_API_Get_Media_Endpoint extends WPCOM_JSON_API_Endpoint { 
  2. function callback( $path = '', $blog_id = 0, $media_id = 0 ) { 
  3. $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); 
  4. if ( is_wp_error( $blog_id ) ) { 
  5. return $blog_id; 
  6.  
  7. //upload_files can probably be used for other endpoints but we want contributors to be able to use media too 
  8. if ( !current_user_can( 'edit_posts', $media_id ) ) { 
  9. return new WP_Error( 'unauthorized', 'User cannot view media', 403 ); 
  10.  
  11. return $this->get_media_item( $media_id );