WP_REST_Global_Styles_Controller::get_theme_items() WordPress Method

The WP_REST_Global_Styles_Controller::get_theme_items() method is used to get a list of all available themes. This method returns an array of theme objects, each containing a name, description, and screenshot.

WP_REST_Global_Styles_Controller::get_theme_items( WP_REST_Request $request ) #

Returns the given theme global styles variations.


Parameters

$request

(WP_REST_Request)(Required)The request instance.


Top ↑

Return

(WP_REST_Response|WP_Error)


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php

	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;
	}


Top ↑

Changelog

Changelog
VersionDescription
6.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.