diff --git a/projects/plugins/jetpack/changelog/add-restful-json-api-fetch-posts b/projects/plugins/jetpack/changelog/add-restful-json-api-fetch-posts new file mode 100644 index 0000000000000..180ae6b6a446d --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-restful-json-api-fetch-posts @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +JSON API: activate REST for posts fetching endpoint. diff --git a/projects/plugins/jetpack/class.json-api-endpoints.php b/projects/plugins/jetpack/class.json-api-endpoints.php index 5a8f0a2c48ab4..c65b72d326e99 100644 --- a/projects/plugins/jetpack/class.json-api-endpoints.php +++ b/projects/plugins/jetpack/class.json-api-endpoints.php @@ -2820,7 +2820,9 @@ final public function rest_permission_callback() { return new WP_Error( 'site_not_connected' ); } - if ( ( $this->allow_jetpack_site_auth && Rest_Authentication::is_signed_with_blog_token() ) || ( get_current_user_id() && Rest_Authentication::is_signed_with_user_token() ) ) { + if ( ( ( $this->allow_jetpack_site_auth || $this->allow_fallback_to_jetpack_blog_token ) && Rest_Authentication::is_signed_with_blog_token() ) + || ( get_current_user_id() && Rest_Authentication::is_signed_with_user_token() ) + ) { $custom_permission_result = $this->rest_permission_callback_custom(); // Successful custom permission check. diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-endpoint.php index 42741742231e1..9d2327f91ea00 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-endpoint.php @@ -16,6 +16,8 @@ 'path_labels' => array( '$site' => '(int|string) Site ID or domain', ), + 'rest_route' => '/posts', + 'rest_min_jp_version' => '14.5-a.1', 'allow_fallback_to_jetpack_blog_token' => true, diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-v1-1-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-v1-1-endpoint.php index bda2d8fb74d7c..33e1a16e28531 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-v1-1-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-v1-1-endpoint.php @@ -17,6 +17,8 @@ 'path_labels' => array( '$site' => '(int|string) Site ID or domain', ), + 'rest_route' => '/posts', + 'rest_min_jp_version' => '14.5-a.1', 'allow_fallback_to_jetpack_blog_token' => true, diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-v1-2-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-v1-2-endpoint.php index ac8da8f46c4a3..7ad0606c7c235 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-v1-2-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-posts-v1-2-endpoint.php @@ -17,6 +17,8 @@ 'path_labels' => array( '$site' => '(int|string) Site ID or domain', ), + 'rest_route' => '/posts', + 'rest_min_jp_version' => '14.5-a.1', 'allow_fallback_to_jetpack_blog_token' => true,