WP_REST_Global_Styles_Controller::get_theme_items()publicWP 6.0.0

Returns the given theme global styles variations.

Метод класса: WP_REST_Global_Styles_Controller{}

Хуков нет.

Возвращает

WP_REST_Response|WP_Error.

Использование

$WP_REST_Global_Styles_Controller = new WP_REST_Global_Styles_Controller();
$WP_REST_Global_Styles_Controller->get_theme_items( $request );
$request(WP_REST_Request) (обязательный)
The request instance.

Список изменений

С версии 6.0.0 Введена.
С версии 6.2.0 Returns parent theme variations, if they exist.

Код WP_REST_Global_Styles_Controller::get_theme_items() WP 6.5.2

public function get_theme_items( $request ) {
	if ( 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();

	return rest_ensure_response( $variations );
}