$wp_filesystem returns NULL. What are the dependencies?

$wp_filesystem is a global variable containing the instance of the (auto-)configured filesystem object after the filesystem “factory” has been run.

To run the factory “over” the global variable (so to set it), just call the WP_Filesystem() function which is, guess what, undocumented in codex. At least the docblock contains some information and you can read the sourcecode (if that’s an option for you).

Anyway, I would give it a try to add a function call to your code after requiring the file.php from the /wp-admin/includes directory. Probably this already solves your issue.

If you are looking for a (better) file-system abstraction than/next to the built-in one, consider the file-system objects in SPL which is part of PHP already.

Leave a Comment