balancetags

函式
balancetags ( $text, $force = false )
引數
  • (string) $text Text to be balanced
    Required:
  • (bool) $force If true, forces balancing, ignoring the value of the option. Default false.
    Required:
    Default: false
返回值
  • (string) Balanced text
定義位置
相關方法
force_balance_tagsallowed_tagsmaintenance_nagget_tagsthe_tags
引入
0.71
棄用
-

balancetags: 這個函式用於平衡字串中的HTML標籤。它接收一個字串作為引數,並返回帶有平衡HTML標籤的字串。

如果被迫這樣做,或者如果’use_balanceTags’選項被設定為”true”,則會平衡標籤。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
}
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; } }
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;
	}
}

常見問題

FAQs
檢視更多 >