WordPress.org

Make WordPress Core

Changeset 4663


Ignore:
Timestamp:
12/23/2006 06:33:24 AM (14 years ago)
Author:
markjaquith
Message:

Sync balanceTags() and force_balance_tags() to trunk. fixes #2714

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/wp-includes/functions-formatting.php

    r4661 r4663  
    400400/*
    401401 balanceTags
    402  
     402
    403403 Balances Tags of string using a modified stack.
    404  
     404
    405405 @param text      Text to be balanced
     406 @param force     Forces balancing, ignoring the value of the option
    406407 @return          Returns balanced text
    407408 @author          Leonard Lin (leonard@acm.org)
     
    409410 @date            November 4, 2001
    410411 @license         GPL v2.0
    411  @notes           
    412  @changelog       
     412 @notes
     413 @changelog
    413414 ---  Modified by Scott Reilly (coffee2code) 02 Aug 2004
    414              1.2  ***TODO*** Make better - change loop condition to $text
    415              1.1  Fixed handling of append/stack pop order of end text
    416                   Added Cleaning Hooks
    417              1.0  First Version
     415    1.2  ***TODO*** Make better - change loop condition to $text
     416    1.1  Fixed handling of append/stack pop order of end text
     417         Added Cleaning Hooks
     418    1.0  First Version
    418419*/
    419 function balanceTags($text, $is_comment = 0) {
    420    
    421     if ( get_option('use_balanceTags') == 0)
     420function balanceTags($text, $force = false) {
     421
     422    if ( !$force && get_option('use_balanceTags') == 0 )
    422423        return $text;
    423424
     
    441442            $tag = strtolower(substr($regex[1],1));
    442443            // if too many closing tags
    443             if($stacksize <= 0) { 
     444            if($stacksize <= 0) {
    444445                $tag = '';
    445446                //or close to be safe $tag = '/' . $tag;
     
    498499        $newtext .= substr($text,0,$i) . $tag;
    499500        $text = substr($text,$i+$l);
    500     } 
     501    }
    501502
    502503    // Clear Tag Queue
     
    519520
    520521function force_balance_tags($text) {
    521     return balanceTags($text, 0, true);
     522    return balanceTags($text, true);
    522523}
    523524
Note: See TracChangeset for help on using the changeset viewer.