API / Minn\Theme / UserStyles

UserStyles final readonly class

Minn\Theme\UserStyles · public/minn/src/Minn/Theme/UserStyles.php · 109 lines

The site editor's saved global styles: one wp_global_styles post per theme, tied to it by the wp_theme term, holding a versioned JSON body of the settings and styles the editor wrote. Every changed save leaves a revision behind, as a post's does.

Constants and properties

privatereadonly Minn\Db $db

Promoted from the constructor.

privatereadonly Minn\Content\Posts $posts

Promoted from the constructor.

privatereadonly Minn\Content\PostWriter $writer

Promoted from the constructor.

privatereadonly Minn\Content\Terms $terms

Promoted from the constructor.

privatereadonly Minn\Content\Site $site

Promoted from the constructor.

Public

new__construct(Minn\Db $db, Minn\Content\Posts $posts, Minn\Content\PostWriter $writer, Minn\Content\Terms $terms, Minn\Content\Site $site)#
methodidFor(string $stylesheet): ?int#

The newest published global-styles post carrying the theme's term, or null.

methodensure(string $stylesheet, int $userId): int#

The theme's post, made the way the reference makes it when there is none yet.

methodfind(int $id): ?Minn\Content\PostRecord#

The post when it is a global-styles post, else null.

staticdecode(string $json): array#

What a global-styles body holds; a missing, malformed, or list-shaped node is empty, as the reference reads it.

@return array{settings: array, styles: array}
staticisBlank(string $json): bool#

True when the body carries nothing at all under settings or styles, malformed or not.

methodchanges(int $id, ?string $title, ?array $settings, ?array $styles): ?array#

What a save changes, as columns: the title when one is given, and, when the caller names settings or styles, the content rebuilt from them, the stored styles and settings it leaves out (a node the stored config never had stays out), the marker and version 3, as the reference rewrites it; any other stored key is dropped. A save naming neither leaves the content as stored, broken or not. Null for no such post. The REST controller saves it as a post update.

@return array<string, string>|null