{"id":7320,"date":"2022-10-23T15:49:04","date_gmt":"2022-10-23T07:49:04","guid":{"rendered":"http:\/\/www.yptk.cn\/?p=7320"},"modified":"2022-10-23T15:49:04","modified_gmt":"2022-10-23T07:49:04","slug":"%e5%ad%a6%e4%b9%a0%e5%86%99wordpress%e6%8f%92%e4%bb%b6%e4%ba%8c","status":"publish","type":"post","link":"http:\/\/yptk.cn\/index.php\/2022\/10\/23\/%e5%ad%a6%e4%b9%a0%e5%86%99wordpress%e6%8f%92%e4%bb%b6%e4%ba%8c\/","title":{"rendered":"\u5b66\u4e60\u5199wordpress\u63d2\u4ef6(\u4e8c)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u7684\u7b2c\u4e00\u4e2a\u63d2\u4ef6nidaye\uff0c\u5982\u679c\u4fee\u6539\u663e\u793a\u5185\u5bb9\u5c31\u8981\u4fee\u6539\u6e90\u4ee3\u7801\uff0c\u8fd9\u663e\u7136\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\u3002\u7ee7\u7eed\u6539\u8fdb\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4eca\u5929\u76ee\u6807\uff1a<br>1\u3001\u5728\u540e\u53f0\u6dfb\u52a0\u72ec\u7acb\u9875\u9762\u548c\u83dc\u5355<br>2\u3001\u7528\u6237\u81ea\u5b9a\u4e49\u663e\u793a\u5185\u5bb9\uff0c\u4fdd\u5b58\u5728\u6570\u636e\u5e93\u4e2d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n\/*\nPlugin Name:ni2daye\nPlugin URI: http:\/\/www.yptk.cn\nVersion:V0.1\nAuthor: YPTK\nAuthor URI:http:\/\/www.yptk.cn\nDescription:My second plugin named ni2daye\n*\/\n?>\n&lt;?php\n\n\/* \u6ce8\u518c\u6fc0\u6d3b\u63d2\u4ef6\u65f6\u8981\u8c03\u7528\u7684\u51fd\u6570 *\/ \nregister_activation_hook( __FILE__, 'ni2daye_install');\n\n\/* \u6ce8\u518c\u505c\u7528\u63d2\u4ef6\u65f6\u8981\u8c03\u7528\u7684\u51fd\u6570 *\/ \nregister_deactivation_hook( __FILE__, 'ni2daye_remove' );\n\nfunction ni2daye_install() {  \n    \/* \u5728\u6570\u636e\u5e93\u7684 wp_options \u8868\u4e2d\u6dfb\u52a0\u4e00\u6761\u8bb0\u5f55\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a\u9ed8\u8ba4\u503c *\/ \n    add_option(\"ni_2daye\", \"\u6211\u662f\u5584\u53d8\u7684\u4f60\u4e8c\u5927\u7237\u3002\", '', 'yes');  \n}\n\nfunction ni2daye_remove() {  \n    \/* \u5220\u9664 wp_options \u8868\u4e2d\u7684\u5bf9\u5e94\u8bb0\u5f55 *\/ \n    delete_option('ni_2daye');  \n}\n\nif( is_admin() ) {\n    \/*  \u5229\u7528 admin_menu \u94a9\u5b50\uff0c\u6dfb\u52a0\u83dc\u5355 *\/\n    add_action('admin_menu', 'display_ni2daye_menu');\n}\n\nfunction display_ni2daye_menu() {\n    \/* add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function);  *\/\n    \/* \u9875\u540d\u79f0\uff0c\u83dc\u5355\u540d\u79f0\uff0c\u8bbf\u95ee\u7ea7\u522b\uff0c\u83dc\u5355\u522b\u540d\uff0c\u70b9\u51fb\u8be5\u83dc\u5355\u65f6\u7684\u56de\u8c03\u51fd\u6570\uff08\u7528\u4ee5\u663e\u793a\u8bbe\u7f6e\u9875\u9762\uff09 *\/\n    add_options_page('Set ni2daye', 'ni2daye Menu', 'administrator','display_ni2daye', 'display_ni2daye_html_page');\n}\n\nfunction display_ni2daye_html_page() {\n    ?>\n    &lt;div>  \n        &lt;h2>Set ni2daye&lt;\/h2>  \n        &lt;form method=\"post\" action=\"options.php\">  \n            &lt;?php \/* \u4e0b\u9762\u8fd9\u884c\u4ee3\u7801\u7528\u6765\u4fdd\u5b58\u8868\u5355\u4e2d\u5185\u5bb9\u5230\u6570\u636e\u5e93 *\/ ?>  \n            &lt;?php wp_nonce_field('update-options'); ?>  \n \n            &lt;p>  \n                &lt;textarea  \n                    name=\"ni_2daye\" \n                    id=\"ni_2daye\"\n                    cols=\"40\" \n                    rows=\"6\">&lt;?php echo get_option('ni_2daye'); ?>&lt;\/textarea>  \n            &lt;\/p>  \n \n            &lt;p>  \n                &lt;input type=\"hidden\" name=\"action\" value=\"update\" \/>  \n                &lt;input type=\"hidden\" name=\"page_options\" value=\"ni_2daye\" \/>  \n \n                &lt;input type=\"submit\" value=\"Save\" class=\"button-primary\" \/>  \n            &lt;\/p>  \n        &lt;\/form>  \n    &lt;\/div>  \n&lt;?php  \n}  \nadd_filter( 'the_content',  'display_ni2daye' );  \n\/*the_content \u662f\u94a9\u5b50\u7684\u540d\u5b57\uff0cdisplay_copyright \u662f\u56de\u8c03\u51fd\u6570\u540d\u79f0\u3002*\/\nfunction display_ni2daye( $content ) {  \n        $content = get_option('ni_2daye').$content; \/\/\u628a\u5185\u5bb9\u6dfb\u52a0\u5230\u6bcf\u7bc7\u6587\u7ae0\u7684\u5f00\u5934\u3002\n    return $content;  \n}  \n?><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6210\u529f\uff01<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"http:\/\/www.yptk.cn\/wp-content\/uploads\/2022\/10\/\u56fe\u7247-4-1024x718.png\" alt=\"\" class=\"wp-image-7323\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fee\u6539\uff0cSave\u6210\u529f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"http:\/\/www.yptk.cn\/wp-content\/uploads\/2022\/10\/\u56fe\u7247-5.png\" alt=\"\" class=\"wp-image-7327\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u663e\u793a\u6210\u529f\uff01<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"http:\/\/www.yptk.cn\/wp-content\/uploads\/2022\/10\/\u56fe\u7247-6.png\" alt=\"\" class=\"wp-image-7329\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u7684\u7b2c\u4e00\u4e2a\u63d2\u4ef6nidaye\uff0c\u5982\u679c\u4fee\u6539\u663e\u793a\u5185\u5bb9\u5c31\u8981\u4fee\u6539\u6e90\u4ee3\u7801\uff0c\u8fd9\u663e\u7136\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\u3002\u7ee7\u7eed\u6539\u8fdb\u3002 \u4eca\u5929\u76ee\u6807\uff1a1\u3001\u5728\u540e\u53f0\u6dfb\u52a0\u72ec\u7acb\u9875\u9762\u548c\u83dc\u53552\u3001\u7528\u6237\u81ea\u5b9a\u4e49\u663e\u793a\u5185\u5bb9\uff0c\u4fdd\u5b58\u5728\u6570\u636e\u5e93\u4e2d\u3002 \u6210\u529f\uff01 \u4fee\u6539\uff0cSave\u6210\u529f\u3002 \u663e\u793a\u6210\u529f\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[15],"tags":[],"class_list":["post-7320","post","type-post","status-publish","format-standard","hentry","category-15"],"_links":{"self":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/posts\/7320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/comments?post=7320"}],"version-history":[{"count":0,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/posts\/7320\/revisions"}],"wp:attachment":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/media?parent=7320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/categories?post=7320"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/tags?post=7320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}