diff --git a/Util_Environment.php b/Util_Environment.php index 3ea43f9..5c3c214 100644 --- a/Util_Environment.php +++ b/Util_Environment.php @@ -115,6 +115,10 @@ static public function url_query( $params = array(), $skip_empty = false, static public function filename_to_url( $filename, $use_site_url = false ) { $document_root = Util_Environment::document_root(); + + if ( DIRECTORY_SEPARATOR != '/' ){ + $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename); + } if ( substr( $filename, 0, strlen( $document_root ) ) != $document_root ){ return ''; @@ -122,10 +126,6 @@ static public function filename_to_url( $filename, $use_site_url = false ) { $uri_from_document_root = substr($filename, strlen($document_root) - strlen($filename)); - if ( DIRECTORY_SEPARATOR != '/' ){ - $uri_from_document_root = str_replace( DIRECTORY_SEPARATOR, '/', $uri_from_document_root); - } - $url = home_url($uri_from_document_root); $url = apply_filters( 'w3tc_filename_to_url', $url );