wordpress默认的后台有太多的自动检测并更新功能,而wordpress及大多数主题 又都是老外开发,导致在自动检测主题或是插件版本的时候会消耗网站大量的资源,得不尝失。 所以,只能用代码去掉相关的程序勾子来进行优化。 在当前使用的主题functions.php文件当中添加如下代码: //禁止后台自动更新升级 define( 'AUTOMATIC_UPDATER_DISABLED', true ); //禁用自动更新 /*关闭程序更新提示*/ add_filter( 'pre_site_transient_update_core', function($a){ return null; }); /*关闭插件更新提示*/ add_filter('pre_site_transient_update_plugins', function($a){return null;}); /*关闭主题更新提示*/ add_filter('pre_site_transient_update_themes', function($a){return null;}); remove_action('admin_init', '_maybe_update_core'); // 禁止 WordPress 检查更新 remove_action('admin_init', '_maybe_update_plugins'); // 禁止 WordPress 更新插件 remove_action('admin_init', '_maybe_update_themes'); // 禁止 WordPress 更新主题 /*彻底关闭自动更新 关闭核心程序、主题、插件及翻译自动更新*/ add_filter('automatic_updater_disabled', '__return_true'); /*关闭更新检查定时作业*/ remove_action('init', 'wp_schedule_update_checks'); /*移除已有的版本检查定时作业*/ wp_clear_scheduled_hook('wp_version_check'); /*移除已有的插件更新定时作业*/ wp_clear_scheduled_hook('wp_update_plugins'); /*移除已有的主题更新定时作业*/ wp_clear_scheduled_hook('wp_update_themes'); /*移除已有的自动更新定时作业*/ wp_clear_scheduled_hook('wp_maybe_auto_update'); /*移除后台内核更新检查*/ remove_action( 'admin_init', '_maybe_update_core' ); /*移除后台插件更新检查*/ remove_action( 'load-plugins.php', 'wp_update_plugins' ); remove_action( 'load-update.php', 'wp_update_plugins' ); remove_action( 'load-update-core.php', 'wp_update_plugins' ); remove_action( 'admin_init', '_maybe_update_plugins' ); /*移除后台主题更新检查*/ remove_action( 'load-themes.php', 'wp_update_themes' ); remove_action( 'load-update.php', 'wp_update_themes' ); remove_action( 'load-update-core.php', 'wp_update_themes' ); remove_action( 'admin_init', '_maybe_update_themes' ); 看,是不是很简单?! 未经允许不得转载:泥人传说 » wordpress最新版后台优化更新加载策略,亲测可用。 wordpress建站技巧wordpress建站技巧分享wordpress技术wordpress自定义多重筛选字段wordpress自定义多重筛选字段列表自定义多重筛选字段列表 分享到: 赞(1)