wp_kses_no_null()WP 1.0.0

Removes any invalid control characters in a text string.

Also removes any instance of the \0 string.

Хуков нет.

Возвращает

Строку. Filtered content.

Использование

wp_kses_no_null( $content, $options );
$content(строка) (обязательный)
Content to filter null characters from.
$options(массив)
Set 'slash_zero' => 'keep' when '\0' is allowed.
По умолчанию: 'remove'

Список изменений

С версии 1.0.0 Введена.

Код wp_kses_no_null() WP 6.4.3

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

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

	return $content;
}