TextFilters final class
Minn\Content\TextFilters · public/minn/src/Minn/Content/TextFilters.php · 161 lines
The small text filters the reference runs over content, titles and comments, each from its observed rules (contracts/runtime.md "The content filters", "The comment form"): smilies, the capital P, insecure home addresses, the feed's embed clean-up, and a comment's links and spans.
Constants and properties
| private | IMAGE = '/\\.(png|gif|jpe?g|svg|webp)$/i' | |
| private | IGNORED = array ( 0 => 'code', 1 => 'pre', 2 => 'script', 3 => 'style', 4 => 'textarea', ) |
Public
| static | smiliesSearch(array $codes): string# | The search pattern smilies_init leaves in $wp_smiliessearch, from the codes in their stored order (reverse-sorted): one alternative per first character, its code's rest quoted and joined, each bounded by whitespace, a no-break space or the line's ends (probe functions-utils).
| |||
| static | smilies(string $text, array $table, Closure $image): string# | Smilies become their emoji, or an image for the few that have one: a code only counts as a whole word between spaces, and nothing inside a code, pre, script, style or textarea element, or inside a tag, changes.
| |||
| static | capitalP(string $text): string# | "Wordpress" spelled right after a space, a parenthesis, a tag, or an opening curly quote; elsewhere it stays. | |||
| static | capitalPEverywhere(string $text): string# | "Wordpress" spelled right everywhere, as a title is. | |||
| static | secureHome(string $content, string $insecure, string $secure): string# | The site's own http address made https, escaped forms included. | |||
| static | feedEmbeds(string $content): string# | A feed carries an embedded post's iframe without the style that hides it until its script runs. | |||
| static | rel(string $slashed, string $rel, Closure $internal): string# | Every link given a rel (wp_rel_nofollow, wp_rel_ugc), on slashed text as the content filters carry it, slashed again after (probes comment-fields, plugin-queue5). A link to the site itself does not take "nofollow". | |||
| static | linkRel(string $inner, string $rel, Closure $internal): string# | One link's opening tag with the rel added (wp_rel_callback): a tag that has a rel keeps its words first, gains the new ones, and is written again with every attribute double-quoted and rel last; one without keeps its attributes as written and takes rel at the end. | |||
| static | noteMentionClasses(string $slashed): string# | A span keeps no class in a comment (where a note's mention would be faked); slashed text in, slashed out. |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | ignoring(string $tag, ?string $current): ?string# | The element whose text is left alone after a tag: one of the ignored elements opening, or the one still open. | |||
| private | words(string $text, array $table, Closure $image): string# | One text run, word by word. @param array<string, string> $table
| |||
| private | attributes(string $raw): array# | A tag's attributes in order, name => value (quotes removed; a bare name has null). @return array<string, ?string> @return array<string, ?string> |
Nothing matches.