REST API: Refactor global styles endpoints in REST API to register with post type.

Updated the global styles endpoints in the REST API to extend from existing posts and revisions controllers. This reduces duplicated code and inconsistencies. The revisions controller is now a subclass of the WP_REST_Revisions_Controller. Related redundant methods were removed and schema generation and collection parameters were adjusted to suit the global styles context. Updated permission checks, constructor, and collection parameters accordingly. This change allows for easy override of these classes using the `register_post_type_args` filter. 

Props ramonopoly, spacedmonkey, mukesh27.
Fixes #60131.

git-svn-id: https://develop.svn.wordpress.org/trunk@57624 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonny Harris
2024-02-13 14:07:38 +00:00
parent 2480e16d99
commit 85576726b9
8 changed files with 312 additions and 552 deletions

View File

@@ -420,6 +420,7 @@ class WP_REST_Global_Styles_Revisions_Controller_Test extends WP_Test_REST_Contr
/**
* @ticket 58524
* @ticket 60131
*
* @covers WP_REST_Global_Styles_Controller::get_item_permissions_check
*/
@@ -428,7 +429,7 @@ class WP_REST_Global_Styles_Revisions_Controller_Test extends WP_Test_REST_Contr
$request = new WP_REST_Request( 'GET', '/wp/v2/global-styles/' . self::$global_styles_id . '/revisions' );
$response = rest_get_server()->dispatch( $request );
$this->assertErrorResponse( 'rest_cannot_view', $response, 403 );
$this->assertErrorResponse( 'rest_cannot_read', $response, 403 );
}
/**
@@ -829,7 +830,7 @@ class WP_REST_Global_Styles_Revisions_Controller_Test extends WP_Test_REST_Contr
* @doesNotPerformAssertions
*/
public function test_context_param() {
// Controller does not implement test_context_param().
// Controller does not implement get_context_param().
}
/**