• Hi all,
    Currently have wordpress setup on Centos 6.4 with LAMP.
    Everything is running fine.

    I’ve searched google and forums but just need a little more help to make the linking to local files easier using file:///

    I’ve added the following plugin into wordpress with the following code and activated …

    <?php
    /*
    Plugin name: Allow file protocol
    */
    
    function rh_allow_file_protocol( $protocols ) {
             $protocols[] = 'file';
             return $protocols;
    }
    
    add_filter( 'kses_allowed_protocols', 'rh_allow_file_protocol' );

    The URL now support the file:///

    I copy the local path for a file to link for eg T:\test\test document.doc and paste the path into the URL field
    I then publish my changes
    In the browser when I hover over the link it reports the following file:///T:testtest%20document.doc

    It’s part way there.
    – It automatically appends the file:/// then the path I copied
    – It automatically replaced the ‘space’ with %20
    – However it strips the backward slash out completely
    I need it to strip the backward slash out and replace it with a forward slash so the path works.

    I’ve had a play around with preg_replace, but don’t exactly know where to put it.

    Any ideas?
    Thanks

  • The topic ‘wordpress file:/// replace backward slash with forward slash’ is closed to new replies.