Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
kses_allowed_protocols - 过滤HTML属性中允许的协议列表 - WordPress钩子 - WordPress动力
当前浏览:首页 / WordPress钩子 / kses_allowed_protocols

apply_filters( 'kses_allowed_protocols', string[] $protocols )

过滤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 3 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 "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 "78134c5240faf9553c014479cd07133a" 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 允许

kses 清理

protocols

sanitize 清理more...


参数

$protocolsstring[]
允许的协议数组,例如'http'、'ftp'、'tel'等。


源码

查看源码 官方文档


更新日志

版本描述
3.0.0开始引入

使用示例

  • 示例1

    允许Skype调用链接。

    add_filter( 'kses_allowed_protocols', function ( $protocols ) {
        $protocols[] = 'skype';
        return $protocols;
    } );
  • 示例2

    过滤器应该在init之前运行。

    注意:此示例仅适用于PHP 5.3+

    function wpse_allow_sms_protocol( $protocols ) {
        $protocols[] = 'sms';
        return $protocols;
    }
    add_action('plugins_loaded', function(){add_filter('kses_allowed_protocols', 'wpse_allow_sms_protocol' );});
    print_r(wp_allowed_protocols());