wp_kses_no_null

Removes any invalid control characters in $string.

Description

(string) wp_kses_no_null( (string) $string, (null) $options = null ); 

Also removes any instance of the \0 string.

Returns (string)

Parameters (2)

0. $string (string)
The string.
1. $options — Optional. (null) => null
Set slash_zero => keep. when \0 is allowed. Default is remove.

Usage

  1. if ( !function_exists( 'wp_kses_no_null' ) ) { 
  2. require_once ABSPATH . WPINC . '/kses.php'; 
  3.  
  4. // The string. 
  5. $string = ''; 
  6.  
  7. // Set 'slash_zero' => 'keep' when '\0' is allowed. Default is 'remove'. 
  8. $options = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_kses_no_null($string, $options); 
  12.  

Defined (1)

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

/wp-includes/kses.php  
  1. function wp_kses_no_null( $string, $options = null ) { 
  2. if ( ! isset( $options['slash_zero'] ) ) { 
  3. $options = array( 'slash_zero' => 'remove' ); 
  4.  
  5. $string = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string ); 
  6. if ( 'remove' == $options['slash_zero'] ) { 
  7. $string = preg_replace( '/\\\\+0+/', '', $string ); 
  8.  
  9. return $string;