我想知道自动更新的新过滤器(自WordPress 3.7以来)是否可以修改为只针对一个或多个特定的插件?
这是WordPress Codex中的原始过滤器:
add_filter( 'auto_update_plugin', '__return_true' );
非常感谢任何帮助。非常感谢!!
问候,1月
这段代码应该排除某些自动更新的插件。
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 );
应该只更新指定的插件。
我还没有能够测试上述任何一个,因为我没有任何插件需要更新,但在第一个例子中的代码在这里找到,应该工作。