Get WPFTS Pro today with 25% discount!

  • Recently we found an issue with Media Library Folders Pro plugin. Our client is using it to upload new files to the WP Media Library using the folder structure. But the problem was after the new file is successfully uploaded, it does not get indexed automatically by the WPFTS Pro.

    After some investigation, we detected that reason was that Media Library Folders Pro plugin does not encode file paths properly on Windows OS servers.

    For example, if you're uploading the file "file.pdf" into the subfolder "2020/12" of the standard WP uploads folder, the path normally should be


    Later, the WP Core function parses this path and cuts out the highlighted part, because it is EXACTLY equal to WP's "upload_dir" value.

    But because of the Media Library Folders Pro bug, the file path becomes different:


    Because of this, the WP Core function can not cut out the upload_dir part, and also it removes backslashes, so the final result becomes very strange and not acceptable by WPFTS Pro in any case:


    To fix this, we have to create the custom code for the _wp_relative_upload_path filter. So the result looks like this:

    add_filter('_wp_relative_upload_path', function($new_path, $path)
    	// This code will only work in case Media Library Folders is installed and active
    	if (class_exists('MaxGalleriaMediaLib')) {
    		// We going to replace '\' to '/' before comparison
    		// to make this code compatible with Windows-style paths
    		$new_path = str_replace("\\", "/", $path);
    		$uploads = wp_get_upload_dir();
    		$up_dir = str_replace("\\", "/", $uploads['basedir']);
    		if ( 0 === strpos( $new_path, $up_dir ) ) {
    				$new_path = str_replace( $up_dir, '', $new_path );
    				$new_path = ltrim( $new_path, '/' );
    	return $new_path;
    }, 30, 2);

    If you need the ready solution only, just download, install, and activate this: