返回介绍

wp_kses_attr_check()

发布于 2017-09-11 12:19:14 字数 2717 浏览 1105 评论 0 收藏 0

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

Determine whether an attribute is allowed.


description


参数

$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;
}

更新日志

Versiondescription
4.2.3Introduced.

相关函数

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文