Make WordPress Core

Changeset 45574


Ignore:
Timestamp:
06/28/2019 07:15:31 AM (5 years ago)
Author:
pento
Message:

Formatting: Add correct <p> tags near <hr> tags.

It can be tricky to know when wpautop() should add <p> tags, but one thing we can be certain about is that they really shouldn't be anywhere near <hr> tags.

Now they aren't.

Props solarissmoke, MattyRob, pento.
Fixes #14674.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r45573 r45574  
    500500    // Add a double line break below block-level closing tags.
    501501    $pee = preg_replace( '!(</' . $allblocks . '>)!', "$1\n\n", $pee );
     502
     503    // Add a double line break after hr tags, which are self closing.
     504    $pee = preg_replace( '!(<hr\s*?/?>)!', "$1\n\n", $pee );
    502505
    503506    // Standardize newline characters to "\n".
  • trunk/tests/phpunit/tests/formatting/Autop.php

    r42636 r45574  
    313313            'h5',
    314314            'h6',
    315             'hr',
    316315            'fieldset',
    317316            'legend',
     
    559558    }
    560559
     560    /**
     561     * @ticket 14674
     562     */
     563    function test_the_hr_is_not_peed() {
     564        $content  = 'paragraph1<hr>paragraph2';
     565        $expected = "<p>paragraph1</p>\n<hr>\n<p>paragraph2</p>";
     566
     567        $this->assertEquals( $expected, trim( wpautop( $content ) ) );
     568    }
    561569}
Note: See TracChangeset for help on using the changeset viewer.