2017-05-13 27 views
0

如果我編寫一個私人插件,有什麼方法可以使用WordPress自動更新機制來更新它?如何自動更新個人WordPress插件

我想封裝這些功能,但是它特定於我自己的5個博客,所以它不適合公開插件的資源。但我喜歡簡單的更新機制。

有沒有辦法做到這一點?

+0

您是否試圖與'的add_filter( 'auto_update_plugin', '__return_true');'? – vel

+0

我認爲這是最有名的解決方案:http://w-shadow.com/blog/2010/09/02/automatic-updates-for-any-plugin/ – brasofilo

回答

0

試試這個。

function auto_update_specific_plugins ($update, $item) { 
    // Array of plugin slugs to always auto-update 
    $plugins = array ( 
     'akismet',   
     'yourplugin', 
    ); 
    if (in_array($item->slug, $plugins)) { 
     return true; // Always update plugins in this array 
    } else { 
     return $update; // Else, use the normal API response to decide whether to update or not 
    } 
} 
add_filter('auto_update_plugin', 'auto_update_specific_plugins', 10, 2); 

Configuring Automatic Background Updates