clean_url()清除Html中的所有链接

目录

描述

译文

查看并过滤URL。

URL中若干字符被删除。如果URL用于在文本中显示链接地址,URL中的&号也会被替换。clean_url对返回的已过滤URL进行再次过滤。

原文

Checks and cleans a URL.

A number of characters are removed from the URL. If the URL is for displaying (the default behaviour) ampersands (&) are also replaced. The 'clean_url' filter is applied to the returned cleaned URL.

clean_url() 描述

用法

<?php clean_url$url$protocols$context ?>

clean_url() 用法

参数

$url

(string) (必填) The URL to be cleaned.

默认值: None

$protocols

(array) (可选) An array of acceptable protocols. Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set.

默认值: null

$context

(string) (可选) How the URL will be used. Default is 'display'.

默认值: 'display'

clean_url() 参数

返回值

(string) 

The cleaned $url after the 'cleaned_url' filter is applied.

clean_url() 返回值

注意

  • 使用到: wp_kses_bad_protocol() to only permit protocols in the URL set via $protocols or the common ones set in the function.

clean_url() 注意

源文件

clean_url() 函数的代码位于 wp-includes/formatting.php.

clean_url() 源文件

相关