Extending Allowed URL Protocols
For security and proper URL formatting, we use the standard WordPress function esc_url
in multiple areas.
This function has a peculiarity: it will only allow certain known and safe protocols. By default in WordPress it will only allow these protocols:
http, https, ftp, ftps, mailto, news, irc, gopher, nntp, feed, telnet, mms, rtsp, svn, tel, fax, xmpp
In Themify themes and Builder, we have also added:
skype, sms, comgooglemaps, comgooglemapsurl, comgooglemaps-x-callback
But perhaps you need even another protocol. You can add your own protocol by following these steps:
1. Create a child theme and a functions.php file (if you don't have it yet)
2. Add this code in the child theme functions.php:
<?php
/**
* Add extra protocols to list of allowed protocols.
*
* @param array $protocols List of protocols allowed by default by WordPress.
*
* @return array $protocols Updated list including extra protocols added.
*/
function custom_themify_add_more_protocols( $protocols ){
$protocols[] = 'andromo';
return $protocols;
}
add_filter( 'kses_allowed_protocols' , 'custom_themify_add_more_protocols' );