Read file contents the WP way

I’m developing a sidebar widget. I need to read a txt file in a particular directory of the website. I can do it with file_get_contents or readfile PHP functions, but what’s the best way to safely do it in WordPress?

(I don’t know if the information is useful, but once red the content, I simply need to echo it)

Any help is appreciated

1 Answer
1

Have you had a look at the Filesystem API?.

The method of your choice would probably be get_contents() or get_contents_array()

Leave a Comment