_wp_add_global_attributes

The timeline below displays how wordpress function _wp_add_global_attributes has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Helper function to add global attributes to a tag in the allowed HTML list.
 *
 * @since 3.5.0
 * @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.
 *
 * @access private
 * @ignore
 *
 * @param array $value An array of attributes.
 * @return array The array of attributes with global attributes added.
 */
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;
}

WordPress Version: 6.3

/**
 * Helper function to add global attributes to a tag in the allowed HTML list.
 *
 * @since 3.5.0
 * @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.
 *
 * @access private
 * @ignore
 *
 * @param array $value An array of attributes.
 * @return array The array of attributes with global attributes added.
 */
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-label' => true, 'aria-labelledby' => true, 'aria-hidden' => true, 'class' => true, 'data-*' => true, 'dir' => 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;
}

WordPress Version: 6.1

/**
 * Helper function to add global attributes to a tag in the allowed HTML list.
 *
 * @since 3.5.0
 * @since 5.0.0 Added support for `data-*` wildcard attributes.
 * @since 6.0.0 Added `dir`, `lang`, and `xml:lang` to global attributes.
 *
 * @access private
 * @ignore
 *
 * @param array $value An array of attributes.
 * @return array The array of attributes with global attributes added.
 */
function _wp_add_global_attributes($value)
{
    $global_attributes = array('aria-describedby' => true, 'aria-details' => true, 'aria-label' => true, 'aria-labelledby' => true, 'aria-hidden' => true, 'class' => true, 'data-*' => true, 'dir' => 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;
}

WordPress Version: 5.5

/**
 * Helper function to add global attributes to a tag in the allowed HTML list.
 *
 * @since 3.5.0
 * @since 5.0.0 Add support for `data-*` wildcard attributes.
 * @access private
 * @ignore
 *
 * @param array $value An array of attributes.
 * @return array The array of attributes with global attributes added.
 */
function _wp_add_global_attributes($value)
{
    $global_attributes = array('aria-describedby' => true, 'aria-details' => true, 'aria-label' => true, 'aria-labelledby' => true, 'aria-hidden' => true, 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'role' => true, 'data-*' => true);
    if (true === $value) {
        $value = array();
    }
    if (is_array($value)) {
        return array_merge($value, $global_attributes);
    }
    return $value;
}

WordPress Version: 5.1

/**
 * Helper function to add global attributes to a tag in the allowed html list.
 *
 * @since 3.5.0
 * @since 5.0.0 Add support for `data-*` wildcard attributes.
 * @access private
 * @ignore
 *
 * @param array $value An array of attributes.
 * @return array The array of attributes with global attributes added.
 */
function _wp_add_global_attributes($value)
{
    $global_attributes = array('aria-describedby' => true, 'aria-details' => true, 'aria-label' => true, 'aria-labelledby' => true, 'aria-hidden' => true, 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'role' => true, 'data-*' => true);
    if (true === $value) {
        $value = array();
    }
    if (is_array($value)) {
        return array_merge($value, $global_attributes);
    }
    return $value;
}

WordPress Version: 5.0

/**
 * Helper function to add global attributes to a tag in the allowed html list.
 *
 * @since 3.5.0
 * @since 5.0.0 Add support for `data-*` wildcard attributes.
 * @access private
 *
 * @param array $value An array of attributes.
 * @return array The array of attributes with global attributes added.
 */
function _wp_add_global_attributes($value)
{
    $global_attributes = array('aria-describedby' => true, 'aria-details' => true, 'aria-label' => true, 'aria-labelledby' => true, 'aria-hidden' => true, 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'role' => true, 'data-*' => true);
    if (true === $value) {
        $value = array();
    }
    if (is_array($value)) {
        return array_merge($value, $global_attributes);
    }
    return $value;
}

WordPress Version: 3.9

/**
 * Helper function to add global attributes to a tag in the allowed html list.
 *
 * @since 3.5.0
 * @access private
 *
 * @param array $value An array of attributes.
 * @return array The array of attributes with global attributes added.
 */
function _wp_add_global_attributes($value)
{
    $global_attributes = array('class' => true, 'id' => true, 'style' => true, 'title' => true, 'role' => true);
    if (true === $value) {
        $value = array();
    }
    if (is_array($value)) {
        return array_merge($value, $global_attributes);
    }
    return $value;
}

WordPress Version: 3.7

/**
 * Helper function to add global attributes to a tag in the allowed html list.
 *
 * @since 3.5.0
 * @access private
 *
 * @param array $value An array of attributes.
 * @return array The array of attributes with global attributes added.
 */
function _wp_add_global_attributes($value)
{
    $global_attributes = array('class' => true, 'id' => true, 'style' => true, 'title' => true);
    if (true === $value) {
        $value = array();
    }
    if (is_array($value)) {
        return array_merge($value, $global_attributes);
    }
    return $value;
}