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
This commit is contained in:
gziolo 2022-04-19 14:58:09 +00:00
parent d2e9cf1f81
commit c795115b0a
3 changed files with 5 additions and 9 deletions

View File

@ -155,7 +155,7 @@ function _register_remote_theme_patterns() {
} }
$request = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/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 ); $response = rest_do_request( $request );
if ( $response->is_error() ) { if ( $response->is_error() ) {
return; return;

View File

@ -25,8 +25,8 @@ class WP_REST_Pattern_Directory_Controller extends WP_REST_Controller {
* @since 5.8.0 * @since 5.8.0
*/ */
public function __construct() { public function __construct() {
$this->namespace = 'wp/v2'; $this->namespace = 'wp/v2';
$this->rest_base = 'pattern-directory'; $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 ); $raw_patterns = get_site_transient( $transient_key );
if ( ! $raw_patterns ) { if ( ! $raw_patterns ) {
$api_url = add_query_arg( $api_url = 'http://api.wordpress.org/patterns/1.0/?' . build_query( $query_args );
array_map( 'rawurlencode', $query_args ),
'http://api.wordpress.org/patterns/1.0/'
);
if ( wp_http_supports( array( 'ssl' ) ) ) { if ( wp_http_supports( array( 'ssl' ) ) ) {
$api_url = set_url_scheme( $api_url, 'https' ); $api_url = set_url_scheme( $api_url, 'https' );
} }

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.