| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 ) ); |
||
|
|
|||
| 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 |