API / Minn\Theme / UserStyles

UserStyles final readonly class

Minn\Theme\UserStyles · public/minn/src/Minn/Theme/UserStyles.php · 111 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.

methodsave(int $id, int $userId, ?string $title, ?array $settings, ?array $styles, ?Closure $filter = NULL): void#

Replaces what the caller names (null keeps the stored value), stamps the modified time, and snapshots a revision when anything changed. A filter, when given, has the last word on the content and title written (the save filters a REST save runs them through).

$filternull|Closure(array<string, string>): array<string, string>