wp_kses_uri_attributes() WordPress Function

The wp_kses_uri_attributes() function is used to remove any dangerous or unwanted attributes from a given URL. It is important to note that this function only works on URLs, and not on other types of data. This function is often used to clean user- inputted data before it is stored in the database, or displayed on the front- end of a website.

wp_kses_uri_attributes() #

Returns an array of HTML attribute names whose value contains a URL.


Description

This function returns a list of all HTML attributes that must contain a URL according to the HTML specification.

This list includes URI attributes both allowed and disallowed by KSES.


Top ↑

Return

(string[]) HTML attribute names whose value contains a URL.


Top ↑

Source

File: wp-includes/kses.php

964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
function wp_kses_uri_attributes() {
    $uri_attributes = array(
        'action',
        'archive',
        'background',
        'cite',
        'classid',
        'codebase',
        'data',
        'formaction',
        'href',
        'icon',
        'longdesc',
        'manifest',
        'poster',
        'profile',
        'src',
        'usemap',
        'xmlns',
    );
 
    /**
     * Filters the list of attributes that are required to contain a URL.
     *
     * Use this filter to add any `data-` attributes that are required to be
     * validated as a URL.
     *
     * @since 5.0.1
     *
     * @param string[] $uri_attributes HTML attribute names whose value contains a URL.
     */
    $uri_attributes = apply_filters( 'wp_kses_uri_attributes', $uri_attributes );
 
    return $uri_attributes;
}


Top ↑

Changelog

Changelog
VersionDescription
5.0.1Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.