mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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]. git-svn-id: https://develop.svn.wordpress.org/trunk@53218 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5ae266fdc4
commit
32f1bdeec6
@ -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;
|
||||
|
||||
@ -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' );
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user