WordPress.org

Make WordPress Core

Ticket #23135: formats.diff

File formats.diff, 1.4 KB (added by luehrsen, 16 months ago)

Defined preexisting block elements as array, filtered that array, imploded to regex.

  • trunk/wp-includes/formatting.php

     
    219219        } 
    220220 
    221221        $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee); 
     222         
     223        // Define Blog elements 
     224        $block_elements = array("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", "samp", "legend", "section", "article", "aside", "hgroup", "header", "footer", "nav", "figure", "figcaption", "details", "menu", "summary"); 
     225         
     226        $block_elements = apply_filters("wpautop_block_elements", $block_elements); 
     227                 
    222228        // Space things out a little 
    223         $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|samp|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; 
     229        $allblocks = '(?:'.implode("|", $block_elements).')'; 
    224230        $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); 
    225231        $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee); 
    226232        $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines