Ticket #1597: 1597.diff
| File 1597.diff, 2.4 KB (added by coffee2code, 20 months ago) |
|---|
-
wp-includes/formatting.php
1 1 2 <?php 2 3 /** 3 4 * Main WordPress Formatting API. … … 993 994 $stacksize = 0; 994 995 $tagqueue = ''; 995 996 $newtext = ''; 996 $single_tags = array(' br', 'hr', 'img', 'input'); // Known single-entity/self-closing tags997 $single_tags = array('area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source'); // Known single-entity/self-closing tags 997 998 $nestable_tags = array('blockquote', 'div', 'span'); // Tags that can be immediately nested within themselves 998 999 999 1000 // WP bug fix for comments - in case you REALLY meant to type '< !--' … … 1041 1042 1042 1043 // Tag Cleaning 1043 1044 1044 // If self-closing or '', don't do anything.1045 if ( substr($regex[2],-1) == '/' || $tag == '') {1045 // If it's an empty tag "< >", do nothing 1046 if ( '' == $tag ) { 1046 1047 // do nothing 1047 1048 } 1049 // ElseIf it presents itself as a self-closing tag... 1050 elseif ( substr($regex[2],-1) == '/' ) { 1051 // ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and 1052 // immediately close it with a closing tag (the tag will encapsulate no text as a result) 1053 if ( !in_array($tag, $single_tags) ) 1054 $regex[2] = substr($regex[2], 0, -1) . "></$tag"; 1055 } 1048 1056 // ElseIf it's a known single-entity tag but it doesn't close itself, do so 1049 1057 elseif ( in_array($tag, $single_tags) ) { 1050 1058 $regex[2] .= '/'; 1051 } else { // Push the tag onto the stack 1059 } 1060 // Else it's not a single-entity tag 1061 else { 1052 1062 // If the top of the stack is the same as the tag we want to push, close previous tag 1053 1063 if ( $stacksize > 0 && !in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag ) { 1054 $tagqueue = '</' . array_pop ($tagstack) . '>';1064 $tagqueue = '</' . array_pop($tagstack) . '>'; 1055 1065 $stacksize--; 1056 1066 } 1057 $stacksize = array_push ($tagstack, $tag);1067 $stacksize = array_push($tagstack, $tag); 1058 1068 } 1059 1069 1060 1070 // Attributes 1061 1071 $attributes = $regex[2]; 1062 1072 if( !empty($attributes) ) 1063 $attributes = ' ' .$attributes;1073 $attributes = ' ' . $attributes; 1064 1074 1065 1075 $tag = '<' . $tag . $attributes . '>'; 1066 1076 //If already queuing a close tag, then put this tag on, too
