← All changes
|
json-endpoints/class.wpcom-json-api-list-media-v1-1-endpoint.php
+18
-6
12.3.2
→
16.3-a.7
View file →
| @@ -1,6 +1,10 @@ | ||
| 1 | 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | 2 | |
| 3 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 4 | + exit( 0 ); | |
| 5 | +} | |
| 6 | + | |
| 3 | 7 | /** |
| 4 | 8 | * List Media v1_1 endpoint. |
| 5 | 9 | */ |
| 6 | 10 | new WPCOM_JSON_API_List_Media_v1_1_Endpoint( |
| @@ -53,8 +57,10 @@ | ||
| 53 | 57 | ); |
| 54 | 58 | |
| 55 | 59 | /** |
| 56 | 60 | * List media v1_1 endpoint class. |
| 61 | + * | |
| 62 | + * @phan-constructor-used-for-side-effects | |
| 57 | 63 | */ |
| 58 | 64 | class WPCOM_JSON_API_List_Media_v1_1_Endpoint extends WPCOM_JSON_API_Endpoint { // phpcs:ignore |
| 59 | 65 | |
| 60 | 66 | /** |
| @@ -71,8 +77,15 @@ | ||
| 71 | 77 | */ |
| 72 | 78 | public $page_handle = array(); |
| 73 | 79 | |
| 74 | 80 | /** |
| 81 | + * Performed query | |
| 82 | + * | |
| 83 | + * @var array | |
| 84 | + */ | |
| 85 | + public $performed_query = array(); | |
| 86 | + | |
| 87 | + /** | |
| 75 | 88 | * API callback. |
| 76 | 89 | * |
| 77 | 90 | * @param string $path - the path. |
| 78 | 91 | * @param string $blog_id - the blog ID. |
| @@ -110,14 +123,14 @@ | ||
| 110 | 123 | |
| 111 | 124 | $query = array( |
| 112 | 125 | 'post_type' => 'attachment', |
| 113 | 126 | 'post_status' => 'inherit', |
| 114 | - 'post_parent' => isset( $args['post_ID'] ) ? $args['post_ID'] : null, | |
| 127 | + 'post_parent' => $args['post_ID'] ?? null, | |
| 115 | 128 | 'posts_per_page' => $args['number'], |
| 116 | - 'post_mime_type' => isset( $args['mime_type'] ) ? $args['mime_type'] : null, | |
| 117 | - 'order' => isset( $args['order'] ) ? $args['order'] : 'DESC', | |
| 118 | - 'orderby' => isset( $args['order_by'] ) ? $args['order_by'] : 'date', | |
| 119 | - 's' => isset( $args['search'] ) ? $args['search'] : null, | |
| 129 | + 'post_mime_type' => $args['mime_type'] ?? null, | |
| 130 | + 'order' => $args['order'] ?? 'DESC', | |
| 131 | + 'orderby' => $args['order_by'] ?? 'date', | |
| 132 | + 's' => $args['search'] ?? null, | |
| 120 | 133 | 'meta_query' => array( |
| 121 | 134 | array( |
| 122 | 135 | 'key' => 'videopress_poster_image', |
| 123 | 136 | 'compare' => 'NOT EXISTS', |
| @@ -340,6 +353,5 @@ | ||
| 340 | 353 | } |
| 341 | 354 | $orderby .= " `$wpdb->posts`.ID $order"; |
| 342 | 355 | return $orderby; |
| 343 | 356 | } |
| 344 | - | |
| 345 | 357 | } |