I know that i should use Filesystem API to write files and I understand why but is there any difference if I read file with wp_filesystem or plain PHP? And what about listing directories?

Consider this example: In wp-content I have my-plugin-templates-folder which has to be listed by my-plugin. Does anybody met with configuration which disallow webserver process list this directory so I should use wp_filesystem?


No you don't, and not even sure if you can use it for listing files in directories. The only limitation on reading files is that they will be readable to the web server, and obviously plugin directories has to be readable for the web server to be able to read the PHP files.

Now, if you are trying to read something outside of the wordpress file structure you might need to use the filesystem API.

|improve this answer|||||
  • Thank you for your reply. :) It's possible to list directories via filesystem API, just look here – Mateusz Marchel Nov 16 '15 at 16:51
  • ok, never used the API itself, just assumed it depends on the capabilities of the FTP server on the other side. – Mark Kaplun Nov 16 '15 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.