Automattic /
jetpack
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | class WPCOM_JSON_API_Get_Media_Endpoint extends WPCOM_JSON_API_Endpoint { |
||
| 4 | function callback( $path = '', $blog_id = 0, $media_id = 0 ) { |
||
| 5 | $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 6 | if ( is_wp_error( $blog_id ) ) { |
||
| 7 | return $blog_id; |
||
| 8 | } |
||
| 9 | |||
| 10 | //upload_files can probably be used for other endpoints but we want contributors to be able to use media too |
||
| 11 | if ( !current_user_can( 'edit_posts', $media_id ) ) { |
||
| 12 | return new WP_Error( 'unauthorized', 'User cannot view media', 403 ); |
||
| 13 | } |
||
| 14 | |||
| 15 | return $this->get_media_item( $media_id ); |
||
| 16 | } |
||
| 17 | } |
||
| 18 |