Templates final readonly class
Minn\Theme\Templates · public/minn/src/Minn/Theme/Templates.php · 204 lines
Which template renders a resolution, and where its markup comes from: a wp_template post saved from the site editor (matched by slug and the theme term) wins over the theme's file. Parts resolve the same way through wp_template_part.
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\Theme\Theme $theme | Promoted from the constructor. |
| private | readonly ?Minn\Runtime\BlockTemplates $registered | Promoted from the constructor. |
Public
| new | __construct(Minn\Db $db, Minn\Content\Posts $posts, Minn\Theme\Theme $theme, ?Minn\Runtime\BlockTemplates $registered = NULL)# | |
| method | forResolution(Minn\Front\Resolution $resolution): ?array# | The template that renders a resolution, or null. @return array{slug: string, markup: string}|null |
| method | template(string $slug): ?string# | A template's markup by slug, saved first. |
| method | part(string $slug): ?string# | A template part's markup by slug, saved first. |
| method | partSource(string $slug): array# | Where a template part comes from: a part saved for the theme (its post id), the theme's file (its path), or nowhere; with its markup. @return array{0: 'post'|'file'|'none', 1: int|string, 2: ?string} |
| method | candidates(Minn\Front\Resolution $resolution): array# | The block-theme template hierarchy for each kind of resolution. @return list<string> |
| method | userStyles(): ?array# | The site editor's saved global styles for the active theme, when any. An emptied node is stored as [] and reads as nothing, the way the reference reads it; a list where a map belongs is dropped the same way. |
| method | customTemplate(int $pageId): ?string# | A page's chosen custom template, from _wp_page_template meta. |
Internals 5
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | filtered(Minn\Front\Resolution $resolution, array $slugs): array# | Plugins reshape the hierarchy through the reference's "{type}_template_hierarchy" filters (WooCommerce sends its taxonomies to archive-product that way); the filter sees PHP file names and hands back the same, which become slugs again.
@return list<string> | |||
| private | hierarchy(Minn\Front\Resolution $resolution): array# | @return list<string> | |||
| private | savedOfTheme(): array# | Every published template, part and global styles post saved for the theme, newest first by type: read in one query once a request. @return array<string, list<array<string, mixed>>> | |||
| private | saved(string $type, ?string $slug): ?string# | ||||
| private | savedRow(string $type, ?string $slug): ?array# | The newest published template of a type (and slug) saved for the theme. Every saved one of the type is read once a request, newest first, so a template's candidates and its parts cost one query. @return array{ID: int|string, post_content: string}|null |
Nothing matches.