WP_Interactivity_API::is_bindable_object_attribute
Determines whether a binding may set or remove an attribute of an object element.
KSES only allows an object element in post content after checking the values of its data and type attributes. Neither the server nor the client can repeat that check for a bound value, so a binding on an object element may only change attributes that cannot change what it loads: aria-* attributes, data-* attributes other than directives, width, height, and the global attributes KSES allows on any element. Any aria-* attribute is allowed, where KSES lists only some. A data-wp-* attribute is refused because it is a directive, which could bind data or type once rendered. The client runtime enforces the same set.
Method of the class: WP_Interactivity_API{}
No Hooks.
Returns
bool. Whether the attribute may be bound on an object element.
Usage
$result = WP_Interactivity_API::is_bindable_object_attribute( $attribute_name ): bool;
- $attribute_name(string) (required)
- The name of the bound attribute.
Changelog
| Since 7.1.4 | Introduced. |
WP_Interactivity_API::is_bindable_object_attribute() WP Interactivity API::is bindable object attribute code WP 7.1.4
private static function is_bindable_object_attribute( string $attribute_name ): bool {
$attribute_name = strtolower( $attribute_name );
return (
str_starts_with( $attribute_name, 'aria-' ) ||
( str_starts_with( $attribute_name, 'data-' ) && ! str_starts_with( $attribute_name, 'data-wp-' ) ) ||
in_array( $attribute_name, array( 'class', 'dir', 'height', 'hidden', 'id', 'lang', 'role', 'style', 'tabindex', 'title', 'width' ), true )
);
}