wp_kses_split

Searches for HTML tags, no matter how malformed.

Description

(string) wp_kses_split( (string) $string, (array) $allowed_html, (array) $allowed_protocols ); 

It also matches stray > characters.

Returns (string)

Content with fixed HTML tags

Parameters (3)

0. $string (string)
Content to filter
1. $allowed_html (array)
Allowed HTML elements
2. $allowed_protocols (array)
Allowed protocols to keep

Usage

  1. if ( !function_exists( 'wp_kses_split' ) ) { 
  2. require_once ABSPATH . WPINC . '/kses.php'; 
  3.  
  4. // Content to filter 
  5. $string = ''; 
  6.  
  7. // Allowed HTML elements 
  8. $allowed_html = array(); 
  9.  
  10. // Allowed protocols to keep 
  11. $allowed_protocols = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wp_kses_split($string, $allowed_html, $allowed_protocols); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/kses.php  
  1. function wp_kses_split( $string, $allowed_html, $allowed_protocols ) { 
  2. global $pass_allowed_html, $pass_allowed_protocols; 
  3. $pass_allowed_html = $allowed_html; 
  4. $pass_allowed_protocols = $allowed_protocols; 
  5. return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $string );