Make WordPress Core

Changeset 58225

Timestamp:
05/28/2024 12:38:28 PM (2 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
     509
    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
    5354                ),
    5455            )
     
    8081                        ),
    8182                    ),
     83
    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    p 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();
    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
     374
    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() {
    461403        $rels = array();
    462404
    463         $post_type = get_post_type_object( $this->post_type );
     405        $post_type = get_post_type_object( $->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..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..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_item_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
    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';
     290
    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
    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

    r58216 r58225  
    66956695            ]
    66966696        },
     6697
     6698
     6699
     6700
     6701
     6702
     6703
     6704
     6705
     6706
     6707
     6708
     6709
     6710
     6711
     6712
     6713
     6714
     6715
     6716
     6717
     6718
     6719
     6720
     6721
     6722
     6723
     6724
     6725
     6726
     6727
     6728
     6729
     6730
     6731
     6732
     6733
     6734
     6735
     6736
     6737
     6738
     6739
     6740
     6741
     6742
     6743
     6744
     6745
     6746
     6747
     6748
     6749
     6750
     6751
     6752
     6753
     6754
     6755
     6756
     6757
     6758
     6759
     6760
     6761
     6762
     6763
     6764
     6765
     6766
     6767
     6768
     6769
     6770
     6771
     6772
     6773
     6774
     6775
     6776
     6777
     6778
     6779
     6780
     6781
     6782
     6783
     6784
     6785
     6786
     6787
     6788
     6789
     6790
     6791
     6792
     6793
     6794
     6795
     6796
     6797
     6798
     6799
     6800
     6801
     6802
     6803
     6804
     6805
     6806
     6807
     6808
     6809
     6810
     6811
     6812
     6813
     6814
     6815
     6816
     6817
     6818
     6819
     6820
     6821
     6822
     6823
     6824
     6825
     6826
     6827
     6828
     6829
     6830
     6831
     6832
     6833
     6834
     6835
     6836
     6837
     6838
     6839
     6840
     6841
     6842
     6843
     6844
     6845
     6846
     6847
     6848
     6849
     6850
     6851
     6852
     6853
     6854
     6855
     6856
     6857
     6858
     6859
     6860
     6861
     6862
     6863
     6864
     6865
     6866
     6867
     6868
     6869
     6870
     6871
     6872
     6873
     6874
     6875
     6876
     6877
     6878
     6879
     6880
     6881
     6882
     6883
     6884
     6885
     6886
     6887
     6888
     6889
     6890
     6891
     6892
     6893
     6894
     6895
     6896
     6897
     6898
     6899
     6900
     6901
     6902
     6903
     6904
     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
    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
     13141
     13142
     13143
     13144
     13145
     13146
     13147
     13148
     13149
     13150
     13151
     13152
     13153
     13154
     13155
     13156
     13157
     13158
     13159
     13160
     13161
     13162
     13163
     13164
     13165
     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.