有跡象表明,你可能要採取幾個步驟,其中大部分可以從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