On this page
WP_REST_Global_Styles_Controller::get_theme_items( WP_REST_Request $request ): WP_REST_Response|WP_Error
Returns the given theme global styles variations.
Parameters
$requestWP_REST_Request Required-
The request instance.
Return
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php. View all references
public function get_theme_items( $request ) {
if ( wp_get_theme()->get_stylesheet() !== $request['stylesheet'] ) {
// This endpoint only supports the active theme for now.
return new WP_Error(
'rest_theme_not_found',
__( 'Theme not found.' ),
array( 'status' => 404 )
);
}
$variations = WP_Theme_JSON_Resolver::get_style_variations();
$response = rest_ensure_response( $variations );
return $response;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Theme_JSON_Resolver::get_style_variations() wp-includes/class-wp-theme-json-resolver.php | Returns the style variations defined by the theme. |
| WP_Theme::get_stylesheet() wp-includes/class-wp-theme.php | Returns the directory name of the theme’s “stylesheet” files, inside the theme root. |
| rest_ensure_response() wp-includes/rest-api.php | Ensures a REST response is a response object (for consistency). |
| wp_get_theme() wp-includes/theme.php | Gets a WP_Theme object for a theme. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| WP_Error::__construct() wp-includes/class-wp-error.php | Initializes the error. |
Changelog
| Version | Description |
|---|---|
| 6.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/get_theme_items