Changeset 21828
- Timestamp:
- 09/13/2012 04:39:06 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r21718 r21828 1156 1156 $tagqueue = ''; 1157 1157 $newtext = ''; 1158 $single_tags = array( 'br', 'hr', 'img', 'input' ); // Known single-entity/self-closing tags 1159 $nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' ); // Tags that can be immediately nested within themselves 1158 // Known single-entity/self-closing tags 1159 $single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source' ); 1160 // Tags that can be immediately nested within themselves 1161 $nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' ); 1160 1162 1161 1163 // WP bug fix for comments - in case you REALLY meant to type '< !--' … … 1204 1206 // Tag Cleaning 1205 1207 1206 // If self-closing or '', don't do anything.1207 if ( substr($regex[2],-1) == '/' || $tag == '') {1208 // If it's an empty tag "< >", do nothing 1209 if ( '' == $tag ) { 1208 1210 // do nothing 1211 } 1212 // ElseIf it presents itself as a self-closing tag... 1213 elseif ( substr( $regex[2], -1 ) == '/' ) { 1214 // ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and 1215 // immediately close it with a closing tag (the tag will encapsulate no text as a result) 1216 if ( ! in_array( $tag, $single_tags ) ) 1217 $regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag"; 1209 1218 } 1210 1219 // ElseIf it's a known single-entity tag but it doesn't close itself, do so 1211 1220 elseif ( in_array($tag, $single_tags) ) { 1212 1221 $regex[2] .= '/'; 1213 } else { // Push the tag onto the stack 1222 } 1223 // Else it's not a single-entity tag 1224 else { 1214 1225 // If the top of the stack is the same as the tag we want to push, close previous tag 1215 1226 if ( $stacksize > 0 && !in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag ) { 1216 $tagqueue = '</' . array_pop ($tagstack) . '>';1227 $tagqueue = '</' . array_pop( $tagstack ) . '>'; 1217 1228 $stacksize--; 1218 1229 } 1219 $stacksize = array_push ($tagstack, $tag);1230 $stacksize = array_push( $tagstack, $tag ); 1220 1231 } 1221 1232 1222 1233 // Attributes 1223 1234 $attributes = $regex[2]; 1224 if( ! empty($attributes))1225 $attributes = ' ' .$attributes;1235 if( ! empty( $attributes ) && $attributes[0] != '>' ) 1236 $attributes = ' ' . $attributes; 1226 1237 1227 1238 $tag = '<' . $tag . $attributes . '>';
Note: See TracChangeset
for help on using the changeset viewer.