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-v1-1-endpoint.php +11 -3 13.2.416.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 v1_1 endpoint.
5 9 */
6 10 new WPCOM_JSON_API_List_Posts_v1_1_Endpoint(
@@ -16,8 +20,10 @@
16 20 'path' => '/sites/%s/posts/',
17 21 'path_labels' => array(
18 22 '$site' => '(int|string) Site ID or domain',
19 23 ),
24 + 'rest_route' => '/posts',
25 + 'rest_min_jp_version' => '15.9',
20 26
21 27 'allow_fallback_to_jetpack_blog_token' => true,
22 28
23 29 'query_parameters' => array(
@@ -67,8 +73,10 @@
67 73 /**
68 74 * List Posts v1_1 Endpoint class.
69 75 *
70 76 * /sites/%s/posts/ -> $blog_id
77 + *
78 + * @phan-constructor-used-for-side-effects
71 79 */
72 80 class WPCOM_JSON_API_List_Posts_v1_1_Endpoint extends WPCOM_JSON_API_Post_v1_1_Endpoint { // phpcs:ignore
73 81 /**
74 82 * Date range
@@ -179,9 +187,9 @@
179 187 $status = array();
180 188 }
181 189
182 190 // let's be explicit about defaulting to 'post'.
183 - $args['type'] = isset( $args['type'] ) ? $args['type'] : 'post';
191 + $args['type'] ??= 'post';
184 192
185 193 // make sure the user can read or edit the requested post type(s).
186 194 if ( is_array( $args['type'] ) ) {
187 195 $allowed_types = array();
@@ -210,9 +218,9 @@
210 218 'order' => $args['order'],
211 219 'orderby' => $args['order_by'],
212 220 'post_type' => $args['type'],
213 221 'post_status' => $status,
214 - 'post_parent' => isset( $args['parent_id'] ) ? $args['parent_id'] : null,
222 + 'post_parent' => $args['parent_id'] ?? null,
215 223 'author' => isset( $args['author'] ) && 0 < $args['author'] ? $args['author'] : null,
216 224 's' => isset( $args['search'] ) && '' !== $args['search'] ? $args['search'] : null,
217 225 'fields' => 'ids',
218 226 );
@@ -436,9 +444,9 @@
436 444 ),
437 445 );
438 446 }
439 447
440 - if ( $is_eligible_for_page_handle && $return['posts'] ) {
448 + if ( $is_eligible_for_page_handle && $return['posts'] && is_array( $return['posts'] ) ) {
441 449 $last_post = end( $return['posts'] );
442 450 reset( $return['posts'] );
443 451 $post_count = is_countable( $return['posts'] ) ? count( $return['posts'] ) : 0;
444 452 if ( ( $return['found'] > $post_count ) && $last_post ) {