WordPress:如何阻止插件向开发者站点查询更新
Hey Thall, totally get where you’re coming from—those unnecessary external update checks can be a real drain on production site resources, especially when you’re managing deployments via Git. Here are a few solid methods to block those plugin update queries, tailored to your needs:
1. 全局禁用所有插件更新检查
If you want to shut down all plugin version checks across the site (since you’re handling updates via Git anyway), add this code to your theme’s functions.php file or create a tiny custom plugin for it:
// 让WordPress认为没有插件更新可用 add_filter('pre_site_transient_update_plugins', '__return_null'); // 阻止WordPress请求外部插件更新数据 add_filter('plugins_api', '__return_null', 10, 3); // 移除后台的插件更新触发动作 remove_action('load-update-core.php', 'wp_update_plugins');
This works by overriding the transient that stores update data and blocking the API calls WordPress uses to fetch new version info from external servers.
2. 只阻止特定插件(比如WPMUdev)的检查
If you want to leave other plugins’ checks intact but target just WPMUdev or specific problematic plugins, use this targeted approach. Replace the plugin paths in the array with the main file paths of the plugins you want to block:
add_filter('pre_site_transient_update_plugins', 'block_selected_plugin_updates'); function block_selected_plugin_updates($transient) { if (!empty($transient->response)) { // 列出要阻止更新检查的插件主文件路径 $blocked_plugins = [ 'wpmudev-plugin/wpmudev-plugin.php', // 替换为实际的WPMUdev插件路径 // 可以添加更多插件,比如 'another-plugin/another-plugin.php' ]; foreach ($blocked_plugins as $plugin) { if (isset($transient->response[$plugin])) { unset($transient->response[$plugin]); } } } return $transient; }
You can find a plugin’s main file path by checking the wp-content/plugins directory—each plugin has a main PHP file that matches its folder name (usually).
3. 服务器层面拦截请求
For an extra layer of protection, you can block requests to specific developer domains directly via your server config. This prevents the site from even sending the request in the first place.
Nginx Config Example
Add this to your site’s Nginx configuration:
location ~* ^https?://wpmudev\.org { deny all; return 444; }
Apache (.htaccess) Example
Add this to your site’s .htaccess file:
RewriteEngine On RewriteCond %{HTTP_HOST} ^wpmudev\.org$ [NC] RewriteRule ^ - [F,L]
Quick Notes
- When pushing updates via Git, make sure you’ve tested the updated plugin versions in a staging environment first to avoid breaking your production site.
- Some optimization or management plugins (like certain security suites) have built-in options to disable update checks—worth checking your existing plugins’ settings before writing custom code!
内容的提问来源于stack exchange,提问作者ThallerThanYall

