GlobalStylesController final readonly class
Minn\Rest\GlobalStylesController · public/minn/src/Minn/Rest/GlobalStylesController.php · 159 lines
wp/v2/global-styles: the site editor's saved styles (one post per theme, read and written by id, with its revisions) and the active theme's own styles and variations. There is no collection, no create and no delete; the post is made on first use, as on the reference.
Constants and properties
| private | CANNOT_EDIT = 'Sorry, you are not allowed to edit this global style.' | |
| private | CANNOT_READ_REVISIONS = 'Sorry, you are not allowed to view revisions of this post.' | |
| private | readonly Minn\Theme\UserStyles $styles | Promoted from the constructor. |
| private | readonly Minn\Theme\ThemeStyles $theme | Promoted from the constructor. |
| private | readonly Minn\Rest\GlobalStylesObject $object | Promoted from the constructor. |
| private | readonly Minn\Content\Revisions $revisions | Promoted from the constructor. |
| private | readonly Minn\Rest\Caller $caller | Promoted from the constructor. |
Public
| new | __construct(Minn\Theme\UserStyles $styles, Minn\Theme\ThemeStyles $theme, Minn\Rest\GlobalStylesObject $object, Minn\Content\Revisions $revisions, Minn\Rest\Caller $caller)# | |
| method | single(Minn\Http\Request $request, string $id): Minn\Http\ResponseGET /wp/v2/global-styles/{id:[\/\d+]+} (public; global styles {id} must exist)# | The saved styles by id: anyone who edits posts may read them, editing context needs the theme. |
| method | update(Minn\Http\Request $request, string $id): Minn\Http\ResponsePOST /wp/v2/global-styles/{id:[\/\d+]+} (cap edit_theme_options; global styles {id} must exist)PUT /wp/v2/global-styles/{id:[\/\d+]+} (cap edit_theme_options; global styles {id} must exist)PATCH /wp/v2/global-styles/{id:[\/\d+]+} (cap edit_theme_options; global styles {id} must exist)# | Replaces the title, settings, or styles the body names; what it leaves out stays. |
| method | variations(Minn\Http\Request $request, string $stylesheet): Minn\Http\ResponseGET /wp/v2/global-styles/themes/{stylesheet:[\/\s%\w\.\(\)\[\]\@_\-]+}/variations (cap edit_posts)# | The style variations the active theme ships; listed ahead of the theme's own route, whose pattern would take this path too. |
| method | theme(Minn\Http\Request $request, string $stylesheet): Minn\Http\ResponseGET /wp/v2/global-styles/themes/{stylesheet:[^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?} (cap edit_posts)# | The active theme's settings and styles, the engine's defaults underneath. |
| method | revisions(Minn\Http\Request $request, string $parent): Minn\Http\ResponseGET /wp/v2/global-styles/{parent:[\d]+}/revisions (cap edit_theme_options; global styles parent {parent} must exist)# | The revisions of the saved styles, newest first; all of them unless per_page pages them. |
| method | revision(Minn\Http\Request $request, string $parent, string $id): Minn\Http\ResponseGET /wp/v2/global-styles/{parent:[\d]+}/revisions/{id:[\d]+} (cap edit_theme_options; global styles parent {parent} must exist)# | One revision of the saved styles. |
Internals 6
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | refuseIllegalCss(mixed $css): void# | Custom CSS that would close its style tag is refused, for every user (probe global-styles-unfiltered): "</style" followed by white space, a slash or ">", in any case, quoted as written; or "</style" at its end. |
| private | post(int $id): Minn\Content\PostRecord# | |
| private | requireTheme(string $stylesheet): void# | The theme routes answer only for the active stylesheet, and only to those who edit posts. |
| private | requireParent(int $parentId): int# | Revisions are for those who edit the theme, of a parent that is a global-styles post. |
| private | title(mixed $title): ?string# | A title arrives as a string or as {raw}; anything else is ignored. |
| private | node(array $body, string $name): ?array# | settings and styles are objects when present; a scalar is the reference's type error, null is ignored. |
Nothing matches.