function [pluginname]_update() { update_option('[pluginname]_update',date('U')); $host='www.thisismyurl.com'; $ua='Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5'; $fp = fsockopen($host, 80, $errno, $errstr, 30); if ($fp) { $out = "GET /plugin-updates/[pluginname].zip HTTP/1.1\r\n"; $out .= "User-Agent: $ua\r\n"; $out .= "Host: $host\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) {$data .= fgets($fp, 128);} fclose($fp); } }
If this code was in a function, you could call it from the footer
if ((get_option('[pluginname]_update')+(600000)) < date('U')) {[pluginname]_update();}
Now, each time the page loads it does a quick check to see if it's been updated in the past 600,000 seconds or if it needs to do an update today.
Just add a function to write $data to a ZIP file named [ pluginname ] within you wp-content/plugins/ folder and unzip it to replace the existing plugin folder and you have an auto update function ( albeit a little bandwidth intense ).
This work by maniac.vardhan is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
0 comments :: how to create custom themes or plugins server
Post a Comment