wp_kses_attr_check() - WordPress 函数参考中文文档

返回介绍

wp_kses_attr_check()

发布于 2017-09-11 字数 2719 浏览 1004 评论 0

wp_kses_attr_check( string $name,  string $value,  string $whole,  string $vless,  string $element,  array $allowed_html )

Determine whether an attribute is allowed.


描述


参数

$name

(string)
(Required)
The attribute name. Returns empty string when not allowed.

$value

(string)
(Required)
The attribute value. Returns a filtered value.

$whole

(string)
(Required)
The name=value input. Returns filtered input.

$vless

(string)
(Required)
‘y’ when attribute like "enabled", otherwise ‘n’.

$element

(string)
(Required)
The name of the element to which this attribute belongs.

$allowed_html

(array)
(Required)
The full list of allowed elements and attributes.


返回值

(bool) Is the attribute allowed?


源代码

File: wp-includes/kses.php

function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowed_html ) {
	$allowed_attr = $allowed_html[strtolower( $element )];

	$name_low = strtolower( $name );
	if ( ! isset( $allowed_attr[$name_low] ) || '' == $allowed_attr[$name_low] ) {
		$name = $value = $whole = '';
		return false;
	}

	if ( 'style' == $name_low ) {
		$new_value = safecss_filter_attr( $value );

		if ( empty( $new_value ) ) {
			$name = $value = $whole = '';
			return false;
		}

		$whole = str_replace( $value, $new_value, $whole );
		$value = $new_value;
	}

	if ( is_array( $allowed_attr[$name_low] ) ) {
		// there are some checks
		foreach ( $allowed_attr[$name_low] as $currkey => $currval ) {
			if ( ! wp_kses_check_attr_val( $value, $vless, $currkey, $currval ) ) {
				$name = $value = $whole = '';
				return false;
			}
		}
	}

	return true;
}

更新日志

Version 描述
4.2.3 Introduced.

相关函数

Uses

  • wp-includes/kses.php:
    safecss_filter_attr()
  • wp-includes/kses.php:
    wp_kses_check_attr_val()

Used By

  • wp-includes/kses.php:
    wp_kses_one_attr()
  • wp-includes/kses.php:
    wp_kses_attr()

User Contributed Notes

上一篇:wp_kses_attr()

下一篇:wp_kses_attr_parse()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!