WP_Interactivity_API::is_bindable_object_attribute │ private static │ WP 7.1.4

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.

Метод класса: WP_Interactivity_API{}

Хуков нет.

Возвращает

bool. Whether the attribute may be bound on an object element.

Использование

$result = WP_Interactivity_API::is_bindable_object_attribute( $attribute_name ): bool;
$attribute_name(строка) (обязательный)
The name of the bound attribute.

Список изменений

С версии 7.1.4 Введена.

Код WP_Interactivity_API::is_bindable_object_attribute() 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 )
	);
}