[wp-trac] [WordPress Trac] #60131: Global styles controllers: extend classes with WP_REST_Posts_Controller and WP_REST_Revisions_Controller
WordPress Trac
noreply at wordpress.org
Wed Feb 7 02:20:55 UTC 2024
#60131: Global styles controllers: extend classes with WP_REST_Posts_Controller and
WP_REST_Revisions_Controller
---------------------------------------------+---------------------------
Reporter: ramonopoly | Owner: spacedmonkey
Type: enhancement | Status: assigned
Priority: normal | Milestone: 6.5
Component: REST API | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests commit | Focuses:
---------------------------------------------+---------------------------
Description changed by ramonopoly:
Old description:
> As part of the efforts to improve the maintainability of Global Styles
> REST controllers, and to remove a lot of duplicate code we can:
>
> - extend `WP_REST_Global_Styles_Controller` with
> `WP_REST_Posts_Controller`.
> - extend `WP_REST_Global_Styles_Revisions_Controller` with
> `WP_REST_Revisions_Controller`.
>
>
> Originally, global styles were a bit new and had the following
> characteristics:
>
> - Didn't, and still doesn't, return excerpt, content, guid fields
> - Had to do some JSON parsing when preparing the response
>
> In other words, the functionality was "special" enough not to warrant
> extending the base controller instead of using WP_REST_Posts_Controller.
> Also, global styles were new and evolving.
>
> For revisions especially, more code was required to override the parent
> class's functions, and having a stand alone class left more elbow room
> for subsequent tweaks and changes.
>
> Now that global styles have "settled" however, and shares more methods
> with `WP_REST_Posts_Controller` amd `WP_REST_Revisions_Controller`, it
> makes sense to change the base classes for more consistent interface,
> less code and less maintenance burden.
>
> See discussion and related PRs:
>
> -
> [https://github.com/WordPress/gutenberg/pull/55827#discussion_r1399856581
> WordPress/gutenberg#55827 (comment)]
> - [https://github.com/WordPress/gutenberg/pull/49974 Rest API: add
> /revisions endpoint for global styles]
> - [https://github.com/WordPress/gutenberg/pull/35801 Add a Global Styles
> endpoint and use it in the site editor]
New description:
As part of the efforts to improve the maintainability of Global Styles
REST controllers, and to remove a lot of duplicate code we can:
- extend `WP_REST_Global_Styles_Controller` with
`WP_REST_Posts_Controller`.
- extend `WP_REST_Global_Styles_Revisions_Controller` with
`WP_REST_Revisions_Controller`.
The Global styles REST response has the following characteristics:
- Doesn't return excerpt, content, guid fields
- Does some JSON parsing when preparing the response
In other words, the functionality was "special" enough not to warrant
extending the base controller instead of using WP_REST_Posts_Controller.
Also, global styles were new and evolving.
For revisions especially, more code was required to override the parent
class's functions, and having a stand alone class left more elbow room for
subsequent tweaks and changes.
Now that global styles have "settled" however, and shares more methods
with `WP_REST_Posts_Controller` and `WP_REST_Revisions_Controller`, it
makes sense to change the base classes for more consistent interface, less
code and less maintenance burden.
See discussion and related PRs:
-
[https://github.com/WordPress/gutenberg/pull/55827#discussion_r1399856581
WordPress/gutenberg#55827 (comment)]
- [https://github.com/WordPress/gutenberg/pull/49974 Rest API: add
/revisions endpoint for global styles]
- [https://github.com/WordPress/gutenberg/pull/35801 Add a Global Styles
endpoint and use it in the site editor]
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60131#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list