{"id":3865,"date":"2025-06-12T05:44:43","date_gmt":"2025-06-11T21:44:43","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/3865.html"},"modified":"2025-06-12T05:44:43","modified_gmt":"2025-06-11T21:44:43","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e6%8f%92%e4%bb%b6%e5%bf%ab%e9%80%9f%e5%88%9b%e5%bb%bawordpress%e6%8f%92%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/3865.html","title":{"rendered":"\u5982\u4f55\u4f7f\u7528\u63d2\u4ef6\u5feb\u901f\u521b\u5efaWordPress\u63d2\u4ef6"},"content":{"rendered":"<div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--1\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/dyA-1-400x300.jpg\" alt=\"Bug&#32534;&#35793;&#29422;\" class=\"wp-image-1842\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<p class=\"my-0\">Bug&#32534;&#35793;&#29422;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#35201;&#24555;&#36895;&#21019;&#24314;&#19968;&#20010;WordPress&#25554;&#20214;&#65292;&#25105;&#20204;&#21487;&#20197;&#21033;&#29992;&#19968;&#20123;&#20869;&#32622;&#30340;&#24037;&#20855;&#21644;&#26041;&#27861;&#26469;&#31616;&#21270;&#36825;&#20010;&#36807;&#31243;&#12290;&#39318;&#20808;&#65292;&#20320;&#38656;&#35201;&#30830;&#20445;&#20320;&#30340;WordPress&#29615;&#22659;&#24050;&#32463;&#35774;&#32622;&#22909;&#65292;&#24182;&#19988;&#26377;&#36866;&#24403;&#30340;&#26435;&#38480;&#26469;&#23433;&#35013;&#21644;&#32534;&#36753;&#25554;&#20214;&#12290;<\/p>\n<ol>\n<li>\n<p><strong>&#36873;&#25321;&#21512;&#36866;&#30340;&#25554;&#20214;&#27169;&#26495;<\/strong>&#65306;&#22823;&#22810;&#25968;&#25554;&#20214;&#37117;&#26159;&#22522;&#20110;&#29616;&#26377;&#30340;PHP&#20195;&#30721;&#25110;&#31867;&#24211;&#26500;&#24314;&#30340;&#65292;&#36825;&#20123;&#27169;&#26495;&#25552;&#20379;&#20102;&#22522;&#26412;&#30340;&#21151;&#33021;&#32467;&#26500;&#12290;&#20320;&#21487;&#20197;&#20174;WordPress&#23448;&#26041;&#25991;&#26723;&#25110;&#32773;GitHub&#19978;&#25214;&#21040;&#35768;&#22810;&#24320;&#28304;&#30340;&#25554;&#20214;&#27169;&#26495;&#12290;<\/p>\n<\/li>\n<li>\n<p><strong>&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;&#25554;&#20214;&#30446;&#24405;<\/strong>&#65306;&#22312;&#20320;&#30340;WordPress&#25554;&#20214;&#30446;&#24405;&#65288;&#36890;&#24120;&#26159;<code>wp-content\/plugins<\/code>&#65289;&#19979;&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;&#25991;&#20214;&#22841;&#12290;&#21629;&#21517;&#36825;&#20010;&#25991;&#20214;&#22841;&#26102;&#65292;&#35831;&#36981;&#24490;&#26631;&#20934;&#30340;&#21629;&#21517;&#35268;&#21017;&#65292;&#20363;&#22914;<code>my-new-plugin<\/code>&#12290;<\/p>\n<\/li>\n<li>\n<p><strong>&#32534;&#20889;&#25554;&#20214;&#30340;&#20027;&#35201;&#20195;&#30721;<\/strong>&#65306;&#22312;&#26032;&#21019;&#24314;&#30340;&#25991;&#20214;&#22841;&#37324;&#65292;&#25171;&#24320;&#19968;&#20010;&#21517;&#20026;<code>plugin.php<\/code>&#30340;&#25991;&#20214;&#12290;&#22312;&#36825;&#20010;&#25991;&#20214;&#20013;&#65292;&#20320;&#20250;&#30475;&#21040;&#19968;&#20123;&#40664;&#35748;&#30340;&#20989;&#25968;&#21644;&#21464;&#37327;&#65292;&#23427;&#20204;&#23450;&#20041;&#20102;&#25554;&#20214;&#30340;&#22522;&#26412;&#21151;&#33021;&#12290;&#20320;&#21487;&#20197;&#26681;&#25454;&#33258;&#24049;&#30340;&#38656;&#27714;&#20462;&#25913;&#36825;&#20123;&#20195;&#30721;&#65292;&#28155;&#21152;&#26032;&#30340;&#21151;&#33021;&#25110;&#32773;&#26367;&#25442;&#29616;&#26377;&#21151;&#33021;&#12290;<\/p>\n<\/li>\n<li>\n<p><strong>&#28155;&#21152;&#24517;&#35201;&#30340;&#38057;&#23376;&#21644;&#21160;&#20316;<\/strong>&#65306;&#20026;&#20102;&#20351;&#20320;&#30340;&#25554;&#20214;&#33021;&#22815;&#19982;WordPress&#30340;&#26680;&#24515;&#21151;&#33021;&#20132;&#20114;&#65292;&#20320;&#38656;&#35201;&#20026;&#29305;&#23450;&#30340;&#20107;&#20214;&#27880;&#20876;&#22238;&#35843;&#20989;&#25968;&#12290;&#36825;&#20123;&#20989;&#25968;&#36890;&#24120;&#20301;&#20110;<code>functions.php<\/code>&#25991;&#20214;&#20013;&#65292;&#20294;&#20063;&#21487;&#20197;&#22312;<code>plugin.php<\/code>&#25991;&#20214;&#20013;&#33258;&#23450;&#20041;&#12290;&#36890;&#36807;&#20351;&#29992;WordPress&#25552;&#20379;&#30340;&#38057;&#23376;&#21644;&#21160;&#20316;&#65292;&#20320;&#21487;&#20197;&#23454;&#29616;&#21508;&#31181;&#29992;&#25143;&#30028;&#38754;&#20803;&#32032;&#12289;&#25968;&#25454;&#23384;&#20648;&#12289;&#29992;&#25143;&#39564;&#35777;&#31561;&#21151;&#33021;&#12290;<\/p>\n<\/li>\n<li>\n<p><strong>&#27979;&#35797;&#25554;&#20214;<\/strong>&#65306;&#20445;&#23384;&#24182;&#20851;&#38381;&#25152;&#26377;&#25991;&#20214;&#21518;&#65292;&#20320;&#24212;&#35813;&#33021;&#22815;&#22312;&#27983;&#35272;&#22120;&#20013;&#35775;&#38382;&#20320;&#30340;WordPress&#32593;&#31449;&#19978;&#30340;&#25554;&#20214;&#30446;&#24405;&#65288;&#36890;&#24120;&#26159;<code>\/wp-admin\/plugins.php<\/code>&#65289;&#65292;&#26597;&#30475;&#26159;&#21542;&#25104;&#21151;&#21152;&#36733;&#20102;&#20320;&#30340;&#25554;&#20214;&#12290;<\/p>\n<\/li>\n<li>\n<p><strong>&#28608;&#27963;&#25554;&#20214;<\/strong>&#65306;&#26368;&#21518;&#19968;&#27493;&#26159;&#28608;&#27963;&#20320;&#30340;&#25554;&#20214;&#12290;&#22312;&#25554;&#20214;&#21015;&#34920;&#39029;&#38754;&#28857;&#20987;&ldquo;&#28608;&#27963;&rdquo;&#25353;&#38062;&#21363;&#21487;&#23436;&#25104;&#12290;&#29616;&#22312;&#65292;&#20320;&#30340;&#25554;&#20214;&#24212;&#35813;&#24050;&#32463;&#22312;WordPress&#29615;&#22659;&#20013;&#36816;&#34892;&#20102;&#65281;<\/p>\n<\/li>\n<\/ol>\n<h3>&#31034;&#20363;&#20195;&#30721;<\/h3>\n<p>&#20197;&#19979;&#26159;&#19968;&#20010;&#31616;&#21333;&#30340;WordPress&#25554;&#20214;&#31034;&#20363;&#65292;&#23427;&#20250;&#22312;&#29992;&#25143;&#25552;&#20132;&#34920;&#21333;&#26102;&#33258;&#21160;&#26356;&#26032;&#25968;&#25454;&#24211;&#20013;&#30340;&#26576;&#20010;&#23383;&#27573;&#65306;<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\/*\nPlugin Name: My Custom Plugin\nDescription: A simple plugin to demonstrate how to use WordPress hooks and actions.\nVersion: 1.0\nAuthor: Your Name\n*\/\n\n\/\/ Hook into the 'save_post' action, which is triggered when a post or page is saved.\nadd_action('save_post', 'update_field');\n\nfunction update_field($post_id) {\n    \/\/ Get the current value of the field you want to update from the database.\n    $current_value = get_post_meta($post_id, '_custom_field_name', true);\n\n    \/\/ If this is not the first time saving the post (i.e., it's an edit), check if the user has entered new content.\n    if ($post-&gt;post_type == 'post') {\n        if ($current_value != $_POST['_custom_field_name']) {\n            \/\/ Update the database with the new value.\n            update_post_meta($post_id, '_custom_field_name', sanitize_text_field($_POST['_custom_field_name']));\n        }\n    }\n}\n?&gt;<\/code><\/pre>\n<p>&#20197;&#19978;&#20195;&#30721;&#21482;&#26159;&#19968;&#20010;&#22522;&#30784;&#31034;&#20363;&#65292;&#23454;&#38469;&#24320;&#21457;&#20013;&#21487;&#33021;&#38656;&#35201;&#26356;&#22810;&#30340;&#23450;&#21046;&#21644;&#20248;&#21270;&#12290;&#24076;&#26395;&#36825;&#20010;&#25351;&#21335;&#33021;&#24110;&#21161;&#20320;&#24320;&#22987;&#21046;&#20316;&#20320;&#30340;&#31532;&#19968;&#20010;WordPress&#25554;&#20214;&#65281;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div><div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--2\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/zp-400x300.jpg\" alt=\"&#40657;&#26495;&#21069;&#30340;Bug&#35821;&#27861;&#35762;&#24072;\" class=\"wp-image-1849\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<p class=\"my-0\">&#40657;&#26495;&#21069;&#30340;Bug&#35821;&#27861;&#35762;&#24072;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#22312;WordPress&#20013;&#21019;&#24314;&#21644;&#31649;&#29702;&#25554;&#20214;&#26159;&#19968;&#39033;&#37325;&#35201;&#30340;&#25216;&#33021;&#65292;&#21487;&#20197;&#24110;&#21161;&#24744;&#26356;&#22909;&#22320;&#25511;&#21046;&#32593;&#31449;&#30340;&#21151;&#33021;&#21644;&#29992;&#25143;&#20307;&#39564;&#12290;&#20197;&#19979;&#26159;&#19968;&#20123;&#27493;&#39588;&#65292;&#29992;&#20110;&#20351;&#29992;&#25554;&#20214;&#24555;&#36895;&#21019;&#24314;WordPress&#25554;&#20214;&#65306;<\/p>\n<h3>1. &#23433;&#35013;WordPress&#25554;&#20214;<\/h3>\n<p>&#39318;&#20808;&#65292;&#20320;&#38656;&#35201;&#23433;&#35013;&#19968;&#20010;WordPress&#25554;&#20214;&#26469;&#24320;&#22987;&#24037;&#20316;&#12290;&#20320;&#21487;&#20197;&#36890;&#36807;WordPress&#23448;&#32593;&#25110;&#33258;&#23450;&#20041;&#25554;&#20214;&#30446;&#24405;&#65288;&#36890;&#24120;&#20301;&#20110;<code>wp-content\/plugins\/<\/code>&#65289;&#19979;&#36733;&#24182;&#28608;&#27963;&#25554;&#20214;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">function activate_my_plugin() {\n    \/\/ &#20551;&#35774;&#25105;&#20204;&#26377;&#19968;&#20010;&#21517;&#20026;myplugin&#30340;&#25554;&#20214;\n    wp_register_script('myplugin', plugins_url('\/myplugin.js', __FILE__), ['jquery'], '2023-01-01');\n    wp_enqueue_script('myplugin');\n\n    \/\/ &#36825;&#26679;&#21487;&#20197;&#30830;&#20445;&#25105;&#20204;&#30340;&#25554;&#20214;&#22312;&#39029;&#38754;&#21152;&#36733;&#26102;&#31435;&#21363;&#36816;&#34892;\n    wp_localize_script('myplugin', 'myplugin_data', [\n        'ajaxurl' =&gt; admin_url('admin-ajax.php'),\n    ]);\n\n    \/\/ &#36824;&#21487;&#20197;&#27880;&#20876;&#26032;&#30340;&#20989;&#25968;\n    add_action('init', 'register_my_plugin_actions');\n}\n\nadd_action('plugins_loaded', 'activate_my_plugin');<\/code><\/pre>\n<h3>2. &#32534;&#20889;&#25554;&#20214;&#20195;&#30721;<\/h3>\n<p>&#19968;&#26086;&#23433;&#35013;&#20102;&#25554;&#20214;&#65292;&#23601;&#21487;&#20197;&#32534;&#20889;&#20195;&#30721;&#20197;&#23454;&#29616;&#20854;&#21151;&#33021;&#12290;&#36825;&#36890;&#24120;&#28041;&#21450;&#21019;&#24314;JavaScript&#12289;CSS&#25991;&#20214;&#20197;&#21450;&#21487;&#33021;&#38656;&#35201;&#30340;PHP&#33050;&#26412;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-javascript\">\/\/ JavaScript&#25991;&#20214;\n(function($) {\n    $(document).ready(function() {\n        \/\/ &#22312;&#36825;&#37324;&#28155;&#21152;&#24744;&#30340;&#20195;&#30721;\n    });\n})(jQuery);\n\n\/\/ CSS&#25991;&#20214;\n\/* CSS&#26679;&#24335; *\/\n&lt;style&gt;\n    \/* &#22312;&#27492;&#22788;&#28155;&#21152;&#24744;&#30340;&#26679;&#24335; *\/\n&lt;\/style&gt;\n\n\/\/ PHP&#33050;&#26412;\n&lt;?php\n\/\/ &#36825;&#37324;&#21487;&#20197;&#25918;&#32622;&#22788;&#29702;&#29992;&#25143;&#36755;&#20837;&#12289;&#39564;&#35777;&#31561;&#36923;&#36753;\n?&gt;<\/code><\/pre>\n<h3>3. &#21019;&#24314;&#25554;&#20214;&#31867;<\/h3>\n<p>&#20026;&#20102;&#20351;&#25554;&#20214;&#26131;&#20110;&#31649;&#29702;&#21644;&#32500;&#25252;&#65292;&#21019;&#24314;&#19968;&#20010;&#21253;&#21547;&#25554;&#20214;&#25152;&#26377;&#21151;&#33021;&#30340;&#31867;&#26159;&#38750;&#24120;&#26377;&#29992;&#30340;&#12290;&#36825;&#23558;&#24110;&#21161;&#24744;&#26356;&#23481;&#26131;&#22320;&#25193;&#23637;&#21644;&#20462;&#25913;&#25554;&#20214;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">class MyPlugin extends WP_Admin_Menu {\n\n    public function init() {\n        $this-&gt;add_menu_page();\n        $this-&gt;setup_custom_fields();\n    }\n\n    private function add_menu_page() {\n        \/\/ &#28155;&#21152;&#33756;&#21333;&#39029;\n    }\n\n    private function setup_custom_fields() {\n        \/\/ &#35774;&#32622;&#33258;&#23450;&#20041;&#23383;&#27573;\n    }\n}<\/code><\/pre>\n<h3>4. &#37197;&#32622;&#25554;&#20214;<\/h3>\n<p>&#20026;&#20102;&#35753;&#25554;&#20214;&#22312;WordPress&#19978;&#27491;&#24120;&#24037;&#20316;&#65292;&#23427;&#38656;&#35201;&#37197;&#32622;&#21040;&#27491;&#30830;&#30340;&#20027;&#39064;&#25110;&#26694;&#26550;&#20013;&#12290;&#21487;&#20197;&#36890;&#36807;&#22312;&#25554;&#20214;&#30446;&#24405;&#19979;&#21019;&#24314;<code>.htaccess<\/code>&#25991;&#20214;&#26469;&#23436;&#25104;&#27492;&#25805;&#20316;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-apache\"># &#27492;&#25991;&#20214;&#24212;&#20445;&#23384;&#22312;plugins&#30446;&#24405;&#19979;&#30340;&#23376;&#30446;&#24405;&#20013;\n&lt;IfModule mod_rewrite.c&gt;\n    RewriteEngine On\n    RewriteBase \/\n    RewriteRule ^(.*)$ index.php?post_type=your-plugin&amp;slug=$1 [L]\n&lt;\/IfModule&gt;<\/code><\/pre>\n<h3>&#24635;&#32467;<\/h3>\n<p>&#20197;&#19978;&#27493;&#39588;&#25552;&#20379;&#20102;&#19968;&#20010;&#22522;&#26412;&#30340;&#25351;&#21335;&#26469;&#20351;&#29992;WordPress&#25554;&#20214;&#12290;&#35760;&#20303;&#65292;&#22312;&#24320;&#21457;&#25554;&#20214;&#30340;&#36807;&#31243;&#20013;&#65292;&#20445;&#25345;&#20195;&#30721;&#31616;&#27905;&#12289;&#27169;&#22359;&#21270;&#20197;&#21450;&#36981;&#24490;WordPress&#30340;&#26368;&#20339;&#23454;&#36341;&#26159;&#38750;&#24120;&#37325;&#35201;&#30340;&#12290;&#19981;&#26029;&#23398;&#20064;&#21644;&#23454;&#36341;&#21487;&#20197;&#20351;&#24744;&#25104;&#20026;&#19968;&#20010;&#20248;&#31168;&#30340;&#25554;&#20214;&#24320;&#21457;&#32773;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bug&#32534;&#35793;&#29422; &#35201;&#24555;&#36895;&#21019;&#24314;&#19968;&#20010;WordPress&#25554;&#20214;&#65292;&#25105;&#20204;&#21487;&#20197;&#21033;&#038;#2..<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[2107,2106],"tuisongtax":[],"class_list":["post-3865","post","type-post","status-publish","format-standard","hentry","category-wpdt","tag-cjyy","tag-cjzn"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/3865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/comments?post=3865"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/3865\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=3865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=3865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=3865"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=3865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}