API / Minn\Theme / ThemeHeaders

ThemeHeaders final class

Minn\Theme\ThemeHeaders · public/minn/src/Minn/Theme/ThemeHeaders.php · 95 lines

A theme's headers as the reference's WP_Theme reads and shows them (probe theme-headers): sanitized as read, in the theme's language, and with markup.

Constants and properties

privatePLAIN = array ( 'abbr' => array ( 'title' => true, ), 'acronym' => array ( 'title' => true, ), 'code' => array ( ), 'em' => array ( ), 'strong' => array ( ), )

The tags a name or a status may keep.

privateALLOWED = array ( 'a' => array ( 'title' => true, 'href' => true, ), 'abbr' => array ( 'title' => true, ), 'acronym' => array ( 'title' => true, ), 'code' => array ( ), 'em' => array ( ), 'strong' => array ( ), )

The tags a description or an author may keep: those, and links.

privatestatic ?WeakMap $read
privatestatic ?WeakMap $loaded

Public

staticread(object $theme, string $header, mixed $raw): mixed#

A header as WP_Theme::get reads it, once for its theme object (probe theme-headers): Tags as a list; a value sanitized (the name and status through kses, the description and author too with links, the addresses as URLs, the version and requirements, and each tag, without tags; the rest as written); Status "publish" when an existing theme leaves it out.

staticshown(string $header, mixed $value, mixed $markup, mixed $translate, string $domain, Closure $loadDomain, Closure $plain): mixed#

A header's value as shown, sanitized as read (read()): unless asked not to, in the theme's language (any header with a value, its text domain loaded first); then with markup a list joined, the author linked to their address (shown the same way), the addresses escaped and the description texturized.

$loadDomainClosure(): mixedloads the theme's text domain, once for its theme object
$plainClosure(string): mixedanother header of the theme, shown without markup
staticloadFor(object $theme): bool#

A theme object's text domain (WP_Theme::load_textdomain), loaded once for it.

Internals 2

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

privatesanitized(string $header, mixed $value): mixed#
privateloadDomain(string $domain, string $folder, string $domainPath): bool#

A theme's text domain named to load from its folder, as load_theme_textdomain names it: the folder its Domain Path names, its languages folder when it names none. False for a theme that names no domain.