有迹象表明,你可能要采取几个步骤,其中大部分可以从WordPress的是如何处理它自己内部的更新很容易借用。
每次管理页面加载时都不要运行它,编写自己的_maybe_update_plugins()版本并让它检查定时间隔,可能每天大概只检查一次。
WordPress的WP_Upgrader类“可湿性粉剂管理员/包括/类WP-upgrader.php”(我相信你将需要包括在你的插件)做你想做的。看看可湿性粉剂管理员/ update.php,并确保你在这里模拟的安全防范措施十分严密,好像不加小心,你可能会引入巨大的安全漏洞。
一旦你整理出您的通知,并确保这个过程是安全的,这是因为网址传递给你的插件的新版本,下面的代码为“$ DOWNLOAD_LINK”一样简单。
$upgrader = new WP_Upgrader;
$upgrader->run(array(
'package' => '', //this should be the name of your plugin
'destination' => '', //this should be defined to the directory you want to install the plugin to
'clear_destination' => false, //set this if you want to remove the old version first
'clear_working' => true, //change this if you want to leave a copy of the zip file
'is_multi' => false, //only change this if you're calling the function multiple times
));
如果不这样做的伎俩(我还没有时间和动机,以测试它),周围挖一点多在WP_Upgrader类,并借用他们的功能,下载和解压文件。
谢谢。我需要在这个月的某个时候找到时间来测试这个。这是我的待办事项列表上的任务。 – Volomike 2011-04-10 00:30:55