← All changes
|
_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-app-media.php
+8
-3
13.6.2
→
16.3-beta
View file →
| @@ -5,8 +5,12 @@ | ||
| 5 | 5 | * @package automattic/jetpack |
| 6 | 6 | * @since 13.1 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | + exit( 0 ); | |
| 11 | +} | |
| 12 | + | |
| 9 | 13 | /** |
| 10 | 14 | * Media uploaded by the Jetpack app helper API. |
| 11 | 15 | * |
| 12 | 16 | * @since 13.1 |
| @@ -44,8 +48,9 @@ | ||
| 44 | 48 | |
| 45 | 49 | ), |
| 46 | 50 | 'page_handle' => array( |
| 47 | 51 | 'type' => 'number', |
| 52 | + 'default' => 1, | |
| 48 | 53 | 'required' => false, |
| 49 | 54 | 'sanitize_callback' => 'absint', |
| 50 | 55 | |
| 51 | 56 | ), |
| @@ -121,14 +126,13 @@ | ||
| 121 | 126 | * @return array|\WP_Error|mixed |
| 122 | 127 | */ |
| 123 | 128 | public function get_media( \WP_REST_Request $request ) { |
| 124 | 129 | $params = $request->get_params(); |
| 125 | - $number = $params['number']; | |
| 126 | 130 | |
| 127 | - $query_args = array( | |
| 131 | + $query_args = array( | |
| 128 | 132 | 'post_type' => 'attachment', |
| 129 | 133 | 'post_status' => 'inherit', |
| 130 | - 'number' => $number, | |
| 134 | + 'number' => $params['number'], | |
| 131 | 135 | 'date_query' => array( |
| 132 | 136 | 'after' => gmdate( DATE_RSS, intval( $params['after'] ) ), |
| 133 | 137 | ), |
| 134 | 138 | 'paged' => $params['page_handle'], |
| @@ -134,8 +138,9 @@ | ||
| 134 | 138 | 'paged' => $params['page_handle'], |
| 135 | 139 | 'author' => get_current_user_id(), |
| 136 | 140 | 'orderby' => 'date', |
| 137 | 141 | ); |
| 142 | + | |
| 138 | 143 | $media_query = new WP_Query( $query_args ); |
| 139 | 144 | $response = $this->format_response( $media_query ); |
| 140 | 145 | |
| 141 | 146 | wp_reset_postdata(); |