Theme final class
Minn\Theme\Theme · public/minn/src/Minn/Theme/Theme.php · 347 lines
The active block theme on disk, read as data: theme.json, the templates and parts directories, and the patterns index. A child theme's files win and its parent fills in what the child does not define; theme.json merges the same way, with the child's preset lists replacing the parent's whole. The engine reads the site's installed theme the way it reads the site's database; it never runs the theme's PHP.
Constants and properties
| private | ?array $json | |
| private | ?array $patterns | |
| prop | readonly string $slug | Promoted from the constructor. |
| prop | readonly string $dir | Promoted from the constructor. |
| prop | readonly string $uri | Promoted from the constructor. |
| prop | readonly ?Minn\Theme\Theme $parent | Promoted from the constructor. |
Public
| new | __construct(string $slug, string $dir, string $uri, ?Minn\Theme\Theme $parent = NULL)# | |
| static | active(Minn\Content\Site $site, Minn\Front\Permalinks $permalinks, string $themesDir): ?self# | The active block theme, or null under a classic one. |
| static | forStyles(Minn\Content\Site $site, Minn\Front\Permalinks $permalinks, string $themesDir): ?self# | The active theme as styling data (theme.json present), whether or not it is a block theme; the classic renderer prints its presets where the reference prints a classic theme's global styles. |
| method | parentSlug(): ?string# | The theme's own name, and the parent's, for body classes. |
| method | json(): array# | The theme.json with the parent's merged in; with plugins loaded, through wp_theme_json_data_theme. |
| method | styleFiles(): array# | Every JSON file under styles/, the parent theme's first and each theme's in path order: block style partials and style variations alike. @return list<string> |
| static | merge(array $base, array $over): array# | Layered theme.json: maps merge key by key, lists (palettes, font sizes, template parts) replace as a whole. |
| method | templateFile(string $slug): ?string# | A template file's markup, or null. |
| method | templatePath(string $slug): ?string# | The file a template is read from: this theme's, else its parent's; null when neither has one. |
| method | partFile(string $slug): ?string# | A template part file's markup, or null. |
| method | partPath(string $slug): ?string# | The file a template part is read from: this theme's, else its parent's; null when neither has one. |
| method | name(): string# | The theme's display name, as the stylesheet header states it; a child theme answers with its own. Falls back to theme.json's title, then the folder name. |
| method | fileSlugs(string $folder): array# | Every template (or part) slug the theme offers, the child's files first and the parent's after, each in the order the directory hands them back: the reference walks these directories unsorted and its template list carries that order through. @return list<string> |
| method | customTemplate(string $slug): ?array# | A template title and description the theme declares for a custom template slug. |
| method | partTitle(string $slug): ?string# | The title theme.json gives a template part, when it names one. |
| method | partArea(string $slug): string# | The template-part area declared in theme.json (header, footer, or uncategorized). |
| method | pattern(string $slug): ?string# | A pattern's markup, with its PHP text subset interpreted; null when unknown. |
| method | patternMeta(string $slug): array# | A pattern's declared Block Types and Categories, the header fields a plugin reads to tell (say) a header pattern from any other. @return array{blockTypes: list<string>, categories: list<string>} |
| method | patternHeader(string $slug): ?array# | The header fields a pattern declares, as the metadata attribute the reference writes onto the pattern's first block when it splices the pattern into a template. A field the header omits is omitted here. @return array{patternName: string, name: string, description?: string, categories?: list<string>}|null |
| method | styleUri(): ?string# | The theme's stylesheet URL when it ships one; a child's own, else nothing (the parent's is not enqueued for it). |
Internals 7
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | at(string $slug, string $themesDir, Minn\Front\Permalinks $permalinks, ?Minn\Theme\Theme $parent = NULL): ?self# | |
| private | rawJson(): array# | The theme.json as written, the parent's merged in. |
| private | withStylePartials(array $json): array# | A theme's styles/ folder can hold block style variations: a JSON file with blockTypes and a slug (else the file name) whose styles become styles.blocks.{type}.variations.{slug} for each named block type. The parent's partials load first, the child's over them. |
| private | partialFiles(string $dir): array# | @return list<string> |
| private | safe(string $slug): bool# | A template or part name is a file name, never a path. |
| private | htmlFiles(string $dir): array# | @return list<string> |
| private | patternIndex(): array# | @return array<string, string> |
Nothing matches.