tag_escape

函式
tag_escape ( $tag_name )
引數
  • (string) $tag_name
    Required:
返回值
  • (string)
定義位置
相關方法
js_escapelike_escapetag_descriptionattribute_escapetag_exists
引入
2.5.0
棄用
-

tag_escape: 這是一個WordPress函式,用於轉義標籤名稱或描述中的特殊字元。這對於確保標籤資料的格式正確,並在查詢和HTML輸出中安全使用是很重要的。

轉移一個HTML標籤的名稱。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function tag_escape( $tag_name ) {
$safe_tag = strtolower( preg_replace( '/[^a-zA-Z0-9_:]/', '', $tag_name ) );
/**
* Filters a string cleaned and escaped for output as an HTML tag.
*
* @since 2.8.0
*
* @param string $safe_tag The tag name after it has been escaped.
* @param string $tag_name The text before it was escaped.
*/
return apply_filters( 'tag_escape', $safe_tag, $tag_name );
}
function tag_escape( $tag_name ) { $safe_tag = strtolower( preg_replace( '/[^a-zA-Z0-9_:]/', '', $tag_name ) ); /** * Filters a string cleaned and escaped for output as an HTML tag. * * @since 2.8.0 * * @param string $safe_tag The tag name after it has been escaped. * @param string $tag_name The text before it was escaped. */ return apply_filters( 'tag_escape', $safe_tag, $tag_name ); }
function tag_escape( $tag_name ) {
	$safe_tag = strtolower( preg_replace( '/[^a-zA-Z0-9_:]/', '', $tag_name ) );
	/**
	 * Filters a string cleaned and escaped for output as an HTML tag.
	 *
	 * @since 2.8.0
	 *
	 * @param string $safe_tag The tag name after it has been escaped.
	 * @param string $tag_name The text before it was escaped.
	 */
	return apply_filters( 'tag_escape', $safe_tag, $tag_name );
}

常見問題

FAQs
檢視更多 >