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

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



(string) (Required) Text to be balanced


(bool) (Optional) If true, forces balancing, ignoring the value of the option.

Default value: false

Top ↑


(string) Balanced text

Top ↑

More Information

The option ‘use_balanceTags’ is used for whether the tags will be balanced. Either the $force parameter or ‘use_balanceTags’ option need to be true before the tags will be balanced.

Top ↑


File: wp-includes/formatting.php

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;

Top ↑


Version Description
0.71 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.