API / Minn\Rest / InstalledThemesController

InstalledThemesController final readonly class

Minn\Rest\InstalledThemesController · public/minn/src/Minn/Rest/InstalledThemesController.php · 141 lines

wp/v2/themes as the reference answers it (probe rest-themes): the installed themes, or only those with a status (active, inactive), each with its style.css headers raw and rendered, where it lives, and whether it is a block theme. The active theme also carries its supports as the editor reads them, the template types and part areas it may define, and a link to the theme export; any theme with user styles links to them. Anyone who can edit a type shown in REST may read the active theme; listing the others takes switch_themes. Each theme goes through rest_prepare_theme. Served with plugins loaded, since a theme's supports come from its own code.

Used by 1

Constants and properties

privateSTATUS = array ( 'status' => array ( 'type' => 'array', 'items' => array ( 'type' => 'string', 'enum' => array ( 0 => 'active', 1 => 'inactive', ), ), 'description' => 'Limit result set to themes assigned one or more statuses.', 'required' => false, ), )
privatereadonly Minn\Rest\RestUrl $url

Promoted from the constructor.

privatereadonly Minn\Rest\Caller $caller

Promoted from the constructor.

Public

new__construct(Minn\Rest\RestUrl $url, Minn\Rest\Caller $caller)#
methodlist(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/themes (public)#

The installed themes the caller may see.

methodsingle(Minn\Http\Request $request, string $stylesheet): Minn\Http\ResponseGET /wp/v2/themes/{stylesheet:[^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?} (public)#

One theme by its stylesheet.

methodfields(WP_Theme $theme, WP_REST_Request $request): array#

A theme in the wp/v2 shape, its links included, before rest_prepare_theme (the runtime's WP_REST_Themes_Controller shapes through here); the request is what the supports' callbacks are handed.

@return array<string, mixed>

Internals 6

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateitem(WP_Theme $theme): array#
@return array<string, mixed>
privatelinks(WP_Theme $theme): array#
@return array<string, list<array<string, mixed>>>
privateviewsThemes(): bool#

May list the installed themes.

privateviewsActive(): bool#

May read the active theme: anyone who lists themes, or edits a type shown in REST.

privatestatus(string $stylesheet): string#
privaterequireRuntime(): void#

A theme's supports come from its own code: without the runtime there is no answer to give.