WordPress.org

Make WordPress Core

Changeset 39912


Ignore:
Timestamp:
01/16/17 01:05:33 (2 months ago)
Author:
azaozz
Message:

Formatting: fix wpautop() to stop adding paragraph tags around <figcaption>.

Fixes #39307 for trunk.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/editor.js

    r39911 r39912  
    168168         */ 
    169169        function removep( html ) { 
    170             var blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset', 
     170            var blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure', 
    171171                blocklist1 = blocklist + '|div|p', 
    172172                blocklist2 = blocklist + '|pre', 
     
    330330                    return a.replace( /\n/g, '<wp-line-break>' ); 
    331331                }); 
     332            } 
     333 
     334            if ( text.indexOf( '<figcaption' ) !== -1 ) { 
     335                text = text.replace( /\s*(<figcaption[^>]*>)/g, '$1' ); 
     336                text = text.replace( /<\/figcaption>\s*/g, '</figcaption>' ); 
    332337            } 
    333338 
  • trunk/src/wp-includes/formatting.php

    r39326 r39912  
    505505        $pee = preg_replace( '%\s*([<\[]/(?:audio|video)[>\]])%', '$1', $pee ); 
    506506        $pee = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $pee ); 
     507    } 
     508 
     509    // Collapse line breaks before and after <figcaption> elements. 
     510    if ( strpos( $pee, '<figcaption' ) !== false ) { 
     511        $pee = preg_replace( '|\s*(<figcaption[^>]*>)|', '$1', $pee ); 
     512        $pee = preg_replace( '|</figcaption>\s*|', '</figcaption>', $pee ); 
    507513    } 
    508514 
Note: See TracChangeset for help on using the changeset viewer.