wp_kses_split( string $content, array[]|string $allowed_html, string[] $allowed_protocols ): string

Searches for HTML tags, no matter how malformed.

Description

It also matches stray > characters.

Parameters

$contentstringrequired
Content to filter.
$allowed_htmlarray[]|stringrequired
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_protocolsstring[]required
Array of allowed URL protocols.

Return

string Content with fixed HTML tags

Source

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 );
}

Changelog

VersionDescription
1.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.