目录
描述
译文
过滤文本中的bad protocol和其它字符。
该函数在处理空格符和HTML实体时,在$string的开始部分查找URL protocol(协议)。
原文
清理字符串,删除 误的 URL 协议和 他字符。
这个函数删除 $string
开 的不允许 协议,它会忽略空格 处理 HTML 。
用法
<?php wp_kses_bad_protocol_once( $string, $allowed_protocols ) ?>
参数
$string
(string) (必填) 需 过滤错误 URL 议的字符串
默 值: None
$allowed_protocols
(string) (必填) 许的协
默认值: None
返回值
历史
添加于 版本: 1.0.0
源文件
wp_kses_bad_protocol_once() 函数的代码位于 wp-includes/kses.php
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
/* ---------------------------------- * wordpress之魂 © http://wphun.com * ---------------------------------- */ /** * Sanitizes content from bad protocols and other characters. * * This function searches for URL protocols at the beginning of $string, while * handling whitespace and HTML entities. * * @since 1.0.0 * * @param string $string Content to check for bad protocols * @param string $allowed_protocols Allowed protocols * @return string Sanitized content */ function wp_kses_bad_protocol_once($string, $allowed_protocols, $count = 1 ) { $string2 = preg_split( '/:|�*58;|�*3a;/i', $string, 2 ); if ( isset($string2[1]) && ! preg_match('%/?%', $string2[0]) ) { $string = trim( $string2[1] ); $protocol = wp_kses_bad_protocol_once2( $string2[0], $allowed_protocols ); if ( 'feed:' == $protocol ) { if ( $count > 2 ) return ''; $string = wp_kses_bad_protocol_once( $string, $allowed_protocols, ++$count ); if ( empty( $string ) ) return $string; } $string = $protocol . $string; } return $string; } |
- 原文:http://codex.wordpress.org/Function_Reference/wp_kses_bad_protocol_once
- 翻译:黄聪@WordPress之魂