Skip to content

Commit

Permalink
Jetpack: activate REST for posts fetching JSON API endpoint (#42311)
Browse files Browse the repository at this point in the history
Make the posts fetching JSON API endpoint RESTful.
  • Loading branch information
sergeymitr authored Mar 7, 2025
1 parent 4646b8a commit b29be00
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

JSON API: activate REST for posts fetching endpoint.
4 changes: 3 additions & 1 deletion projects/plugins/jetpack/class.json-api-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down

0 comments on commit b29be00

Please sign in to comment.