Index: wp-includes/deprecated.php =================================================================== --- wp-includes/deprecated.php (revision 20209) +++ wp-includes/deprecated.php (working copy) @@ -2980,4 +2980,32 @@ return $theme; return wp_get_theme()->get('Name'); -} \ No newline at end of file +} + +/** + * Accepts matches array from preg_replace_callback in wpautop() or a string. + * + * Ensures that the contents of a <
>...<> 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] . ""; + else + $text = $matches; + + $text = str_replace('
', "\n", $text); + $text = str_replace('
', '', $text); + + return $text; +} + Index: wp-includes/formatting.php =================================================================== --- wp-includes/formatting.php (revision 20209) +++ wp-includes/formatting.php (working copy) @@ -173,30 +173,6 @@ } /** - * Accepts matches array from preg_replace_callback in wpautop() or a string. - * - * Ensures that the contents of a <>...<> HTML block are not - * converted into paragraphs or line-breaks. - * - * @since 1.2.0 - * - * @param array|string $matches The array or string - * @return string The pre block without paragraph/line-break conversion. - */ -function clean_pre($matches) { - if ( is_array($matches) ) - $text = $matches[1] . $matches[2] . ""; - else - $text = $matches; - - $text = str_replace('
', "\n", $text); - $text = str_replace('
', '', $text); - - return $text; -} - -/** * Replaces double line-breaks with paragraph elements. * * A group of regex replaces used to identify text formatted with newlines and @@ -207,14 +183,42 @@ * @since 0.71 * * @param string $pee The text which has to be formatted. - * @param int|bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true. + * @param bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true. * @return string Text which has been converted into correct paragraph tags. */ -function wpautop($pee, $br = 1) { +function wpautop($pee, $br = true) { + $pre_tags = array(); if ( trim($pee) === '' ) return ''; + $pee = $pee . "\n"; // just to make things a little easier, pad the end + + if ( strpos($pee, '', $pee ); + $last_pee = array_pop($pee_parts); + $pee = ''; + $i = 0; + + foreach ( $pee_parts as $pee_part ) { + $start = strpos($pee_part, '"; + $pre_tags[$name] = substr( $pee_part, $start ) . ''; + + $pee .= substr( $pee_part, 0, $start ) . $name; + $i++; + } + + $pee .= $last_pee; + } + $pee = preg_replace('|
\s*(?' . $allblocks . '[^>]*>)!', "$1", $pee); $pee = preg_replace('!(?' . $allblocks . '[^>]*>)\s*
!', "$1", $pee); - if ($br) { + if ( $br ) { $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee); $pee = preg_replace('|(?)\s*\n|', "]*>)(.*?)!is', 'clean_pre', $pee ); $pee = preg_replace( "|\n$|", '', $pee ); + if ( !empty($pre_tags) ) + $pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee); + return $pee; }