API / Minn\Theme / PatternText

PatternText final class

Minn\Theme\PatternText · public/minn/src/Minn/Theme/PatternText.php · 234 lines

Block-theme patterns are PHP files whose only code is a handful of echo-and-escape calls around literal strings. The engine never executes them: it interprets that small text grammar (string literals, "." concatenation, the i18n and escaping wrappers, the theme URI helper, and printf with %s) and leaves anything else out. A translated string is looked up in its domain (the theme's own), with its context where it gives one, as the reference's patterns ask for theirs. The header comment block is dropped, and every byte outside the PHP tags is kept as-is.

Used by 1

Constants and properties

privatePASSTHROUGH = array ( 0 => 'wp_kses_post', )

Wrappers whose value is their first argument, unchanged.

privateURLS = array ( 0 => 'esc_url', 1 => 'esc_url_raw', )

Wrappers whose value is their first argument as a URL: empty when what stands before a colon is no allowed scheme.

privateESCAPING = array ( 0 => 'esc_html', 1 => 'esc_attr', )

Wrappers whose value is their first argument with HTML special characters encoded.

privateTRANSLATING = array ( '__' => 'text', '_x' => 'context', 'esc_html__' => 'text escaped', 'esc_attr__' => 'text escaped', 'esc_html_x' => 'context escaped', 'esc_attr_x' => 'context escaped', )

The translating wrappers, by how they read: "text" (text, domain) or "context" (text, context, domain), escaped or not; those that echo are statements, the rest values.

privateECHOING = array ( '_e' => 'text', '_ex' => 'context', 'esc_html_e' => 'text escaped', 'esc_attr_e' => 'text escaped', )
privatestring $themeUri
privatestring $source
privateint $position

Public

new__construct(string $source, string $themeUri)#
staticrender(string $file, string $themeUri): string#

A pattern file's HTML with its PHP interpreted, never executed.

Internals 10

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

privatestatements(): string#
privateprintf(array $arguments): string#
privateexpression(): ?string#

A concatenation of terms.

privateterm(): ?string#
privatetranslated(string $layout, array $arguments): string#

A message in the site's language, read as its wrapper reads it (TRANSLATING): (text, domain) or (text, context, domain), escaped for the escaping wrappers.

$argumentslist<string|null>
privateescape(string $text): string#

Special characters encoded once; entities already present are kept.

privatearguments(): array#
@return list<string|null>
privatestringLiteral(string $quote): string#
privateidentifier(): ?string#
privateskipSpace(): void#

Whitespace and comments, anywhere a token may follow.