Make WordPress Core

Ticket #22230: 22230.3.patch

File 22230.3.patch, 1.9 KB (added by kirasong, 11 years ago)

Remove <option> from blocks as well; adjust unit test name to reflect the change.

  • src/wp-includes/formatting.php

    diff --git src/wp-includes/formatting.php src/wp-includes/formatting.php
    index 00d730b..ee3bcd0 100644
    function wpautop($pee, $br = true) { 
    234234
    235235        $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
    236236        // Space things out a little
    237         $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|noscript|legend|section|article|aside|hgroup|header|footer|nav|figure|details|menu|summary)';
     237        $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|noscript|legend|section|article|aside|hgroup|header|footer|nav|figure|details|menu|summary)';
    238238        $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
    239239        $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
    240240        $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
  • tests/phpunit/tests/formatting/Autop.php

    diff --git tests/phpunit/tests/formatting/Autop.php tests/phpunit/tests/formatting/Autop.php
    index d2f78bc..50c10c7 100644
    Paragraph two.'; 
    263263                $this->assertEquals( $expected1, trim( wpautop( $content1 ) ) );
    264264                $this->assertEquals( $expected2, trim( wpautop( $content2 ) ) );
    265265        }
     266
     267        /**
     268         * wpautop() Should not add <br/> to "<select>" or "<option>" elements
     269         *
     270         * @ticket 22230
     271         */
     272        public function test_skip_select_option_elements() {
     273                $str = 'Country: <select id="state" name="state"><option value="1">Alabama</option><option value="2">Alaska</option><option value="3">Arizona</option><option value="4">Arkansas</option><option value="5">California</option></select>';
     274                $this->assertEquals( "<p>$str</p>", trim( wpautop( $str ) ) );
     275        }
    266276}