On this page
balanceTags( string $text, bool $force = false ): string
Balances tags if forced to, or if the ‘use_balanceTags’ option is set to true.
Parameters
$textstring Required-
Text to be balanced
$forcebool Optional-
If true, forces balancing, ignoring the value of the option.
Default:
false
Return
string Balanced text
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.
Source
File: wp-includes/formatting.php. View all references
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;
}
}
Related
Uses
| Uses | Description |
|---|---|
| force_balance_tags() wp-includes/formatting.php | Balances tags of string using a modified stack. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
Changelog
| Version | Description |
|---|---|
| 0.71 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/balancetags