如何自动更新个人Wordpress插件

时间:2017-05-13 05:21:35

标签: wordpress webhooks

如果我编写私有插件,有没有办法使用WordPress自动更新机制来更新它?

我想封装功能,但它特定于我自己的5个左右的博客,因此它不适合公共插件的资源。但我喜欢简单的更新机制。

有办法做到这一点吗?

1 个答案:

答案 0 :(得分: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