• The plugin is great if you manage your own WordPress site and don’t have access to FTP. But it could be even better if there was a way to limit the directory tree the plugin has access to. In my case, I need to let my client upload files to a certain directory but I do not want them to be able to delete or modify core WP files. Maybe an options panel to set a root directory? At the very least, it would be nice if the plugin applied filters to the ‘path’ and ‘URL’ variables before launching the file manager. This would allow me to add filters in my functions.php to control the directory. I hate to modify someone else’s plugin so this could be a deal breaker for me.

    Something like this simple change would be great!

    $opts = array(
    			'debug' => true,
    			'roots' => array(
    				array(
    					'driver'        => 'LocalFileSystem',           // driver for accessing file system (REQUIRED)
    					'path'          => apply_filters( 'file_manager_path', ABSPATH ),                     // path to files (REQUIRED)
    					'URL'           => apply_filters( 'file_manager_url', site_url() ),                  // URL to files (REQUIRED)
    					'uploadDeny'    => array(),                     // All Mimetypes not allowed to upload
    					'uploadAllow'   => array('image', 'text/plain', 'codeclimate.yml'),// Mimetype <code>image</code> and <code>text/plain</code> allowed to upload
    					'uploadOrder'   => array('deny', 'allow'),      // allowed Mimetype <code>image</code> and <code>text/plain</code> only
    					'accessControl' => 'access'                     // disable and hide dot starting files (OPTIONAL)
    				)
    			)
    		);
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter aapc

    (@aapc)

    Part II – adding this to your functions.php file will allow you to limit access to the uploads directory.

    add_filter( 'file_manager_path', 'myFileManagerPath' );
    function myFileManagerPath( $path ){
    	// by default, $path = ABSPATH
    	return $path . '/wp-content/uploads';
    }
    add_filter( 'file_manager_url', 'myFileManagerUrl' );
    function myFileManagerUrl( $url ){
    	// by default, $url = site_url()
    	return $url . '/wpcontent/uploads';
    }
    Thread Starter aapc

    (@aapc)

    Or even better yet…leave the options as they are and add a filter to the $opts variable after it’s been defined and before launching elFinder:

    $opts = apply_filters( 'file_manager_opts', $opts );
    
    $elFinder = new FM_EL_Finder();
    $elFinder = $elFinder->connect($opts);
    $elFinder->run();

    This will allow you to change any option via a WP filter in your functions.php file.

    Plugin Contributor Aftabul Islam

    (@aihimel)

    @aapc

    Thanks for the suggestion and also the code snippets. We have a premium plugin for the same purpose.

    We expect our users of this plugin to rate us on overall features and efforts to create the plugin.

    Aftabul Islam

    To create a way for my website managers (who have authorization) to log into the back-end but don’t have access to FTP, this is a great alternative. I created a link they can use (after WP login) that opens “File Manager” and takes them directly to the folder I want them to see or upload to.

    To generate the link, open “File Manager”, then navigate to the folder you want to share (with authorized user), then you’ll see that folder link in the URL window. This way they are not having to go through the Dashboard and all the folders inside “File Manager’s” tree to find the correct one. Each folder generates a unique URL.

    Again, the user must be logged into WordPress before using the link or they will get a Fatal Error message.

    Thread Starter aapc

    (@aapc)

    I posted the code snippet because even with the File Manager Permission System addon, it doesn’t seem to solve my problem. I needed to give admins the ability to upload files to a specific folder and not allow access to core WP files or other plugin directories. Adding a filter allows for some flexibility in the configuration for people like myself. There is nothing wrong with offering paid add-ons for folks that are not comfortable writing code. I just think flexibility is a good thing. Thanks again for the great plugin. I do appreciate your hard work!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Very nice but…could be better’ is closed to new replies.