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

Props azaozz, pbearne for tests.
Merges [39912], [39914] to the 4.7 branch.
Fixes #39307 for 4.7.


Built from https://develop.svn.wordpress.org/branches/4.7@40091


git-svn-id: http://core.svn.wordpress.org/branches/4.7@40028 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2017-02-21 03:42:38 +00:00
parent f65de13e9f
commit e18e5acce8
4 changed files with 14 additions and 3 deletions

View File

@ -118,7 +118,7 @@
// Replace paragraphs with double line breaks
function removep( html ) {
var blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset',
var blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure',
blocklist1 = blocklist + '|div|p',
blocklist2 = blocklist + '|pre',
preserve_linebreaks = false,
@ -257,6 +257,11 @@
});
}
if ( text.indexOf( '<figcaption' ) !== -1 ) {
text = text.replace( /\s*(<figcaption[^>]*>)/g, '$1' );
text = text.replace( /<\/figcaption>\s*/g, '</figcaption>' );
}
// keep <br> tags inside captions and convert line breaks
if ( text.indexOf( '[caption' ) !== -1 ) {
preserve_br = true;

File diff suppressed because one or more lines are too long

View File

@ -506,6 +506,12 @@ function wpautop( $pee, $br = true ) {
$pee = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $pee );
}
// Collapse line breaks before and after <figcaption> elements.
if ( strpos( $pee, '<figcaption' ) !== false ) {
$pee = preg_replace( '|\s*(<figcaption[^>]*>)|', '$1', $pee );
$pee = preg_replace( '|</figcaption>\s*|', '</figcaption>', $pee );
}
// Remove more than two contiguous line breaks.
$pee = preg_replace("/\n\n+/", "\n\n", $pee);

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7.3-alpha-40090';
$wp_version = '4.7.3-alpha-40091';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.