Make WordPress Core

Changeset 53218


Ignore:
Timestamp:
04/19/2022 02:56:40 PM (3 years ago)
Author:
gziolo
Message:

REST API: Add array argument to getItems for Pattern Directory endopoint

Since http://api.wordpress.org/patterns API supports array parameters, there is no need to implode slug values inside the _register_remote_theme_patterns function.
Both WP_REST_Pattern_Directory_Controller and _register_remote_theme_patternsmust be updated to support array request arguments.

Props antonvlasenko.
Fixes #55574.
Follow-up #55505, [53152].

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

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

    r53152 r53218  
    156156
    157157    $request         = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
    158     $request['slug'] = implode( ',', $pattern_settings );
     158    $request['slug'] = $pattern_settings;
    159159    $response        = rest_do_request( $request );
    160160    if ( $response->is_error() ) {
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php

    r53152 r53218  
    2626     */
    2727    public function __construct() {
    28         $this->namespace     = 'wp/v2';
    29             $this->rest_base = 'pattern-directory';
     28        $this->namespace = 'wp/v2';
     29        $this->rest_base = 'pattern-directory';
    3030    }
    3131
     
    138138
    139139        if ( ! $raw_patterns ) {
    140             $api_url = add_query_arg(
    141                 array_map( 'rawurlencode', $query_args ),
    142                 'http://api.wordpress.org/patterns/1.0/'
    143             );
    144 
     140            $api_url = 'http://api.wordpress.org/patterns/1.0/?' . build_query( $query_args );
    145141            if ( wp_http_supports( array( 'ssl' ) ) ) {
    146142                $api_url = set_url_scheme( $api_url, 'https' );
Note: See TracChangeset for help on using the changeset viewer.