Remove select and input from wpautop()'s HTML blocks list.
props rachelbaker, DH-Shredder. fixes #22230. git-svn-id: https://develop.svn.wordpress.org/trunk@27761 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
814de88f7a
commit
28663b08e8
|
@ -203,8 +203,8 @@ window.switchEditors = {
|
|||
_wp_Autop: function(pee) {
|
||||
var preserve_linebreaks = false,
|
||||
preserve_br = false,
|
||||
blocklist = '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' +
|
||||
blocklist = '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';
|
||||
|
||||
if ( pee.indexOf( '<object' ) !== -1 ) {
|
||||
|
|
|
@ -234,7 +234,7 @@ function wpautop($pee, $br = true) {
|
|||
|
||||
$pee = preg_replace('|<br />\s*<br />|', "\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|noscript|legend|section|article|aside|hgroup|header|footer|nav|figure|details|menu|summary)';
|
||||
$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)';
|
||||
$pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
|
||||
$pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
|
||||
$pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
|
||||
|
|
|
@ -263,4 +263,14 @@ Paragraph two.';
|
|||
$this->assertEquals( $expected1, trim( wpautop( $content1 ) ) );
|
||||
$this->assertEquals( $expected2, trim( wpautop( $content2 ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* wpautop() Should not add <br/> to "<select>" or "<option>" elements
|
||||
*
|
||||
* @ticket 22230
|
||||
*/
|
||||
public function test_skip_select_option_elements() {
|
||||
$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>';
|
||||
$this->assertEquals( "<p>$str</p>", trim( wpautop( $str ) ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue