WordPress 关闭后台主题、插件、系统自动更新与提示-蚂蚁资源

WordPress 关闭后台主题、插件、系统自动更新与提示

有时候会发现wordperss后台越来越卡,是什么原因呢?原因可能很多,但是一些更新的获取可能是其中之一。那么可以按需关系这些更新。,将以下代码加入主题的functions.php里(最后一个 ?> 之前):,以上代码是一个插件里的代码,插件名称好像是 disabled wordpress updates 。但是,我们能不用插件就尽量不用插件!,class OS_Disable_WordPress_Updates { private $__pluginsFiles; private $__themeFiles; /** * The OS_Disable_WordPress_Updates class constructor * initializing required stuff for the plugin * * PHP 5 Constructor * * @since 1.3 * @author scripts@schloebe.de */ 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’); /* * Disable Theme Updates * 2.8 to 3.0 */ add_filter( ‘pre_transient_update_themes’, array($this, ‘last_checked_themes’) ); /* * 3.0 */ add_filter( ‘pre_site_transient_update_themes’, array($this, ‘last_checked_themes’) ); /* * Disable Plugin Updates * 2.8 to 3.0 */ add_action( ‘pre_transient_update_plugins’, array(&$this, ‘last_checked_plugins’) ); /* * 3.0 */ add_filter( ‘pre_site_transient_update_plugins’, array($this, ‘last_checked_plugins’) ); /* * Disable Core Updates * 2.8 to 3.0 */ add_filter( ‘pre_transient_update_core’, array($this, ‘last_checked_core’) ); /* * 3.0 */ add_filter( ‘pre_site_transient_update_core’, array($this, ‘last_checked_core’) ); /* * Disable All Automatic Updates * 3.7+ * * @author sLa NGjI’s @ slangji.wordpress.com */ 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 ); } /** * The OS_Disable_WordPress_Updates class constructor * initializing required stuff for the plugin * * PHP 4 Compatible Constructor * * @since 1.3 * @author scripts@schloebe.de */ function OS_Disable_WordPress_Updates() { $this->__construct(); } /** * Initialize and load the plugin stuff * * @since 1.3 * @author scripts@schloebe.de */ function admin_init() { if ( !function_exists(“remove_action”) ) return; /* * Hide maintenance and update nag */ 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’ ); /* * Disable Theme Updates * 2.8 to 3.0 */ 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’ ); /* * 3.0 */ remove_action( ‘load-update-core.php’, ‘wp_update_themes’ ); wp_clear_scheduled_hook( ‘wp_update_themes’ ); /* * Disable Plugin Updates * 2.8 to 3.0 */ 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’ ); /* * 3.0 */ remove_action( ‘load-update-core.php’, ‘wp_update_plugins’ ); wp_clear_scheduled_hook( ‘wp_update_plugins’ ); /* * Disable Core Updates * 2.8 to 3.0 */ 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’ ); /* * 3.0 */ wp_clear_scheduled_hook( ‘wp_version_check’ ); /* * 3.7+ */ 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’ ); } /** * Check the outgoing request * * @since 1.4.4 */ public function block_request($pre, $args, $url) { /* Empty url */ if( empty( $url ) ) { return $pre; } /* Invalid host */ if( !$host = parse_url($url, PHP_URL_HOST) ) { return $pre; } $url_data = parse_url( $url ); /* block request */ if( false !== stripos( $host, ‘api.wordpress.org’ ) && (false !== stripos( $url_data[‘path’], ‘update-check’ ) || false !== stripos( $url_data[‘path’], ‘browse-happy’ )) ) { return true; } return $pre; } /** * Override core version check info * * @since 1.4.3 */ public function last_checked_core() { global $wp_version; return (object) array( ‘last_checked’ => time(), ‘updates’ => array(), ‘version_checked’ => $wp_version ); } /** * Override themes version check info * * @since 1.4.3 */ public function last_checked_themes() { global $wp_version; return (object) array( ‘last_checked’ => time(), ‘updates’ => array(), ‘version_checked’ => $wp_version, ‘checked’ => $this->__themeFiles ); } /** * Override plugins version check info * * @since 1.4.3 */ public function last_checked_plugins() { global $wp_version; return (object) array( ‘last_checked’ => time(), ‘updates’ => array(), ‘version_checked’ => $wp_version, ‘checked’ => $this->__pluginsFiles ); } } if ( class_exists(‘OS_Disable_WordPress_Updates’) ) { $OS_Disable_WordPress_Updates = new OS_Disable_WordPress_Updates(); }

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,默认解压密码为"www.antziyuan.com",如遇到无法解压的请联系管理员!

蚂蚁资源 » WordPress 关闭后台主题、插件、系统自动更新与提示

常见问题FAQ

免费下载或者VIP会员专享资源能否直接商用?
该资源仅供学习和研究传播,大家请在下载后24小时内删除,一切关于该资源商业行为与我们无关。 请勿将该软件进行商业交易、转载等行为,该软件只为研究、学习所提供,该软件使用后发生的一切问题与本站无关。
提示下载完但解压或打开不了?
最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。若排除这种情况,可在对应资源底部留言,或 联络我们.。
找不到素材资源介绍文章里的示例图片?
对于PPT,KEY,Mockups,APP,网页模版等类型的素材,文章内用于介绍的图片通常并不包含在对应可供下载素材包内。这些相关商业图片需另外购买,且本站不负责(也没有办法)找到出处。 同样地一些字体文件也是这种情况,但部分素材会在素材包内有一份字体下载链接清单。
蚂蚁资源
大家都喜欢的资源网站!
  • 47会员总数(位)
  • 793资源总数(个)
  • 3本周发布(个)
  • 0 今日发布(个)
  • 173稳定运行(天)

提供最优质的资源集合

立即查看 了解详情
升级SVIP尊享更多特权立即升级