Removes any invalid control characters in a text string.
Description
Also removes any instance of the \0 string.
Parameters
$contentstringrequired- Content to filter null characters from.
$optionsarrayoptional- Set
'slash_zero'=>'keep'when''is allowed. Default is'remove'.Default:
null
Source
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;
}
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.