Php 只为一个特定插件自动更新WordPress插件

Php 只为一个特定插件自动更新WordPress插件,php,wordpress,plugins,Php,Wordpress,Plugins,我想知道自动更新的新过滤器(自WordPress 3.7以来)是否可以修改为只针对一个或多个特定插件 这是WordPress Codex中的原始过滤器: add_filter( 'auto_update_plugin', '__return_true' ); 非常感谢您的帮助。非常感谢你 问候, Jan此代码应排除自动更新的某些插件 function exclude_plugins_from_auto_update ( $update, $item ) { $plugins = arr

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

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

add_filter( 'auto_update_plugin', '__return_true' );
非常感谢您的帮助。非常感谢你

问候,


Jan

此代码应排除自动更新的某些插件

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 );
应该只更新指定的插件

我无法测试以上任何一个,因为我没有任何需要更新的插件,但是第一个示例中的代码已经找到,应该可以工作了