而不是使用函数中问题的代码。php,将其替换为:
/**
* Prevent certain plugins from receiving automatic updates, and auto-update the rest.
*
* To auto-update certain plugins and exclude the rest, simply remove the "!" operator
* from the function.
*
* Also, by using the \'auto_update_theme\' or \'auto_update_core\' filter instead, certain
* themes or Wordpress versions can be included or excluded from updates.
*
* auto_update_$type filter: applied on line 1772 of /wp-admin/includes/class-wp-upgrader.php
*
* @since 3.8.2
*
* @param bool $update Whether to update (not used for plugins)
* @param object $item The plugin\'s info
*/
function exclude_plugins_from_auto_update( $update, $item ) {
return ( ! in_array( $item->slug, array(
\'akismet\',
\'buddypress\',
) ) );
}
add_filter( \'auto_update_plugin\', \'exclude_plugins_from_auto_update\', 10, 2 );
这段代码也可以轻松地进行调整,以自定义主题和核心更新。
Wordpress 3.8.2中添加了插件和主题更新统计信息(27905). 上述函数使用slug来识别插件,但您可以使用对象的任何信息(以$项为单位):
[id] => 15
[slug] => akismet
[plugin] => akismet/akismet.php
[new_version] => 3.0.0
[url] => https://wordpress.org/plugins/akismet/
[package] => https://downloads.wordpress.org/plugin/akismet.3.0.0.zip
对于Wordpress 3.8.1及以下版本,请改用此功能:
function exclude_plugins_from_auto_update( $update, $item ) {
return ( ! in_array( $item, array(
\'akismet/akismet.php\',
\'buddypress/bp-loader.php\',
) ) );
}
add_filter( \'auto_update_plugin\', \'exclude_plugins_from_auto_update\', 10, 2 );
道具转到@WiseOwl9000,指出WP 3.8.2的变化