PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | json-endpoints/class.wpcom-json-api-list-posts-endpoint.php +10 -2 13.7.216.3-a.1 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 posts endpoint.
5 9 */
6 10 new WPCOM_JSON_API_List_Posts_Endpoint(
@@ -15,8 +19,10 @@
15 19 'path' => '/sites/%s/posts/',
16 20 'path_labels' => array(
17 21 '$site' => '(int|string) Site ID or domain',
18 22 ),
23 + 'rest_route' => '/posts',
24 + 'rest_min_jp_version' => '15.9',
19 25
20 26 'allow_fallback_to_jetpack_blog_token' => true,
21 27
22 28 'query_parameters' => array(
@@ -70,8 +76,10 @@
70 76 /**
71 77 * List posts endpoint class.
72 78 *
73 79 * /sites/%s/posts/ -> $blog_id
80 + *
81 + * @phan-constructor-used-for-side-effects
74 82 */
75 83 class WPCOM_JSON_API_List_Posts_Endpoint extends WPCOM_JSON_API_Post_Endpoint {
76 84
77 85 /**
@@ -154,9 +162,9 @@
154 162 $status = array();
155 163 }
156 164
157 165 // let's be explicit about defaulting to 'post'.
158 - $args['type'] = isset( $args['type'] ) ? $args['type'] : 'post';
166 + $args['type'] ??= 'post';
159 167
160 168 // make sure the user can read or edit the requested post type(s).
161 169 if ( is_array( $args['type'] ) ) {
162 170 $allowed_types = array();
@@ -185,9 +193,9 @@
185 193 'order' => $args['order'],
186 194 'orderby' => $args['order_by'],
187 195 'post_type' => $args['type'],
188 196 'post_status' => $status,
189 - 'post_parent' => isset( $args['parent_id'] ) ? $args['parent_id'] : null,
197 + 'post_parent' => $args['parent_id'] ?? null,
190 198 'author' => isset( $args['author'] ) && 0 < $args['author'] ? $args['author'] : null,
191 199 's' => isset( $args['search'] ) && '' !== $args['search'] ? $args['search'] : null,
192 200 'fields' => 'ids',
193 201 );