This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
Omphaloskepsis/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-media-v1-1-endpoint.php
2018-03-21 18:19:20 +00:00

22 lines
693 B
PHP

<?php
class WPCOM_JSON_API_Get_Media_v1_1_Endpoint extends WPCOM_JSON_API_Endpoint {
function callback( $path = '', $blog_id = 0, $media_id = 0 ) {
$blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
if ( is_wp_error( $blog_id ) ) {
return $blog_id;
}
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
$this->load_theme_functions();
}
//upload_files can probably be used for other endpoints but we want contributors to be able to use media too
if ( ! current_user_can( 'edit_posts', $media_id ) ) {
return new WP_Error( 'unauthorized', 'User cannot view media', 403 );
}
return $this->get_media_item_v1_1( $media_id );
}
}