Make WordPress Core


Ignore:
Timestamp:
02/13/2024 02:07:38 PM (3 months ago)
Author:
spacedmonkey
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-post-type.php

    r56819 r57624  
    914914     *
    915915     * @since 6.4.0
     916     * @since 6.5.0 Prevents autosave class instantiation for wp_global_styles post types.
    916917     *
    917918     * @return WP_REST_Controller|null The controller instance, or null if the post type
     
    923924        }
    924925
    925         if ( 'attachment' === $this->name ) {
     926        if ( in_array( $this->name, array( 'attachment', 'wp_global_styles' ), true ) ) {
    926927            return null;
    927928        }
Note: See TracChangeset for help on using the changeset viewer.