API / Minn\Runtime / TemplateFiles

TemplateFiles final class

Minn\Runtime\TemplateFiles · public/minn/src/Minn/Runtime/TemplateFiles.php · 254 lines

The theme templates WordPress's template functions name: the index and embed templates found through the hierarchy, the slugs a block template stands for, the template types and part areas core knows, and a block template made from the theme's file or from a saved post, as the reference makes one (probe template-part-lookup): the theme's names and folders read on the way, the area a theme declares checked against the areas core knows, and the markup passed through the block hooks.

Constants and properties

privatePLAIN_TITLES = array ( 0 => 'attachment', 1 => 'privacy-policy', )

Template types named without a context.

privateFORMAT_SLUG = 'taxonomy-post_format-post-format-'

The prefix of the post format archives' template slugs.

Public

staticindex(): mixed#

The theme's index template (get_index_template).

staticembed(): mixed#

The template an embed is shown with (get_embed_template): embed-{type}-{format}.php, embed-{type}.php, then embed.php.

statichierarchy(mixed $slug, mixed $isCustom = false, mixed $templatePrefix = ''): array#

The template slugs a slug stands for, most specific first (get_template_hierarchy).

@return list<string>
staticdefaultTypes(): mixed#

The template types core knows (get_default_block_template_types), as default_template_types leaves them: each named and described in the site's language, then one per post format.

staticpartAreas(): mixed#

The template part areas core knows (get_allowed_block_template_part_areas), each named in the site's language, as default_wp_template_part_areas leaves them.

staticpartArea(mixed $type): mixed#

A template part's area as the areas core knows it (_filter_block_template_part_area): one it does not know becomes uncategorized, with a notice.

statictemplateIndex(): ?Minn\Theme\TemplateIndex#

The active theme's templates, saved and in its files; null with no block theme booted.

staticfile(mixed $type, mixed $slug): ?array#

One theme template file, described (_get_block_template_file), after the theme's names and folders are read: its slug, path, theme and type; a part's area, the one theme.json declares checked against the areas core knows (_filter_block_template_part_area); a custom template's title and post types. Null for no such file, or a type that is neither.

@return array<string, mixed>|null
staticfromFile(mixed $file, mixed $type): object#

A template built from a file as file() describes one (_build_block_template_result_from_file): the default template types' title and description for a template they name (which is not custom), a part's area, a custom template's post types, and the markup through the block hooks, the theme named on every template part in it.

$filearray<string, mixed>|object
staticsaved(string $type, string $theme, string $slug): ?object#

The template or part a site saved for a theme (any theme, by its wp_theme term) under a slug, built as fromPost() builds it, block hooks applied; null when none is saved (probe taxonomy-blocks-user-doubts).

staticfileTemplate(mixed $id, mixed $type = 'wp_template'): mixed#

A theme file's template by id, past whatever the site saved over it (get_block_file_template): pre_get_block_file_template may answer first; only the active theme's files are found; the template, or null, through get_block_file_template.

staticfromPost(mixed $post): mixed#

A saved template or part as a template (_build_block_template_result_from_post), under the theme its wp_theme term names; an error when it names none. A part's area is its wp_template_part_area term's, none without one. Its origin and suggestion meta and whether the theme has the file are read as the reference reads them; its markup goes through the block hooks, a part's with the hooked blocks its post says to leave out.

Internals 1

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

privatehookedPart(string $markup, object $template, array $ignored): string#

A part's markup through the block hooks, as the reference runs them: wrapped in a template-part block (so blocks hooked as its first or last child are placed), that block marked with the hooked blocks to leave out, then unwrapped.

$ignoredlist<string>