_wp_add_global_attributes()
Helper function to add global attributes to a tag in the allowed HTML list.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
Array
. The array of attributes with global attributes added.
Usage
_wp_add_global_attributes( $value );
- $value(array) (required)
- An array of attributes.
Changelog
Since 3.5.0 | Introduced. |
Since 5.0.0 | Added support for data-* wildcard attributes. |
Since 6.0.0 | Added dir, lang, and xml:lang to global attributes. |
Since 6.3.0 | Added aria-controls, aria-current, and aria-expanded attributes. |
Since 6.4.0 | Added aria-live and hidden attributes. |
_wp_add_global_attributes() wp add global attributes code WP 6.4.3
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; }