Guys,
I just had the same problem and hoped to find a plugin as always when wanting WordPress to do something that can’t be done out of the box… but this time without success. ??
What I have found is that WP 3.4.2 uses a funtion returning the allowed protocols. I found it in wp-include\functions.php named wp_allowed_protocols(). Adding ‘file’ to the array did the trick.
Since it’s not the best idea to edit core files of WP I ended up with following solution, which works like a charm:
- create a directory (if not already existing) named wp-content\mu-plugins
- create a file in the mu-plugins folder e.g. called allowFileLink.php
- copy & paste the following code snippet into the file and that’s it
<?php
function custom_allowed_protocols() {
static $protocols;
if ( empty( $protocols ) ) {
$protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'file' );
$protocols = apply_filters( 'kses_allowed_protocols', $protocols );
}
return $protocols;
}
$hook = wp_allowed_protocols;
add_filter($hook,custom_allowed_protocols);
?>
You now can add links like file:///X:/somefolder/somesubfolder/sometextfile.txt
Let me know if it works for you. If you have better solutions than this fast hack, please provide them.
Cheers
Sascha