wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



wp_kses_split › WordPress Function

Desde1.0.0
Obsoleton/a
wp_kses_split ( $content, $allowed_html, $allowed_protocols )
Parâmetros: (3)
  • (string) $content Content to filter.
    Required: Yes
  • (array[]|string) $allowed_html 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.
    Required: Yes
  • (string[]) $allowed_protocols Array of allowed URL protocols.
    Required: Yes
Retorna:
  • (string) Content with fixed HTML tags
Definido em:
Codex:
Log de mudanças:
  • 6.6.0

Searches for HTML tags, no matter how malformed.

It also matches stray > characters.


Fonte

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;

	$token_pattern = <<<REGEX
~
	(                      # Detect comments of various flavors before attempting to find tags.
		(<!--.*?(-->|$))   #  - Normative HTML comments.
		|
		</[^a-zA-Z][^>]*>  #  - Closing tags with invalid tag names.
		|
		<![^>]*>           #  - Invalid markup declaration nodes. Not all invalid nodes
		                   #    are matched so as to avoid breaking legacy behaviors.
	)
	|
	(<[^>]*(>|$)|>)        # Tag-like spans of text.
~x
REGEX;
	return preg_replace_callback( $token_pattern, '_wp_kses_split_callback', $content );
}