返回给定上下文的允许标记和属性列表。
原型
wp_kses_allowed_html( string|array $context = '' )
参数
$context
(string|array)
(Optional)
要检索标记的上下文。允许的值是post,strip,data,entities或字段过滤器的名称,例如pre_user_description。
返回值
(array)
允许的标签及其允许的属性列表。
源文件
路径:wp-includes/kses.php
<?php
...
function wp_kses_allowed_html( $context = '' ) {
global $allowedposttags, $allowedtags, $allowedentitynames;
if ( is_array( $context ) ) {
/**
* Filters HTML elements allowed for a given context.
*
* @since 3.5.0
*
* @param array $context Context to judge allowed tags by.
* @param string $context_type Context type (explicit).
*/
return apply_filters( 'wp_kses_allowed_html', $context, 'explicit' );
}
switch ( $context ) {
case 'post':
/** This filter is documented in wp-includes/kses.php */
return apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );
case 'user_description':
case 'pre_user_description':
$tags = $allowedtags;
$tags['a']['rel'] = true;
/** This filter is documented in wp-includes/kses.php */
return apply_filters( 'wp_kses_allowed_html', $tags, $context );
case 'strip':
/** This filter is documented in wp-includes/kses.php */
return apply_filters( 'wp_kses_allowed_html', array(), $context );
case 'entities':
/** This filter is documented in wp-includes/kses.php */
return apply_filters( 'wp_kses_allowed_html', $allowedentitynames, $context);
case 'data':
default:
/** This filter is documented in wp-includes/kses.php */
return apply_filters( 'wp_kses_allowed_html', $allowedtags, $context );
}
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_kses_allowed_html/