API / Minn\Runtime / KsesRules

KsesRules final class

Minn\Runtime\KsesRules · public/minn/src/Minn/Runtime/KsesRules.php · 95 lines

The HTML WordPress's kses functions let through: the elements and attributes allowed in a context (data/kses.json, as wp_kses_allowed_html leaves them), content filtered to them, one attribute judged, and the null bytes taken out.

Constants and properties

privatestatic ?array $table

Public

statictable(): array#

The tables the contexts start from: post, data (the comment and description rules) and entities.

@return array<string, mixed>
staticallowedHtml(mixed $context = ''): mixed#

The elements and attributes allowed in a context (wp_kses_allowed_html): post, a user's description, strip, entities, the comment rules for any other, or an explicit list; as wp_kses_allowed_html leaves them.

staticfilter(mixed $content, mixed $allowedHtml, mixed $allowedProtocols = array ( )): string#

Content filtered to the HTML allowed (wp_kses), with the site's protocols unless others are given. A context given as another scalar is read as text, as wp_kses_data's current_filter() is false outside a filter.

staticpost(mixed $data): string#

Content filtered to what a post may hold (wp_kses_post).

staticoneAttribute(mixed $attr, mixed $element): string#

One attribute judged as a post's element would carry it (wp_kses_one_attr).

staticwithoutNull(mixed $content, mixed $options = NULL): string#

Content without its null bytes (wp_kses_no_null), or without any control characters when slash_zero is kept.

staticpolicy(array|string $allowedHtml, array $allowedProtocols, ?string $content = NULL): Minn\Support\KsesPolicy#

A caller's allowed HTML in any of its shapes, with the protocols and URI attributes in force. For content, the URI attributes are asked only when an opening tag of an allowed element that may carry attributes is there, as the reference asks them of each such tag; otherwise none are consulted.

$allowedHtmlarray<string, mixed>|string
$allowedProtocolsarray<int, string>