balanceTags

Balances tags if forced to, or if the 'use_balanceTags' option is set to true.

Description

(string) balanceTags( (string) $text, (bool) $force = false ); 

Returns (string)

Balanced text

Parameters (2)

0. $text (string)
Text to be balanced
1. $force — Optional. (bool) => false
If true, forces balancing, ignoring the value of the option. Default false.

Usage

  1. if ( !function_exists( 'balanceTags' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // Text to be balanced 
  5. $text = ''; 
  6.  
  7. // If true, forces balancing, ignoring the value of the option. Default false. 
  8. $force = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = balanceTags($text, $force); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/formatting.php  
  1. function balanceTags( $text, $force = false ) { 
  2. if ( $force || get_option('use_balanceTags') == 1 ) { 
  3. return force_balance_tags( $text ); 
  4. } else { 
  5. return $text;