wordpress 函数:wp-云顶国际

这个函数确保只有被允许的 html 标签和属性名,属性值,以及一些正确的 html 实体出现在 $string 中,在调用这个函数之前,需要先移除 php magic quotes 生成的 / 。

用法

参数

$string
(string) (required) 将通过 kses 过滤的内容
default: none

$allowed_html
(array) (required) 允许的 html 标签列表
default: none

$allowed_protocols
(array) (optional) $string 中的链接允许的协议
default: 默认的协议是:http, https, ftp, mailto, news, irc, gopher, nntp, feed, 和 telnet。 这个基本覆盖了大部分的链接协议,除了 javascript,它不允许被一些不受信任用户使用。

返回值

(string)
过滤了不合法 html 代码之后的字符串。

注解

下面是一个创建允许的html标签和属性的实例:

array(
    'a' => array(
        'href' => array(),
        'title' => array()
    ),
    'br' => array(),
    'em' => array(),
    'strong' => array()
);

修改记录

since: 1.0.0

源文件

wp-includes/kses.php

         
网站地图