{"id":193,"date":"2026-04-16T19:16:34","date_gmt":"2026-04-16T11:16:34","guid":{"rendered":"https:\/\/www.anutool.com\/?p=193"},"modified":"2026-04-16T19:16:34","modified_gmt":"2026-04-16T11:16:34","slug":"%e7%a6%81%e7%94%a8%e6%8f%92%e4%bb%b6%e6%9b%b4%e6%96%b0%e7%a4%ba%e4%be%8b","status":"publish","type":"post","link":"https:\/\/www.anutool.com\/index.php\/2026\/04\/16\/%e7%a6%81%e7%94%a8%e6%8f%92%e4%bb%b6%e6%9b%b4%e6%96%b0%e7%a4%ba%e4%be%8b\/","title":{"rendered":"\u7981\u7528\u63d2\u4ef6\u66f4\u65b0\u793a\u4f8b"},"content":{"rendered":"<pre class=\"corepress-code-pre\"><code>\/**\r\n * \u7981\u7528\u6240\u6709\u63d2\u4ef6\u81ea\u52a8\u66f4\u65b0\u5e76\u9690\u85cf\u63d2\u4ef6\u66f4\u65b0\u901a\u77e5\r\n * \u653e\u5230\uff1a wp-content\/mu-plugins\/disable-all-plugin-updates.php\r\n *\r\n * \u8bf4\u660e\uff1a\r\n * - \u9002\u7528\u4e8e single-site \u548c multisite\uff08\u540c\u65f6\u5904\u7406 site_transient \/ transient\uff09\u3002\r\n * - \u628a\u6587\u4ef6\u653e\u5728 mu-plugins \u6839\u76ee\u5f55\uff08\u4e0d\u662f\u5b50\u76ee\u5f55\uff09\uff0cWP \u4f1a\u5728\u6bcf\u6b21\u52a0\u8f7d\u65f6\u5305\u542b\u5b83\u3002\r\n * - \u90e8\u7f72\u540e\u8bf7\u6e05\u9664 transient \/ object cache\uff08\u89c1\u4e0b\u9762\u7684\u6b65\u9aa4\uff09\u3002\r\n *\/\r\n\r\nif ( ! defined( 'ABSPATH' ) ) {\r\n    exit;\r\n}\r\n\r\n\/* 1) \u7981\u7528\u6240\u6709\u63d2\u4ef6\u7684\u81ea\u52a8\u66f4\u65b0\uff08\u53ea\u5f71\u54cd\u81ea\u52a8\u66f4\u65b0\u884c\u4e3a\uff09 *\/\r\nadd_filter( 'auto_update_plugin', '__return_false' );\r\n\r\n\/* 2) \u5728\u8bfb\u53d6\u66f4\u65b0\u7684 transient \u4e4b\u524d\u77ed\u8def\uff0c\u8fd4\u56de\u201c\u65e0\u66f4\u65b0\u201d \u2014\u2014 single + multisite *\/\r\nadd_filter( 'pre_transient_update_plugins', '__return_null' );\r\nadd_filter( 'pre_site_transient_update_plugins', '__return_null' );\r\n\r\n\/* 3) \u4f5c\u4e3a\u540e\u5907\uff1a\u786e\u4fdd\u5982\u679c transient \u88ab\u52a0\u8f7d\uff0c\u6e05\u7a7a response\uff0c\u4f7f WP \u770b\u4e0d\u5230\u4efb\u4f55\u63d2\u4ef6\u66f4\u65b0 *\/\r\n$dpwu_empty_response = function( $transient ) {\r\n    if ( empty( $transient ) ) {\r\n        return $transient;\r\n    }\r\n\r\n    \/\/ transient-&gt;response \u5728 WP \u4e2d\u901a\u5e38\u662f\u6570\u7ec4\uff0c\u786e\u4fdd\u5b83\u4e3a\u7a7a\u6570\u7ec4\r\n    if ( isset( $transient-&gt;response ) &amp;&amp; is_array( $transient-&gt;response ) ) {\r\n        $transient-&gt;response = array();\r\n    }\r\n\r\n    \/\/ \u517c\u5bb9\u4e0d\u540c WP \u7248\u672c\uff0c\u5c3d\u91cf\u79fb\u9664\u4efb\u4f55\u8bb0\u5f55\u66f4\u65b0\u7684\u5b57\u6bb5\r\n    if ( isset( $transient-&gt;updates ) ) {\r\n        $transient-&gt;updates = array();\r\n    }\r\n\r\n    return $transient;\r\n};\r\n\r\nadd_filter( 'transient_update_plugins', $dpwu_empty_response );\r\nadd_filter( 'site_transient_update_plugins', $dpwu_empty_response );\r\n\r\n\/* 4) \u8f85\u52a9\u51fd\u6570\uff1a\u6e05\u9664\u4e0e\u66f4\u65b0\u76f8\u5173\u7684 transient \u4e0e object cache\uff08\u624b\u52a8\u8fd0\u884c\u6216\u5728\u9700\u8981\u65f6\u542f\u7528\u81ea\u52a8\u6e05\u7406\uff09 *\/\r\nif ( ! function_exists( 'dpwu_clear_update_cache' ) ) {\r\n    function dpwu_clear_update_cache() {\r\n        \/\/ \u5355\u7ad9\u70b9 transient\r\n        if ( function_exists( 'delete_transient' ) ) {\r\n            @delete_transient( 'update_plugins' );\r\n        }\r\n        \/\/ \u591a\u7ad9\u70b9 site_transient\r\n        if ( function_exists( 'delete_site_transient' ) ) {\r\n            @delete_site_transient( 'update_plugins' );\r\n        }\r\n        \/\/ \u5982\u679c\u4f7f\u7528\u5bf9\u8c61\u7f13\u5b58\uff08Redis\/Memcached\uff09\uff0c\u5c1d\u8bd5\u6e05\u7a7a WP cache\uff08\u89c6\u73af\u5883\u800c\u5b9a\uff09\r\n        if ( function_exists( 'wp_cache_flush' ) ) {\r\n            @wp_cache_flush();\r\n        }\r\n    }\r\n}\r\n\r\n\/* \u53ef\u9009\uff1a\u5982\u679c\u4f60\u5e0c\u671b\u6bcf\u6b21\u7ba1\u7406\u5458\u8bbf\u95ee\u65f6\u81ea\u52a8\u6e05\u4e00\u6b21\u7f13\u5b58\uff08\u90e8\u7f72\u540e\u53ef\u6ce8\u91ca\u6389\uff09 *\/\r\n\/*\r\nadd_action( 'admin_init', function() {\r\n    if ( current_user_can( 'manage_options' ) ) {\r\n        dpwu_clear_update_cache();\r\n    }\r\n}, 1 );\r\n*\/<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/** * \u7981\u7528\u6240\u6709\u63d2\u4ef6\u81ea\u52a8\u66f4\u65b0\u5e76\u9690\u85cf\u63d2\u4ef6\u66f4\u65b0\u901a\u77e5 * \u653e\u5230\uff1a wp-content\/mu-plugins\/d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58,64],"tags":[],"class_list":["post-193","post","type-post","status-publish","format-standard","hentry","category-wordpress","category-64"],"_links":{"self":[{"href":"https:\/\/www.anutool.com\/index.php\/wp-json\/wp\/v2\/posts\/193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.anutool.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anutool.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anutool.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anutool.com\/index.php\/wp-json\/wp\/v2\/comments?post=193"}],"version-history":[{"count":1,"href":"https:\/\/www.anutool.com\/index.php\/wp-json\/wp\/v2\/posts\/193\/revisions"}],"predecessor-version":[{"id":194,"href":"https:\/\/www.anutool.com\/index.php\/wp-json\/wp\/v2\/posts\/193\/revisions\/194"}],"wp:attachment":[{"href":"https:\/\/www.anutool.com\/index.php\/wp-json\/wp\/v2\/media?parent=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anutool.com\/index.php\/wp-json\/wp\/v2\/categories?post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anutool.com\/index.php\/wp-json\/wp\/v2\/tags?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}