{"id":32481,"date":"2024-11-25T11:21:01","date_gmt":"2024-11-25T03:21:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/32481\/"},"modified":"2024-11-25T11:21:01","modified_gmt":"2024-11-25T03:21:01","slug":"%e5%9c%a8%e6%82%a8%e7%9a%84%e4%b8%bb%e9%a2%98%e4%b8%ad%e5%88%a9%e7%94%a8-tgm-%e6%8f%92%e4%bb%b6%e6%bf%80%e6%b4%bb%e5%ba%93%e7%9a%84%e5%bc%ba%e5%a4%a7%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/32481\/","title":{"rendered":"\u5728\u60a8\u7684\u4e3b\u9898\u4e2d\u5229\u7528 TGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93\u7684\u5f3a\u5927\u529f\u80fd"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/169357974349555.jpg\" class=\"aligncenter\" title=\"\u5728\u60a8\u7684\u4e3b\u9898\u4e2d\u5229\u7528 TGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93\u7684\u5f3a\u5927\u529f\u80fd\u63d2\u56fe\" alt=\"\u5728\u60a8\u7684\u4e3b\u9898\u4e2d\u5229\u7528 TGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93\u7684\u5f3a\u5927\u529f\u80fd\u63d2\u56fe\" \/><\/p>\n<\/p>\n<p>\u4e3b\u9898\u5e76\u4e0d\u610f\u5473\u7740\u5177\u6709\u529f\u80fd\u6027\uff0c\u4f46\u4f5c\u4e3a\u4e3b\u9898\u5f00\u53d1\u4eba\u5458\uff0c\u6211\u4eec\u4e3b\u8981\u9700\u8981\u5305\u542b\u4e00\u4e9b\u529f\u80fd\u4ee5\u4f7f\u6211\u4eec\u7684\u4e3b\u9898\u66f4\u597d\u4e00\u70b9\uff0c\u5e76\u4e14\u5177\u6709\u529f\u80fd\u6027\u3002 <\/p>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4e86\u89e3\u201c\u63d2\u4ef6\u9886\u57df\u201d\u4e00\u8bcd\uff0c\u5e76\u5b66\u4e60\u4f7f\u7528 Thomas Griffin \u7f16\u5199\u7684\u51fa\u8272\u5de5\u5177\uff1aTGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93\u3002<\/p>\n<h2>\u4e3b\u9898\u529f\u80fd\uff1a\u5165\u4fb5\u63d2\u4ef6\u9886\u5730<\/h2>\n<p>\u4e3b\u9898\u65e8\u5728\u6539\u53d8\u60a8\u7684 WordPress \u7f51\u7ad9\u7684\u8bbe\u8ba1\u3002\u7406\u60f3\u60c5\u51b5\u4e0b\uff0c\u5b83\u5e94\u8be5\u662f<em>\u89c6\u89c9<\/em>\u3002\u4f46\u5728 WordPress \u7684\u9ec4\u91d1\u65f6\u4ee3\uff0c\u4e3b\u9898\u5f00\u53d1\u4eba\u5458\u7ecf\u5e38\u5728\u5176\u4e3b\u9898\u4e2d\u5305\u542b\u529f\u80fd\u7279\u6027\uff0c\u4ee5\u4fdd\u6301\u5e02\u573a\u7ade\u4e89\u529b\u3002\u672c\u6765\u5e94\u8be5\u5982\u6b64\uff0c\u4f46\u4e8b\u5b9e\u5374\u5982\u6b64\u3002<\/p>\n<p>\u8fd9\u662f\u5bf9\u63d2\u4ef6\u9886\u5730\u7684\u5165\u4fb5\u3002\u6211\u4eec\u53ef\u4ee5\u7528\u7b80\u5355\u7684\u672f\u8bed\u6765\u5b9a\u4e49\u201c\u63d2\u4ef6\u9886\u57df\u201d\uff1a\u4ee3\u7801\u7684\u529f\u80fd\u90e8\u5206\u4f4d\u4e8e\u8be5\u9886\u57df\u7684\u8fb9\u754c\u5185\u3002\u6539\u53d8\u7f51\u7ad9\u529f\u80fd\u7684\u6bcf\u4e00\u6bb5\u4ee3\u7801\u90fd\u9700\u8981\u4f5c\u4e3a\u63d2\u4ef6\u63d0\u4f9b\uff08\u5982\u679c\u5c1a\u672a\u5728 WordPress \u6838\u5fc3\u4e2d\u63d0\u4f9b\uff09\u3002 <\/p>\n<p>\u5728\u6211\u4e4b\u524d\u7684\u4e00\u7bc7\u6587\u7ae0\uff08\u201c\u5236\u4f5c\u5b8c\u7f8e\u7684 WordPress \u4e3b\u9898\u201d\u7cfb\u5217\u4e2d\uff09\u4e2d\uff0c\u6211\u63d0\u5230\u4e86\u201c\u63d2\u4ef6\u9886\u57df\u201d\u7684<em>\u7ecf\u9a8c\u6cd5\u5219<\/em>\uff1a<\/p>\n<blockquote><p>\n  \u5982\u679c\u8be5\u529f\u80fd\u4e0e\u7f51\u7ad9\u7684\u89c6\u89c9\u5916\u89c2\u6709\u5173\uff0c\u5219\u5e94\u4f4d\u4e8e\u4e3b\u9898\u4e2d\uff0c\u4f46\u5982\u679c\u4e0e\u7f51\u7ad9\u7684\u529f\u80fd\u6709\u5173\uff0c\u5219\u5e94\u5728\u4e3b\u9898\u4e2d\u5e94\u4f5c\u4e3a\u5355\u72ec\u7684\u63d2\u4ef6\u5305\u542b\u5728\u5185\u3002\n<\/p><\/blockquote>\n<p>\u5f88\u7b80\u5355\uff0c\u5bf9\u5427\uff1f <\/p>\n<p>\u5c3d\u7ba1\u4eba\u4eec\u4ecd\u7136\u503e\u5411\u4e8e\u5c06\u529f\u80fd\u4f4d\u786c\u7f16\u7801\u5230\u4ed6\u4eec\u7684\u4e3b\u9898\u4e2d\uff0c\u4f46\u4e3b\u9898\u76ee\u5f55\uff08\u5982 WordPress.org \u548c ThemeForest\uff09\u4e0d\u63a5\u53d7\u4fb5\u5165\u201c\u63d2\u4ef6\u9886\u57df\u201d\u7684\u4e3b\u9898\u3002\u56e0\u6b64\uff0c\u63d0\u4f9b\u5e26\u6709\u4e3b\u9898\u7684\u529f\u80fd\u5c31\u6210\u4e86\u4e00\u4e2a\u95ee\u9898\u3002<\/p>\n<p>\u5e78\u8fd0\u7684\u662f\uff0c\u6709\u4e00\u4e2a\u76f8\u5f53\u7b80\u5355\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u5e76\u4e14\u5b83\u4e0d\u8fdd\u53cd\u201c\u63d2\u4ef6\u9886\u57df\u201d\u89c4\u5219\u3002<\/p>\n<h2>\u4ecb\u7ecd TGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93<\/h2>\n<p>TGM Plugin Activation \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u5e93\uff0c\u65e8\u5728\u5c06\u4e3b\u9898\u4e0e\u63d2\u4ef6\u6346\u7ed1\u5728\u4e00\u8d77\u3002\u8fd9\u4e2a\u60f3\u6cd5\u5f88\u7b80\u5355\uff1a\u5f53\u7528\u6237\u5b89\u88c5\u60a8\u7684\u4e3b\u9898\u65f6\uff0c\u5b83\u4f1a\u8ba9\u7528\u6237\u5b89\u88c5\u6765\u81ea WordPress.org\u3001\u5916\u90e8\u7f51\u7ad9\u6216\u4e3b\u9898\u6587\u4ef6\u5939\u7684\u63d2\u4ef6\u3002\u4ee5\u4e0b\u662f\u8be5\u5e93\u7684\u521b\u5efa\u8005 Thomas Griffin \u5bf9\u8fd9\u4e2a\u65b9\u4fbf\u7684\u5c0f\u5de5\u5177\u7684\u5b9a\u4e49\uff1a<\/p>\n<blockquote>\n<p><strong>TGM \u63d2\u4ef6\u6fc0\u6d3b<\/strong> \u662f\u4e00\u4e2a PHP \u5e93\uff0c\u53ef\u8ba9\u60a8\u8f7b\u677e\u5730\u4e3a\u60a8\u7684 WordPress \u4e3b\u9898\uff08\u548c\u63d2\u4ef6\uff09\u8bf7\u6c42\u6216\u63a8\u8350\u63d2\u4ef6\u3002\u5b83\u5141\u8bb8\u60a8\u7684\u7528\u6237\u4f7f\u7528\u672c\u673a WordPress \u7c7b\u3001\u51fd\u6570\u548c\u63a5\u53e3\u4ee5\u5355\u4e00\u6216\u6279\u91cf\u65b9\u5f0f\u5b89\u88c5\u751a\u81f3\u81ea\u52a8\u6fc0\u6d3b\u63d2\u4ef6\u3002\u60a8\u53ef\u4ee5\u5f15\u7528\u9884\u6253\u5305\u7684\u63d2\u4ef6\u3001WordPress \u63d2\u4ef6\u5b58\u50a8\u5e93\u4e2d\u7684\u63d2\u4ef6\uff0c\u751a\u81f3\u662f\u4e92\u8054\u7f51\u4e0a\u5176\u4ed6\u5730\u65b9\u6258\u7ba1\u7684\u63d2\u4ef6\u3002<\/p>\n<\/blockquote>\n<p>\u8fd9\u53ef\u80fd\u662f\u89e3\u51b3\u201c\u63d2\u4ef6\u9886\u5730\u5165\u4fb5\u201d\u95ee\u9898\u7684\u6700\u660e\u667a\u7684\u89e3\u51b3\u65b9\u6848\u3002\u800c\u4e14\u7533\u8bf7\u4e5f\u5f88\u5bb9\u6613\u3002 <\/p>\n<p>\u6211\u4eec\u6765\u770b\u770b\u5427\uff01<\/p>\n<h3>\u5b89\u88c5 TGM \u63d2\u4ef6\u6fc0\u6d3b<\/h3>\n<p>\u5b89\u88c5 TGM \u63d2\u4ef6\u6fc0\u6d3b\u975e\u5e38\u7b80\u5355\u3002\u53ea\u9700\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li> \u4ece\u9875\u9762\u7684\u201c\u4e0b\u8f7d\u201d\u90e8\u5206\u4e0b\u8f7d TGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93\u3002<\/li>\n<li>\u6253\u5f00 zip \u6587\u4ef6\u5e76\u5c06 class-tgm-plugin-activation.php \u89e3\u538b\u5230\u60a8\u7684\u4e3b\u9898\u6587\u4ef6\u5939\uff08\u4efb\u4f55\u60a8\u559c\u6b22\u7684\u4f4d\u7f6e\uff09\u3002<\/li>\n<li>\u6253\u5f00\u4e3b\u9898\u7684 functions.php \u6587\u4ef6\u5e76\u4f7f\u7528 require_once() \u51fd\u6570\u5728\u4e3b\u9898\u4e2d\uff08\u4e00\u6b21\uff09\u8bf7\u6c42\u7c7b\u6587\u4ef6\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u51fd\u6570\u6765\u914d\u7f6e TGM \u63d2\u4ef6\u6fc0\u6d3b\uff0c\u5e76\u901a\u8fc7 add_action() \u51fd\u6570\u5c06\u5176\u6302\u94a9\u5230 tgmpa_register\u3002<\/li>\n<li>\u5b8c\u6210\uff01<\/li>\n<\/ul>\n<p>\u8fd9\u975e\u5e38\u7b80\u5355\uff0c\u60a8\u751a\u81f3\u4e0d\u9700\u8981\u590d\u6742\u7684 PHP \u4ee3\u7801\u6765\u8981\u6c42\u6216\u63a8\u8350\u63d2\u4ef6\u3002\u770b\u4e00\u4e0b\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;?php \/**\n * Since I'm already doing a tutorial, I'm not going to include comments to\n * this code, but if you want, you can check out the \"example.php\" file\n * inside the ZIP you downloaded - it has a very detailed documentation.\n *\/\n\nrequire_once dirname( __FILE__ ) . '\/class-tgm-plugin-activation.php';\n\nadd_action( 'tgmpa_register', 'mytheme_require_plugins' );\n\nfunction mytheme_require_plugins() {\n\n    $plugins = array( \/* The array to install plugins *\/ );\n    $config = array( \/* The array to configure TGM Plugin Activation *\/ );\n\n    tgmpa( $plugins, $config );\n\n}\n\n?&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ece\u73b0\u5728\u5f00\u59cb\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u521a\u521a\u521b\u5efa\u7684\u51fd\u6570\u4e2d\u8bbe\u7f6e $plugins \u53d8\u91cf\u6765\u8ba9\u7528\u6237\u5b89\u88c5\u65b0\u63d2\u4ef6\u3002 <\/p>\n<p>\u8ba9\u6211\u4eec\u770b\u770b\u5b83\u662f\u5982\u4f55\u5b8c\u6210\u7684\u3002<\/p>\n<h3>\u901a\u8fc7 TGM \u63d2\u4ef6\u6fc0\u6d3b\u5b89\u88c5\u63d2\u4ef6<\/h3>\n<p>\u4ece\u4e0a\u9762\u53ef\u4ee5\u770b\u51fa\uff0c$plugins \u53d8\u91cf\u662f\u4e00\u4e2a\u6570\u7ec4\u3002\u8981\u5b9a\u4e49\u8981\u5b89\u88c5\u7684\u63d2\u4ef6\uff0c\u60a8\u9700\u8981\u5728\u8be5\u6570\u7ec4\u4e2d\u521b\u5efa\u6570\u7ec4\uff08\u4ee5\u4fbf\u60a8\u53ef\u4ee5\u8bbe\u7f6e\u81ea\u5df1\u7684\u53c2\u6570\uff09\u3002\u542c\u8d77\u6765\u5f88\u96be\uff0c\u4f46\u4e8b\u5b9e\u5e76\u975e\u5982\u6b64\uff1a<\/p>\n<pre>&lt;?php $plugins = array(\n\tarray( \/* my first plugin *\/ ),\n\tarray( \/* my second plugin *\/ ),\n\tarray( \/* my third plugin *\/ ),\n\t\/\/ ...\n\tarray( \/* my nth plugin *\/ )\n);\n\n?&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6709\u51e0\u4e2a\u53c2\u6570\u53ef\u4f9b\u4f7f\u7528\uff1a<\/p>\n<ul>\n<li> name\uff08\u5b57\u7b26\u4e32\uff0c\u5fc5\u9700\uff09- \u63d2\u4ef6\u7684\u540d\u79f0\u3002<\/li>\n<li> slug \uff08\u5b57\u7b26\u4e32\uff0c\u5fc5\u9700\uff09- \u63d2\u4ef6\u7684 slug\uff08\u901a\u5e38\u662f\u5176\u6587\u4ef6\u5939\u7684\u540d\u79f0\uff09\u3002<\/li>\n<li> required \uff08\u5e03\u5c14\u503c\uff0c\u5fc5\u9700\uff09 &#8211; \u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u60a8\u7684\u4e3b\u9898\u5c06\u201c\u9700\u8981\u201d\u8be5\u63d2\u4ef6\u3002\u5982\u679cfalse\uff0c\u4e3b\u9898\u5c06\u201c\u63a8\u8350\u201d\u5b83\u3002<\/li>\n<li> source \uff08\u5b57\u7b26\u4e32\uff0c\u6709\u65f6\u9700\u8981\uff09- \u63d2\u4ef6\u7684\u6e90\u3002\u5982\u679c\u662f WordPress.org \u63d2\u4ef6\uff0c\u5219\u4e0d\u5e94\u4f7f\u7528\u6b64\u53c2\u6570\uff1b\u5426\u5219\uff0c\u8fd9\u662f\u5fc5\u9700\u7684\u3002<\/li>\n<li> version (\u5b57\u7b26\u4e32\uff0c\u53ef\u9009) &#8211; \u63d2\u4ef6\u6240\u9700\u7684\u6700\u4f4e\u7248\u672c\u3002\u4f8b\u5982;\u5982\u679c\u4e3b\u9898\u7528\u6237\u5df2\u7ecf\u5b89\u88c5\u4e86\u6240\u9700\u7684\u63d2\u4ef6\uff0c\u4f46\u6ca1\u6709\u8fbe\u5230\u60a8\u6307\u5b9a\u7684\u6700\u4f4e\u7248\u672c\u53f7\uff0cTGM \u63d2\u4ef6\u6fc0\u6d3b\u4f1a\u8b66\u544a\u7528\u6237\u8fdb\u884c\u66f4\u65b0\u3002<\/li>\n<li> force_activation \uff08\u5e03\u5c14\u503c\uff0c\u53ef\u9009\uff09 &#8211; \u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u5f53\u60a8\u7684\u4e3b\u9898\u5904\u4e8e\u6d3b\u52a8\u72b6\u6001\u65f6\uff0c\u7528\u6237\u5c06\u65e0\u6cd5\u505c\u7528\u63d2\u4ef6\u3002\u6709\u70b9\u70e6\u4eba\uff0c\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u662f\u5fc5\u8981\u7684\u3002<\/li>\n<li> force_deactivation \uff08\u5e03\u5c14\u503c\uff0c\u53ef\u9009\uff09 &#8211; \u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u4e00\u65e6\u7528\u6237\u5207\u6362\u4e3b\u9898\uff0c\u63d2\u4ef6\u5c06\u88ab\u505c\u7528\u3002<\/li>\n<li> external_url (\u5b57\u7b26\u4e32\uff0c\u53ef\u9009) &#8211; \u5982\u679c\u8bbe\u7f6e\uff0c\u63d2\u4ef6\u7684\u540d\u79f0\u5c06\u94fe\u63a5\u5230\u63d2\u4ef6\u8981\u6c42\u901a\u77e5\u4e2d\u7684\u6b64\u5730\u5740\u3002<\/li>\n<\/ul>\n<p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u4e09\u4e2a\u9009\u9879\u8ba9\u60a8\u7684\u7528\u6237\u901a\u8fc7 TGM \u63d2\u4ef6\u6fc0\u6d3b\u5b89\u88c5\u63d2\u4ef6\uff1a\u60a8\u53ef\u4ee5\u4ece WordPress \u63d2\u4ef6\u76ee\u5f55\u3001\u5916\u90e8\u6e90\uff08\u4f8b\u5982\u60a8\u81ea\u5df1\u7684\u670d\u52a1\u5668\u6216 CDN\uff09\u6216\u60a8\u7684\u4e3b\u9898\u6587\u4ef6\u5939\uff08\u4f8b\u5982\/my-theme\/plugins\/shortcodes.zip)\u3002<\/p>\n<h4>\u9700\u8981 WordPress.org \u7684\u63d2\u4ef6<\/h4>\n<pre>&lt;?php $plugins = array(\n\tarray(\n\t\t'name'      =&gt; 'BuddyPress',\n\t\t'slug'      =&amp;gt; 'buddypress',\n\t\t'required'  =&amp;gt; false, \/\/ this plugin is recommended\n\t)\n);\n\n?&amp;gt;\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h4>\u4ece\u5916\u90e8\u6e90\u8bf7\u6c42\u63d2\u4ef6<\/h4>\n<pre>&lt;?php $plugins = array(\n\tarray(\n\t\t'name'               =&gt; 'My Awesome Plugin',\n\t\t'slug'               =&amp;gt; 'my-awesome-plugin',\n\t\t'source'             =&amp;gt; 'http:\/\/files.my-website.com\/my-awesome-plugin.zip',\n\t\t'required'           =&amp;gt; true, \/\/ this plugin is required\n\t\t'external_url'       =&amp;gt; 'http:\/\/my-website.com\/introducing-my-awesome-plugin', \/\/ page of my plugin\n\t\t'force_deactivation' =&amp;gt; true, \/\/ deactivate this plugin when the user switches to another theme\n\t)\n);\n\n?&amp;gt;\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h4>\u4ece\u4e3b\u9898\u76ee\u5f55\u4e2d\u83b7\u53d6\u63d2\u4ef6<\/h4>\n<pre>&lt;?php $plugins = array(\n\tarray(\n\t\t'name'               =&gt; 'My Super Sleek Slider',\n\t\t'slug'               =&amp;gt; 'my-super-sleek-slider',\n\t\t'source'             =&amp;gt; get_stylesheet_directory() . '\/lib\/plugins\/my-super-sleek-slider.zip', \/\/ The \"internal\" source of the plugin.\n\t\t'required'           =&amp;gt; true, \/\/ this plugin is required\n\t\t'version'            =&amp;gt; '1.2', \/\/ the user must use version 1.2 (or higher) of this plugin\n\t\t'force_activation'   =&amp;gt; false, \/\/ this plugin is going to stay activated unless the user switches to another theme\n\t)\n);\n\n?&amp;gt;\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>\u914d\u7f6e TGM \u63d2\u4ef6\u6fc0\u6d3b<\/h3>\n<p>\u6ce8\u610f\u5230\u793a\u4f8b\u4ee3\u7801\u672b\u5c3e\u5e26\u6709\u4e24\u4e2a\u53c2\u6570\u7684 tgmpa() \u51fd\u6570\u4e86\u5417\uff1f\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f $config \u53d8\u91cf\uff0c\u5b83\u4e5f\u6070\u597d\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u5c31\u50cf $plugins \u53c2\u6570\u4e00\u6837\u3002\u987e\u540d\u601d\u4e49\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u6b64\u6570\u7ec4\u914d\u7f6e TGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93\u3002\u5b83\u8fd8\u6709\u81ea\u5df1\u7684\u4e00\u7ec4\u9009\u9879\u9700\u8981\u8bbe\u7f6e\uff1a<\/p>\n<ul>\n<li> id\uff08\u5b57\u7b26\u4e32\uff09 &#8211; \u60a8\u5728\u4e3b\u9898\u4e2d\u5b9e\u73b0\u7684 TGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93\u7684\u552f\u4e00 ID\u3002\u8fd9\u5b9e\u9645\u4e0a\u975e\u5e38\u91cd\u8981\uff1a\u5982\u679c\u53e6\u4e00\u4e2a\u63d2\u4ef6\u4e5f\u4f7f\u7528 TGM \u63d2\u4ef6\u6fc0\u6d3b\uff0c\u5219\u4e0d\u540c\u7684 ID \u53ef\u4ee5\u9632\u6b62\u51b2\u7a81\u3002<\/li>\n<li> default_path (string) &#8211; \u4e3b\u9898\u5185\u63d2\u4ef6\u7684\u9ed8\u8ba4\u7edd\u5bf9\u8def\u5f84\u3002\u8bbe\u7f6e\u6b64\u9009\u9879\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 ZIP \u6587\u4ef6\u7684\u540d\u79f0\u4f5c\u4e3a\u63d2\u4ef6\u7684 source \u53c2\u6570\u3002<\/li>\n<li> menu (\u5b57\u7b26\u4e32) &#8211; \u63d2\u4ef6\u5b89\u88c5\u9875\u9762\u7684\u83dc\u5355\u9879\u3002<\/li>\n<li> has_notices (boolean) &#8211; \u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u5219\u4f1a\u663e\u793a\u5fc5\u9700\/\u63a8\u8350\u63d2\u4ef6\u7684\u7ba1\u7406\u5458\u901a\u77e5\u3002<\/li>\n<li> dismissible (boolean) &#8211; \u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7528\u6237\u53ef\u4ee5\u201c\u5ffd\u7565\u201d\u901a\u77e5\u3002<\/li>\n<li> dismiss_msg (string) &#8211; \u5982\u679c dismissable \u9009\u9879\u8bbe\u7f6e\u4e3a false\uff0c\u5219\u6b64\u6d88\u606f\u5c06\u663e\u793a\u5728\u7ba1\u7406\u901a\u77e5\u4e0a\u65b9\u3002<\/li>\n<li> is_automatic (boolean) &#8211; \u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u63d2\u4ef6\u5c06\u5728\u7528\u6237\u540c\u610f\u5b89\u88c5\u540e\u6fc0\u6d3b\u3002<\/li>\n<li> message (string) &#8211; \u5728\u63d2\u4ef6\u8868\u4e4b\u524d\u663e\u793a\u7684\u53ef\u9009 HTML\u3002<\/li>\n<li> strings (array) &#8211; \u53e6\u4e00\u4e2a array \u5305\u542b\u8981\u663e\u793a\u7684\u6d88\u606f\u3002\u60a8\u4e5f\u53ef\u4ee5\u5c06\u5b83\u4eec\u8bbe\u7f6e\u4e3a\u53ef\u7ffb\u8bd1\u5b57\u7b26\u4e32\u3002\u67e5\u770b example.php \u6587\u4ef6\u4ee5\u67e5\u770b\u6d88\u606f\u5b57\u7b26\u4e32\u7684\u5b8c\u6574\u5217\u8868\u3002<\/li>\n<\/ul>\n<pre>&lt;?php $config = array(\n\t'id'           =&gt; 'mytheme-tgmpa', \/\/ your unique TGMPA ID\n\t'default_path' =&amp;gt; get_stylesheet_directory() . '\/lib\/plugins\/', \/\/ default absolute path\n\t'menu'         =&amp;gt; 'mytheme-install-required-plugins', \/\/ menu slug\n\t'has_notices'  =&amp;gt; true, \/\/ Show admin notices\n\t'dismissable'  =&amp;gt; false, \/\/ the notices are NOT dismissable\n\t'dismiss_msg'  =&amp;gt; 'I really, really need you to install these plugins, okay?', \/\/ this message will be output at top of nag\n\t'is_automatic' =&amp;gt; true, \/\/ automatically activate plugins after installation\n\t'message'      =&amp;gt; '&lt;!--Hey there.--&gt;', \/\/ message to output right before the plugins table\n\t'strings'      =&amp;gt; array(); \/\/ The array of message strings that TGM Plugin Activation uses\n);\n\n?&amp;gt;\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h2>\u603b\u7ed3\u4e00\u5207<\/h2>\n<p>\u6b63\u5982\u60a8\u6240\u770b\u5230\u7684\uff0c\u901a\u8fc7 WordPress \u4e3b\u9898\u63d0\u4f9b\u529f\u80fd\u5e76\u975e\u4e0d\u53ef\u80fd &#8211; \u60a8\u53ea\u9700\u8003\u8651\u7528\u6237\u4ece\u60a8\u7684\u4e3b\u9898\u5207\u6362\u5230\u53e6\u4e00\u4e2a\u4e3b\u9898\u65f6\u7684\u60c5\u51b5\u3002 TGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93\u63d0\u4f9b\u4e86\u4e00\u79cd\u975e\u5e38\u806a\u660e\u7684\u6309\u4e66\u672c\u64cd\u4f5c\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u60a8\u89c9\u5f97\u8fd9\u4e2a\u5de5\u5177\u600e\u4e48\u6837\uff1f\u60a8\u66fe\u7ecf\u4f7f\u7528\u8fc7\u5b83\uff0c\u6216\u8005\u60a8\u6253\u7b97\u5c06\u6765\u4f7f\u7528\u5b83\u5417\uff1f\u8bf7\u5728\u4e0b\u9762\u53d1\u8868\u8bc4\u8bba\uff0c\u544a\u8bc9\u6211\u4eec\u60a8\u7684\u60f3\u6cd5\u3002\u5982\u679c\u60a8\u559c\u6b22\u8fd9\u7bc7\u6587\u7ae0\uff0c\u8bf7\u4e0d\u8981\u5fd8\u8bb0\u4e0e\u60a8\u7684\u670b\u53cb\u5206\u4eab\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5728\u60a8\u7684\u4e3b\u9898\u4e2d\u5229\u7528 TGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93\u7684\u5f3a\u5927\u529f\u80fd\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3b\u9898\u5e76\u4e0d\u610f\u5473\u7740\u5177\u6709\u529f\u80fd\u6027\uff0c\u4f46\u4f5c\u4e3a\u4e3b\u9898\u5f00\u53d1\u4eba\u5458\uff0c\u6211\u4eec\u4e3b\u8981\u9700\u8981\u5305\u542b\u4e00\u4e9b\u529f\u80fd\u4ee5\u4f7f\u6211\u4eec\u7684\u4e3b\u9898\u66f4\u597d\u4e00\u70b9\uff0c\u5e76\u4e14\u5177\u6709\u529f\u80fd\u6027\u3002 \u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4e86\u89e3\u201c\u63d2\u4ef6\u9886\u57df\u201d\u4e00\u8bcd\uff0c\u5e76\u5b66\u4e60\u4f7f\u7528 Thomas Griffin \u7f16\u5199\u7684\u51fa\u8272\u5de5\u5177\uff1aTGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93\u3002 \u4e3b\u9898\u529f\u80fd\uff1a\u5165\u4fb5\u63d2\u4ef6\u9886\u5730 \u4e3b\u9898\u65e8\u5728\u6539\u53d8\u60a8\u7684 WordPress \u7f51\u7ad9\u7684\u8bbe\u8ba1\u3002\u7406\u60f3\u60c5\u51b5\u4e0b\uff0c\u5b83\u5e94\u8be5\u662f\u89c6\u89c9\u3002\u4f46\u5728 WordPress \u7684\u9ec4\u91d1\u65f6\u4ee3\uff0c\u4e3b\u9898\u5f00\u53d1\u4eba\u5458\u7ecf\u5e38\u5728\u5176\u4e3b\u9898\u4e2d\u5305\u542b\u529f\u80fd\u7279\u6027\uff0c\u4ee5\u4fdd\u6301\u5e02\u573a\u7ade\u4e89\u529b\u3002\u672c\u6765\u5e94\u8be5\u5982\u6b64\uff0c\u4f46\u4e8b\u5b9e\u5374\u5982\u6b64\u3002 \u8fd9\u662f\u5bf9\u63d2\u4ef6\u9886\u5730\u7684\u5165\u4fb5\u3002\u6211\u4eec\u53ef\u4ee5\u7528\u7b80\u5355\u7684\u672f\u8bed\u6765\u5b9a\u4e49\u201c\u63d2\u4ef6\u9886\u57df\u201d\uff1a\u4ee3\u7801\u7684\u529f\u80fd\u90e8\u5206\u4f4d\u4e8e\u8be5\u9886\u57df\u7684\u8fb9\u754c\u5185\u3002\u6539\u53d8\u7f51\u7ad9\u529f\u80fd\u7684\u6bcf\u4e00\u6bb5\u4ee3\u7801\u90fd\u9700\u8981\u4f5c\u4e3a\u63d2\u4ef6\u63d0\u4f9b\uff08\u5982\u679c\u5c1a\u672a\u5728 WordPress \u6838\u5fc3\u4e2d\u63d0\u4f9b\uff09\u3002 \u5728\u6211\u4e4b\u524d\u7684\u4e00\u7bc7\u6587\u7ae0\uff08\u201c\u5236\u4f5c\u5b8c\u7f8e\u7684 WordPress \u4e3b\u9898\u201d\u7cfb\u5217\u4e2d\uff09\u4e2d\uff0c\u6211\u63d0\u5230\u4e86\u201c\u63d2\u4ef6\u9886\u57df\u201d\u7684\u7ecf\u9a8c\u6cd5\u5219\uff1a \u5982\u679c\u8be5\u529f\u80fd\u4e0e\u7f51\u7ad9\u7684\u89c6\u89c9\u5916\u89c2\u6709\u5173\uff0c\u5219\u5e94\u4f4d\u4e8e\u4e3b\u9898\u4e2d\uff0c\u4f46\u5982\u679c\u4e0e\u7f51\u7ad9\u7684\u529f\u80fd\u6709\u5173\uff0c\u5219\u5e94\u5728\u4e3b\u9898\u4e2d\u5e94\u4f5c\u4e3a\u5355\u72ec\u7684\u63d2\u4ef6\u5305\u542b\u5728\u5185\u3002 \u5f88\u7b80\u5355\uff0c\u5bf9\u5427\uff1f \u5c3d\u7ba1\u4eba\u4eec\u4ecd\u7136\u503e\u5411\u4e8e\u5c06\u529f\u80fd\u4f4d\u786c\u7f16\u7801\u5230\u4ed6\u4eec\u7684\u4e3b\u9898\u4e2d\uff0c\u4f46\u4e3b\u9898\u76ee\u5f55\uff08\u5982 WordPress.org \u548c ThemeForest\uff09\u4e0d\u63a5\u53d7\u4fb5\u5165\u201c\u63d2\u4ef6\u9886\u57df\u201d\u7684\u4e3b\u9898\u3002\u56e0\u6b64\uff0c\u63d0\u4f9b\u5e26\u6709\u4e3b\u9898\u7684\u529f\u80fd\u5c31\u6210\u4e86\u4e00\u4e2a\u95ee\u9898\u3002 \u5e78\u8fd0\u7684\u662f\uff0c\u6709\u4e00\u4e2a\u76f8\u5f53\u7b80\u5355\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u5e76\u4e14\u5b83\u4e0d\u8fdd\u53cd\u201c\u63d2\u4ef6\u9886\u57df\u201d\u89c4\u5219\u3002 \u4ecb\u7ecd TGM \u63d2\u4ef6\u6fc0\u6d3b\u5e93 TGM Plugin Activation \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u5e93\uff0c\u65e8\u5728\u5c06\u4e3b\u9898\u4e0e\u63d2\u4ef6\u6346\u7ed1\u5728\u4e00\u8d77\u3002\u8fd9\u4e2a\u60f3\u6cd5\u5f88\u7b80\u5355\uff1a\u5f53\u7528\u6237\u5b89\u88c5\u60a8\u7684\u4e3b\u9898\u65f6\uff0c\u5b83\u4f1a\u8ba9\u7528\u6237\u5b89\u88c5\u6765\u81ea WordPress.org\u3001\u5916\u90e8\u7f51\u7ad9\u6216\u4e3b\u9898\u6587\u4ef6\u5939\u7684\u63d2\u4ef6\u3002\u4ee5\u4e0b\u662f\u8be5\u5e93\u7684\u521b\u5efa\u8005 Thomas Griffin \u5bf9\u8fd9\u4e2a\u65b9\u4fbf\u7684\u5c0f\u5de5\u5177\u7684\u5b9a\u4e49\uff1a TGM \u63d2\u4ef6\u6fc0\u6d3b \u662f\u4e00\u4e2a PHP \u5e93\uff0c\u53ef\u8ba9\u60a8\u8f7b\u677e\u5730\u4e3a\u60a8\u7684 WordPress \u4e3b\u9898\uff08\u548c\u63d2\u4ef6\uff09\u8bf7\u6c42\u6216\u63a8\u8350\u63d2\u4ef6\u3002\u5b83\u5141\u8bb8\u60a8\u7684\u7528\u6237\u4f7f\u7528\u672c\u673a WordPress \u7c7b\u3001\u51fd\u6570\u548c\u63a5\u53e3\u4ee5\u5355\u4e00\u6216\u6279\u91cf\u65b9\u5f0f\u5b89\u88c5\u751a\u81f3\u81ea\u52a8\u6fc0\u6d3b\u63d2\u4ef6\u3002\u60a8\u53ef\u4ee5\u5f15\u7528\u9884\u6253\u5305\u7684\u63d2\u4ef6\u3001WordPress \u63d2\u4ef6\u5b58\u50a8\u5e93\u4e2d\u7684\u63d2\u4ef6\uff0c\u751a\u81f3\u662f\u4e92\u8054\u7f51\u4e0a\u5176\u4ed6\u5730\u65b9\u6258\u7ba1\u7684\u63d2\u4ef6\u3002 \u8fd9\u53ef\u80fd\u662f\u89e3\u51b3\u201c\u63d2\u4ef6\u9886\u5730\u5165\u4fb5\u201d\u95ee\u9898\u7684\u6700\u660e\u667a\u7684\u89e3\u51b3\u65b9\u6848\u3002\u800c\u4e14\u7533\u8bf7\u4e5f\u5f88\u5bb9\u6613\u3002 \u6211\u4eec\u6765\u770b\u770b\u5427\uff01 \u5b89\u88c5 TGM \u63d2\u4ef6\u6fc0\u6d3b \u5b89\u88c5 TGM \u63d2\u4ef6\u6fc0\u6d3b\u975e\u5e38\u7b80\u5355\u3002\u53ea\u9700\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a \u4ece\u9875\u9762\u7684\u201c\u4e0b\u8f7d\u201d\u90e8\u5206\u4e0b\u8f7d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-32481","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=32481"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32481\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=32481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=32481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=32481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}