Make WordPress Core

Changeset 58225


Ignore:
Timestamp:
05/28/2024 12:38:28 PM (8 months ago)
Author:
swissspidy
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.

This reintroduces [57624] (reverted in [57628]) with improved backward compatibility and further enhancements.

Props ramonopoly, spacedmonkey, mukesh27, swissspidy.
Fixes #60131.

Location:
trunk
Files:
7 edited

Legend:

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

    r58201 r58225  
    477477        'wp_global_styles',
    478478        array(
    479             'label'        => _x( 'Global Styles', 'post type general name' ),
    480             'description'  => __( 'Global styles to include in themes.' ),
    481             'public'       => false,
    482             '_builtin'     => true, /* internal use only. don't use this when registering your own post type. */
    483             '_edit_link'   => '/site-editor.php?canvas=edit', /* internal use only. don't use this when registering your own post type. */
    484             'show_ui'      => false,
    485             'show_in_rest' => false,
    486             'rewrite'      => false,
    487             'capabilities' => array(
     479            'label'                           => _x( 'Global Styles', 'post type general name' ),
     480            'description'                     => __( 'Global styles to include in themes.' ),
     481            'public'                          => false,
     482            '_builtin'                        => true, /* internal use only. don't use this when registering your own post type. */
     483            '_edit_link'                      => '/site-editor.php?canvas=edit', /* internal use only. don't use this when registering your own post type. */
     484            'show_ui'                         => false,
     485            'show_in_rest'                    => true,
     486            'rewrite'                         => false,
     487            'rest_base'                       => 'global-styles',
     488            'rest_controller_class'           => 'WP_REST_Global_Styles_Controller',
     489            'revisions_rest_controller_class' => 'WP_REST_Global_Styles_Revisions_Controller',
     490            'late_route_registration'         => true,
     491            'capabilities'                    => array(
    488492                'read'                   => 'edit_theme_options',
    489493                'create_posts'           => 'edit_theme_options',
     
    494498                'delete_others_posts'    => 'edit_theme_options',
    495499            ),
    496             'map_meta_cap' => true,
    497             'supports'     => array(
     500            'map_meta_cap'                    => true,
     501            'supports'                        => array(
    498502                'title',
    499503                'editor',
     
    502506        )
    503507    );
     508    // Disable autosave endpoints for global styles.
     509    remove_post_type_support( 'wp_global_styles', 'autosave' );
    504510
    505511    $navigation_post_edit_link = 'site-editor.php?' . build_query(
  • trunk/src/wp-includes/rest-api.php

    r57692 r58225  
    322322    // Block Types.
    323323    $controller = new WP_REST_Block_Types_Controller();
    324     $controller->register_routes();
    325 
    326     // Global Styles revisions.
    327     $controller = new WP_REST_Global_Styles_Revisions_Controller();
    328     $controller->register_routes();
    329 
    330     // Global Styles.
    331     $controller = new WP_REST_Global_Styles_Controller();
    332324    $controller->register_routes();
    333325
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php

    r57628 r58225  
    1111 * Base Global Styles REST API Controller.
    1212 */
    13 class WP_REST_Global_Styles_Controller extends WP_REST_Controller {
    14 
    15     /**
    16      * Post type.
    17      *
    18      * @since 5.9.0
    19      * @var string
    20      */
    21     protected $post_type;
     13class WP_REST_Global_Styles_Controller extends WP_REST_Posts_Controller {
     14    /**
     15     * Whether the controller supports batching.
     16     *
     17     * @since 6.6.0
     18     * @var array
     19     */
     20    protected $allow_batch = array( 'v1' => false );
    2221
    2322    /**
    2423     * Constructor.
    25      * @since 5.9.0
    26      */
    27     public function __construct() {
    28         $this->namespace = 'wp/v2';
    29         $this->rest_base = 'global-styles';
    30         $this->post_type = 'wp_global_styles';
     24     *
     25     * @since 6.6.0
     26     *
     27     * @param string $post_type Post type.
     28     */
     29    public function __construct( $post_type = 'wp_global_styles' ) {
     30        parent::__construct( $post_type );
    3131    }
    3232
     
    5151                        ),
    5252                    ),
     53                    'allow_batch'         => $this->allow_batch,
    5354                ),
    5455            )
     
    8081                        ),
    8182                    ),
     83                    'allow_batch'         => $this->allow_batch,
    8284                ),
    8385            )
     
    107109                    'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
    108110                ),
    109                 'schema' => array( $this, 'get_public_item_schema' ),
     111                'schema'      => array( $this, 'get_public_item_schema' ),
     112                'allow_batch' => $this->allow_batch,
    110113            )
    111114        );
     
    195198     * @return bool Whether the post can be read.
    196199     */
    197     protected function check_read_permission( $post ) {
     200    public function check_read_permission( $post ) {
    198201        return current_user_can( 'read_post', $post->ID );
    199     }
    200 
    201     /**
    202      * Returns the given global styles config.
    203      *
    204      * @since 5.9.0
    205      *
    206      * @param WP_REST_Request $request The request instance.
    207      *
    208      * @return WP_REST_Response|WP_Error
    209      */
    210     public function get_item( $request ) {
    211         $post = $this->get_post( $request['id'] );
    212         if ( is_wp_error( $post ) ) {
    213             return $post;
    214         }
    215 
    216         return $this->prepare_item_for_response( $post, $request );
    217202    }
    218203
     
    240225
    241226        return true;
    242     }
    243 
    244     /**
    245      * Checks if a global style can be edited.
    246      *
    247      * @since 5.9.0
    248      *
    249      * @param WP_Post $post Post object.
    250      * @return bool Whether the post can be edited.
    251      */
    252     protected function check_update_permission( $post ) {
    253         return current_user_can( 'edit_post', $post->ID );
    254     }
    255 
    256     /**
    257      * Updates a single global style config.
    258      *
    259      * @since 5.9.0
    260      *
    261      * @param WP_REST_Request $request Full details about the request.
    262      * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
    263      */
    264     public function update_item( $request ) {
    265         $post_before = $this->get_post( $request['id'] );
    266         if ( is_wp_error( $post_before ) ) {
    267             return $post_before;
    268         }
    269 
    270         $changes = $this->prepare_item_for_database( $request );
    271         if ( is_wp_error( $changes ) ) {
    272             return $changes;
    273         }
    274 
    275         $result = wp_update_post( wp_slash( (array) $changes ), true, false );
    276         if ( is_wp_error( $result ) ) {
    277             return $result;
    278         }
    279 
    280         $post          = get_post( $request['id'] );
    281         $fields_update = $this->update_additional_fields_for_object( $post, $request );
    282         if ( is_wp_error( $fields_update ) ) {
    283             return $fields_update;
    284         }
    285 
    286         wp_after_insert_post( $post, true, $post_before );
    287 
    288         $response = $this->prepare_item_for_response( $post, $request );
    289 
    290         return rest_ensure_response( $response );
    291227    }
    292228
     
    408344            $response->add_links( $links );
    409345            if ( ! empty( $links['self']['href'] ) ) {
    410                 $actions = $this->get_available_actions();
     346                $actions = $this->get_available_actions( $post, $request );
    411347                $self    = $links['self']['href'];
    412348                foreach ( $actions as $rel ) {
     
    432368
    433369        $links = array(
    434             'self' => array(
     370            'self'  => array(
    435371                'href' => rest_url( trailingslashit( $base ) . $id ),
     372            ),
     373            'about' => array(
     374                'href' => rest_url( 'wp/v2/types/' . $this->post_type ),
    436375            ),
    437376        );
     
    455394     * @since 5.9.0
    456395     * @since 6.2.0 Added 'edit-css' action.
    457      *
     396     * @since 6.6.0 Added $post and $request parameters.
     397     *
     398     * @param WP_Post         $post    Post object.
     399     * @param WP_REST_Request $request Request object.
    458400     * @return array List of link relations.
    459401     */
    460     protected function get_available_actions() {
     402    protected function get_available_actions( $post, $request ) {
    461403        $rels = array();
    462404
    463         $post_type = get_post_type_object( $this->post_type );
     405        $post_type = get_post_type_object( $post->post_type );
    464406        if ( current_user_can( $post_type->cap->publish_posts ) ) {
    465407            $rels[] = 'https://api.w.org/action-publish';
     
    471413
    472414        return $rels;
    473     }
    474 
    475     /**
    476      * Overwrites the default protected title format.
    477      *
    478      * By default, WordPress will show password protected posts with a title of
    479      * "Protected: %s", as the REST API communicates the protected status of a post
    480      * in a machine readable format, we remove the "Protected: " prefix.
    481      *
    482      * @since 5.9.0
    483      *
    484      * @return string Protected title format.
    485      */
    486     public function protected_title_format() {
    487         return '%s';
    488415    }
    489416
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php

    r57648 r58225  
    1515 * @see WP_REST_Controller
    1616 */
    17 class WP_REST_Global_Styles_Revisions_Controller extends WP_REST_Controller {
     17class WP_REST_Global_Styles_Revisions_Controller extends WP_REST_Revisions_Controller {
     18    /**
     19     * Parent controller.
     20     *
     21     * @since 6.6.0
     22     * @var WP_REST_Controller
     23     */
     24    private $parent_controller;
     25
     26    /**
     27     * The base of the parent controller's route.
     28     *
     29     * @since 6.3.0
     30     * @var string
     31     */
     32    protected $parent_base;
     33
    1834    /**
    1935     * Parent post type.
    2036     *
    21      * @since 6.3.0
     37     * @since 6.6.0
    2238     * @var string
    2339     */
     
    2541
    2642    /**
    27      * The base of the parent controller's route.
    28      *
    29      * @since 6.3.0
    30      * @var string
    31      */
    32     protected $parent_base;
    33 
    34     /**
    3543     * Constructor.
    3644     *
    3745     * @since 6.3.0
    38      */
    39     public function __construct() {
    40         $this->parent_post_type = 'wp_global_styles';
    41         $this->rest_base        = 'revisions';
    42         $this->parent_base      = 'global-styles';
    43         $this->namespace        = 'wp/v2';
     46     * @since 6.6.0 Extends class from WP_REST_Revisions_Controller.
     47     *
     48     * @param string $parent_post_type Post type of the parent.
     49     */
     50    public function __construct( $parent_post_type = 'wp_global_styles' ) {
     51        parent::__construct( $parent_post_type );
     52        $post_type_object  = get_post_type_object( $parent_post_type );
     53        $parent_controller = $post_type_object->get_rest_controller();
     54
     55        if ( ! $parent_controller ) {
     56            $parent_controller = new WP_REST_Global_Styles_Controller( $parent_post_type );
     57        }
     58
     59        $this->parent_controller = $parent_controller;
     60        $this->rest_base         = 'revisions';
     61        $this->parent_base       = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name;
     62        $this->namespace         = ! empty( $post_type_object->rest_namespace ) ? $post_type_object->rest_namespace : 'wp/v2';
    4463    }
    4564
     
    4867     *
    4968     * @since 6.3.0
    50      * @since 6.5.0 Added route to fetch individual global styles revisions.
     69     * @since 6.6.0 Added route to fetch individual global styles revisions.
    5170     */
    5271    public function register_routes() {
     
    6483                    'methods'             => WP_REST_Server::READABLE,
    6584                    'callback'            => array( $this, 'get_items' ),
    66                     'permission_callback' => array( $this, 'get_item_permissions_check' ),
     85                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
    6786                    'args'                => $this->get_collection_params(),
    6887                ),
     
    99118
    100119    /**
    101      * Retrieves the query params for collections.
    102      *
    103      * Inherits from WP_REST_Controller::get_collection_params(),
    104      * also reflects changes to return value WP_REST_Revisions_Controller::get_collection_params().
    105      *
    106      * @since 6.3.0
    107      *
    108      * @return array Collection parameters.
    109      */
    110     public function get_collection_params() {
    111         $collection_params                       = parent::get_collection_params();
    112         $collection_params['context']['default'] = 'view';
    113         $collection_params['offset']             = array(
    114             'description' => __( 'Offset the result set by a specific number of items.' ),
    115             'type'        => 'integer',
    116         );
    117         unset( $collection_params['search'] );
    118         unset( $collection_params['per_page']['default'] );
    119 
    120         return $collection_params;
    121     }
    122 
    123     /**
    124120     * Returns decoded JSON from post content string,
    125121     * or a 404 if not found.
     
    270266
    271267    /**
    272      * Retrieves one global styles revision from the collection.
    273      *
    274      * @since 6.5.0
    275      *
    276      * @param WP_REST_Request $request Full details about the request.
    277      * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
    278      */
    279     public function get_item( $request ) {
    280         $parent = $this->get_parent( $request['parent'] );
    281         if ( is_wp_error( $parent ) ) {
    282             return $parent;
    283         }
    284 
    285         $revision = $this->get_revision( $request['id'] );
    286         if ( is_wp_error( $revision ) ) {
    287             return $revision;
    288         }
    289 
    290         $response = $this->prepare_item_for_response( $revision, $request );
    291         return rest_ensure_response( $response );
    292     }
    293 
    294     /**
    295      * Gets the global styles revision, if the ID is valid.
    296      *
    297      * @since 6.5.0
    298      *
    299      * @param int $id Supplied ID.
    300      * @return WP_Post|WP_Error Revision post object if ID is valid, WP_Error otherwise.
    301      */
    302     protected function get_revision( $id ) {
    303         $error = new WP_Error(
    304             'rest_post_invalid_id',
    305             __( 'Invalid global styles revision ID.' ),
    306             array( 'status' => 404 )
    307         );
    308 
    309         if ( (int) $id <= 0 ) {
    310             return $error;
    311         }
    312 
    313         $revision = get_post( (int) $id );
    314         if ( empty( $revision ) || empty( $revision->ID ) || 'revision' !== $revision->post_type ) {
    315             return $error;
    316         }
    317 
    318         return $revision;
    319     }
    320 
    321     /**
    322      * Checks the post_date_gmt or modified_gmt and prepare any post or
    323      * modified date for single post output.
    324      *
    325      * Duplicate of WP_REST_Revisions_Controller::prepare_date_response.
    326      *
    327      * @since 6.3.0
    328      *
    329      * @param string      $date_gmt GMT publication time.
    330      * @param string|null $date     Optional. Local publication time. Default null.
    331      * @return string|null ISO8601/RFC3339 formatted datetime, otherwise null.
    332      */
    333     protected function prepare_date_response( $date_gmt, $date = null ) {
    334         if ( '0000-00-00 00:00:00' === $date_gmt ) {
    335             return null;
    336         }
    337 
    338         if ( isset( $date ) ) {
    339             return mysql_to_rfc3339( $date );
    340         }
    341 
    342         return mysql_to_rfc3339( $date_gmt );
    343     }
    344 
    345     /**
    346268     * Prepares the revision for the REST response.
    347269     *
     
    412334     *
    413335     * @since 6.3.0
     336     * @since 6.6.0 Merged parent and parent controller schema data.
    414337     *
    415338     * @return array Item schema data.
     
    420343        }
    421344
    422         $schema = array(
    423             '$schema'    => 'http://json-schema.org/draft-04/schema#',
    424             'title'      => "{$this->parent_post_type}-revision",
    425             'type'       => 'object',
    426             // Base properties for every revision.
    427             'properties' => array(
    428 
    429                 /*
    430                  * Adds settings and styles from the WP_REST_Revisions_Controller item fields.
    431                  * Leaves out GUID as global styles shouldn't be accessible via URL.
    432                  */
    433                 'author'       => array(
    434                     'description' => __( 'The ID for the author of the revision.' ),
    435                     'type'        => 'integer',
    436                     'context'     => array( 'view', 'edit', 'embed' ),
    437                 ),
    438                 'date'         => array(
    439                     'description' => __( "The date the revision was published, in the site's timezone." ),
    440                     'type'        => 'string',
    441                     'format'      => 'date-time',
    442                     'context'     => array( 'view', 'edit', 'embed' ),
    443                 ),
    444                 'date_gmt'     => array(
    445                     'description' => __( 'The date the revision was published, as GMT.' ),
    446                     'type'        => 'string',
    447                     'format'      => 'date-time',
    448                     'context'     => array( 'view', 'edit' ),
    449                 ),
    450                 'id'           => array(
    451                     'description' => __( 'Unique identifier for the revision.' ),
    452                     'type'        => 'integer',
    453                     'context'     => array( 'view', 'edit', 'embed' ),
    454                 ),
    455                 'modified'     => array(
    456                     'description' => __( "The date the revision was last modified, in the site's timezone." ),
    457                     'type'        => 'string',
    458                     'format'      => 'date-time',
    459                     'context'     => array( 'view', 'edit' ),
    460                 ),
    461                 'modified_gmt' => array(
    462                     'description' => __( 'The date the revision was last modified, as GMT.' ),
    463                     'type'        => 'string',
    464                     'format'      => 'date-time',
    465                     'context'     => array( 'view', 'edit' ),
    466                 ),
    467                 'parent'       => array(
    468                     'description' => __( 'The ID for the parent of the revision.' ),
    469                     'type'        => 'integer',
    470                     'context'     => array( 'view', 'edit', 'embed' ),
    471                 ),
    472 
    473                 // Adds settings and styles from the WP_REST_Global_Styles_Controller parent schema.
    474                 'styles'       => array(
    475                     'description' => __( 'Global styles.' ),
    476                     'type'        => array( 'object' ),
    477                     'context'     => array( 'view', 'edit' ),
    478                 ),
    479                 'settings'     => array(
    480                     'description' => __( 'Global settings.' ),
    481                     'type'        => array( 'object' ),
    482                     'context'     => array( 'view', 'edit' ),
    483                 ),
    484             ),
    485         );
    486 
    487         $this->schema = $schema;
     345        $schema               = parent::get_item_schema();
     346        $parent_schema        = $this->parent_controller->get_item_schema();
     347        $schema['properties'] = array_merge( $schema['properties'], $parent_schema['properties'] );
     348
     349        unset(
     350            $schema['properties']['guid'],
     351            $schema['properties']['slug'],
     352            $schema['properties']['meta'],
     353            $schema['properties']['content'],
     354            $schema['properties']['title']
     355        );
     356
     357            $this->schema = $schema;
    488358
    489359        return $this->add_additional_fields_schema( $this->schema );
     
    491361
    492362    /**
    493      * Checks if a given request has access to read a single global style.
    494      *
    495      * @since 6.3.0
    496      *
    497      * @param WP_REST_Request $request Full details about the request.
    498      * @return true|WP_Error True if the request has read access, WP_Error object otherwise.
    499      */
    500     public function get_item_permissions_check( $request ) {
    501         $post = $this->get_parent( $request['parent'] );
    502         if ( is_wp_error( $post ) ) {
    503             return $post;
    504         }
    505 
    506         /*
    507          * The same check as WP_REST_Global_Styles_Controller::get_item_permissions_check.
    508          */
    509         if ( ! current_user_can( 'read_post', $post->ID ) ) {
    510             return new WP_Error(
    511                 'rest_cannot_view',
    512                 __( 'Sorry, you are not allowed to view revisions for this global style.' ),
    513                 array( 'status' => rest_authorization_required_code() )
    514             );
    515         }
    516 
    517         return true;
    518     }
    519 
    520     /**
    521      * Gets the parent post, if the ID is valid.
    522      *
    523      * Duplicate of WP_REST_Revisions_Controller::get_parent.
    524      *
    525      * @since 6.3.0
    526      *
    527      * @param int $parent_post_id Supplied ID.
    528      * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.
    529      */
    530     protected function get_parent( $parent_post_id ) {
    531         $error = new WP_Error(
    532             'rest_post_invalid_parent',
    533             __( 'Invalid post parent ID.' ),
    534             array( 'status' => 404 )
    535         );
    536 
    537         if ( (int) $parent_post_id <= 0 ) {
    538             return $error;
    539         }
    540 
    541         $parent_post = get_post( (int) $parent_post_id );
    542 
    543         if ( empty( $parent_post ) || empty( $parent_post->ID )
    544             || $this->parent_post_type !== $parent_post->post_type
    545         ) {
    546             return $error;
    547         }
    548 
    549         return $parent_post;
     363     * Retrieves the query params for collections.
     364     * Removes params that are not supported by global styles revisions.
     365     *
     366     * @since 6.6.0
     367     *
     368     * @return array Collection parameters.
     369     */
     370    public function get_collection_params() {
     371        $query_params = parent::get_collection_params();
     372        unset(
     373            $query_params['exclude'],
     374            $query_params['include'],
     375            $query_params['search'],
     376            $query_params['order'],
     377            $query_params['orderby']
     378        );
     379        return $query_params;
    550380    }
    551381}
  • trunk/src/wp-settings.php

    r58188 r58225  
    285285require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-attachments-controller.php';
    286286require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-global-styles-controller.php';
    287 require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php';
    288287require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-types-controller.php';
    289288require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-statuses-controller.php';
    290289require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-revisions-controller.php';
     290require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php';
    291291require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-template-revisions-controller.php';
    292292require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-autosaves-controller.php';
  • trunk/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php

    r57987 r58225  
    421421    /**
    422422     * @ticket 58524
     423     * @ticket 60131
    423424     *
    424425     * @covers WP_REST_Global_Styles_Controller::get_item_permissions_check
     
    429430        $response = rest_get_server()->dispatch( $request );
    430431
    431         $this->assertErrorResponse( 'rest_cannot_view', $response, 403 );
     432        $this->assertErrorResponse( 'rest_cannot_read', $response, 403 );
    432433    }
    433434
     
    830831     */
    831832    public function test_context_param() {
    832         // Controller does not implement test_context_param().
     833        // Controller does not implement get_context_param().
    833834    }
    834835
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r58216 r58225  
    66956695            ]
    66966696        },
     6697        "/wp/v2/global-styles/(?P<parent>[\\d]+)/revisions": {
     6698            "namespace": "wp/v2",
     6699            "methods": [
     6700                "GET"
     6701            ],
     6702            "endpoints": [
     6703                {
     6704                    "methods": [
     6705                        "GET"
     6706                    ],
     6707                    "args": {
     6708                        "parent": {
     6709                            "description": "The ID for the parent of the revision.",
     6710                            "type": "integer",
     6711                            "required": false
     6712                        },
     6713                        "context": {
     6714                            "description": "Scope under which the request is made; determines fields present in response.",
     6715                            "type": "string",
     6716                            "enum": [
     6717                                "view",
     6718                                "embed",
     6719                                "edit"
     6720                            ],
     6721                            "default": "view",
     6722                            "required": false
     6723                        },
     6724                        "page": {
     6725                            "description": "Current page of the collection.",
     6726                            "type": "integer",
     6727                            "default": 1,
     6728                            "minimum": 1,
     6729                            "required": false
     6730                        },
     6731                        "per_page": {
     6732                            "description": "Maximum number of items to be returned in result set.",
     6733                            "type": "integer",
     6734                            "minimum": 1,
     6735                            "maximum": 100,
     6736                            "required": false
     6737                        },
     6738                        "offset": {
     6739                            "description": "Offset the result set by a specific number of items.",
     6740                            "type": "integer",
     6741                            "required": false
     6742                        }
     6743                    }
     6744                }
     6745            ]
     6746        },
     6747        "/wp/v2/global-styles/(?P<parent>[\\d]+)/revisions/(?P<id>[\\d]+)": {
     6748            "namespace": "wp/v2",
     6749            "methods": [
     6750                "GET"
     6751            ],
     6752            "endpoints": [
     6753                {
     6754                    "methods": [
     6755                        "GET"
     6756                    ],
     6757                    "args": {
     6758                        "parent": {
     6759                            "description": "The ID for the parent of the global styles revision.",
     6760                            "type": "integer",
     6761                            "required": false
     6762                        },
     6763                        "id": {
     6764                            "description": "Unique identifier for the global styles revision.",
     6765                            "type": "integer",
     6766                            "required": false
     6767                        },
     6768                        "context": {
     6769                            "description": "Scope under which the request is made; determines fields present in response.",
     6770                            "type": "string",
     6771                            "enum": [
     6772                                "view",
     6773                                "embed",
     6774                                "edit"
     6775                            ],
     6776                            "default": "view",
     6777                            "required": false
     6778                        }
     6779                    }
     6780                }
     6781            ]
     6782        },
     6783        "/wp/v2/global-styles/themes/(?P<stylesheet>[\\/\\s%\\w\\.\\(\\)\\[\\]\\@_\\-]+)/variations": {
     6784            "namespace": "wp/v2",
     6785            "methods": [
     6786                "GET"
     6787            ],
     6788            "endpoints": [
     6789                {
     6790                    "methods": [
     6791                        "GET"
     6792                    ],
     6793                    "allow_batch": {
     6794                        "v1": false
     6795                    },
     6796                    "args": {
     6797                        "stylesheet": {
     6798                            "description": "The theme identifier",
     6799                            "type": "string",
     6800                            "required": false
     6801                        }
     6802                    }
     6803                }
     6804            ]
     6805        },
     6806        "/wp/v2/global-styles/themes/(?P<stylesheet>[^\\/:<>\\*\\?\"\\|]+(?:\\/[^\\/:<>\\*\\?\"\\|]+)?)": {
     6807            "namespace": "wp/v2",
     6808            "methods": [
     6809                "GET"
     6810            ],
     6811            "endpoints": [
     6812                {
     6813                    "methods": [
     6814                        "GET"
     6815                    ],
     6816                    "allow_batch": {
     6817                        "v1": false
     6818                    },
     6819                    "args": {
     6820                        "stylesheet": {
     6821                            "description": "The theme identifier",
     6822                            "type": "string",
     6823                            "required": false
     6824                        }
     6825                    }
     6826                }
     6827            ]
     6828        },
     6829        "/wp/v2/global-styles/(?P<id>[\\/\\w-]+)": {
     6830            "namespace": "wp/v2",
     6831            "methods": [
     6832                "GET",
     6833                "POST",
     6834                "PUT",
     6835                "PATCH"
     6836            ],
     6837            "endpoints": [
     6838                {
     6839                    "methods": [
     6840                        "GET"
     6841                    ],
     6842                    "allow_batch": {
     6843                        "v1": false
     6844                    },
     6845                    "args": {
     6846                        "id": {
     6847                            "description": "The id of a template",
     6848                            "type": "string",
     6849                            "required": false
     6850                        }
     6851                    }
     6852                },
     6853                {
     6854                    "methods": [
     6855                        "POST",
     6856                        "PUT",
     6857                        "PATCH"
     6858                    ],
     6859                    "allow_batch": {
     6860                        "v1": false
     6861                    },
     6862                    "args": {
     6863                        "styles": {
     6864                            "description": "Global styles.",
     6865                            "type": [
     6866                                "object"
     6867                            ],
     6868                            "required": false
     6869                        },
     6870                        "settings": {
     6871                            "description": "Global settings.",
     6872                            "type": [
     6873                                "object"
     6874                            ],
     6875                            "required": false
     6876                        },
     6877                        "title": {
     6878                            "description": "Title of the global styles variation.",
     6879                            "type": [
     6880                                "object",
     6881                                "string"
     6882                            ],
     6883                            "properties": {
     6884                                "raw": {
     6885                                    "description": "Title for the global styles variation, as it exists in the database.",
     6886                                    "type": "string",
     6887                                    "context": [
     6888                                        "view",
     6889                                        "edit",
     6890                                        "embed"
     6891                                    ]
     6892                                },
     6893                                "rendered": {
     6894                                    "description": "HTML title for the post, transformed for display.",
     6895                                    "type": "string",
     6896                                    "context": [
     6897                                        "view",
     6898                                        "edit",
     6899                                        "embed"
     6900                                    ],
     6901                                    "readonly": true
     6902                                }
     6903                            },
     6904                            "required": false
     6905                        }
     6906                    }
     6907                }
     6908            ]
     6909        },
    66976910        "/wp/v2/navigation": {
    66986911            "namespace": "wp/v2",
     
    92889501                                    "wp_template": "wp_template",
    92899502                                    "wp_template_part": "wp_template_part",
     9503                                    "wp_global_styles": "wp_global_styles",
    92909504                                    "wp_navigation": "wp_navigation",
    92919505                                    "wp_font_family": "wp_font_family",
     
    1049610710                            ],
    1049710711                            "default": "view",
    10498                             "required": false
    10499                         }
    10500                     }
    10501                 }
    10502             ]
    10503         },
    10504         "/wp/v2/global-styles/(?P<parent>[\\d]+)/revisions": {
    10505             "namespace": "wp/v2",
    10506             "methods": [
    10507                 "GET"
    10508             ],
    10509             "endpoints": [
    10510                 {
    10511                     "methods": [
    10512                         "GET"
    10513                     ],
    10514                     "args": {
    10515                         "parent": {
    10516                             "description": "The ID for the parent of the revision.",
    10517                             "type": "integer",
    10518                             "required": false
    10519                         },
    10520                         "context": {
    10521                             "description": "Scope under which the request is made; determines fields present in response.",
    10522                             "type": "string",
    10523                             "enum": [
    10524                                 "view",
    10525                                 "embed",
    10526                                 "edit"
    10527                             ],
    10528                             "default": "view",
    10529                             "required": false
    10530                         },
    10531                         "page": {
    10532                             "description": "Current page of the collection.",
    10533                             "type": "integer",
    10534                             "default": 1,
    10535                             "minimum": 1,
    10536                             "required": false
    10537                         },
    10538                         "per_page": {
    10539                             "description": "Maximum number of items to be returned in result set.",
    10540                             "type": "integer",
    10541                             "minimum": 1,
    10542                             "maximum": 100,
    10543                             "required": false
    10544                         },
    10545                         "offset": {
    10546                             "description": "Offset the result set by a specific number of items.",
    10547                             "type": "integer",
    10548                             "required": false
    10549                         }
    10550                     }
    10551                 }
    10552             ]
    10553         },
    10554         "/wp/v2/global-styles/(?P<parent>[\\d]+)/revisions/(?P<id>[\\d]+)": {
    10555             "namespace": "wp/v2",
    10556             "methods": [
    10557                 "GET"
    10558             ],
    10559             "endpoints": [
    10560                 {
    10561                     "methods": [
    10562                         "GET"
    10563                     ],
    10564                     "args": {
    10565                         "parent": {
    10566                             "description": "The ID for the parent of the global styles revision.",
    10567                             "type": "integer",
    10568                             "required": false
    10569                         },
    10570                         "id": {
    10571                             "description": "Unique identifier for the global styles revision.",
    10572                             "type": "integer",
    10573                             "required": false
    10574                         },
    10575                         "context": {
    10576                             "description": "Scope under which the request is made; determines fields present in response.",
    10577                             "type": "string",
    10578                             "enum": [
    10579                                 "view",
    10580                                 "embed",
    10581                                 "edit"
    10582                             ],
    10583                             "default": "view",
    10584                             "required": false
    10585                         }
    10586                     }
    10587                 }
    10588             ]
    10589         },
    10590         "/wp/v2/global-styles/themes/(?P<stylesheet>[\\/\\s%\\w\\.\\(\\)\\[\\]\\@_\\-]+)/variations": {
    10591             "namespace": "wp/v2",
    10592             "methods": [
    10593                 "GET"
    10594             ],
    10595             "endpoints": [
    10596                 {
    10597                     "methods": [
    10598                         "GET"
    10599                     ],
    10600                     "args": {
    10601                         "stylesheet": {
    10602                             "description": "The theme identifier",
    10603                             "type": "string",
    10604                             "required": false
    10605                         }
    10606                     }
    10607                 }
    10608             ]
    10609         },
    10610         "/wp/v2/global-styles/themes/(?P<stylesheet>[^\\/:<>\\*\\?\"\\|]+(?:\\/[^\\/:<>\\*\\?\"\\|]+)?)": {
    10611             "namespace": "wp/v2",
    10612             "methods": [
    10613                 "GET"
    10614             ],
    10615             "endpoints": [
    10616                 {
    10617                     "methods": [
    10618                         "GET"
    10619                     ],
    10620                     "args": {
    10621                         "stylesheet": {
    10622                             "description": "The theme identifier",
    10623                             "type": "string",
    10624                             "required": false
    10625                         }
    10626                     }
    10627                 }
    10628             ]
    10629         },
    10630         "/wp/v2/global-styles/(?P<id>[\\/\\w-]+)": {
    10631             "namespace": "wp/v2",
    10632             "methods": [
    10633                 "GET",
    10634                 "POST",
    10635                 "PUT",
    10636                 "PATCH"
    10637             ],
    10638             "endpoints": [
    10639                 {
    10640                     "methods": [
    10641                         "GET"
    10642                     ],
    10643                     "args": {
    10644                         "id": {
    10645                             "description": "The id of a template",
    10646                             "type": "string",
    10647                             "required": false
    10648                         }
    10649                     }
    10650                 },
    10651                 {
    10652                     "methods": [
    10653                         "POST",
    10654                         "PUT",
    10655                         "PATCH"
    10656                     ],
    10657                     "args": {
    10658                         "styles": {
    10659                             "description": "Global styles.",
    10660                             "type": [
    10661                                 "object"
    10662                             ],
    10663                             "required": false
    10664                         },
    10665                         "settings": {
    10666                             "description": "Global settings.",
    10667                             "type": [
    10668                                 "object"
    10669                             ],
    10670                             "required": false
    10671                         },
    10672                         "title": {
    10673                             "description": "Title of the global styles variation.",
    10674                             "type": [
    10675                                 "object",
    10676                                 "string"
    10677                             ],
    10678                             "properties": {
    10679                                 "raw": {
    10680                                     "description": "Title for the global styles variation, as it exists in the database.",
    10681                                     "type": "string",
    10682                                     "context": [
    10683                                         "view",
    10684                                         "edit",
    10685                                         "embed"
    10686                                     ]
    10687                                 },
    10688                                 "rendered": {
    10689                                     "description": "HTML title for the post, transformed for display.",
    10690                                     "type": "string",
    10691                                     "context": [
    10692                                         "view",
    10693                                         "edit",
    10694                                         "embed"
    10695                                     ],
    10696                                     "readonly": true
    10697                                 }
    10698                             },
    1069910712                            "required": false
    1070010713                        }
     
    1312513138        }
    1312613139    },
     13140    "wp_global_styles": {
     13141        "description": "Global styles to include in themes.",
     13142        "hierarchical": false,
     13143        "has_archive": false,
     13144        "name": "Global Styles",
     13145        "slug": "wp_global_styles",
     13146        "icon": null,
     13147        "taxonomies": [],
     13148        "rest_base": "global-styles",
     13149        "rest_namespace": "wp/v2",
     13150        "_links": {
     13151            "collection": [
     13152                {
     13153                    "href": "http://example.org/index.php?rest_route=/wp/v2/types"
     13154                }
     13155            ],
     13156            "wp:items": [
     13157                {
     13158                    "href": "http://example.org/index.php?rest_route=/wp/v2/global-styles"
     13159                }
     13160            ],
     13161            "curies": [
     13162                {
     13163                    "name": "wp",
     13164                    "href": "https://api.w.org/{rel}",
     13165                    "templated": true
     13166                }
     13167            ]
     13168        }
     13169    },
    1312713170    "wp_navigation": {
    1312813171        "description": "Navigation menus that can be inserted into your site.",
Note: See TracChangeset for help on using the changeset viewer.