From bf83dbd55f0b56c9aa84f2a496f458a6a42a197f Mon Sep 17 00:00:00 2001 From: markjaquith Date: Sat, 23 Dec 2006 06:33:24 +0000 Subject: [PATCH] Sync balanceTags() and force_balance_tags() to trunk. fixes #2714 git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@4663 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions-formatting.php | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/wp-includes/functions-formatting.php b/wp-includes/functions-formatting.php index ef5c80b5fd..e6e1670609 100644 --- a/wp-includes/functions-formatting.php +++ b/wp-includes/functions-formatting.php @@ -399,26 +399,27 @@ function funky_javascript_fix($text) { /* balanceTags - + Balances Tags of string using a modified stack. - + @param text Text to be balanced + @param force Forces balancing, ignoring the value of the option @return Returns balanced text @author Leonard Lin (leonard@acm.org) @version v1.1 @date November 4, 2001 @license GPL v2.0 - @notes - @changelog + @notes + @changelog --- Modified by Scott Reilly (coffee2code) 02 Aug 2004 - 1.2 ***TODO*** Make better - change loop condition to $text - 1.1 Fixed handling of append/stack pop order of end text - Added Cleaning Hooks - 1.0 First Version + 1.2 ***TODO*** Make better - change loop condition to $text + 1.1 Fixed handling of append/stack pop order of end text + Added Cleaning Hooks + 1.0 First Version */ -function balanceTags($text, $is_comment = 0) { - - if ( get_option('use_balanceTags') == 0) +function balanceTags($text, $force = false) { + + if ( !$force && get_option('use_balanceTags') == 0 ) return $text; $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = ''; @@ -440,7 +441,7 @@ function balanceTags($text, $is_comment = 0) { if ($regex[1][0] == "/") { // End Tag $tag = strtolower(substr($regex[1],1)); // if too many closing tags - if($stacksize <= 0) { + if($stacksize <= 0) { $tag = ''; //or close to be safe $tag = '/' . $tag; } @@ -497,7 +498,7 @@ function balanceTags($text, $is_comment = 0) { } $newtext .= substr($text,0,$i) . $tag; $text = substr($text,$i+$l); - } + } // Clear Tag Queue $newtext .= $tagqueue; @@ -518,7 +519,7 @@ function balanceTags($text, $is_comment = 0) { } function force_balance_tags($text) { - return balanceTags($text, 0, true); + return balanceTags($text, true); } function format_to_edit($content, $richedit = false) {