From c795115b0a23d302b6dc50d7cbaa411ef21ce970 Mon Sep 17 00:00:00 2001 From: gziolo Date: Tue, 19 Apr 2022 14:58:09 +0000 Subject: [PATCH] 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]. Built from https://develop.svn.wordpress.org/trunk@53218 git-svn-id: http://core.svn.wordpress.org/trunk@52807 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/block-patterns.php | 2 +- .../class-wp-rest-pattern-directory-controller.php | 10 +++------- wp-includes/version.php | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/wp-includes/block-patterns.php b/wp-includes/block-patterns.php index 0498db7e01..8b922e7dd1 100644 --- a/wp-includes/block-patterns.php +++ b/wp-includes/block-patterns.php @@ -155,7 +155,7 @@ function _register_remote_theme_patterns() { } $request = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' ); - $request['slug'] = implode( ',', $pattern_settings ); + $request['slug'] = $pattern_settings; $response = rest_do_request( $request ); if ( $response->is_error() ) { return; diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php index 2deb3c7e7a..28f42fd5a4 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php @@ -25,8 +25,8 @@ class WP_REST_Pattern_Directory_Controller extends WP_REST_Controller { * @since 5.8.0 */ public function __construct() { - $this->namespace = 'wp/v2'; - $this->rest_base = 'pattern-directory'; + $this->namespace = 'wp/v2'; + $this->rest_base = 'pattern-directory'; } /** @@ -137,11 +137,7 @@ class WP_REST_Pattern_Directory_Controller extends WP_REST_Controller { $raw_patterns = get_site_transient( $transient_key ); if ( ! $raw_patterns ) { - $api_url = add_query_arg( - array_map( 'rawurlencode', $query_args ), - 'http://api.wordpress.org/patterns/1.0/' - ); - + $api_url = 'http://api.wordpress.org/patterns/1.0/?' . build_query( $query_args ); if ( wp_http_supports( array( 'ssl' ) ) ) { $api_url = set_url_scheme( $api_url, 'https' ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 57b40480c4..a4e328df30 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-beta1-53217'; +$wp_version = '6.0-beta1-53218'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.