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
查看更多 >