I've written a WordPress wordpress plugin, and i'm trying to get the best method of getting this program look for updates on my small server, and installing them instantly in the user's request. This can essentially be employed to download additional features that I'd rather not put in the WordPress repository due them not getting the GNU license.

I have coded this program to check on for updates, what I don't know about may be the download part.

Must I use file_get_contents() after which fwrite() to create the outcomes to some directory? I am sure this is a method of doing the work, however i am searching for probably the most mix-server safe method of carrying this out since the wordpress plugin can be used by 1000's of individuals on different configurations, although they all are PHP, and many of them are PHP5+. I'm afraid certain hosts might have some kind of security stopping me from carrying this out. Would cURL be considered a more sensible choice?


You should use [cde], which is a lot more efficient than loading everything into memory with file_put_contents after which calling file_get_contents. The 2nd parameter accepts a stream resource, which you'll open with [cde] or (if you wish to circumvent fwrite limitations, [cde]).

Therefore, the easiest option that utilizes only core functions (no curl extension, etc) and works in almost evry configuration is:

  • Open a transport stream with [cde]
  • Send the HTTP headers by hand with [cde]
  • Write the response with [cde]

Don't re-invent the wheel! WordPress comes with an HTTP API with this exact purpose!

Browse the codex for that necessities - http://codex.wordpress.org/HTTP_API

You may also see the source in fopen