normalize_whitespace

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

WordPress Version: 6.1

/**
 * Normalizes EOL characters and strips duplicate whitespace.
 *
 * @since 2.7.0
 *
 * @param string $str The string to normalize.
 * @return string The normalized string.
 */
function normalize_whitespace($str)
{
    $str = trim($str);
    $str = str_replace("\r", "\n", $str);
    $str = preg_replace(array('/\n+/', '/[ \t]+/'), array("\n", ' '), $str);
    return $str;
}

WordPress Version: 3.7

/**
 * Normalize EOL characters and strip duplicate whitespace.
 *
 * @since 2.7.0
 *
 * @param string $str The string to normalize.
 * @return string The normalized string.
 */
function normalize_whitespace($str)
{
    $str = trim($str);
    $str = str_replace("\r", "\n", $str);
    $str = preg_replace(array('/\n+/', '/[ \t]+/'), array("\n", ' '), $str);
    return $str;
}