How can I disables WordPress updates, plugins updates and themes updates using hooks. There are many plugins for unable updates but how can I do that with hooks.
1条回答 默认 最新
- douzhe2981 2015-08-10 08:46关注
Here is the class with hooks you just copy and paste in function.php. This code will disable your all updates (WordPress, plugins and theme).
/* The OS_Disable_WordPress_Updates class */ class OS_Disable_WordPress_Updates { private $__pluginsFiles; private $__themeFiles; function __construct() { $this->__pluginsFiles = array(); $this->__themeFiles = array(); add_action( 'admin_init', array(&$this, 'admin_init') ); if( !function_exists( 'get_plugins' ) ) require_once ABSPATH . 'wp-admin/includes/plugin.php'; if( count( get_plugins() ) > 0 ) foreach( get_plugins() as $file => $pl ) $this->__pluginsFiles[$file] = $pl['Version']; if( count( wp_get_themes() ) > 0 ) foreach( wp_get_themes() as $theme ) $this->__themeFiles[$theme->get_stylesheet()] = $theme->get('Version'); add_filter( 'pre_transient_update_themes', array($this, 'last_checked_themes') ); add_filter( 'pre_site_transient_update_themes', array($this, 'last_checked_themes') ); add_action( 'pre_transient_update_plugins', array(&$this, 'last_checked_plugins') ); add_filter( 'pre_site_transient_update_plugins', array($this, 'last_checked_plugins') ); add_filter( 'pre_transient_update_core', array($this, 'last_checked_core') ); add_filter( 'pre_site_transient_update_core', array($this, 'last_checked_core') ); add_filter( 'auto_update_translation', '__return_false' ); add_filter( 'automatic_updater_disabled', '__return_true' ); add_filter( 'allow_minor_auto_core_updates', '__return_false' ); add_filter( 'allow_major_auto_core_updates', '__return_false' ); add_filter( 'allow_dev_auto_core_updates', '__return_false' ); add_filter( 'auto_update_core', '__return_false' ); add_filter( 'wp_auto_update_core', '__return_false' ); add_filter( 'auto_core_update_send_email', '__return_false' ); add_filter( 'send_core_update_notification_email', '__return_false' ); add_filter( 'auto_update_plugin', '__return_false' ); add_filter( 'auto_update_theme', '__return_false' ); add_filter( 'automatic_updates_send_debug_email', '__return_false' ); add_filter( 'automatic_updates_is_vcs_checkout', '__return_true' ); add_filter( 'automatic_updates_send_debug_email ', '__return_false', 1 ); if( !defined( 'AUTOMATIC_UPDATER_DISABLED' ) ) define( 'AUTOMATIC_UPDATER_DISABLED', true ); if( !defined( 'WP_AUTO_UPDATE_CORE') ) define( 'WP_AUTO_UPDATE_CORE', false ); add_filter( 'pre_http_request', array($this, 'block_request'), 10, 3 ); } function OS_Disable_WordPress_Updates() { $this->__construct(); } function admin_init() { if ( !function_exists("remove_action") ) return; remove_action( 'admin_notices', 'update_nag', 3 ); remove_action( 'network_admin_notices', 'update_nag', 3 ); remove_action( 'admin_notices', 'maintenance_nag' ); remove_action( 'network_admin_notices', 'maintenance_nag' ); remove_action( 'load-themes.php', 'wp_update_themes' ); remove_action( 'load-update.php', 'wp_update_themes' ); remove_action( 'admin_init', '_maybe_update_themes' ); remove_action( 'wp_update_themes', 'wp_update_themes' ); wp_clear_scheduled_hook( 'wp_update_themes' ); remove_action( 'load-update-core.php', 'wp_update_themes' ); wp_clear_scheduled_hook( 'wp_update_themes' ); remove_action( 'load-plugins.php', 'wp_update_plugins' ); remove_action( 'load-update.php', 'wp_update_plugins' ); remove_action( 'admin_init', '_maybe_update_plugins' ); remove_action( 'wp_update_plugins', 'wp_update_plugins' ); wp_clear_scheduled_hook( 'wp_update_plugins' ); remove_action( 'load-update-core.php', 'wp_update_plugins' ); wp_clear_scheduled_hook( 'wp_update_plugins' ); add_action( 'init', create_function( '', 'remove_action( \'init\', \'wp_version_check\' );' ), 2 ); add_filter( 'pre_option_update_core', '__return_null' ); remove_action( 'wp_version_check', 'wp_version_check' ); remove_action( 'admin_init', '_maybe_update_core' ); wp_clear_scheduled_hook( 'wp_version_check' ); wp_clear_scheduled_hook( 'wp_version_check' ); remove_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' ); remove_action( 'admin_init', 'wp_maybe_auto_update' ); remove_action( 'admin_init', 'wp_auto_update_core' ); wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); } public function block_request($pre, $args, $url) {} public function last_checked_core() {} public function last_checked_themes() {} public function last_checked_plugins() {} } if ( class_exists('OS_Disable_WordPress_Updates') ) { $OS_Disable_WordPress_Updates = new OS_Disable_WordPress_Updates(); }
I think it will work.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
- ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
- ¥16 mybatis的代理对象无法通过@Autowired装填
- ¥15 可见光定位matlab仿真
- ¥15 arduino 四自由度机械臂
- ¥15 wordpress 产品图片 GIF 没法显示
- ¥15 求三国群英传pl国战时间的修改方法
- ¥15 matlab代码代写,需写出详细代码,代价私
- ¥15 ROS系统搭建请教(跨境电商用途)
- ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。