Make WordPress Core

Changeset 57624

Timestamp:
02/13/2024 02:07:38 PM (6 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.

Location:
trunk
Files:
8 edited

Legend:

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

    r56819 r57624  
    914914     *
    915915     * @since 6.4.0
     916
    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 ( ) {
    926927            return null;
    927928        }
  • trunk/src/wp-includes/post.php

    r57548 r57624  
    474474        'wp_global_styles',
    475475        array(
    476             'label'        => _x( 'Global Styles', 'post type general name' ),
    477             'description'  => __( 'Global styles to include in themes.' ),
    478             'public'       => false,
    479             '_builtin'     => true, /* internal use only. don't use this when registering your own post type. */
    480             '_edit_link'   => '/site-editor.php?canvas=edit', /* internal use only. don't use this when registering your own post type. */
    481             'show_ui'      => false,
    482             'show_in_rest' => false,
    483             'rewrite'      => false,
    484             'capabilities' => array(
     476            'label'                           => _x( 'Global Styles', 'post type general name' ),
     477            'description'                     => __( 'Global styles to include in themes.' ),
     478            'public'                          => false,
     479            '_builtin'                        => true, /* internal use only. don't use this when registering your own post type. */
     480            '_edit_link'                      => '/site-editor.php?canvas=edit', /* internal use only. don't use this when registering your own post type. */
     481            'show_ui'                         => false,
     482            'show_in_rest'                    => true,
     483            'rewrite'                         => false,
     484            'rest_base'                       => 'global-styles',
     485            'rest_controller_class'           => 'WP_REST_Global_Styles_Controller',
     486            'revisions_rest_controller_class' => 'WP_REST_Global_Styles_Revisions_Controller',
     487            'late_route_registration'         => true,
     488            'capabilities'                    => array(
    485489                'read'                   => 'edit_theme_options',
    486490                'create_posts'           => 'edit_theme_options',
     
    491495                'delete_others_posts'    => 'edit_theme_options',
    492496            ),
    493             'map_meta_cap' => true,
    494             'supports'     => array(
     497            'map_meta_cap' => true,
     498            'supports'     => array(
    495499                'title',
    496500                'editor',
  • trunk/src/wp-includes/rest-api.php

    r57548 r57624  
    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

    r56753 r57624  
    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;
    22 
    23     /**
    24      * 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';
    31     }
     13class WP_REST_Global_Styles_Controller extends WP_REST_Posts_Controller {
     14    /**
     15     * Whether the controller supports batching.
     16     *
     17     * @since 6.5.0
     18     * @var array
     19     */
     20    protected $allow_batch = array( 'v1' => false );
    3221
    3322    /**
     
    195184     * @return bool Whether the post can be read.
    196185     */
    197     protected function check_read_permission( $post ) {
     186    p function check_read_permission( $post ) {
    198187        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 );
    217188    }
    218189
     
    240211
    241212        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 );
    291213    }
    292214
     
    408330            $response->add_links( $links );
    409331            if ( ! empty( $links['self']['href'] ) ) {
    410                 $actions = $this->get_available_actions();
     332                $actions = $this->get_available_actions();
    411333                $self    = $links['self']['href'];
    412334                foreach ( $actions as $rel ) {
     
    432354
    433355        $links = array(
    434             'self' => array(
     356            'self' => array(
    435357                'href' => rest_url( trailingslashit( $base ) . $id ),
     358
     359
     360
    436361            ),
    437362        );
     
    455380     * @since 5.9.0
    456381     * @since 6.2.0 Added 'edit-css' action.
    457      *
     382     * @since 6.5.0 Added $post and $request parameters.
     383     *
     384     * @param WP_Post         $post    Post object.
     385     * @param WP_REST_Request $request Request object.
    458386     * @return array List of link relations.
    459387     */
    460     protected function get_available_actions() {
     388    protected function get_available_actions() {
    461389        $rels = array();
    462390
    463         $post_type = get_post_type_object( $this->post_type );
     391        $post_type = get_post_type_object( $->post_type );
    464392        if ( current_user_can( $post_type->cap->publish_posts ) ) {
    465393            $rels[] = 'https://api.w.org/action-publish';
     
    471399
    472400        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';
    488401    }
    489402
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php

    r57494 r57624  
    1515 * @see WP_REST_Controller
    1616 */
    17 class WP_REST_Global_Styles_Revisions_Controller extends WP_REST_Controller {
    18     /**
    19      * Parent post type.
     17class WP_REST_Global_Styles_Revisions_Controller extends WP_REST_Revisions_Controller {
     18    /**
     19     * Parent controller.
     20     *
     21     * @since 6.5.0
     22     * @var WP_REST_Controller
     23     */
     24    private $parent_controller;
     25
     26    /**
     27     * The base of the parent controller's route.
    2028     *
    2129     * @since 6.3.0
    2230     * @var string
    2331     */
    24     protected $parent_post_type;
    25 
    26     /**
    27      * The base of the parent controller's route.
    28      *
    29      * @since 6.3.0
    30      * @var string
    31      */
    3232    protected $parent_base;
    3333
     
    3636     *
    3737     * @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';
     38     * @since 6.5.0 Extends class from WP_REST_Revisions_Controller.
     39     *
     40     * @param string $parent_post_type Post type of the parent.
     41     */
     42    public function __construct( $parent_post_type ) {
     43        parent::__construct( $parent_post_type );
     44        $post_type_object  = get_post_type_object( $parent_post_type );
     45        $parent_controller = $post_type_object->get_rest_controller();
     46
     47        if ( ! $parent_controller ) {
     48            $parent_controller = new WP_REST_Global_Styles_Controller( $parent_post_type );
     49        }
     50
     51        $this->parent_controller = $parent_controller;
     52        $this->rest_base         = 'revisions';
     53        $this->parent_base       = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name;
     54        $this->namespace         = ! empty( $post_type_object->rest_namespace ) ? $post_type_object->rest_namespace : 'wp/v2';
    4455    }
    4556
     
    6475                    'methods'             => WP_REST_Server::READABLE,
    6576                    'callback'            => array( $this, 'get_items' ),
    66                     'permission_callback' => array( $this, 'get_item_permissions_check' ),
     77                    'permission_callback' => array( $this, 'get_item_permissions_check' ),
    6778                    'args'                => $this->get_collection_params(),
    6879                ),
     
    99110
    100111    /**
    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     /**
    124112     * Returns decoded JSON from post content string,
    125113     * or a 404 if not found.
     
    270258
    271259    /**
    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     /**
    346260     * Prepares the revision for the REST response.
    347261     *
     
    412326     *
    413327     * @since 6.3.0
     328
    414329     *
    415330     * @return array Item schema data.
     
    420335        }
    421336
    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         );
     337        $schema               = parent::get_item_schema();
     338        $parent_schema        = $this->parent_controller->get_item_schema();
     339        $schema['properties'] = array_merge( $schema['properties'], $parent_schema['properties'] );
     340
     341        unset( $schema['properties']['guid'] );
     342        unset( $schema['properties']['slug'] );
     343        unset( $schema['properties']['meta'] );
     344        unset( $schema['properties']['content'] );
     345        unset( $schema['properties']['title'] );
    486346
    487347        $this->schema = $schema;
     
    491351
    492352    /**
    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;
     353     * Retrieves the query params for collections.
     354     * Removes params that are not supported by global styles revisions.
     355     *
     356     * @since 6.5.0
     357     *
     358     * @return array Collection parameters.
     359     */
     360    public function get_collection_params() {
     361        $query_params = parent::get_collection_params();
     362        unset( $query_params['exclude'] );
     363        unset( $query_params['include'] );
     364        unset( $query_params['search'] );
     365        unset( $query_params['order'] );
     366        unset( $query_params['orderby'] );
     367        return $query_params;
    550368    }
    551369}
  • trunk/src/wp-settings.php

    r57622 r57624  
    277277require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-attachments-controller.php';
    278278require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-global-styles-controller.php';
    279 require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php';
    280279require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-types-controller.php';
    281280require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-statuses-controller.php';
    282281require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-revisions-controller.php';
     282
    283283require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-template-revisions-controller.php';
    284284require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-autosaves-controller.php';
  • trunk/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php

    r57494 r57624  
    421421    /**
    422422     * @ticket 58524
     423
    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_', $response, 403 );
    432433    }
    433434
     
    830831     */
    831832    public function test_context_param() {
    832         // Controller does not implement test_context_param().
     833        // Controller does not implement t_context_param().
    833834    }
    834835
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r57603 r57624  
    58065806                            "default": false,
    58075807                            "description": "Whether to bypass Trash and force deletion.",
     5808
     5809
     5810
     5811
     5812
     5813
     5814
     5815
     5816
     5817
     5818
     5819
     5820
     5821
     5822
     5823
     5824
     5825
     5826
     5827
     5828
     5829
     5830
     5831
     5832
     5833
     5834
     5835
     5836
     5837
     5838
     5839
     5840
     5841
     5842
     5843
     5844
     5845
     5846
     5847
     5848
     5849
     5850
     5851
     5852
     5853
     5854
     5855
     5856
     5857
     5858
     5859
     5860
     5861
     5862
     5863
     5864
     5865
     5866
     5867
     5868
     5869
     5870
     5871
     5872
     5873
     5874
     5875
     5876
     5877
     5878
     5879
     5880
     5881
     5882
     5883
     5884
     5885
     5886
     5887
     5888
     5889
     5890
     5891
     5892
     5893
     5894
     5895
     5896
     5897
     5898
     5899
     5900
     5901
     5902
     5903
     5904
     5905
     5906
     5907
     5908
     5909
     5910
     5911
     5912
     5913
     5914
     5915
     5916
     5917
     5918
     5919
     5920
     5921
     5922
     5923
     5924
     5925
     5926
     5927
     5928
     5929
     5930
     5931
     5932
     5933
     5934
     5935
     5936
     5937
     5938
     5939
     5940
     5941
     5942
     5943
     5944
     5945
     5946
     5947
     5948
     5949
     5950
     5951
     5952
     5953
     5954
     5955
     5956
     5957
     5958
     5959
     5960
     5961
     5962
     5963
     5964
     5965
     5966
     5967
     5968
     5969
     5970
     5971
     5972
     5973
     5974
     5975
     5976
     5977
     5978
     5979
     5980
     5981
     5982
     5983
     5984
     5985
     5986
     5987
     5988
     5989
     5990
     5991
     5992
     5993
     5994
     5995
     5996
     5997
     5998
     5999
     6000
     6001
     6002
     6003
     6004
     6005
     6006
     6007
     6008
    58086009                            "required": false
    58096010                        }
     
    91709371                                    "wp_template": "wp_template",
    91719372                                    "wp_template_part": "wp_template_part",
     9373
    91729374                                    "wp_navigation": "wp_navigation",
    91739375                                    "wp_font_family": "wp_font_family",
     
    1037610578                            ],
    1037710579                            "default": "view",
    10378                             "required": false
    10379                         }
    10380                     }
    10381                 }
    10382             ]
    10383         },
    10384         "/wp/v2/global-styles/(?P<parent>[\\d]+)/revisions": {
    10385             "namespace": "wp/v2",
    10386             "methods": [
    10387                 "GET"
    10388             ],
    10389             "endpoints": [
    10390                 {
    10391                     "methods": [
    10392                         "GET"
    10393                     ],
    10394                     "args": {
    10395                         "parent": {
    10396                             "description": "The ID for the parent of the revision.",
    10397                             "type": "integer",
    10398                             "required": false
    10399                         },
    10400                         "context": {
    10401                             "description": "Scope under which the request is made; determines fields present in response.",
    10402                             "type": "string",
    10403                             "enum": [
    10404                                 "view",
    10405                                 "embed",
    10406                                 "edit"
    10407                             ],
    10408                             "default": "view",
    10409                             "required": false
    10410                         },
    10411                         "page": {
    10412                             "description": "Current page of the collection.",
    10413                             "type": "integer",
    10414                             "default": 1,
    10415                             "minimum": 1,
    10416                             "required": false
    10417                         },
    10418                         "per_page": {
    10419                             "description": "Maximum number of items to be returned in result set.",
    10420                             "type": "integer",
    10421                             "minimum": 1,
    10422                             "maximum": 100,
    10423                             "required": false
    10424                         },
    10425                         "offset": {
    10426                             "description": "Offset the result set by a specific number of items.",
    10427                             "type": "integer",
    10428                             "required": false
    10429                         }
    10430                     }
    10431                 }
    10432             ]
    10433         },
    10434         "/wp/v2/global-styles/(?P<parent>[\\d]+)/revisions/(?P<id>[\\d]+)": {
    10435             "namespace": "wp/v2",
    10436             "methods": [
    10437                 "GET"
    10438             ],
    10439             "endpoints": [
    10440                 {
    10441                     "methods": [
    10442                         "GET"
    10443                     ],
    10444                     "args": {
    10445                         "parent": {
    10446                             "description": "The ID for the parent of the global styles revision.",
    10447                             "type": "integer",
    10448                             "required": false
    10449                         },
    10450                         "id": {
    10451                             "description": "Unique identifier for the global styles revision.",
    10452                             "type": "integer",
    10453                             "required": false
    10454                         },
    10455                         "context": {
    10456                             "description": "Scope under which the request is made; determines fields present in response.",
    10457                             "type": "string",
    10458                             "enum": [
    10459                                 "view",
    10460                                 "embed",
    10461                                 "edit"
    10462                             ],
    10463                             "default": "view",
    10464                             "required": false
    10465                         }
    10466                     }
    10467                 }
    10468             ]
    10469         },
    10470         "/wp/v2/global-styles/themes/(?P<stylesheet>[\\/\\s%\\w\\.\\(\\)\\[\\]\\@_\\-]+)/variations": {
    10471             "namespace": "wp/v2",
    10472             "methods": [
    10473                 "GET"
    10474             ],
    10475             "endpoints": [
    10476                 {
    10477                     "methods": [
    10478                         "GET"
    10479                     ],
    10480                     "args": {
    10481                         "stylesheet": {
    10482                             "description": "The theme identifier",
    10483                             "type": "string",
    10484                             "required": false
    10485                         }
    10486                     }
    10487                 }
    10488             ]
    10489         },
    10490         "/wp/v2/global-styles/themes/(?P<stylesheet>[^\\/:<>\\*\\?\"\\|]+(?:\\/[^\\/:<>\\*\\?\"\\|]+)?)": {
    10491             "namespace": "wp/v2",
    10492             "methods": [
    10493                 "GET"
    10494             ],
    10495             "endpoints": [
    10496                 {
    10497                     "methods": [
    10498                         "GET"
    10499                     ],
    10500                     "args": {
    10501                         "stylesheet": {
    10502                             "description": "The theme identifier",
    10503                             "type": "string",
    10504                             "required": false
    10505                         }
    10506                     }
    10507                 }
    10508             ]
    10509         },
    10510         "/wp/v2/global-styles/(?P<id>[\\/\\w-]+)": {
    10511             "namespace": "wp/v2",
    10512             "methods": [
    10513                 "GET",
    10514                 "POST",
    10515                 "PUT",
    10516                 "PATCH"
    10517             ],
    10518             "endpoints": [
    10519                 {
    10520                     "methods": [
    10521                         "GET"
    10522                     ],
    10523                     "args": {
    10524                         "id": {
    10525                             "description": "The id of a template",
    10526                             "type": "string",
    10527                             "required": false
    10528                         }
    10529                     }
    10530                 },
    10531                 {
    10532                     "methods": [
    10533                         "POST",
    10534                         "PUT",
    10535                         "PATCH"
    10536                     ],
    10537                     "args": {
    10538                         "styles": {
    10539                             "description": "Global styles.",
    10540                             "type": [
    10541                                 "object"
    10542                             ],
    10543                             "required": false
    10544                         },
    10545                         "settings": {
    10546                             "description": "Global settings.",
    10547                             "type": [
    10548                                 "object"
    10549                             ],
    10550                             "required": false
    10551                         },
    10552                         "title": {
    10553                             "description": "Title of the global styles variation.",
    10554                             "type": [
    10555                                 "object",
    10556                                 "string"
    10557                             ],
    10558                             "properties": {
    10559                                 "raw": {
    10560                                     "description": "Title for the global styles variation, as it exists in the database.",
    10561                                     "type": "string",
    10562                                     "context": [
    10563                                         "view",
    10564                                         "edit",
    10565                                         "embed"
    10566                                     ]
    10567                                 },
    10568                                 "rendered": {
    10569                                     "description": "HTML title for the post, transformed for display.",
    10570                                     "type": "string",
    10571                                     "context": [
    10572                                         "view",
    10573                                         "edit",
    10574                                         "embed"
    10575                                     ],
    10576                                     "readonly": true
    10577                                 }
    10578                             },
    1057910580                            "required": false
    1058010581                        }
     
    1297512976        }
    1297612977    },
     12978
     12979
     12980
     12981
     12982
     12983
     12984
     12985
     12986
     12987
     12988
     12989
     12990
     12991
     12992
     12993
     12994
     12995
     12996
     12997
     12998
     12999
     13000
     13001
     13002
     13003
     13004
     13005
     13006
     13007
    1297713008    "wp_navigation": {
    1297813009        "description": "Navigation menus that can be inserted into your site.",
Note: See TracChangeset for help on using the changeset viewer.