{"id":12375077,"date":"2026-03-18T00:28:41","date_gmt":"2026-03-17T16:28:41","guid":{"rendered":"https:\/\/www.likacloud.com\/knowledge\/%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%e6%8e%8c%e6%8f%a1-wordpress-%e6%8f%92%e4%bb%b6%e5%bc%80%e5%8f%91%ef%bc%9a%e5%ae%8c%e6%95%b4%e6%8c%87%e5%8d%97%e4%b8%8e%e5%ae%9e%e6%88%98%e6%95%99%e7%a8%8b\/"},"modified":"2026-06-03T20:44:19","modified_gmt":"2026-06-03T12:44:19","slug":"wordpress-plugin-development-complete-guide-tutorial-12375077","status":"publish","type":"knowledge_post","link":"https:\/\/www.likacloud.com\/pt\/knowledge\/wordpress\/wordpress-plugin-development-complete-guide-tutorial-12375077\/","title":{"rendered":"Aprenda a desenvolver plugins para o WordPress do zero: guia completo e tutoriais pr\u00e1ticos."},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e3a\u4ec0\u4e48\u9009\u62e9\u5f00\u53d1 WordPress \u63d2\u4ef6<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u5f53\u4eca\u7684\u7f51\u7ad9\u751f\u6001\u4e2d\uff0cWordPress \u4ee5\u5176\u65e0\u4e0e\u4f26\u6bd4\u7684\u7075\u6d3b\u6027\u548c\u5e9e\u5927\u7684\u7528\u6237\u57fa\u7840\u5360\u636e\u4e3b\u5bfc\u5730\u4f4d\u3002\u8fd9\u79cd\u7075\u6d3b\u6027\u5f88\u5927\u7a0b\u5ea6\u4e0a\u5f52\u529f\u4e8e\u5176\u63d2\u4ef6\u7cfb\u7edf\u3002\u901a\u8fc7\u5f00\u53d1\u81ea\u5df1\u7684\u63d2\u4ef6\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5c06\u4e00\u4e2a\u60f3\u6cd5\u8f6c\u5316\u4e3a\u53ef\u590d\u7528\u7684\u529f\u80fd\u6a21\u5757\uff0c\u670d\u52a1\u4e8e\u5168\u7403\u6570\u767e\u4e07\u7f51\u7ad9\u3002\u8fd9\u4e0d\u4ec5\u80fd\u591f\u89e3\u51b3\u7279\u5b9a\u4e1a\u52a1\u9700\u6c42\uff0c\u8fd8\u80fd\u901a\u8fc7 WordPress \u5b98\u65b9\u76ee\u5f55\u6216\u7b2c\u4e09\u65b9\u5e02\u573a\u8fdb\u884c\u5206\u53d1\uff0c\u521b\u9020\u6301\u7eed\u7684\u4ef7\u503c\u548c\u6536\u5165\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0e\u76f4\u63a5\u4fee\u6539\u4e3b\u9898\u7684 <code>functions.php<\/code> \u6587\u4ef6\u4e0d\u540c\uff0c\u63d2\u4ef6\u5c06\u529f\u80fd\u903b\u8f91\u4e0e\u4e3b\u9898\u5916\u89c2\u5206\u79bb\uff0c\u786e\u4fdd\u4e86\u7f51\u7ad9\u7684\u53ef\u6301\u7eed\u7ef4\u62a4\u6027\u3002\u5f53\u60a8\u66f4\u6362\u4e3b\u9898\u65f6\uff0c\u63d2\u4ef6\u63d0\u4f9b\u7684\u529f\u80fd\u53ef\u4ee5\u65e0\u7f1d\u8fc1\u79fb\uff0c\u800c\u5199\u5728\u4e3b\u9898\u4e2d\u7684\u4ee3\u7801\u5219\u9700\u8981\u91cd\u65b0\u5904\u7406\u3002\u8fd9\u79cd\u6a21\u5757\u5316\u7684\u5f00\u53d1\u65b9\u5f0f\uff0c\u662f\u6784\u5efa\u4e13\u4e1a\u3001\u7a33\u5b9a WordPress \u7ad9\u70b9\u7684\u6700\u4f73\u5b9e\u8df5\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u642d\u5efa\u4f60\u7684\u7b2c\u4e00\u4e2a\u63d2\u4ef6<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u59cb\u63d2\u4ef6\u5f00\u53d1\u7684\u7b2c\u4e00\u6b65\uff0c\u662f\u521b\u5efa\u4e00\u4e2a\u7b26\u5408 WordPress \u6807\u51c6\u7684\u57fa\u672c\u7ed3\u6784\u3002\u8fd9\u4e0d\u4ec5\u4ec5\u662f\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\uff0c\u66f4\u662f\u5efa\u7acb\u4e00\u79cd\u53ef\u7ef4\u62a4\u3001\u53ef\u6269\u5c55\u7684\u4ee3\u7801\u7ec4\u7ec7\u65b9\u5f0f\u3002<\/p>\n<!-- AUTO_INTERNAL_LINKS_START --><p>\u63a8\u8350\u9605\u8bfb <a href=\"https:\/\/www.likacloud.com\/ro\/knowledge\/wordpress\/wordpress-plugin-development-guide-custom-extension\/\">WordPress \u63d2\u4ef6\u5f00\u53d1\u5165\u95e8\u6307\u5357\uff1a\u4ece\u96f6\u6784\u5efa\u4f60\u7684\u7b2c\u4e00\u4e2a\u81ea\u5b9a\u4e49\u529f\u80fd\u6269\u5c55<\/a>\u3002<\/p><!-- AUTO_INTERNAL_LINKS_END -->\n\n\n\n\n<h3 class=\"wp-block-heading\">\u521b\u5efa\u6838\u5fc3\u63d2\u4ef6\u6587\u4ef6<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bcf\u4e2a WordPress \u63d2\u4ef6\u90fd\u5fc5\u987b\u6709\u4e00\u4e2a\u4e3b\u6587\u4ef6\uff0c\u901a\u5e38\u4ee5\u63d2\u4ef6\u540d\u79f0\u547d\u540d\uff0c\u4f8b\u5982 <code>my-first-plugin.php<\/code>\u3002\u8fd9\u4e2a\u6587\u4ef6\u7684\u5934\u90e8\u6ce8\u91ca\u662f\u63d2\u4ef6\u7684\u201c\u8eab\u4efd\u8bc1\u201d\uff0c\u5b83\u5411 WordPress \u7cfb\u7edf\u63d0\u4f9b\u63d2\u4ef6\u7684\u5143\u4fe1\u606f\uff0c\u5982\u540d\u79f0\u3001\u63cf\u8ff0\u3001\u7248\u672c\u3001\u4f5c\u8005\u7b49\u3002\u6ca1\u6709\u8fd9\u4e2a\u5934\u90e8\uff0cWordPress \u5c06\u65e0\u6cd5\u8bc6\u522b\u5e76\u6fc0\u6d3b\u4f60\u7684\u63d2\u4ef6\u3002<\/p>\n<!-- AUTO_SYNCED_PATTERN_INSERT_START -->\n\r\n<div class=\"flex justify-between items-center flex-col lg:flex-row xl:flex-col 2xl:flex-row gap-6 sm:gap-8 rounded-lg border border-gray-200 dark:border-gray-700 p-4 mb-8 lg:mb-10 sm:p-6 bg-white dark:bg-gray-750 shadow-md transition-colors duration-300\"\r\n     data-link=\"https:\/\/www.likacloud.com\/pt\/tolink\/ultahost-wordpress-hosting\/\">\r\n     \r\n  <div class=\"flex flex-col gap-3 gap-4 sm:gap-6 w-full\">\r\n    <strong class=\"text-2xl font-semibold text-gray-900 dark:text-gray-200\">\r\n      UltaHost WordPress \u4e3b\u673a    <\/strong>\r\n    <div class=\"text-gray-600 dark:text-gray-300 word-word\">30\u5929\u9000\u6b3e\u4fdd\u8bc1\uff0c\u65e0\u9650\u5e26\u5bbd\u4e0e\u6570\u636e\u5e93\uff0c\u514d\u8d39\u7684 DDoS \u9632\u62a4\uff0c\u8d2d\u4e703\u5e74\u4f18\u60e050%<\/div>\r\n  <\/div>\r\n\r\n  <div class=\"flex items-center flex-col md:flex-row lg:flex-col xl:flex-row 2xl:flex-col gap-6 shrink-0\">\r\n          <a href=\"https:\/\/www.likacloud.com\/pt\/tolink\/ultahost-wordpress-hosting\/\">\r\n                  <img decoding=\"async\" src=\"https:\/\/www.likacloud.com\/wp-content\/uploads\/2025\/12\/20251227020448.webp\" alt=\"UltaHost LOGO\" class=\"content-promotion-card-icon h-9 min-h-9 dark:hidden\" title=\"\">\r\n          <img decoding=\"async\" src=\"https:\/\/www.likacloud.com\/wp-content\/uploads\/2025\/12\/20251229052118.webp\" alt=\"UltaHost LOGO\" class=\"content-promotion-card-icon h-9 min-h-9 hidden dark:block\" title=\"\">\r\n              <\/a>\r\n    \r\n    <a href=\"https:\/\/www.likacloud.com\/pt\/tolink\/ultahost-wordpress-hosting\/\"\r\n       class=\"bg-blue-500 w-full md:w-auto lg:w-full xl:w-auto 2xl:w-full text-center !text-white dark:!text-gray-200 !px-5 !py-1.5 rounded-full hover:bg-blue-600 transition-colors\">\r\n       \u8bbf\u95ee\u9875\u9762    <\/a>\r\n  <\/div>\r\n<\/div>\n<!-- AUTO_SYNCED_PATTERN_INSERT_END -->\n\n\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-php\">&lt;?php\n\/**\n * Plugin Name:       \u6211\u7684\u7b2c\u4e00\u4e2a\u63d2\u4ef6\n * Plugin URI:        https:\/\/example.com\/my-first-plugin\n * Description:       \u8fd9\u662f\u4e00\u4e2a\u7528\u4e8e\u5b66\u4e60 WordPress \u63d2\u4ef6\u5f00\u53d1\u7684\u793a\u4f8b\u63d2\u4ef6\u3002\n * Version:           1.0.0\n * Author:            \u4f60\u7684\u540d\u5b57\n * License:           GPL v2 or later\n * Text Domain:       my-first-plugin\n * Domain Path:       \/languages\n *\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u529f\u80fd<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u5b9a\u4e49\u4e86\u63d2\u4ef6\u5934\u90e8\u4e4b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5f00\u59cb\u6dfb\u52a0\u529f\u80fd\u4ee3\u7801\u3002\u4e00\u4e2a\u7ecf\u5178\u7684\u5165\u95e8\u793a\u4f8b\u662f\u5411\u7f51\u7ad9\u9875\u811a\u6dfb\u52a0\u4e00\u884c\u81ea\u5b9a\u4e49\u6587\u672c\u3002\u8fd9\u6d89\u53ca\u5230 WordPress \u7684\u201c\u94a9\u5b50\u201d\uff08Hook\uff09\u673a\u5236\uff0c\u5177\u4f53\u6765\u8bf4\u662f\u4f7f\u7528 <code>wp_footer<\/code> \u8fd9\u4e2a\u52a8\u4f5c\u94a9\u5b50\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-php\">\/\/ \u5728 wp_footer \u94a9\u5b50\u4e0a\u6302\u63a5\u6211\u4eec\u7684\u51fd\u6570\nadd_action(\u2018wp_footer\u2019\uff0c \u2018my_first_plugin_display_footer_text\u2019);\n\n\/**\n * \u5728\u7f51\u7ad9\u524d\u53f0\u9875\u811a\u8f93\u51fa\u81ea\u5b9a\u4e49\u6587\u672c\n *\/\nfunction my_first_plugin_display_footer_text() {\n    echo \u2018&lt;p style=\u201ctext-align: center;\u201d&gt;\u672c\u7ad9\u7531\u6211\u7684\u7b2c\u4e00\u4e2a\u63d2\u4ef6\u63d0\u4f9b\u6280\u672f\u652f\u6301\u3002&lt;\/p&gt;\u2019;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c06\u4e0a\u8ff0\u4ee3\u7801\u5757\u6dfb\u52a0\u5230\u4f60\u7684\u4e3b\u63d2\u4ef6\u6587\u4ef6\u4e2d\uff0c\u4fdd\u5b58\u540e\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u7684 <code>\/wp-content\/plugins\/<\/code> \u76ee\u5f55\u3002\u7136\u540e\u8fdb\u5165 WordPress \u540e\u53f0\u7684\u201c\u63d2\u4ef6\u201d\u9875\u9762\uff0c\u4f60\u5c31\u80fd\u770b\u5230\u5e76\u6fc0\u6d3b\u201c\u6211\u7684\u7b2c\u4e00\u4e2a\u63d2\u4ef6\u201d\u4e86\u3002\u5237\u65b0\u7f51\u7ad9\u524d\u53f0\uff0c\u9875\u9762\u5e95\u90e8\u5c31\u4f1a\u51fa\u73b0\u4f60\u6dfb\u52a0\u7684\u6587\u672c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6df1\u5165\u7406\u89e3 WordPress \u63d2\u4ef6\u67b6\u6784<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8981\u5f00\u53d1\u51fa\u5f3a\u5927\u4e14\u4e13\u4e1a\u7684\u63d2\u4ef6\uff0c\u5fc5\u987b\u6df1\u5165\u7406\u89e3 WordPress \u63d0\u4f9b\u7684\u6838\u5fc3\u7f16\u7a0b\u63a5\u53e3\u548c\u67b6\u6784\u6a21\u5f0f\u3002\u8fd9\u4e0d\u4ec5\u4ec5\u662f\u7f16\u5199 PHP \u51fd\u6570\uff0c\u66f4\u662f\u5b66\u4e60\u5982\u4f55\u4e0e WordPress \u6838\u5fc3\u8fdb\u884c\u5b89\u5168\u3001\u9ad8\u6548\u7684\u4ea4\u4e92\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u94a9\u5b50\u673a\u5236\uff1a\u52a8\u4f5c\u4e0e\u8fc7\u6ee4\u5668<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress \u7684\u94a9\u5b50\u673a\u5236\u662f\u5176\u6269\u5c55\u6027\u7684\u57fa\u77f3\uff0c\u4e3b\u8981\u5206\u4e3a\u52a8\u4f5c\u94a9\u5b50\uff08Action Hooks\uff09\u548c\u8fc7\u6ee4\u5668\u94a9\u5b50\uff08Filter Hooks\uff09\u3002\u52a8\u4f5c\u94a9\u5b50\u5141\u8bb8\u4f60\u5728\u7279\u5b9a\u7684\u65f6\u95f4\u70b9\u201c\u6267\u884c\u201d\u81ea\u5df1\u7684\u4ee3\u7801\u3002\u4f8b\u5982\uff0c<code>init<\/code> \u94a9\u5b50\u5728 WordPress \u521d\u59cb\u5316\u65f6\u89e6\u53d1\uff0c<code>wp_enqueue_scripts<\/code> \u94a9\u5b50\u7528\u4e8e\u5b89\u5168\u5730\u6dfb\u52a0\u811a\u672c\u548c\u6837\u5f0f\u3002<\/p>\n<!-- AUTO_INTERNAL_LINKS_START --><p>\u63a8\u8350\u9605\u8bfb <a href=\"https:\/\/www.likacloud.com\/ro\/knowledge\/wordpress\/wordpress-plugin-development-complete-guide-first-functional-plugin\/\">WordPress\u63d2\u4ef6\u5f00\u53d1\u5b8c\u5168\u6307\u5357\uff1a\u4ece\u96f6\u6253\u9020\u4f60\u7684\u7b2c\u4e00\u4e2a\u529f\u80fd\u63d2\u4ef6<\/a>\u3002<\/p><!-- AUTO_INTERNAL_LINKS_END -->\n\n\n\n\n<p class=\"wp-block-paragraph\">\u8fc7\u6ee4\u5668\u94a9\u5b50\u5219\u5141\u8bb8\u4f60\u201c\u4fee\u6539\u201d\u6570\u636e\u3002\u4f60\u53ef\u4ee5\u5728\u6570\u636e\u88ab\u4f7f\u7528\uff08\u5982\u663e\u793a\u5728\u9875\u9762\u6216\u5b58\u5165\u6570\u636e\u5e93\uff09\u4e4b\u524d\u62e6\u622a\u5e76\u4fee\u6539\u5b83\u3002\u4f8b\u5982\uff0c<code>the_content<\/code> \u8fc7\u6ee4\u5668\u5141\u8bb8\u4f60\u4fee\u6539\u6587\u7ae0\u7684\u5185\u5bb9\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-php\">\/\/ \u4f7f\u7528\u8fc7\u6ee4\u5668\u4fee\u6539\u6587\u7ae0\u5185\u5bb9\uff0c\u5728\u672b\u5c3e\u6dfb\u52a0\u4e00\u6bb5\u8bdd\nadd_filter(\u2018the_content\u2019\uff0c \u2018my_first_plugin_modify_content\u2019);\n\nfunction my_first_plugin_modify_content($content) {\n    if (is_single()) { \/\/ \u4ec5\u5728\u5355\u7bc7\u6587\u7ae0\u9875\u9762\u751f\u6548\n        $extra_text = \u2018&lt;div class=\u201cplugin-note\u201d&gt;\u611f\u8c22\u9605\u8bfb\u672c\u6587\uff01&lt;\/div&gt;\u2019;\n        $content .= $extra_text;\n    }\n    return $content;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u63d2\u4ef6\u5b89\u5168\u4e0e\u6570\u636e\u9a8c\u8bc1<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b89\u5168\u6027\u662f\u63d2\u4ef6\u5f00\u53d1\u4e2d\u4e0d\u53ef\u5ffd\u89c6\u7684\u4e00\u73af\u3002\u6c38\u8fdc\u4e0d\u8981\u4fe1\u4efb\u6765\u81ea\u7528\u6237\u6216\u4efb\u4f55\u5916\u90e8\u6765\u6e90\u7684\u6570\u636e\u3002WordPress \u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u51fd\u6570\u6765\u5e2e\u52a9\u8fdb\u884c\u6570\u636e\u9a8c\u8bc1\u3001\u8f6c\u4e49\u548c\u6e05\u7406\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u5904\u7406\u6765\u81ea\u8868\u5355\u7684 $_POST \u6216 $_GET \u6570\u636e\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528 <code>sanitize_text_field()<\/code>, <code>intval()<\/code>, <code>wp_kses_post()<\/code> \u7b49\u51fd\u6570\u8fdb\u884c\u6e05\u7406\u3002\u5728\u5c06\u6570\u636e\u8f93\u51fa\u5230 HTML \u9875\u9762\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528 <code>esc_html()<\/code>, <code>esc_attr()<\/code>, <code>esc_url()<\/code> \u7b49\u51fd\u6570\u8fdb\u884c\u8f6c\u4e49\uff0c\u4ee5\u9632\u6b62\u8de8\u7ad9\u811a\u672c\uff08XSS\uff09\u653b\u51fb\u3002<\/p>\n<!-- AUTO_SYNCED_PATTERN_INSERT_START -->\n\r\n<div class=\"flex justify-between items-center flex-col lg:flex-row xl:flex-col 2xl:flex-row gap-6 sm:gap-8 rounded-lg border border-gray-200 dark:border-gray-700 p-4 mb-8 lg:mb-10 sm:p-6 bg-white dark:bg-gray-750 shadow-md transition-colors duration-300\"\r\n     data-link=\"https:\/\/www.likacloud.com\/pt\/tolink\/hosting-shared-hosting\/\">\r\n     \r\n  <div class=\"flex flex-col gap-3 gap-4 sm:gap-6 w-full\">\r\n    <strong class=\"text-2xl font-semibold text-gray-900 dark:text-gray-200\">\r\n      hosting.com \u5171\u4eab\u4e3b\u673a    <\/strong>\r\n    <div class=\"text-gray-600 dark:text-gray-300 word-word\">\u9ad8\u6027\u80fd\uff0c\u914d\u5907 AMD EPYC CPU\u3001NVMe SSD \u5b58\u50a8\u548c LiteSpeed\uff0c\u5168\u5929\u501924\u5c0f\u65f6\u3001\u5168\u5929\u5019\u7684\u4e13\u5bb6\u5185\u90e8\u652f\u6301\uff0c\u9ad8\u7ea7\u5b89\u5168\u63aa\u65bd\uff0c\u5305\u62ec SSL\u3001\u66b4\u529b\u7834\u89e3\u3001\u6076\u610f\u8f6f\u4ef6\u548c DDoS \u9632\u62a4\uff0c\u8282\u7701\u9ad8\u8fbe 73%<\/div>\r\n  <\/div>\r\n\r\n  <div class=\"flex items-center flex-col md:flex-row lg:flex-col xl:flex-row 2xl:flex-col gap-6 shrink-0\">\r\n          <a href=\"https:\/\/www.likacloud.com\/pt\/tolink\/hosting-shared-hosting\/\">\r\n                  <img decoding=\"async\" src=\"https:\/\/www.likacloud.com\/wp-content\/uploads\/2025\/09\/20250901222940.svg\" alt=\"hosting.com LOGO\" class=\"content-promotion-card-icon h-9 min-h-9 dark:hidden\" title=\"\">\r\n          <img decoding=\"async\" src=\"https:\/\/www.likacloud.com\/wp-content\/uploads\/2025\/12\/20251228220957.webp\" alt=\"hosting.com LOGO\" class=\"content-promotion-card-icon h-9 min-h-9 hidden dark:block\" title=\"\">\r\n              <\/a>\r\n    \r\n    <a href=\"https:\/\/www.likacloud.com\/pt\/tolink\/hosting-shared-hosting\/\"\r\n       class=\"bg-blue-500 w-full md:w-auto lg:w-full xl:w-auto 2xl:w-full text-center !text-white dark:!text-gray-200 !px-5 !py-1.5 rounded-full hover:bg-blue-600 transition-colors\">\r\n       \u8bbf\u95ee\u9875\u9762    <\/a>\r\n  <\/div>\r\n<\/div>\n<!-- AUTO_SYNCED_PATTERN_INSERT_END -->\n\n\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-php\">\/\/ \u5b89\u5168\u5730\u5904\u7406\u5e76\u8f93\u51fa\u4e00\u4e2a\u6765\u81ea\u77ed\u4ee3\u7801\u7684\u5c5e\u6027\nfunction my_first_plugin_safe_shortcode($atts) {\n    \/\/ \u4f7f\u7528 shortcode_atts \u8bbe\u7f6e\u9ed8\u8ba4\u503c\u5e76\u5408\u5e76\u7528\u6237\u8f93\u5165\n    $atts = shortcode_atts(\n        array(\n            \u2018message\u2019 =&gt; \u2018Hello World\u2019,\n        )\uff0c $atts\n    );\n\n\/\/ \u6e05\u7406\u7528\u6237\u8f93\u5165\u7684 message \u5c5e\u6027\n    $safe_message = sanitize_text_field($atts[\u2018message\u2019]);\n\n\/\/ \u8f6c\u4e49\u540e\u5b89\u5168\u8f93\u51fa\n    return \u2018&lt;div&gt;\u2019 . esc_html($safe_message) . \u2018&lt;\/div&gt;\u2019;\n}\nadd_shortcode(\u2018safe_greeting\u2019\uff0c \u2018my_first_plugin_safe_shortcode\u2019);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6784\u5efa\u4e00\u4e2a\u529f\u80fd\u5b8c\u6574\u7684\u63d2\u4ef6<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8ba9\u6211\u4eec\u5c06\u8fd9\u4e9b\u77e5\u8bc6\u6574\u5408\u8d77\u6765\uff0c\u6784\u5efa\u4e00\u4e2a\u7a0d\u590d\u6742\u4f46\u5b9e\u7528\u7684\u63d2\u4ef6\uff1a\u4e00\u4e2a\u201c\u6587\u7ae0\u9605\u8bfb\u65f6\u95f4\u4f30\u7b97\u201d\u63d2\u4ef6\u3002\u8fd9\u4e2a\u63d2\u4ef6\u4f1a\u81ea\u52a8\u8ba1\u7b97\u6587\u7ae0\u7684\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\uff0c\u5e76\u663e\u793a\u5728\u6587\u7ae0\u6807\u9898\u4e0b\u65b9\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u521b\u5efa\u63d2\u4ef6\u7c7b\u7ed3\u6784<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u529f\u80fd\u7a0d\u590d\u6742\u7684\u63d2\u4ef6\uff0c\u4f7f\u7528\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\uff08OOP\uff09\u7684\u7c7b\u7ed3\u6784\u662f\u66f4\u597d\u7684\u9009\u62e9\u3002\u5b83\u6709\u52a9\u4e8e\u7ec4\u7ec7\u4ee3\u7801\uff0c\u907f\u514d\u51fd\u6570\u540d\u51b2\u7a81\uff0c\u5e76\u63d0\u9ad8\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-php\">&lt;?php\n\/**\n * Plugin Name:       \u6587\u7ae0\u9605\u8bfb\u65f6\u95f4\u4f30\u7b97\n *\/\nclass Article_Reading_Time {\n    \/**\n     * \u6784\u9020\u51fd\u6570\uff0c\u521d\u59cb\u5316\u63d2\u4ef6\n     *\/\n    public function __construct() {\n        \/\/ \u5728\u6587\u7ae0\u5185\u5bb9\u524d\u6dfb\u52a0\u9605\u8bfb\u65f6\u95f4\n        add_filter(\u2018the_content\u2019\uff0c array($this\uff0c \u2018add_reading_time_to_content\u2019));\n        \/\/ \u521d\u59cb\u5316\u811a\u672c\u548c\u6837\u5f0f\uff08\u5982\u679c\u9700\u8981\uff09\n        add_action(\u2018wp_enqueue_scripts\u2019\uff0c array($this\uff0c \u2018enqueue_assets\u2019));\n    }\n\n\/**\n     * \u8ba1\u7b97\u6587\u7ae0\u7684\u9605\u8bfb\u65f6\u95f4\uff08\u4ee5\u5206\u949f\u8ba1\uff09\n     * @param string $content \u6587\u7ae0\u5185\u5bb9\n     * @return int \u9884\u8ba1\u9605\u8bfb\u5206\u949f\u6570\n     *\/\n    private function calculate_reading_time($content) {\n        \/\/ \u53bb\u9664 HTML \u6807\u7b7e\uff0c\u53ea\u8ba1\u7b97\u7eaf\u6587\u672c\n        $text = strip_tags($content);\n        \/\/ \u4f30\u7b97\u4e2d\u6587\u9605\u8bfb\u901f\u5ea6\uff1a\u6bcf\u5206\u949f\u7ea6300-500\u5b57\uff0c\u8fd9\u91cc\u53d6400\u5b57\/\u5206\u949f\n        $word_count = mb_strlen($text\uff0c \u2018UTF-8\u2019);\n        $reading_time = ceil($word_count \/ 400);\n        \/\/ \u81f3\u5c111\u5206\u949f\n        return max(1\uff0c $reading_time);\n    }\n\n\/**\n     * \u5728\u6587\u7ae0\u5185\u5bb9\u524d\u6dfb\u52a0\u9605\u8bfb\u65f6\u95f4\u663e\u793a\n     * @param string $content \u539f\u59cb\u6587\u7ae0\u5185\u5bb9\n     * @return string \u6dfb\u52a0\u9605\u8bfb\u65f6\u95f4\u540e\u7684\u5185\u5bb9\n     *\/\n    public function add_reading_time_to_content($content) {\n        \/\/ \u786e\u4fdd\u53ea\u5728\u4e3b\u5faa\u73af\u7684\u5355\u7bc7\u6587\u7ae0\u9875\u9762\u663e\u793a\n        if (is_single() &amp;&amp; in_the_loop() &amp;&amp; is_main_query()) {\n            $reading_minutes = $this-&gt;calculate_reading_time($content);\n            $reading_time_html = sprintf(\n                \u2018&lt;div class=\u201creading-time\u201d&gt;&lt;strong&gt;\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\uff1a&lt;\/strong&gt;%d \u5206\u949f&lt;\/div&gt;\u2019,\n                esc_html($reading_minutes)\n            );\n            $content = $reading_time_html . $content;\n        }\n        return $content;\n    }\n\n\/**\n     * \u52a0\u8f7d\u63d2\u4ef6\u6240\u9700\u7684CSS\u6837\u5f0f\n     *\/\n    public function enqueue_assets() {\n        if (is_single()) {\n            wp_enqueue_style(\n                \u2018article-reading-time-style\u2019,\n                plugin_dir_url(__FILE__) . \u2018assets\/css\/style.css\u2019,\n                array()\uff0c\n                \u20181.0.0\u2019\n            );\n        }\n    }\n}\n\n\/\/ \u5b9e\u4f8b\u5316\u63d2\u4ef6\u7c7b\uff0c\u542f\u52a8\u63d2\u4ef6\nnew Article_Reading_Time();<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6dfb\u52a0\u7ba1\u7406\u8bbe\u7f6e\u9875\u9762<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e00\u4e2a\u4e13\u4e1a\u7684\u63d2\u4ef6\u901a\u5e38\u9700\u8981\u4e00\u4e2a\u540e\u53f0\u8bbe\u7f6e\u9875\u9762\uff0c\u5141\u8bb8\u7528\u6237\u81ea\u5b9a\u4e49\u5176\u884c\u4e3a\u3002\u6211\u4eec\u53ef\u4ee5\u5229\u7528 WordPress \u7684\u201c\u8bbe\u7f6e API\u201d\u6765\u89c4\u8303\u5730\u521b\u5efa\u9009\u9879\u9875\u9762\u3002<\/p>\n<!-- AUTO_INTERNAL_LINKS_START --><p>\u63a8\u8350\u9605\u8bfb <a href=\"https:\/\/www.likacloud.com\/ro\/knowledge\/wordpress\/wordpress-theme-development-complete-guide-tutorial-12374927\/\">WordPress\u4e3b\u9898\u5f00\u53d1\u5b8c\u6574\u6307\u5357\uff1a\u4ece\u5165\u95e8\u5230\u7cbe\u901a\u5b9e\u6218\u6559\u7a0b<\/a>\u3002<\/p><!-- AUTO_INTERNAL_LINKS_END -->\n\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5728\u63d2\u4ef6\u7c7b\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u65b9\u6cd5\uff0c\u7528\u4e8e\u6ce8\u518c\u8bbe\u7f6e\u83dc\u5355\u548c\u5b57\u6bb5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-php\">\/\/ \u5728\u6784\u9020\u51fd\u6570\u4e2d\u6dfb\u52a0\u7ba1\u7406\u83dc\u5355\u94a9\u5b50\nadd_action(\u2018admin_menu\u2019\uff0c array($this\uff0c \u2018add_admin_menu\u2019));\nadd_action(\u2018admin_init\u2019\uff0c array($this\uff0c \u2018register_settings\u2019));\n\npublic function add_admin_menu() {\n    add_options_page(\n        \u2018\u9605\u8bfb\u65f6\u95f4\u8bbe\u7f6e\u2019\uff0c          \/\/ \u9875\u9762\u6807\u9898\n        \u2018\u9605\u8bfb\u65f6\u95f4\u4f30\u7b97\u2019\uff0c          \/\/ \u83dc\u5355\u6807\u9898\n        \u2018manage_options\u2019\uff0c       \/\/ \u6743\u9650\n        \u2018reading-time-settings\u2019\uff0c \/\/ \u83dc\u5355slug\n        array($this\uff0c \u2018render_settings_page\u2019) \/\/ \u56de\u8c03\u51fd\u6570\n    );\n}\n\npublic function register_settings() {\n    register_setting(\u2018reading_time_settings_group\u2019\uff0c \u2018reading_time_words_per_minute\u2019);\n    add_settings_section(\u2018reading_time_main\u2019\uff0c \u2018\u4e3b\u8981\u8bbe\u7f6e\u2019\uff0c null\uff0c \u2018reading-time-settings\u2019);\n    add_settings_field(\n        \u2018words_per_minute\u2019\uff0c\n        \u2018\u6bcf\u5206\u949f\u9605\u8bfb\u5b57\u6570\u2019\uff0c\n        array($this\uff0c \u2018render_words_per_minute_field\u2019)\uff0c\n        \u2018reading-time-settings\u2019\uff0c\n        \u2018reading_time_main\u2019\n    );\n}\n\npublic function render_words_per_minute_field() {\n    $value = get_option(\u2018reading_time_words_per_minute\u2019\uff0c 400);\n    echo \u2018&lt;input type=\u201cnumber\u201d name=\u201creading_time_words_per_minute\u201d value=\u201c\u2019 . esc_attr($value) . \u2018\u201d \/&gt;\u2019;\n    echo \u2018&lt;p class=\u201cdescription\u201d&gt;\u7528\u4e8e\u8ba1\u7b97\u9605\u8bfb\u65f6\u95f4\u7684\u57fa\u51c6\u503c\uff08\u5b57\/\u5206\u949f\uff09\u3002&lt;\/p&gt;\u2019;\n}\n\npublic function render_settings_page() {\n    ?&gt;\n    &lt;div class=\u201cwrap\u201d&gt;\n        &lt;h1&gt;\u6587\u7ae0\u9605\u8bfb\u65f6\u95f4\u4f30\u7b97\u8bbe\u7f6e&lt;\/h1&gt;\n        &lt;form action=\u201coptions.php\u201d method=\u201cpost\u201d&gt;\n            &lt;?php\n            settings_fields(\u2018reading_time_settings_group\u2019);\n            do_settings_sections(\u2018reading-time-settings\u2019);\n            submit_button();\n            ?&gt;\n        &lt;\/form&gt;\n    &lt;\/div&gt;\n    &lt;?php\n}\n\n\/\/ \u7136\u540e\u4fee\u6539 calculate_reading_time \u65b9\u6cd5\uff0c\u4f7f\u7528\u7528\u6237\u8bbe\u7f6e\u7684\u503c\nprivate function calculate_reading_time($content) {\n    $text = strip_tags($content);\n    $words_per_minute = get_option(\u2018reading_time_words_per_minute\u2019\uff0c 400);\n    $word_count = mb_strlen($text\uff0c \u2018UTF-8\u2019);\n    $reading_time = ceil($word_count \/ $words_per_minute);\n    return max(1\uff0c $reading_time);\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u63d2\u4ef6\u56fd\u9645\u5316\u4e0e\u53d1\u5e03\u51c6\u5907<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4e86\u8ba9\u4f60\u7684\u63d2\u4ef6\u80fd\u88ab\u5168\u4e16\u754c\u7684\u7528\u6237\u4f7f\u7528\uff0c\u56fd\u9645\u5316\uff08i18n\uff09\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u4e00\u6b65\u3002\u540c\u65f6\uff0c\u5728\u53d1\u5e03\u524d\u8fdb\u884c\u5145\u5206\u7684\u6d4b\u8bd5\u548c\u6587\u6863\u6574\u7406\u4e5f\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<!-- AUTO_SYNCED_PATTERN_INSERT_START -->\n\r\n<div class=\"flex justify-between items-center flex-col lg:flex-row xl:flex-col 2xl:flex-row gap-6 sm:gap-8 rounded-lg border border-gray-200 dark:border-gray-700 p-4 mb-8 lg:mb-10 sm:p-6 bg-white dark:bg-gray-750 shadow-md transition-colors duration-300\"\r\n     data-link=\"https:\/\/www.likacloud.com\/pt\/tolink\/interserver-webhosting\/\">\r\n     \r\n  <div class=\"flex flex-col gap-3 gap-4 sm:gap-6 w-full\">\r\n    <strong class=\"text-2xl font-semibold text-gray-900 dark:text-gray-200\">\r\n      InterServer \u5171\u4eab\u4e3b\u673a    <\/strong>\r\n    <div class=\"text-gray-600 dark:text-gray-300 word-word\">\u5171\u4eab\u4e3b\u673a\u6bcf\u6708 $2.50 USD , \u9996\u6708 $0.1 USD \u4f18\u60e0\u7801 tryinterserver, 461\u4e2a\u4e91\u5e94\u7528\u811a\u672c\uff0c\u4e00\u952e\u5b89\u88c5\u3002<\/div>\r\n  <\/div>\r\n\r\n  <div class=\"flex items-center flex-col md:flex-row lg:flex-col xl:flex-row 2xl:flex-col gap-6 shrink-0\">\r\n          <a href=\"https:\/\/www.likacloud.com\/pt\/tolink\/interserver-webhosting\/\">\r\n                  <img decoding=\"async\" src=\"https:\/\/www.likacloud.com\/wp-content\/uploads\/2025\/12\/20251228045033.svg\" alt=\"InterServer LOGO\" class=\"content-promotion-card-icon h-9 min-h-9 dark:hidden\" title=\"\">\r\n          <img decoding=\"async\" src=\"https:\/\/www.likacloud.com\/wp-content\/uploads\/2025\/12\/20251229054830.webp\" alt=\"InterServer LOGO\" class=\"content-promotion-card-icon h-9 min-h-9 hidden dark:block\" title=\"\">\r\n              <\/a>\r\n    \r\n    <a href=\"https:\/\/www.likacloud.com\/pt\/tolink\/interserver-webhosting\/\"\r\n       class=\"bg-blue-500 w-full md:w-auto lg:w-full xl:w-auto 2xl:w-full text-center !text-white dark:!text-gray-200 !px-5 !py-1.5 rounded-full hover:bg-blue-600 transition-colors\">\r\n       \u8bbf\u95ee\u9875\u9762    <\/a>\r\n  <\/div>\r\n<\/div>\n<!-- AUTO_SYNCED_PATTERN_INSERT_END -->\n\n\n\n\n\n<h3 class=\"wp-block-heading\">\u5b9e\u73b0\u6587\u672c\u7ffb\u8bd1\u652f\u6301<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress \u4f7f\u7528 GNU gettext \u6280\u672f\u6765\u5b9e\u73b0\u591a\u8bed\u8a00\u3002\u4f60\u9700\u8981\u5c06\u6240\u6709\u5728\u63d2\u4ef6\u4e2d\u76f4\u63a5\u8f93\u51fa\u7684\u6587\u672c\u7528\u7279\u5b9a\u7684\u51fd\u6570\u5305\u88f9\u8d77\u6765\u3002\u6700\u5e38\u7528\u7684\u662f <code>__()<\/code> \u7528\u4e8e\u8fd4\u56de\u7ffb\u8bd1\u540e\u7684\u5b57\u7b26\u4e32\uff0c\u4ee5\u53ca <code>_e()<\/code> \u7528\u4e8e\u76f4\u63a5\u8f93\u51fa\u7ffb\u8bd1\u540e\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\uff0c\u4fee\u6539\u63d2\u4ef6\u4e2d\u6240\u6709\u786c\u7f16\u7801\u7684\u6587\u672c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-php\">\/\/ \u5728\u63d2\u4ef6\u5934\u90e8\u5b9a\u4e49 Text Domain\n\/\/ Text Domain:       article-reading-time\n\n\/\/ \u5728\u63d2\u4ef6\u521d\u59cb\u5316\u65f6\u52a0\u8f7d\u8bed\u8a00\u6587\u4ef6\nadd_action(\u2018init\u2019\uff0c array($this\uff0c \u2018load_textdomain\u2019));\n\npublic function load_textdomain() {\n    load_plugin_textdomain(\n        \u2018article-reading-time\u2019\uff0c\n        false\uff0c\n        dirname(plugin_basename(__FILE__)) . \u2018\/languages\/\u2019\n    );\n}\n\n\/\/ \u4fee\u6539\u8f93\u51fa\u6587\u672c\u7684\u4ee3\u7801\uff0c\u4f7f\u5176\u53ef\u7ffb\u8bd1\n$reading_time_html = sprintf(\n    \u2018&lt;div class=\u201creading-time\u201d&gt;&lt;strong&gt;%s&lt;\/strong&gt;%d %s&lt;\/div&gt;\u2019,\n    esc_html__(\u2018\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\uff1a\u2019\uff0c \u2018article-reading-time\u2019)\uff0c\n    esc_html($reading_minutes)\uff0c\n    esc_html(_n(\u2018\u5206\u949f\u2019\uff0c \u2018\u5206\u949f\u2019\uff0c $reading_minutes\uff0c \u2018article-reading-time\u2019))\n);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\uff0c\u4f60\u9700\u8981\u4f7f\u7528 Poedit \u8fd9\u7c7b\u5de5\u5177\uff0c\u626b\u63cf\u63d2\u4ef6\u6e90\u4ee3\u7801\u751f\u6210 <code>.pot<\/code> \u6a21\u677f\u6587\u4ef6\uff0c\u8bd1\u8005\u53ef\u4ee5\u636e\u6b64\u521b\u5efa\u5982 <code>zh_CN.po<\/code> \u548c <code>.mo<\/code> \u7684\u7ffb\u8bd1\u6587\u4ef6\uff0c\u5e76\u653e\u7f6e\u5728\u63d2\u4ef6\u7684 <code>\/languages\/<\/code> \u76ee\u5f55\u4e0b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6d4b\u8bd5\u4e0e\u63d0\u4ea4\u5230\u5b98\u65b9\u76ee\u5f55<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u53d1\u5e03\u524d\uff0c\u52a1\u5fc5\u5728\u4e0d\u540c\u73af\u5883\uff08\u4e0d\u540c PHP \u7248\u672c\u3001\u4e0d\u540c WordPress \u7248\u672c\uff09\u4e0b\u6d4b\u8bd5\u63d2\u4ef6\u7684\u6240\u6709\u529f\u80fd\u3002\u68c0\u67e5\u662f\u5426\u6709 PHP \u8b66\u544a\u6216\u9519\u8bef\uff0c\u786e\u4fdd\u4e0e\u5e38\u7528\u4e3b\u9898\u548c\u5176\u4ed6\u63d2\u4ef6\u6ca1\u6709\u51b2\u7a81\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u8ba1\u5212\u63d0\u4ea4\u5230 WordPress \u5b98\u65b9\u63d2\u4ef6\u76ee\u5f55\uff0c\u4f60\u9700\u8981\u9075\u5faa\u4e25\u683c\u7684\u4ee3\u7801\u6807\u51c6\u548c\u6307\u5357\u3002\u8fd9\u5305\u62ec\u4f7f\u7528\u975e\u51b2\u7a81\u7684\u3001\u63cf\u8ff0\u6027\u7684\u51fd\u6570\u548c\u7c7b\u540d\u524d\u7f00\uff0c\u786e\u4fdd\u4ee3\u7801\u5b89\u5168\u6027\uff0c\u63d0\u4f9b\u8be6\u7ec6\u7684 <code>readme.txt<\/code> \u6587\u4ef6\uff08\u683c\u5f0f\u9700\u7b26\u5408\u5b98\u65b9\u6807\u51c6\uff09\uff0c\u5e76\u6e05\u7406\u6240\u6709\u8c03\u8bd5\u4ee3\u7801\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u51c6\u5907\u4e00\u4e2a\u6e05\u6670\u7684 <code>readme.txt<\/code> \u6587\u4ef6\u662f\u6210\u529f\u5ba1\u6838\u7684\u5173\u952e\u3002\u5b83\u5e94\u8be5\u5305\u542b\u63d2\u4ef6\u7684\u63cf\u8ff0\u3001\u5b89\u88c5\u6b65\u9aa4\u3001\u622a\u56fe\u3001\u5e38\u89c1\u95ee\u9898\u3001\u66f4\u65b0\u65e5\u5fd7\u7b49\u4fe1\u606f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress \u63d2\u4ef6\u5f00\u53d1\u662f\u4e00\u9879\u5c06\u521b\u610f\u8f6c\u5316\u4e3a\u53ef\u5206\u53d1\u4ea7\u54c1\u7684\u5f3a\u5927\u6280\u80fd\u3002\u4ece\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5355\u6587\u4ef6\u63d2\u4ef6\u5f00\u59cb\uff0c\u9010\u6b65\u6df1\u5165\u5230\u94a9\u5b50\u673a\u5236\u3001\u5b89\u5168\u5b9e\u8df5\u3001\u9762\u5411\u5bf9\u8c61\u67b6\u6784\u3001\u8bbe\u7f6e API \u4ee5\u53ca\u56fd\u9645\u5316\uff0c\u8fd9\u6761\u5b66\u4e60\u8def\u5f84\u4e3a\u4f60\u6784\u5efa\u5546\u4e1a\u7ea7\u63d2\u4ef6\u5960\u5b9a\u4e86\u575a\u5b9e\u57fa\u7840\u3002\u6838\u5fc3\u5728\u4e8e\u7406\u89e3 WordPress \u7684\u6838\u5fc3\u4ea4\u4e92\u65b9\u5f0f\u2014\u2014\u94a9\u5b50\uff0c\u5e76\u59cb\u7ec8\u575a\u6301\u5b89\u5168\u7f16\u7801\u548c\u6570\u636e\u9a8c\u8bc1\u7684\u539f\u5219\u3002\u901a\u8fc7\u6a21\u5757\u5316\u3001\u7ed3\u6784\u5316\u7684\u65b9\u5f0f\u7ec4\u7ec7\u4ee3\u7801\uff0c\u5e76\u63d0\u524d\u89c4\u5212\u7ba1\u7406\u754c\u9762\u548c\u7ffb\u8bd1\u652f\u6301\uff0c\u4f60\u7684\u63d2\u4ef6\u5c06\u5177\u5907\u66f4\u5f3a\u7684\u4e13\u4e1a\u6027\u3001\u53ef\u7ef4\u62a4\u6027\u548c\u5e02\u573a\u9002\u5e94\u6027\u3002\u8bb0\u4f4f\uff0c\u4e00\u4e2a\u4f18\u79c0\u7684\u63d2\u4ef6\u4e0d\u4ec5\u4ec5\u662f\u529f\u80fd\u7684\u96c6\u5408\uff0c\u66f4\u662f\u7528\u6237\u4f53\u9a8c\u3001\u4ee3\u7801\u8d28\u91cf\u548c\u751f\u6001\u878d\u5408\u7684\u7efc\u5408\u4f53\u73b0\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ \u5e38\u89c1\u95ee\u9898<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5f00\u53d1 WordPress \u63d2\u4ef6\u9700\u8981\u54ea\u4e9b\u5148\u51b3\u77e5\u8bc6\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f60\u9700\u8981\u5177\u5907\u624e\u5b9e\u7684 PHP \u7f16\u7a0b\u57fa\u7840\uff0c\u56e0\u4e3a\u63d2\u4ef6\u6838\u5fc3\u903b\u8f91\u662f\u7528 PHP \u7f16\u5199\u7684\u3002\u540c\u65f6\uff0c\u9700\u8981\u5bf9 HTML\u3001CSS \u548c JavaScript \u6709\u57fa\u672c\u4e86\u89e3\uff0c\u4ee5\u4fbf\u5904\u7406\u524d\u7aef\u5c55\u793a\u548c\u4ea4\u4e92\u3002\u719f\u6089 MySQL \u6570\u636e\u5e93\u7684\u57fa\u672c\u6982\u5ff5\uff08\u5c3d\u7ba1 WordPress \u63d0\u4f9b\u4e86\u4fbf\u6377\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u7c7b\uff09\u548c\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u601d\u60f3\uff0c\u5bf9\u4e8e\u5f00\u53d1\u590d\u6742\u63d2\u4ef6\u4e5f\u5927\u6709\u88e8\u76ca\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u63d2\u4ef6\u548c\u4e3b\u9898\u7684 functions.php \u6587\u4ef6\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c06\u4ee3\u7801\u6dfb\u52a0\u5230\u4e3b\u9898\u7684 <code>functions.php<\/code> \u6587\u4ef6\u662f\u4e00\u79cd\u5feb\u901f\u5b9e\u73b0\u529f\u80fd\u7684\u65b9\u6cd5\uff0c\u4f46\u8be5\u529f\u80fd\u4e0e\u5f53\u524d\u4e3b\u9898\u6df1\u5ea6\u7ed1\u5b9a\u3002\u5f53\u4f60\u5207\u6362\u4e3b\u9898\u65f6\uff0c\u8fd9\u4e9b\u529f\u80fd\u4f1a\u4e22\u5931\u3002\u800c\u63d2\u4ef6\u662f\u72ec\u7acb\u4e8e\u4e3b\u9898\u7684\u529f\u80fd\u6a21\u5757\uff0c\u65e0\u8bba\u4f7f\u7528\u4ec0\u4e48\u4e3b\u9898\uff0c\u53ea\u8981\u63d2\u4ef6\u88ab\u6fc0\u6d3b\uff0c\u5176\u529f\u80fd\u5c31\u4f1a\u4e00\u76f4\u5b58\u5728\u3002\u8fd9\u4fdd\u8bc1\u4e86\u529f\u80fd\u7684\u53ef\u79fb\u690d\u6027\u548c\u7f51\u7ad9\u7ef4\u62a4\u7684\u7075\u6d3b\u6027\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5982\u4f55\u9632\u6b62\u6211\u7684\u63d2\u4ef6\u51fd\u6570\u540d\u4e0e\u5176\u4ed6\u63d2\u4ef6\u51b2\u7a81\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\uff08OOP\uff09\u5e76\u5c06\u4f60\u7684\u4ee3\u7801\u5c01\u88c5\u5728\u4e00\u4e2a\u7c7b\u4e2d\uff0c\u662f\u907f\u514d\u51fd\u6570\u540d\u51b2\u7a81\u7684\u6700\u4f73\u65b9\u5f0f\u3002\u5982\u679c\u4f7f\u7528\u8fc7\u7a0b\u5f0f\u7f16\u7a0b\uff0c\u5219\u5fc5\u987b\u4e3a\u6240\u6709\u51fd\u6570\u3001\u5e38\u91cf\u3001\u5168\u5c40\u53d8\u91cf\u4f7f\u7528\u552f\u4e00\u7684\u524d\u7f00\u3002\u8fd9\u4e2a\u524d\u7f00\u5e94\u8be5\u8db3\u591f\u72ec\u7279\uff0c\u4f8b\u5982\u5305\u542b\u4f60\u7684\u54c1\u724c\u6216\u63d2\u4ef6\u7f29\u5199\uff0c\u4f8b\u5982 <code>myplugin_<\/code> \u6216 <code>art_rt_<\/code>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6211\u5e94\u8be5\u5982\u4f55\u8c03\u8bd5\u6b63\u5728\u5f00\u53d1\u7684\u63d2\u4ef6\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\uff0c\u786e\u4fdd\u5728 WordPress \u7684 <code>wp-config.php<\/code> \u6587\u4ef6\u4e2d\u5f00\u542f\u8c03\u8bd5\u6a21\u5f0f\uff1a\u5c06 <code>define(\u2018WP_DEBUG\u2019, true);<\/code> \u548c <code>define(\u2018WP_DEBUG_LOG\u2019, true);<\/code>\u3002\u8fd9\u6837\uff0cPHP \u9519\u8bef\u548c\u8b66\u544a\u4f1a\u88ab\u8bb0\u5f55\u5230 <code>\/wp-content\/debug.log<\/code> \u6587\u4ef6\u4e2d\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u6d4f\u89c8\u5668\u5f00\u53d1\u8005\u5de5\u5177\u68c0\u67e5\u524d\u7aef\u95ee\u9898\uff0c\u5e76\u53ef\u4ee5\u5229\u7528 <code>error_log()<\/code> \u51fd\u6570\u5728\u4ee3\u7801\u4e2d\u8f93\u51fa\u53d8\u91cf\u503c\u5230\u65e5\u5fd7\u6587\u4ef6\u8fdb\u884c\u8c03\u8bd5\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5f00\u53d1\u5546\u4e1a\u63d2\u4ef6\u9700\u8981\u8003\u8651\u54ea\u4e9b\u6cd5\u5f8b\u95ee\u9898\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u91cd\u8981\u7684\u6cd5\u5f8b\u95ee\u9898\u662f\u9075\u5b88 WordPress \u7684\u8bb8\u53ef\u534f\u8bae\u3002\u5982\u679c\u4f60\u8ba1\u5212\u5728 WordPress \u5b98\u65b9\u76ee\u5f55\u53d1\u5e03\uff0c\u63d2\u4ef6\u5fc5\u987b\u9075\u5faa GPLv2 \u6216\u66f4\u9ad8\u7248\u672c\u7684\u8bb8\u53ef\u8bc1\u3002\u8fd9\u610f\u5473\u7740\u4f60\u7684\u63d2\u4ef6\u4ee3\u7801\u5fc5\u987b\u662f\u5f00\u6e90\u7684\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u9500\u552e\u652f\u6301\u670d\u52a1\u3001\u9ad8\u7ea7\u529f\u80fd\u3001\u6587\u6863\u6216\u6258\u7ba1\u7248\u672c\u7b49\u65b9\u5f0f\u6765\u76c8\u5229\u3002\u6b64\u5916\uff0c\u5982\u679c\u4f60\u5904\u7406\u7528\u6237\u6570\u636e\uff0c\u9700\u8981\u5173\u6ce8\u5e76\u9075\u5b88 GDPR \u7b49\u6570\u636e\u4fdd\u62a4\u6cd5\u89c4\u3002\u5efa\u8bae\u5728\u63d2\u4ef6\u9690\u79c1\u58f0\u660e\u4e2d\u660e\u786e\u8bf4\u660e\u6570\u636e\u6536\u96c6\u548c\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Este artigo \u00e9 um guia pr\u00e1tico completo para o desenvolvimento de plugins para o WordPress. Come\u00e7a explicando as vantagens do desenvolvimento de plugins e seu valor modular, e em seguida, demonstra em detalhes todo o processo, desde a cria\u00e7\u00e3o de arquivos b\u00e1sicos de plugins at\u00e9 a implementa\u00e7\u00e3o de fun\u00e7\u00f5es simples, passando por uma compreens\u00e3o aprofundada do mecanismo de ganchos (actions e filters) do WordPress. O objetivo \u00e9 ajudar os desenvolvedores a dominar os m\u00e9todos e a arquitetura centrais do desenvolvimento de plugins de forma sistem\u00e1tica.<\/p>","protected":false},"author":7,"featured_media":0,"template":"","meta":{"_acf_changed":false,"footnotes":""},"tags":[2410,1978,436,1934,1960],"knowledge_category":[280],"class_list":["post-12375077","knowledge_post","type-knowledge_post","status-publish","hentry","tag-wordpress","tag-wordpress-plugin-development","tag-wordpress-tutorial","tag-wordpress-hooks","tag-plugin-development-guide","knowledge_category-wordpress"],"acf":{"site_seo_keywords":"WordPress\u63d2\u4ef6\u5f00\u53d1\uff0cWordPress\u6559\u7a0b\uff0c\u63d2\u4ef6\u5f00\u53d1\u6307\u5357\uff0c\u52a8\u4f5c\u94a9\u5b50\uff0c\u8fc7\u6ee4\u5668\u94a9\u5b50\uff0cWordPress\u63d2\u4ef6\u67b6\u6784\uff0c\u4ece\u96f6\u5f00\u59cb\u5f00\u53d1\u63d2\u4ef6"},"_links":{"self":[{"href":"https:\/\/www.likacloud.com\/pt\/wp-json\/wp\/v2\/knowledge_posts\/12375077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.likacloud.com\/pt\/wp-json\/wp\/v2\/knowledge_posts"}],"about":[{"href":"https:\/\/www.likacloud.com\/pt\/wp-json\/wp\/v2\/types\/knowledge_post"}],"author":[{"embeddable":true,"href":"https:\/\/www.likacloud.com\/pt\/wp-json\/wp\/v2\/users\/7"}],"version-history":[{"count":1,"href":"https:\/\/www.likacloud.com\/pt\/wp-json\/wp\/v2\/knowledge_posts\/12375077\/revisions"}],"predecessor-version":[{"id":12404152,"href":"https:\/\/www.likacloud.com\/pt\/wp-json\/wp\/v2\/knowledge_posts\/12375077\/revisions\/12404152"}],"wp:attachment":[{"href":"https:\/\/www.likacloud.com\/pt\/wp-json\/wp\/v2\/media?parent=12375077"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.likacloud.com\/pt\/wp-json\/wp\/v2\/tags?post=12375077"},{"taxonomy":"knowledge_category","embeddable":true,"href":"https:\/\/www.likacloud.com\/pt\/wp-json\/wp\/v2\/knowledge_category?post=12375077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}