balanceTags()WP 0.71

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

1 time — 0.0001741 sec (fast) | 50000 times — 0.37 sec (very fast) | PHP 7.4.8, WP 5.8

No Hooks.

Return

String. Balanced text

Usage

balanceTags( $text, $force )  // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid;
$text(string) (required)
Text to be balanced
$force(true|false)
If true, forces balancing, ignoring the value of the option.
Default: false

Changelog

Since 0.71 Introduced.

Code of balanceTags() WP 5.9.3

function balanceTags( $text, $force = false ) {  // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	if ( $force || (int) get_option( 'use_balanceTags' ) === 1 ) {
		return force_balance_tags( $text );
	} else {
		return $text;
	}
}