apply_filters( ‘kses_allowed_protocols’, string[] $protocols )

Filters the list of protocols allowed in HTML attributes.

Parameters

$protocolsstring[]
Array of allowed protocols e.g. 'http', 'ftp', 'tel', and more.

Source

$protocols = array_unique( (array) apply_filters( 'kses_allowed_protocols', $protocols ) );

Changelog

VersionDescription
3.0.0Introduced.

User Contributed Notes

  1. Skip to note 5 content

    Currently wp_kses_post will filter a URL that uses `somelink`.

    Here’s how you can allow it:

    `
    add_filter( ‘kses_allowed_protocols’, function( $protocols ) {
    $protocols[] = ‘javascript’;
    return $protocols;
    } );
    `

  2. Skip to note 6 content

    The filter should to run before init.

    Note: this example only works in PHP 5.3+

    function wpse_allow_sms_protocol( $protocols ) {
        $protocols[] = 'sms';
        return $protocols;
    }
    add_action('plugins_loaded', function(){add_filter('kses_allowed_protocols', 'wpse_allow_sms_protocol' );});
    print_r(wp_allowed_protocols());

You must log in before being able to contribute a note or feedback.