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
| private | readonly Minn\Db $db | Promoted from the constructor. |
| private | readonly Minn\Content\Posts $posts | Promoted from the constructor. |
| private | readonly Minn\Content\PostWriter $writer | Promoted from the constructor. |
| private | readonly Minn\Content\Terms $terms | Promoted from the constructor. |
| private | readonly 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)# | ||||
| method | idFor(string $stylesheet): ?int# | The newest published global-styles post carrying the theme's term, or null. | |||
| method | ensure(string $stylesheet, int $userId): int# | The theme's post, made the way the reference makes it when there is none yet. | |||
| method | find(int $id): ?Minn\Content\PostRecord# | The post when it is a global-styles post, else null. | |||
| static | decode(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} | |||
| static | isBlank(string $json): bool# | True when the body carries nothing at all under settings or styles, malformed or not. | |||
| method | save(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).
|
Nothing matches.