W3cubDocs

/WordPress

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

Removes any invalid control characters in a text string.

Description

Also removes any instance of the \0 string.

Parameters

$string

(string) (Required) Content to filter null characters from.

$options

(array) (Optional) Set 'slash_zero' => 'keep' when '' is allowed. Default is 'remove'.

Default value: null

Return

(string) Filtered content.

Source

File: wp-includes/kses.php

function wp_kses_no_null( $string, $options = null ) {
	if ( ! isset( $options['slash_zero'] ) ) {
		$options = array( 'slash_zero' => 'remove' );
	}

	$string = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string );
	if ( 'remove' === $options['slash_zero'] ) {
		$string = preg_replace( '/\\\\+0+/', '', $string );
	}

	return $string;
}

Changelog

Version Description
1.0.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_kses_no_null