自动WordPress插件仅针对一个特定插件进行更新

时间:2014-08-10 17:27:19

标签: php wordpress plugins

我想知道是否可以修改自动更新的新过滤器(因为WordPress 3.7)只针对一个或多个特定插件?

这是WordPress Codex中的原始过滤器:

add_filter( 'auto_update_plugin', '__return_true' );

非常感谢任何帮助。非常感谢你!!!

此致

1 个答案:

答案 0 :(得分:0)

此代码应排除某些插件以便自动更新。

function exclude_plugins_from_auto_update ( $update, $item ) {
    $plugins = array ( // Plugins to exclude from auto-update
        'akismet',
        'buddypress',
    );
    if ( in_array( $item->slug, $plugins ) )
        return false; // Don't auto-update specified plugins
    else return true; // Auto-update all other plugins
}
add_filter( 'auto_update_plugin', 'exclude_plugins_from_auto_update', 10, 2 );

将其修改为:

function plugins_to_auto_update ( $update, $item ) {
    $plugins = array ( // Plugins to  auto-update
        'akismet',
        'buddypress',
    );
    if ( in_array( $item->slug, $plugins ) )
        return true; // Auto-update specified plugins
    else return false; // Don't auto-update all other plugins
}
add_filter( 'auto_update_plugin', 'plugins_to_auto_update', 10, 2 );

应该只更新指定的插件。

我还没能测试上述任何一项,因为我没有任何需要更新的插件,但第一个示例中的代码找到了here并且应该可以正常工作。< / p>