wp_kses_no_null

The timeline below displays how wordpress function wp_kses_no_null has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Removes any invalid control characters in a text string.
 *
 * Also removes any instance of the `\0` string.
 *
 * @since 1.0.0
 *
 * @param string $content Content to filter null characters from.
 * @param array  $options Set 'slash_zero' => 'keep' when '\0' is allowed. Default is 'remove'.
 * @return string Filtered content.
 */
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;
}

WordPress Version: 5.5

/**
 * Removes any invalid control characters in a text string.
 *
 * Also removes any instance of the `\0` string.
 *
 * @since 1.0.0
 *
 * @param string $string  Content to filter null characters from.
 * @param array  $options Set 'slash_zero' => 'keep' when '\0' is allowed. Default is 'remove'.
 * @return string Filtered content.
 */
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;
}

WordPress Version: 5.1

/**
 * Removes any invalid control characters in a text string.
 *
 * Also removes any instance of the `\0` string.
 *
 * @since 1.0.0
 *
 * @param string $string  Content to filter null characters from.
 * @param array  $options Set 'slash_zero' => 'keep' when '\0' is allowed. Default is 'remove'.
 * @return string Filtered content.
 */
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;
}

WordPress Version: 4.3

/**
 * Removes any invalid control characters in $string.
 *
 * Also removes any instance of the '\0' string.
 *
 * @since 1.0.0
 *
 * @param string $string
 * @param array $options Set 'slash_zero' => 'keep' when '\0' is allowed. Default is 'remove'.
 * @return string
 */
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;
}

WordPress Version: 4.0

/**
 * Removes any invalid control characters in $string.
 *
 * Also removes any instance of the '\0' string.
 *
 * @since 1.0.0
 *
 * @param string $string
 * @return string
 */
function wp_kses_no_null($string)
{
    $string = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string);
    $string = preg_replace('/(\\\\0)+/', '', $string);
    return $string;
}

WordPress Version: 3.7

/**
 * Removes any null characters in $string.
 *
 * @since 1.0.0
 *
 * @param string $string
 * @return string
 */
function wp_kses_no_null($string)
{
    $string = preg_replace('/\0+/', '', $string);
    $string = preg_replace('/(\\\\0)+/', '', $string);
    return $string;
}