I don’t think I ever had practical need to create folders/files in WP before, but for a plugin I need cache (for resized images) folder in wp-content/uploads.

Which raises the question – do I really need to go through all the process with Filesystem API (including messily asking for FTP credentials when needed), or wp_mkdir_p() is good enough for this?

3 s
3

wp-content/uploads/ should be writable for the server (otherwise it would be impossible to upload a file, no?). If you are going to create something under this directory, it is safe to use wp_mkdir_p().

I would only use WP_Filesystem if there is a chance the server does not have permissions to write to the location, like in wp-content/plugins/, which does not have to be writable for the server (at least I think it doesn’t have to be?).

Sidenote: The File Permissions page of the Codex also talks about a wp-content/cache/ directory. Would this be a “more standard” location for cache files?

Leave a Reply

Your email address will not be published. Required fields are marked *