From b358b4acccbaef4b90e25956ce9f515c80af7c40 Mon Sep 17 00:00:00 2001
From: azaozz ', "\n", $text);
+ $text = str_replace(' ', "\n", $text);
- $text = str_replace(' tags with wpautop, replace them with
placeholders, process the rest of the content and then put them back. Part
props kurtpayne, see #19855
git-svn-id: http://svn.automattic.com/wordpress/trunk@20307 1a063a9b-81f0-0310-95a4-ce76da25c4cd
---
wp-includes/deprecated.php | 28 +++++++++++++++++
wp-includes/formatting.php | 63 ++++++++++++++++++++------------------
2 files changed, 62 insertions(+), 29 deletions(-)
diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php
index d37194e925..410a5df70e 100644
--- a/wp-includes/deprecated.php
+++ b/wp-includes/deprecated.php
@@ -2982,6 +2982,34 @@ function get_current_theme() {
return wp_get_theme()->get('Name');
}
+/**
+ * Accepts matches array from preg_replace_callback in wpautop() or a string.
+ *
+ * Ensures that the contents of a <
";
+ else
+ $text = $matches;
+
+ $text = str_replace('>...<
> 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] . "
', '', $text);
+ $text = str_replace('>...<
> 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('
', '', $text);
- $text = str_replace('', $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*
|', "\n\n", $pee);
// Space things out a little
$allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
@@ -239,17 +243,18 @@ function wpautop($pee, $br = 1) {
$pee = str_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; }