A WordPress-centric search engine for devs and theme authors



wp_kses_attr_check ›

Since4.2.3
Deprecatedn/a
wp_kses_attr_check ( $name, $value, $whole, $vless, $element, $allowed_html )
Parameters: (6)
  • (string) $name The attribute name. Passed by reference. Returns empty string when not allowed.
    Required: Yes
  • (string) $value The attribute value. Passed by reference. Returns a filtered value.
    Required: Yes
  • (string) $whole The `name=value` input. Passed by reference. Returns filtered input.
    Required: Yes
  • (string) $vless Whether the attribute is valueless. Use 'y' or 'n'.
    Required: Yes
  • (string) $element The name of the element to which this attribute belongs.
    Required: Yes
  • (array) $allowed_html The full list of allowed elements and attributes.
    Required: Yes
Returns:
  • (bool) Whether or not the attribute is allowed.
Defined at:
Codex:

Determines whether an attribute is allowed.



Source

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