WordPress开发者和主题制作者的搜索引擎



wp_kses_bad_protocol_once2 ›

Since1.0.0
已弃用n/a
wp_kses_bad_protocol_once2 ( $string, $allowed_protocols )
访问:
  • private
参数: (2)
  • (string) $string URI scheme to check against the whitelist.
    Required: Yes
  • (string[]) $allowed_protocols Array of allowed URL protocols.
    Required: Yes
返回:
  • (string) Sanitized content.
定义在:
文档:

Callback for `wp_kses_bad_protocol_once()` regular expression.

This function processes URL protocols, checks to see if they're in the whitelist or not, and returns different data depending on the answer.



源码

function wp_kses_bad_protocol_once2( $string, $allowed_protocols ) {
	$string2 = wp_kses_decode_entities( $string );
	$string2 = preg_replace( '/\s/', '', $string2 );
	$string2 = wp_kses_no_null( $string2 );
	$string2 = strtolower( $string2 );

	$allowed = false;
	foreach ( (array) $allowed_protocols as $one_protocol ) {
		if ( strtolower( $one_protocol ) == $string2 ) {
			$allowed = true;
			break;
		}
	}

	if ( $allowed ) {
		return "$string2:";
	} else {
		return '';
	}
}