Make WordPress Core


Ignore:
Timestamp:
06/01/2007 02:33:03 AM (19 years ago)
Author:
rob1n
Message:

Fix nestable HTML, including <blockquote>'s. Props anonymousbugger (!) and Nazgul. fixes #1170

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r5541 r5623  
    440440
    441441        $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
     442        $single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags
     443        $nestable_tags = array('blockquote', 'div', 'span'); //Tags that can be immediately nested within themselves
    442444
    443445        # WP bug fix for comments - in case you REALLY meant to type '< !--'
    … …  
    490492                        }
    491493                        // ElseIf it's a known single-entity tag but it doesn't close itself, do so
    492                         elseif ($tag == 'br' || $tag == 'img' || $tag == 'hr' || $tag == 'input') {
     494                        elseif ( in_array($tag, $single_tags) ) {
    493495                                $regex[2] .= '/';
    494496                        } else {        // Push the tag onto the stack
    495497                                // If the top of the stack is the same as the tag we want to push, close previous tag
    496                                 if (($stacksize > 0) && ($tag != 'div') && ($tagstack[$stacksize - 1] == $tag)) {
     498                                if (($stacksize > 0) && !in_array($tag, $nestable_tags) && ($tagstack[$stacksize - 1] == $tag)) {
    497499                                        $tagqueue = '</' . array_pop ($tagstack) . '>';
    498500                                        $stacksize--;
Note: See TracChangeset for help on using the changeset viewer.