clean_pre

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

WordPress Version: 5.5

/**
 * Accepts matches array from preg_replace_callback in wpautop() or a string.
 *
 * Ensures that the contents of a `<pre>...</pre>` HTML block are not
 * converted into paragraphs or line breaks.
 *
 * @since 1.2.0
 * @deprecated 3.4.0
 *
 * @param array|string $matches The array or string
 * @return string The pre block without paragraph/line break conversion.
 */
function clean_pre($matches)
{
    _deprecated_function(__FUNCTION__, '3.4.0');
    if (is_array($matches)) {
        $text = $matches[1] . $matches[2] . "</pre>";
    } else {
        $text = $matches;
    }
    $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text);
    $text = str_replace('<p>', "\n", $text);
    $text = str_replace('</p>', '', $text);
    return $text;
}

WordPress Version: 4.6

/**
 * Accepts matches array from preg_replace_callback in wpautop() or a string.
 *
 * Ensures that the contents of a `<pre>...</pre>` HTML block are not
 * converted into paragraphs or line-breaks.
 *
 * @since 1.2.0
 * @deprecated 3.4.0
 *
 * @param array|string $matches The array or string
 * @return string The pre block without paragraph/line-break conversion.
 */
function clean_pre($matches)
{
    _deprecated_function(__FUNCTION__, '3.4.0');
    if (is_array($matches)) {
        $text = $matches[1] . $matches[2] . "</pre>";
    } else {
        $text = $matches;
    }
    $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text);
    $text = str_replace('<p>', "\n", $text);
    $text = str_replace('</p>', '', $text);
    return $text;
}

WordPress Version: 4.1

/**
 * Accepts matches array from preg_replace_callback in wpautop() or a string.
 *
 * Ensures that the contents of a `<pre>...</pre>` HTML block are not
 * converted into paragraphs or line-breaks.
 *
 * @since 1.2.0
 * @deprecated 3.4.0
 *
 * @param array|string $matches The array or string
 * @return string The pre block without paragraph/line-break conversion.
 */
function clean_pre($matches)
{
    _deprecated_function(__FUNCTION__, '3.4');
    if (is_array($matches)) {
        $text = $matches[1] . $matches[2] . "</pre>";
    } else {
        $text = $matches;
    }
    $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text);
    $text = str_replace('<p>', "\n", $text);
    $text = str_replace('</p>', '', $text);
    return $text;
}

WordPress Version: 3.7

/**
 * Accepts matches array from preg_replace_callback in wpautop() or a string.
 *
 * Ensures that the contents of a <<pre>>...<</pre>> HTML block are not
 * converted into paragraphs or line-breaks.
 *
 * @since 1.2.0
 * @deprecated 3.4.0
 *
 * @param array|string $matches The array or string
 * @return string The pre block without paragraph/line-break conversion.
 */
function clean_pre($matches)
{
    _deprecated_function(__FUNCTION__, '3.4');
    if (is_array($matches)) {
        $text = $matches[1] . $matches[2] . "</pre>";
    } else {
        $text = $matches;
    }
    $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text);
    $text = str_replace('<p>', "\n", $text);
    $text = str_replace('</p>', '', $text);
    return $text;
}