-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Best method to get contents of a local file in WordPress #33
Comments
My take is that the Filesystem API is more about securely writing files, reading them isn't really the issue it is trying to solve. What's wrong with |
Thanks JD. I'm right there with you. In lieu of
No necessarily the cleanest solution, but it seemed like it would be a surer bet since Can you see any issue with this solution? Any new info on Thanks! |
@MickeyKay, the only errors I see folks getting is because they are using
Yes, I don't really see any reason that one is better than the other, though I'd still say |
Great explanation, thanks! On Saturday, August 2, 2014, J.D. Grimes notifications@github.com wrote:
|
Agree with |
Hi there,
I'm wondering the best method to get the contents of a local file - say a something like versions.json - in a WordPress plugin or theme.
My searching has turned up several possible solutions, and I'm wondering if you can help elucidate the benefits/drawbacks of each:
This method seems the most straightforward to me, but doesn't work within any particular WordPress API. The reason I include it is that it is so simple and seemingly easier to setup then the two WordPress API's listed below. Are there drawbacks I'm not seeing though?
The HTTP API is really well documented and seems to be the suggested solution for retrieving remote files, however I can't find anything about how appropriate it is when getting the contents of a local file. Furthermore, should I be using
wp_remote_fopen()
?wp_remote_get()
? Another one? When using the HTTP API in the past, I've run into timeout issues, and I'm wondering if there's not a better way since I want to access a local file, not a remote one.Honestly, I haven't tried this one as it seems pretty complicated (credentials, initializing, etc) just to get the contents of a local file (hence my preference for option number 1). Am I missing something?
Thanks Mark!
The text was updated successfully, but these errors were encountered: