wp_kses_split()WP 1.0.0

Searches for HTML tags, no matter how malformed.

It also matches stray > characters.

No Hooks.

Return

String. Content with fixed HTML tags

Usage

wp_kses_split( $content, $allowed_html, $allowed_protocols );
$content(string) (required)
Content to filter.
$allowed_html(array[]|string) (required)
An array of allowed HTML elements and attributes, or a context name such as 'post'. See wp_kses_allowed_html() for the list of accepted context names.
$allowed_protocols(string[]) (required)
Array of allowed URL protocols.

Notes

  • Global. Array[]|String. $pass_allowed_html An array of allowed HTML elements and attributes, or a context name such as 'post'.
  • Global. String[]. $pass_allowed_protocols Array of allowed URL protocols.

Changelog

Since 1.0.0 Introduced.

wp_kses_split() code WP 6.5.2

function wp_kses_split( $content, $allowed_html, $allowed_protocols ) {
	global $pass_allowed_html, $pass_allowed_protocols;

	$pass_allowed_html      = $allowed_html;
	$pass_allowed_protocols = $allowed_protocols;

	return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $content );
}