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-2-endpoint.php +10 -2 13.3.316.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_2 endpoint.
5 9 */
6 10 new WPCOM_JSON_API_List_Posts_v1_2_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(
@@ -68,8 +74,10 @@
68 74 /**
69 75 * List posts v1_2 endpoint.
70 76 *
71 77 * /sites/%s/posts/ -> $blog_id
78 + *
79 + * @phan-constructor-used-for-side-effects
72 80 */
73 81 class WPCOM_JSON_API_List_Posts_v1_2_Endpoint extends WPCOM_JSON_API_List_Posts_v1_1_Endpoint { // phpcs:ignore
74 82
75 83 /**
@@ -177,9 +185,9 @@
177 185 'order' => $args['order'],
178 186 'orderby' => $args['order_by'],
179 187 'post_type' => $args['type'],
180 188 'post_status' => $status,
181 - 'post_parent' => isset( $args['parent_id'] ) ? $args['parent_id'] : null,
189 + 'post_parent' => $args['parent_id'] ?? null,
182 190 'author' => isset( $args['author'] ) && 0 < $args['author'] ? $args['author'] : null,
183 191 's' => isset( $args['search'] ) && '' !== $args['search'] ? $args['search'] : null,
184 192 'fields' => 'ids',
185 193 );
@@ -403,9 +411,9 @@
403 411 ),
404 412 );
405 413 }
406 414
407 - if ( $is_eligible_for_page_handle && $return['posts'] ) {
415 + if ( $is_eligible_for_page_handle && $return['posts'] && is_array( $return['posts'] ) ) {
408 416 $last_post = end( $return['posts'] );
409 417 reset( $return['posts'] );
410 418 $post_count = is_countable( $return['posts'] ) ? count( $return['posts'] ) : 0;
411 419 if ( ( $return['found'] > $post_count ) && $last_post ) {