Html final class
Minn\Html · public/minn/src/Minn/Html.php · 109 lines
HTML, the front door for escaping and cutting markup: plain static calls, one import away (use Minn\Html;), the way Minn\Http and Minn\Json are. Escaping at output boundaries goes through here.
Used by 50 (show)
Constants and properties
| const | SPLIT = '/(<(?:!--.*?(?:-->|$)|!\\[CDATA\\[.*?(?:\\]\\]>|$)|[^>]*>?))/s' | Markup's pieces of HTML: comments and CDATA whole (to the end when unclosed), else from "<" to the next ">". |
Public
| static | split(string $html): array# | Markup cut into text and HTML pieces, the HTML ones at the odd positions (wp_html_split): a comment or CDATA section is one piece whatever it holds, and a "<" in text starts a piece that runs to the next ">". @return list<string> | |||
| static | esc(?string $value): string# | Text escaped for HTML. | |||
| static | attr(?string $value): string# | Text escaped for an attribute value. | |||
| static | addClasses(string $html, array $classes, ?string $onClass = NULL): string# | Appends classes to the first element in a fragment (or to the first element already carrying $onClass), adding a class attribute when the element has none. Existing classes keep their order.
| |||
| static | stripAllTags(string $text, bool $collapseWhitespace = false): string# | Drops script and style elements with their contents, then every other tag; whitespace runs optionally collapse to one space. | |||
| static | textField(string $text, bool $keepNewlines, Closure $validUtf8, Closure $encodeLessThan): string# | A single line of plain text from user input: tags stripped, control whitespace folded, percent escapes removed. The caller passes its own UTF-8 check and less-than encoder so its filters keep applying.
| |||
| static | scriptBody(string $markup): ?string# | The code inside markup that is exactly one bare script element once the surrounding whitespace is gone, or null for anything else: a tag with attributes, an empty element, a missing end. The tag names match in any case and the code is returned as written. |
Nothing matches.