Make WordPress Core


Ignore:
Timestamp:
06/27/2025 08:45:08 PM (14 months ago)
Author:
johnbillion
Message:

Posts, Post Types: Correct the schema for the id property of the global styles REST API endpoint.

This property is an integer as it corresponds to a post ID.

Props narenin, TimothyBlynJacobs, audrasjb, johnbillion, mikinc860, abcd95

Fixes #61911

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php

    r59048 r60359  
    8989                register_rest_route(
    9090                        $this->namespace,
    91                         '/' . $this->rest_base . '/(?P<id>[\/\w-]+)',
     91                        '/' . $this->rest_base . '/(?P<id>[\/\d+]+)',
    9292                        array(
    9393                                array(
     
    9797                                        'args'                => array(
    9898                                                'id' => array(
    99                                                         'description'       => __( 'The id of a template' ),
    100                                                         'type'              => 'string',
    101                                                         'sanitize_callback' => array( $this, '_sanitize_global_styles_callback' ),
     99                                                        'description' => __( 'ID of global styles config.' ),
     100                                                        'type'        => 'integer',
    102101                                                ),
    103102                                        ),
     
    116115
    117116        /**
    118          * Sanitize the global styles ID or stylesheet to decode endpoint.
     117         * Sanitize the global styles stylesheet to decode endpoint.
    119118         * For example, `wp/v2/global-styles/twentytwentytwo%200.4.0`
    120119         * would be decoded to `twentytwentytwo 0.4.0`.
     
    122121         * @since 5.9.0
    123122         *
    124          * @param string $id_or_stylesheet Global styles ID or stylesheet.
    125          * @return string Sanitized global styles ID or stylesheet.
    126          */
    127         public function _sanitize_global_styles_callback( $id_or_stylesheet ) {
    128                 return urldecode( $id_or_stylesheet );
     123         * @param string $stylesheet Global styles stylesheet.
     124         * @return string Sanitized global styles stylesheet.
     125         */
     126        public function _sanitize_global_styles_callback( $stylesheet ) {
     127                return urldecode( $stylesheet );
    129128        }
    130129
     
    140139                $error = new WP_Error(
    141140                        'rest_global_styles_not_found',
    142                         __( 'No global styles config exist with that id.' ),
     141                        __( 'No global styles config exists with that ID.' ),
    143142                        array( 'status' => 404 )
    144143                );
     
    465464                                'id'       => array(
    466465                                        'description' => __( 'ID of global styles config.' ),
    467                                         'type'        => 'string',
     466                                        'type'        => 'integer',
    468467                                        'context'     => array( 'embed', 'view', 'edit' ),
    469468                                        'readonly'    => true,
Note: See TracChangeset for help on using the changeset viewer.