From 77764a5754c1f65d4a967124f3b77a48aae1023c Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 28 Jun 2019 07:15:31 +0000 Subject: [PATCH] Formatting: Add correct `

` tags near `


` tags. It can be tricky to know when `wpautop()` should add `

` tags, but one thing we can be certain about is that they really shouldn't be anywhere near `


` tags. Now they aren't. Props solarissmoke, MattyRob, pento. Fixes #14674. git-svn-id: https://develop.svn.wordpress.org/trunk@45574 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/formatting.php | 3 +++ tests/phpunit/tests/formatting/Autop.php | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 12e5bee017..e2c8aef269 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -500,6 +500,9 @@ function wpautop( $pee, $br = true ) { // Add a double line break below block-level closing tags. $pee = preg_replace( '!()!', "$1\n\n", $pee ); + // Add a double line break after hr tags, which are self closing. + $pee = preg_replace( '!()!', "$1\n\n", $pee ); + // Standardize newline characters to "\n". $pee = str_replace( array( "\r\n", "\r" ), "\n", $pee ); diff --git a/tests/phpunit/tests/formatting/Autop.php b/tests/phpunit/tests/formatting/Autop.php index 3f44949fe2..405b68ad34 100644 --- a/tests/phpunit/tests/formatting/Autop.php +++ b/tests/phpunit/tests/formatting/Autop.php @@ -312,7 +312,6 @@ Paragraph two.'; 'h4', 'h5', 'h6', - 'hr', 'fieldset', 'legend', 'section', @@ -558,4 +557,13 @@ line 2
$this->assertEquals( $expected2, trim( wpautop( $content2 ) ) ); } + /** + * @ticket 14674 + */ + function test_the_hr_is_not_peed() { + $content = 'paragraph1
paragraph2'; + $expected = "

paragraph1

\n
\n

paragraph2

"; + + $this->assertEquals( $expected, trim( wpautop( $content ) ) ); + } }