API / Minn\Theme / TemplateHierarchy

TemplateHierarchy final class

Minn\Theme\TemplateHierarchy · public/minn/src/Minn/Theme/TemplateHierarchy.php · 75 lines

The templates a block theme falls back through for a template slug, as get_template_hierarchy builds them (probe rest-templates-lookup): the slug itself, then its family's chain to index. A single entry's slug reaches single-{type} and single only when the type is registered (and goes straight to singular when not); a taxonomy's reaches taxonomy-{tax} and taxonomy only when the taxonomy is; pages, categories, tags and authors step through their bare name when the slug has more to it. A prefix names the next step outright. A custom template is a page's.

Public

staticfor(string $slug, bool $custom, string $prefix, array $types, array $taxonomies): array#

A slug's fallback chain, most specific first, ending at index.

$typeslist<string>the registered post types
$taxonomieslist<string>the registered taxonomies
@return list<string>

Internals 4

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatechain(string $slug, array $types, array $taxonomies): array#

What follows a slug (or a prefix) down to index.

$typeslist<string>
$taxonomieslist<string>
@return list<string>
privatesingle(string $rest, array $types): array#
$typeslist<string>@return list<string>
privatetaxonomy(string $rest, array $taxonomies): array#
$taxonomieslist<string>@return list<string>
privateregistered(string $rest, array $names): ?string#

The registered name a slug's remainder starts with (the whole of it, or before a hyphen), the longest first. @param list<string> $names

$nameslist<string>