Formatting: Add additional support for single and nestable tags in force_balance_tags().

Adds `track` and `wbr` support for single tags.

Adds `article`, `aside`, `details`, `figure`, and `section` for nestable tags.

Updates tests.

Follow-up to [5805], [21828], [45929].

Props glendaviesnz, costdev, talldanwp, ramonopoly, sergeybiryukov.
Fixes #50225.

git-svn-id: https://develop.svn.wordpress.org/trunk@52188 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork 2021-11-16 19:40:36 +00:00
parent 5d5c9bf6a7
commit dac57bbf50
2 changed files with 9 additions and 2 deletions

View File

@ -2514,9 +2514,9 @@ function force_balance_tags( $text ) {
$tagqueue = '';
$newtext = '';
// Known single-entity/self-closing tags.
$single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source' );
$single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source', 'track', 'wbr' );
// Tags that can be immediately nested within themselves.
$nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' );
$nestable_tags = array( 'article', 'aside', 'blockquote', 'details', 'div', 'figure', 'object', 'q', 'section', 'span' );
// WP bug fix for comments - in case you REALLY meant to type '< !--'.
$text = str_replace( '< !--', '< !--', $text );

View File

@ -7,10 +7,15 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
public function nestable_tags() {
return array(
array( 'article' ),
array( 'aside' ),
array( 'blockquote' ),
array( 'details' ),
array( 'div' ),
array( 'figure' ),
array( 'object' ),
array( 'q' ),
array( 'section' ),
array( 'span' ),
);
}
@ -34,6 +39,8 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
array( 'meta' ),
array( 'param' ),
array( 'source' ),
array( 'track' ),
array( 'wbr' ),
);
}