diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 71dfc84071..5192d95b95 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -126,7 +126,11 @@ function wpautop($pee, $br = 1) { $pee = preg_replace('|\s*\s*|', '', $pee); } $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates - $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "

$1

\n", $pee); // make paragraphs, including one at the end + // make paragraphs, including one at the end + $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY); + $pee = ''; + foreach ( $pees as $tinkle ) + $pee .= '

' . trim($tinkle, "\n") . "

\n"; $pee = preg_replace('|

\s*?

|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace $pee = preg_replace('!

([^<]+)\s*?(]*>)!', "

$1

$2", $pee); $pee = preg_replace( '|

|', "$1

", $pee );