Changeset 2057
- Timestamp:
- 01/06/2005 10:24:11 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions-formatting.php
r2056 r2057 316 316 @notes 317 317 @changelog 318 --- Modified by Scott Reilly (coffee2code) 02 Aug 2004 318 319 1.2 ***TODO*** Make better - change loop condition to $text 319 320 1.1 Fixed handling of append/stack pop order of end text … … 335 336 336 337 while (preg_match("/<(\/?\w*)\s*([^>]*)>/",$text,$regex)) { 337 $newtext = $newtext .$tagqueue;338 $newtext .= $tagqueue; 338 339 339 340 $i = strpos($text,$regex[0]); 340 $l = strlen($ tagqueue) + strlen($regex[0]);341 $l = strlen($regex[0]); 341 342 342 343 // clear the shifter … … 374 375 // Tag Cleaning 375 376 376 // Push if not img or br or hr 377 if($tag != 'br' && $tag != 'img' && $tag != 'hr') { 377 // If self-closing or '', don't do anything. 378 if((substr($regex[2],-1) == '/') || ($tag == '')) { 379 } 380 // ElseIf it's a known single-entity tag but it doesn't close itself, do so 381 elseif ($tag == 'br' || $tag == 'img' || $tag == 'hr' || $tag == 'input') { 382 $regex[2] .= '/'; 383 } else { // Push the tag onto the stack 384 // If the top of the stack is the same as the tag we want to push, close previous tag 385 if (($stacksize > 0) && ($tag != 'div') && ($tagstack[$stacksize - 1] == $tag)) { 386 $tagqueue = '</' . array_pop ($tagstack) . '>'; 387 $stacksize--; 388 } 378 389 $stacksize = array_push ($tagstack, $tag); 379 390 } 380 391 381 392 // Attributes 382 // $attributes = $regex[2];383 393 $attributes = $regex[2]; 384 394 if($attributes) { … … 386 396 } 387 397 $tag = '<'.$tag.$attributes.'>'; 398 //If already queuing a close tag, then put this tag on, too 399 if ($tagqueue) { 400 $tagqueue .= $tag; 401 $tag = ''; 402 } 388 403 } 389 404 $newtext .= substr($text,0,$i) . $tag; … … 392 407 393 408 // Clear Tag Queue 394 $newtext = $newtext .$tagqueue;409 $newtext .= $tagqueue; 395 410 396 411 // Add Remaining text … … 399 414 // Empty Stack 400 415 while($x = array_pop($tagstack)) { 401 $newtext = $newtext . '</' . $x . '>'; // Add remaining tags to close416 $newtext .= '</' . $x . '>'; // Add remaining tags to close 402 417 } 403 418
Note: See TracChangeset
for help on using the changeset viewer.