Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
wp_kses_allowed_html() - 返回给定上下文允许的HTML标签和属性的数组 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / wp_kses_allowed_html()

wp_kses_allowed_html( string|array $context = '' ): array

返回给定上下文允许的HTML标签和属性的数组


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 4 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "15fa1e388482fb7f2250a8ac8d637c44" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "532ee313ff4520dc0faacd8e69ff378a" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "e283cc7ab1dbef6488b2693a393334ea" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "80fa2dd3f78b55ea2349d22e0a81c475" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

allowed 允许

html

kses 清理

sanitize 清理more...


参数

$contextstring|array可选
要检索其标签的上下文。允许的值为'post'、'strip'、'data'、'entities',或字段过滤器(如'pre_user_description')的名称,或允许的HTML元素和属性的数组。

默认:''


返回

array 允许的HTML标签及其允许的属性的数组。


更多信息

返回的值是一个多维数组,标签名为键,属性数组为值。


钩子



源码

查看源码 官方文档


更新日志

版本描述
5.0.1form作为允许的HTML标签被删除。
3.5.0开始引入

使用示例

  • 示例1

    从Codex迁移的示例:

    // strips all html (empty array)
    $allowed_html = wp_kses_allowed_html( 'strip' );
    
    // allows all most inline elements and strips all block level elements except blockquote
    $allowed_html = wp_kses_allowed_html( 'data' );
    
    // very permissive: allows pretty much all HTML to pass - same as what's normally applied to the_content by default
    $allowed_html = wp_kses_allowed_html( 'post' );
    
    // allows a list of HTML Entities such as  
    $allowed_html = wp_kses_allowed_html( 'entities' );