Texturize final class
Minn\Content\Texturize · public/minn/src/Minn/Content/Texturize.php · 269 lines
The texturize subset the reference applies to rendered text: straight quotes, apostrophes, ellipses, dashes, and primes become numeric entities, outside the skip elements only. Coverage is pinned by the texturize battery post; anything beyond it is a documented gap.
Constants and properties
| private | SKIP = array ( 0 => 'pre', 1 => 'code', 2 => 'kbd', 3 => 'style', 4 => 'script', 5 => 'tt', ) | |
| private | static ?bool $run | Whether text is texturized at all (run_wptexturize), once asked; null until then. |
| private | static ?array $characters |
Public
| static | enabled(): bool# | Whether text is texturized at all (run_wptexturize): asked on the first text of a request and again after askAgain(); once the answer is no, it holds for the rest of the request (probe filter-inputs-3). | ||||||
| static | askAgain(): void# | Has the next text ask run_wptexturize again (wptexturize's reset), unless the answer was already no. | ||||||
| static | characters(): array# | The characters texturizing writes, as the site's language writes them (each asked by its translation context, as the reference asks them): the dashes, the curly quotes, the apostrophe and the primes. @return array{en: string, em: string, open1: string, close1: string, apostrophe: string, open2: string, close2: string, prime: string, prime2: string} | ||||||
| static | skipPattern(): string# | The elements whose text stays as written (no_texturize_tags: pre, code, kbd, style, script and tt), read on every text, as a pattern alternation. | ||||||
| static | html(string $html, ?string $skip = NULL): string# | Curly quotes, dashes, and ellipses in the text of HTML, leaving tags and the skipped elements alone; registered shortcodes stay as written (probe shortcode-run), and so does the text inside the ones no_texturize_shortcodes names ([code] by default). Nothing changes once texturizing is off. A caller that already read the skip pattern hands it over, so each text asks the filters once. | ||||||
| static | entities(string $html, string $skip): string# | Bare ampersands made entities outside the skipped elements, as wptexturize leaves them after the rest. | ||||||
| static | text(string $text): string# | The same substitutions on a plain string with no tags. | ||||||
| static | splitPattern(string $shortcodes = ''): string# | The pattern that cuts markup for texturizing (wp_html_split's pieces with comments whole and, given, shortcodes): comments run to "-->" or the end, a tag to its first ">", and each piece is captured. | ||||||
| static | shortcodeTags(array $tags): string# | The pattern fragment for shortcodes with these names: an opening or closing tag, or an escaped [[one]], its name ended by a space, "/" or "]", its attributes up to the first "]".
| ||||||
| static | pushPop(string $text, array $stack, array $disabled): void# | Keeps the stack of open elements texturize leaves alone: an opening tag or shortcode of a listed name is pushed (a self-closing one is not), its closing one pops it when it is the last opened.
| ||||||
| static | primes(string $haystack, string $needle, string $prime, string $closeQuote): string# | Each $needle in the text made a prime after a digit; otherwise a double quote becomes the closing quote, and a single one does only where a word ends (before the end, whitespace, a no-break space or . , ; : ! ? ) ] } -), staying an apostrophe or opening quote elsewhere. |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | shortcodePattern(string $html): string# | The pattern for the registered shortcodes the text opens a bracket with, or "" for none. | |||
| private | quiet(string $delimiter, array $open, array $quiet): void# | Keeps count of the quiet shortcodes open around the text: an opening one is pushed, its closing one pops it, others pass.
| |||
| private | endsWord(string $next): bool# | Whether what follows a single quote ends a word: nothing, whitespace, a no-break space, or . , ; : ! ? ) ] } -. |
Nothing matches.