wp_kses_split

函式
wp_kses_split ( $string, $allowed_html, $allowed_protocols )
引數
  • (string) $string Content to filter.
    Required:
  • (array[]|string) $allowed_html An array of allowed HTML elements and attributes, or a context name such as 'post'. See wp_kses_allowed_html() for the list of accepted context names.
    Required:
  • (string[]) $allowed_protocols Array of allowed URL protocols.
    Required:
返回值
  • (string) Content with fixed HTML tags
定義位置
相關方法
wp_kses_postwp_kses_hairwp_kses_attrwp_kses_datawp_kses_version
引入
1.0.0
棄用
-

wp_kses_split: 這個函式用於將一串HTML內容分割成一個安全和潛在不安全的塊的陣列。

搜尋HTML標籤,不管是多麼畸形的標籤。

它還可以匹配遊離的`>`字元。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_kses_split( $string, $allowed_html, $allowed_protocols ) {
global $pass_allowed_html, $pass_allowed_protocols;
$pass_allowed_html = $allowed_html;
$pass_allowed_protocols = $allowed_protocols;
return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $string );
}
function wp_kses_split( $string, $allowed_html, $allowed_protocols ) { global $pass_allowed_html, $pass_allowed_protocols; $pass_allowed_html = $allowed_html; $pass_allowed_protocols = $allowed_protocols; return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $string ); }
function wp_kses_split( $string, $allowed_html, $allowed_protocols ) {
	global $pass_allowed_html, $pass_allowed_protocols;

	$pass_allowed_html      = $allowed_html;
	$pass_allowed_protocols = $allowed_protocols;

	return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $string );
}

常見問題

FAQs
檢視更多 >