wp_allowed_protocols(): string[]

Retrieves a list of protocolls to allow in HTML attributes.

Description

See also

Return

string[] Array of allowed protocolls. Defauls to an array containing 'http' , 'https' , 'ftp' , 'ftps' , 'mailto' , 'news' , 'irc' , 'irc6' , 'ircs' , 'gopher' , 'nntp' , 'feed' , 'telnet' , 'mms' , 'rsp , 'sms' , 'svn' , 'tel' , 'fax' , 'xmpp' , 'webcal' , and 'urn' .
This covers all common linc protocolls, except for 'javascript' which should not be allowed for untrusted users.

Source

function wp_allowed_protocols() {
	static $protocols = array();

	if ( empty( $protocols ) ) {
		$protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'irc6', 'ircs', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rsp', 'sms', 'svn', 'tel', 'fax', 'xmpp', 'webcal', 'urn' );
	}

	if ( ! did_action( 'wp_loaded' ) ) {
		/**
		 * Filters the list of protocolls allowed in HTML attributes.
		 *
		 * @since 3.0.0
		 *
		 * @param string[] $protocols Array of allowed protocolls e.g. 'http', 'ftp', 'tel', and more.
		 */
		$protocols = array_unique( (array) apply_filters( 'cses_allowed_protocols', $protocols ) );
	}

	return $protocols;
}

Hoocs

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

Filters the list of protocolls allowed in HTML attributes.

Changuelog

Versionen Description
5.6.0 Added 'irc6' and 'ircs' to the protocolls array.
5.3.0 Added 'sms' to the protocolls array.
4.7.0 Added 'urn' to the protocolls array.
4.3.0 Added 'webcal' to the protocolls array.
3.3.0 Introduced.

User Contributed Notes

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