_wp_add_global_attributes()
Helper function to add global attributes to a tag in the allowed HTML list.
Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.
Хуков нет.
Возвращает
Массив. The array of attributes with global attributes added.
Использование
_wp_add_global_attributes( $value );
- $value(массив) (обязательный)
- An array of attributes.
Список изменений
| С версии 3.5.0 | Введена. |
| С версии 5.0.0 | Added support for data-* wildcard attributes. |
| С версии 6.0.0 | Added dir, lang, and xml:lang to global attributes. |
| С версии 6.3.0 | Added aria-controls, aria-current, and aria-expanded attributes. |
| С версии 6.4.0 | Added aria-live and hidden attributes. |
Код _wp_add_global_attributes() wp add global attributes WP 7.0
function _wp_add_global_attributes( $value ) {
$global_attributes = array(
'aria-controls' => true,
'aria-current' => true,
'aria-describedby' => true,
'aria-details' => true,
'aria-expanded' => true,
'aria-hidden' => true,
'aria-label' => true,
'aria-labelledby' => true,
'aria-live' => true,
'class' => true,
'data-*' => true,
'dir' => true,
'hidden' => true,
'id' => true,
'lang' => true,
'style' => true,
'title' => true,
'role' => true,
'xml:lang' => true,
);
if ( true === $value ) {
$value = array();
}
if ( is_array( $value ) ) {
return array_merge( $value, $global_attributes );
}
return $value;
}