diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 12a9b538b5..e2204afbb6 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -439,6 +439,8 @@ function balanceTags($text, $force = false) { return $text; $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = ''; + $single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags + $nestable_tags = array('blockquote', 'div', 'span'); //Tags that can be immediately nested within themselves # WP bug fix for comments - in case you REALLY meant to type '< !--' $text = str_replace('< !--', '< !--', $text); @@ -489,11 +491,11 @@ function balanceTags($text, $force = false) { if((substr($regex[2],-1) == '/') || ($tag == '')) { } // ElseIf it's a known single-entity tag but it doesn't close itself, do so - elseif ($tag == 'br' || $tag == 'img' || $tag == 'hr' || $tag == 'input') { + elseif ( in_array($tag, $single_tags) ) { $regex[2] .= '/'; } else { // Push the tag onto the stack // If the top of the stack is the same as the tag we want to push, close previous tag - if (($stacksize > 0) && ($tag != 'div') && ($tagstack[$stacksize - 1] == $tag)) { + if (($stacksize > 0) && !in_array($tag, $nestable_tags) && ($tagstack[$stacksize - 1] == $tag)) { $tagqueue = ''; $stacksize--; }