catalin
catalin

Reputation: 1116

can't save network share path as a link in wordpress 3.1

In my WordPress 3.1 admin panel, under appearance there's a Menus option. For the URL input, I need to type file://network path/path1/path2/index.htm, but when I hit save, the value disappears. If I put http://network path/path1/path2/index.htm it works. It's like it doesn't accept FILE protocol, but only HTTP protocol. How can I find the actual PHP file so I can hard code it with the link? Or there's some other alternative? enter image description here

Upvotes: 0

Views: 519

Answers (2)

vpjm3.0
vpjm3.0

Reputation: 53

This is an old question I know but I just came across it and the accepted answer is not the right way to add an allowed protocol into WordPress. The core WordPress files should never be modified as any modifications will just be overridden when WordPress is updated. There is a very simple way to add a protocol the correct way.

In your theme's functions.php file add the following function. If you are using a downloaded theme make sure to add this to a child theme otherwise changes made to the main theme's files will be overridden when the theme is updated.

function allowed_link_protocols_filter($protocols){
    $protocols[] = 'file';
    return $protocols;
}
add_filter('kses_allowed_protocols', 'allowed_link_protocols_filter');

https://developer.wordpress.org/reference/hooks/kses_allowed_protocols/

Upvotes: 1

catalin
catalin

Reputation: 1116

I found the solution. In the wp-includes/formatting.php there's a line:

$protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn');

I've just added file into the array and now it accepts the file protocol into the menu

Upvotes: 0

Related Questions