mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-09 01:48:21 +01:00
REST API: Ensure that the get_theme_item method should respect fields param.
Fix the `get_theme_item` method in the `WP_REST_Global_Styles_Controller` class to respect the fields param context filtering and to return links. Props spacedmonkey, hellofromtonya, peterwilsoncc, costdev. Fixes #54595. Built from https://develop.svn.wordpress.org/trunk@52374 git-svn-id: http://core.svn.wordpress.org/trunk@51966 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0124d01d1d
commit
f1f71a0798
@ -377,12 +377,9 @@ class WP_REST_Global_Styles_Controller extends WP_REST_Controller {
|
||||
$base = sprintf( '%s/%s', $this->namespace, $this->rest_base );
|
||||
|
||||
$links = array(
|
||||
'self' => array(
|
||||
'self' => array(
|
||||
'href' => rest_url( trailingslashit( $base ) . $id ),
|
||||
),
|
||||
'collection' => array(
|
||||
'href' => rest_url( $base ),
|
||||
),
|
||||
);
|
||||
|
||||
return $links;
|
||||
@ -535,14 +532,31 @@ class WP_REST_Global_Styles_Controller extends WP_REST_Controller {
|
||||
);
|
||||
}
|
||||
|
||||
$theme = WP_Theme_JSON_Resolver::get_merged_data( 'theme' );
|
||||
$styles = $theme->get_raw_data()['styles'];
|
||||
$settings = $theme->get_settings();
|
||||
$result = array(
|
||||
'settings' => $settings,
|
||||
'styles' => $styles,
|
||||
$theme = WP_Theme_JSON_Resolver::get_merged_data( 'theme' );
|
||||
$data = array();
|
||||
$fields = $this->get_fields_for_response( $request );
|
||||
|
||||
if ( rest_is_field_included( 'settings', $fields ) ) {
|
||||
$data['settings'] = $theme->get_settings();
|
||||
}
|
||||
|
||||
if ( rest_is_field_included( 'styles', $fields ) ) {
|
||||
$data['styles'] = $theme->get_raw_data()['styles'];
|
||||
}
|
||||
|
||||
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
|
||||
$data = $this->add_additional_fields_to_object( $data, $request );
|
||||
$data = $this->filter_response_by_context( $data, $context );
|
||||
|
||||
$response = rest_ensure_response( $data );
|
||||
|
||||
$links = array(
|
||||
'self' => array(
|
||||
'href' => rest_url( sprintf( '%s/%s/themes/%s', $this->namespace, $this->rest_base, $request['stylesheet'] ) ),
|
||||
),
|
||||
);
|
||||
$response = rest_ensure_response( $result );
|
||||
|
||||
$response->add_links( $links );
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.9-beta2-52373';
|
||||
$wp_version = '5.9-beta2-52374';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user