{"id":1965,"date":"2024-10-09T11:37:51","date_gmt":"2024-10-09T03:37:51","guid":{"rendered":"https:\/\/www.openbyt.com\/after-all-is-said-and-done-more-is-said-than-done-2"},"modified":"2024-10-17T19:51:04","modified_gmt":"2024-10-17T11:51:04","slug":"after-all-is-said-and-done-more-is-said-than-done-2","status":"publish","type":"post","link":"https:\/\/www.openbyt.com\/zh\/\u8aaa\u6b78\u8aaa\uff0c\u505a\u6b78\u505a-2","title":{"rendered":"\u5b89\u5168 WordPress \u5916\u639b\u7a0b\u5f0f\u958b\u767c\u5168\u9762\u6307\u5357"},"content":{"rendered":"<p>\u5728\u5efa\u7acb WordPress \u5916\u639b\u7a0b\u5f0f\u6642\uff0c\u5b89\u5168\u6027\u61c9\u653e\u5728\u6700\u91cd\u8981\u7684\u4f4d\u7f6e\u3002WordPress \u5916\u639b\u7a0b\u5f0f\u901a\u5e38\u662f\u653b\u64ca\u8005\u7684\u4e3b\u8981\u76ee\u6a19\uff0c\u56e0\u70ba\u5b83\u5011\u88ab\u5ee3\u6cdb\u4f7f\u7528\uff0c\u4e26\u53ef\u80fd\u5b58\u53d6\u654f\u611f\u8cc7\u6599\u3002\u5916\u639b\u7a0b\u5f0f\u4e2d\u7684\u55ae\u4e00\u6f0f\u6d1e\u5c31\u53ef\u80fd\u5371\u53ca\u6574\u500b\u7db2\u7ad9\uff0c\u5c0e\u81f4\u8cc7\u6599\u5916\u6d29\u3001\u6bc0\u640d\u6216\u5176\u4ed6\u56b4\u91cd\u7684\u5f71\u97ff\u3002\u5b89\u5168\u7684\u5916\u639b\u7a0b\u5f0f\u53ef\u4fdd\u8b77\u4f7f\u7528\u8005\u7684\u8cc7\u6599\u5b89\u5168\uff0c\u4e26\u9632\u6b62\u5e38\u898b\u7684\u653b\u64ca\uff0c\u78ba\u4fdd\u53ef\u9760\u4e14\u503c\u5f97\u4fe1\u8cf4\u7684\u9ad4\u9a57\u3002\u4ee5\u4e0b\uff0c\u6211\u5011\u5c07\u4ecb\u7d39\u4e00\u4e9b\u5efa\u7acb\u5b89\u5168 WordPress \u5916\u639b\u7a0b\u5f0f\u7684\u57fa\u672c\u6700\u4f73\u5be6\u52d9\uff0c\u4e26\u5206\u4eab\u4e00\u4e9b\u5be6\u7528\u7bc4\u4f8b\u3002<\/p><figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.41.20-A-digital-illustration-of-a-computer-screen-displaying-lines-of-code-with-a-shield-icon-symbolizing-security.-The-background-shows-a-subtle-hint-of-W.webp\" alt=\"\" class=\"wp-image-2551\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.41.20-A-digital-illustration-of-a-computer-screen-displaying-lines-of-code-with-a-shield-icon-symbolizing-security.-The-background-shows-a-subtle-hint-of-W.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.41.20-A-digital-illustration-of-a-computer-screen-displaying-lines-of-code-with-a-shield-icon-symbolizing-security.-The-background-shows-a-subtle-hint-of-W-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.41.20-A-digital-illustration-of-a-computer-screen-displaying-lines-of-code-with-a-shield-icon-symbolizing-security.-The-background-shows-a-subtle-hint-of-W-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.41.20-A-digital-illustration-of-a-computer-screen-displaying-lines-of-code-with-a-shield-icon-symbolizing-security.-The-background-shows-a-subtle-hint-of-W-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.41.20-A-digital-illustration-of-a-computer-screen-displaying-lines-of-code-with-a-shield-icon-symbolizing-security.-The-background-shows-a-subtle-hint-of-W-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.41.20-A-digital-illustration-of-a-computer-screen-displaying-lines-of-code-with-a-shield-icon-symbolizing-security.-The-background-shows-a-subtle-hint-of-W-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>1.\u4f7f\u7528 Nonces \u78ba\u4fdd\u8868\u683c\u548c URL \u5b89\u5168<\/strong><\/p><p>Nonces \u5c0d\u65bc\u9632\u6b62\u8de8\u7ad9\u8acb\u6c42\u507d\u9020 (CSRF) \u653b\u64ca\u975e\u5e38\u91cd\u8981\u3002\u5b83\u5011\u6709\u52a9\u65bc\u9a57\u8b49\u8acb\u6c42\u7684\u771f\u5be6\u6027\uff0c\u7279\u5225\u662f\u5c0d\u65bc\u57f7\u884c\u654f\u611f\u64cd\u4f5c\u7684\u8868\u55ae\u548c URL\u3002\u6bcf\u7576\u60a8\u5efa\u7acb\u8868\u55ae\u6216 URL \u6642\uff0c\u8acb\u4f7f\u7528 WordPress \u7684 wp_nonce_field() \u6216 wp_create_nonce() \u7522\u751f\u4e00\u500b nonce\u3002\u5728\u4f3a\u670d\u5668\u7aef\uff0c\u60a8\u61c9\u8a72\u4f7f\u7528 check_admin_referer() \u6216 check_ajax_referer() \u4f86\u9a57\u8b49 nonce\u3002<\/p><pre class=\"wp-block-code\"><code>if (isset($_POST['my_nonce']) &amp;&amp; wp_verify_nonce($_POST['my_nonce'], 'my_action')){\n    \/\/ \u5b89\u5168\u5730\u7e7c\u7e8c\u57f7\u884c\u52d5\u4f5c\n}<\/code><\/pre><figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.44.01-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s.webp\" alt=\"\" class=\"wp-image-2554\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.44.01-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.44.01-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.44.01-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.44.01-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.44.01-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.44.01-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p>\u9019\u7a2e\u4fdd\u8b77\u4e5f\u53ef\u61c9\u7528\u65bc AJAX \u8acb\u6c42\uff0c\u4ee5\u78ba\u4fdd\u5b83\u5011\u4f86\u81ea\u6388\u6b0a\u7528\u6236\uff1a<\/p><pre class=\"wp-block-code\"><code>add_action('wp_ajax_my_secure_action', 'my_secure_ajax_handler')\uff1b\nfunction my_secure_ajax_handler() {\n    check_ajax_referer('my_secure_nonce', 'security')\uff1b\n    \/\/ \u8655\u7406\u8acb\u6c42\n    wp_die()\uff1b\n}<\/code><\/pre><figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.45.05-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s.webp\" alt=\"\" class=\"wp-image-2557\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.45.05-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.45.05-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.45.05-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.45.05-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.45.05-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.45.05-A-modern-visually-engaging-illustration-showing-a-person-working-at-a-laptop-surrounded-by-digital-security-icons-such-as-shields-locks-and-code-s-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>2.\u6de8\u5316\u548c\u9a57\u8b49\u4f7f\u7528\u8005\u8f38\u5165\u7684\u8cc7\u6599<\/strong><\/p><p>\u653b\u64ca\u8005\u5165\u4fb5\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\u6700\u7c21\u55ae\u7684\u65b9\u6cd5\u4e4b\u4e00\u5c31\u662f\u6ce8\u5165\u60e1\u610f\u8cc7\u6599\u3002\u9019\u5c31\u662f\u70ba\u4ec0\u9ebc\u6de8\u5316\u548c\u9a57\u8b49\u6bcf\u500b\u4f7f\u7528\u8005\u8f38\u5165\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002WordPress \u63d0\u4f9b\u4e86\u5e7e\u500b\u5167\u5efa\u7684\u529f\u80fd\u4f86\u5e6b\u52a9\u60a8\u505a\u5230\u9019\u4e00\u9ede\uff1a<\/p><ul class=\"wp-block-list\"><li><code><strong>sanitize_text_field()<\/strong><\/code>:\u9069\u7528\u65bc\u7c21\u55ae\u7684\u6587\u5b57\u6b04\u4f4d\u3002<\/li>\n\n<li><code><strong>sanitize_email()<\/strong><\/code>:\u96fb\u5b50\u90f5\u4ef6\u5730\u5740\u3002<\/li>\n\n<li><code><strong>esc_url()<\/strong><\/code>:\u9069\u7528\u65bc URL\u3002<\/li><\/ul><p>\u9019\u4e9b\u51fd\u6578\u5f88\u9069\u5408\u57fa\u672c\u7684\u60c5\u6cc1\u3002\u7136\u800c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 PHP \u7684 filter_var() \u4f86\u8655\u7406\u66f4\u7279\u6b8a\u7684\u60c5\u6cc1\u3002\u4f8b\u5982\uff0c\u9a57\u8b49\u4e00\u500b\u6574\u6578\uff1a<\/p><pre class=\"wp-block-code\"><code>$input = filter_var($_POST['user_input'], FILTER_VALIDATE_INT)\uff1b\nif ($input !== false) {\n    \/\/ \u8f38\u5165\u6709\u6548\n}<\/code><\/pre><p>\u5c0d\u65bc\u66f4\u8907\u96dc\u7684\u60c5\u6cc1\uff0c\u4f8b\u5982\u9700\u8981\u9a57\u8b49\u591a\u9805\u9078\u64c7\u8f38\u5165\u6642\uff0c\u8acb\u8003\u616e\u4f7f\u7528\u81ea\u8a02\u9a57\u8b49\uff1a<\/p><pre class=\"wp-block-code\"><code>$valid_options = ['option_1', 'option_2', 'option_3']\uff1b\nif (in_array($_POST['selected_option'], $valid_options, true)) {\n    \/\/ \u8f38\u5165\u6709\u6548\n}<\/code><\/pre><p>\u9019\u53ef\u78ba\u4fdd\u53ea\u8655\u7406\u9810\u671f\u7684\u503c\uff0c\u964d\u4f4e\u610f\u5916\u554f\u984c\u767c\u751f\u7684\u98a8\u96aa\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.48.57-A-professional-illustration-representing-secure-data-handling-for-a-WordPress-plugin-suitable-for-a-Western-audience.-The-image-should-include-visual.webp\" alt=\"\" class=\"wp-image-2558\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.48.57-A-professional-illustration-representing-secure-data-handling-for-a-WordPress-plugin-suitable-for-a-Western-audience.-The-image-should-include-visual.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.48.57-A-professional-illustration-representing-secure-data-handling-for-a-WordPress-plugin-suitable-for-a-Western-audience.-The-image-should-include-visual-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.48.57-A-professional-illustration-representing-secure-data-handling-for-a-WordPress-plugin-suitable-for-a-Western-audience.-The-image-should-include-visual-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.48.57-A-professional-illustration-representing-secure-data-handling-for-a-WordPress-plugin-suitable-for-a-Western-audience.-The-image-should-include-visual-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.48.57-A-professional-illustration-representing-secure-data-handling-for-a-WordPress-plugin-suitable-for-a-Western-audience.-The-image-should-include-visual-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.48.57-A-professional-illustration-representing-secure-data-handling-for-a-WordPress-plugin-suitable-for-a-Western-audience.-The-image-should-include-visual-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>3.\u9003\u9038\u8f38\u51fa<\/strong><\/p><p>\u8f49\u7fa9\u8f38\u51fa\u5c0d\u65bc\u9632\u6b62\u8de8\u7ad9\u8173\u672c (XSS) \u653b\u64ca\u975e\u5e38\u91cd\u8981\u3002\u6bcf\u7576\u60a8\u8981\u986f\u793a\u8cc7\u6599\u7d66\u4f7f\u7528\u8005\u6642\uff0c\u8acb\u4f7f\u7528 WordPress \u7684\u8f49\u7fa9\u529f\u80fd\uff0c\u4f8b\u5982\uff1a<\/p><ul class=\"wp-block-list\"><li><code><strong>esc_html()<\/strong><\/code>:\u8981\u8f49\u63db HTML \u5167\u5bb9\u3002<\/li>\n\n<li><code><strong>esc_attr()<\/strong><\/code>:\u5c0d\u65bc\u5c6c\u6027\u503c\u3002<\/li>\n\n<li><code><strong>esc_url()<\/strong><\/code>:\u9069\u7528\u65bc URL\u3002<\/li><\/ul><p>\u9019\u88e1\u6709\u4e00\u500b\u7bc4\u4f8b\uff1a<\/p><pre class=\"wp-block-code\"><code>echo esc_html($user_input)\uff1b<\/code><\/pre><p>\u9019\u53ef\u4ee5\u9632\u6b62\u6f5b\u5728\u7684\u5371\u96aa\u7a0b\u5f0f\u78bc\u5728\u700f\u89bd\u5668\u4e2d\u57f7\u884c\uff0c\u78ba\u4fdd\u4f7f\u7528\u8005\u7684\u5b89\u5168\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.51.18-A-professional-illustration-symbolizing-XSS-prevention-in-web-development.-The-image-should-include-elements-like-code-snippets-a-browser-window-and.webp\" alt=\"\" class=\"wp-image-2562\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.51.18-A-professional-illustration-symbolizing-XSS-prevention-in-web-development.-The-image-should-include-elements-like-code-snippets-a-browser-window-and.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.51.18-A-professional-illustration-symbolizing-XSS-prevention-in-web-development.-The-image-should-include-elements-like-code-snippets-a-browser-window-and-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.51.18-A-professional-illustration-symbolizing-XSS-prevention-in-web-development.-The-image-should-include-elements-like-code-snippets-a-browser-window-and-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.51.18-A-professional-illustration-symbolizing-XSS-prevention-in-web-development.-The-image-should-include-elements-like-code-snippets-a-browser-window-and-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.51.18-A-professional-illustration-symbolizing-XSS-prevention-in-web-development.-The-image-should-include-elements-like-code-snippets-a-browser-window-and-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.51.18-A-professional-illustration-symbolizing-XSS-prevention-in-web-development.-The-image-should-include-elements-like-code-snippets-a-browser-window-and-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>4.\u5b89\u5168\u8cc7\u6599\u5eab\u67e5\u8a62<\/strong><\/p><p>\u70ba\u4e86\u9632\u6b62 SQL \u6ce8\u5165\uff0c\u8acb\u52d9\u5fc5\u4f7f\u7528 <code>$wpdb<\/code> \u985e\u7684\u9810\u5099\u8a9e\u53e5\u3002\u907f\u514d\u5728 SQL \u67e5\u8a62\u4e2d\u76f4\u63a5\u4e32\u9023\u4f7f\u7528\u8005\u8f38\u5165\u3002\u76f8\u53cd\uff0c\u8acb\u4f7f\u7528\u5360\u4f4d\u7b26\uff1a<\/p><pre class=\"wp-block-code\"><code>$results = $wpdb-&gt;get_results($wpdb-&gt;prepare(\"SELECT * FROM {$wpdb-&gt;prefix}my_table WHERE id = %d\", $id))\uff1b<\/code><\/pre><p>\u6e96\u5099\u8a9e\u53e5\u53ef\u78ba\u4fdd\u4f7f\u7528\u8005\u7684\u8f38\u5165\u88ab\u5145\u5206\u8f49\u63db\u4e26\u8996\u70ba\u8cc7\u6599\uff0c\u800c\u975e\u53ef\u57f7\u884c\u7684 SQL \u7a0b\u5f0f\u78bc\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.54.24-An-illustration-representing-secure-database-queries-for-web-development.-The-image-should-include-elements-like-a-database-symbol-SQL-query-snippets.webp\" alt=\"\" class=\"wp-image-2563\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.54.24-An-illustration-representing-secure-database-queries-for-web-development.-The-image-should-include-elements-like-a-database-symbol-SQL-query-snippets.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.54.24-An-illustration-representing-secure-database-queries-for-web-development.-The-image-should-include-elements-like-a-database-symbol-SQL-query-snippets-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.54.24-An-illustration-representing-secure-database-queries-for-web-development.-The-image-should-include-elements-like-a-database-symbol-SQL-query-snippets-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.54.24-An-illustration-representing-secure-database-queries-for-web-development.-The-image-should-include-elements-like-a-database-symbol-SQL-query-snippets-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.54.24-An-illustration-representing-secure-database-queries-for-web-development.-The-image-should-include-elements-like-a-database-symbol-SQL-query-snippets-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.54.24-An-illustration-representing-secure-database-queries-for-web-development.-The-image-should-include-elements-like-a-database-symbol-SQL-query-snippets-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>5.\u6b63\u78ba\u8655\u7406\u4f7f\u7528\u8005\u89d2\u8272\u548c\u80fd\u529b<\/strong><\/p><p>\u5728\u5efa\u7acb\u6d89\u53ca\u4e0d\u540c\u5c64\u7d1a\u4f7f\u7528\u8005\u6b0a\u9650\u7684\u529f\u80fd\u6642\uff0c\u8acb\u4f7f\u7528 current_user_can()\uff0c\u4ee5\u78ba\u4fdd\u53ea\u6709\u5177\u5099\u9069\u7576\u80fd\u529b\u7684\u4f7f\u7528\u8005\u624d\u80fd\u57f7\u884c\u7279\u5b9a\u52d5\u4f5c\uff1a<\/p><pre class=\"wp-block-code\"><code>if (current_user_can('manage_options')){\n    \/\/ \u50c5\u5141\u8a31\u7ba1\u7406\u54e1\u57f7\u884c\u6b64\u4ee3\u78bc\n}<\/code><\/pre><p>\u5c0d\u65bc\u9032\u968e\u7684\u89d2\u8272\u7ba1\u7406\uff0c\u60a8\u53ef\u4ee5\u5b9a\u7fa9\u81ea\u8a02\u529f\u80fd\u4e26\u5c07\u5176\u6307\u5b9a\u7d66\u7279\u5b9a\u89d2\u8272\uff0c\u9019\u6709\u52a9\u65bc\u60a8\u56b4\u683c\u63a7\u5236\u8ab0\u53ef\u4ee5\u5b58\u53d6\u5916\u639b\u7a0b\u5f0f\u7684\u654f\u611f\u90e8\u5206\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.58.35-A-professional-illustration-representing-user-roles-and-capabilities-management-in-WordPress.-The-image-should-include-symbols-like-user-icons-with-di.webp\" alt=\"\" class=\"wp-image-2566\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.58.35-A-professional-illustration-representing-user-roles-and-capabilities-management-in-WordPress.-The-image-should-include-symbols-like-user-icons-with-di.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.58.35-A-professional-illustration-representing-user-roles-and-capabilities-management-in-WordPress.-The-image-should-include-symbols-like-user-icons-with-di-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.58.35-A-professional-illustration-representing-user-roles-and-capabilities-management-in-WordPress.-The-image-should-include-symbols-like-user-icons-with-di-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.58.35-A-professional-illustration-representing-user-roles-and-capabilities-management-in-WordPress.-The-image-should-include-symbols-like-user-icons-with-di-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.58.35-A-professional-illustration-representing-user-roles-and-capabilities-management-in-WordPress.-The-image-should-include-symbols-like-user-icons-with-di-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-10.58.35-A-professional-illustration-representing-user-roles-and-capabilities-management-in-WordPress.-The-image-should-include-symbols-like-user-icons-with-di-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>6.\u9632\u7bc4\u8de8\u7db2\u7ad9\u6307\u4ee4\u78bc (XSS)<\/strong><\/p><p>XSS \u653b\u64ca\u662f\u6700\u5e38\u898b\u7684\u6f0f\u6d1e\u4e4b\u4e00\u3002\u5982\u524d\u6240\u8ff0\uff0c\u8acb\u52d9\u5fc5\u5141\u8a31\u4f7f\u7528\u8005\u8f38\u5165\u548c\u8f49\u7fa9\u8f38\u51fa\u3002\u5982\u679c\u60a8\u9700\u8981\u5141\u8a31\u7279\u5b9a\u7684 HTML \u6a19\u7c64\uff0c\u8acb\u4f7f\u7528 wp_kses() \u5b89\u5168\u5730\u904e\u6ffe\u5b83\u5011\uff1a<\/p><pre class=\"wp-block-code\"><code>$allowed_tags = [\n    'a' =&gt; [\n        'href' =&gt; []\u3001\n        'title' =&gt; []\n    ],\n    'b' =&gt; [],\n    'em' =&gt; [].\n];\n$safe_html = wp_kses($user_input, $allowed_tags)\uff1b<\/code><\/pre><p>\u9019\u6a23\uff0c\u60a8\u5c31\u53ef\u4ee5\u5141\u8a31\u4e00\u4e9b\u57fa\u672c\u683c\u5f0f\u5316\uff0c\u540c\u6642\u4fdd\u8b77\u4f7f\u7528\u8005\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.00.37-A-modern-illustration-representing-Cross-Site-Scripting-XSS-prevention-in-web-development.-The-image-should-include-elements-like-a-web-browser-with.webp\" alt=\"\" class=\"wp-image-2567\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.00.37-A-modern-illustration-representing-Cross-Site-Scripting-XSS-prevention-in-web-development.-The-image-should-include-elements-like-a-web-browser-with.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.00.37-A-modern-illustration-representing-Cross-Site-Scripting-XSS-prevention-in-web-development.-The-image-should-include-elements-like-a-web-browser-with-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.00.37-A-modern-illustration-representing-Cross-Site-Scripting-XSS-prevention-in-web-development.-The-image-should-include-elements-like-a-web-browser-with-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.00.37-A-modern-illustration-representing-Cross-Site-Scripting-XSS-prevention-in-web-development.-The-image-should-include-elements-like-a-web-browser-with-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.00.37-A-modern-illustration-representing-Cross-Site-Scripting-XSS-prevention-in-web-development.-The-image-should-include-elements-like-a-web-browser-with-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.00.37-A-modern-illustration-representing-Cross-Site-Scripting-XSS-prevention-in-web-development.-The-image-should-include-elements-like-a-web-browser-with-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>7.\u5c0f\u5fc3\u8655\u7406\u6a94\u6848<\/strong><\/p><p>\u5982\u679c\u8655\u7406\u4e0d\u7576\uff0c\u6a94\u6848\u4e0a\u50b3\u53ef\u80fd\u6703\u9020\u6210\u5de8\u5927\u7684\u5b89\u5168\u98a8\u96aa\u3002\u70ba\u4e86\u964d\u4f4e\u9019\u4e9b\u98a8\u96aa\uff0c\u8acb\u50c5\u5141\u8a31\u7279\u5b9a\u6a94\u6848\u985e\u578b\u3001\u6aa2\u67e5 MIME \u985e\u578b\uff0c\u4e26\u5c07\u6a94\u6848\u4e0a\u50b3\u81f3\u5b89\u5168\u4f4d\u7f6e\uff1a<\/p><pre class=\"wp-block-code\"><code>$allowed_file_types = ['jpg', 'jpeg', 'png', 'pdf']\uff1b\n$file_type = wp_check_filetype(basename($_FILES['file']['name']))\uff1b\nif (in_array($file_type['ext'], $allowed_file_types)) {\n    \/\/ \u7e7c\u7e8c\u4e0a\u50b3\n}<\/code><\/pre><p>\u60a8\u53ef\u4ee5\u4f7f\u7528 <code>wp_handle_upload()<\/code> \u4ee5\u6839\u64da WordPress \u7684\u6307\u5f15\u5b89\u5168\u5730\u7ba1\u7406\u4e0a\u50b3\uff1a<\/p><pre class=\"wp-block-code\"><code>$uploaded_file = wp_handle_upload($_FILES['file'], ['test_form' =&gt; false])\uff1b\nif ($uploaded_file &amp;&amp; !isset($uploaded_file['error'])){\n    \/\/ \u6a94\u6848\u6210\u529f\u4e0a\u50b3\n}<\/code><\/pre><p>\u9650\u5236\u4e0a\u50b3\u6a94\u6848\u7684\u5927\u5c0f\u4e26\u57f7\u884c\u984d\u5916\u7684\u5b89\u5168\u6aa2\u67e5\uff0c\u4f8b\u5982\u75c5\u6bd2\u6383\u63cf\u6216\u4f7f\u7528\u96dc\u6e4a\u51fd\u6578\u9a57\u8b49\u6a94\u6848\u5b8c\u6574\u6027\uff0c\u4e5f\u662f\u4e00\u500b\u597d\u7684\u505a\u6cd5\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.03.08-An-illustration-representing-secure-file-handling-in-web-development.-The-image-should-include-elements-like-file-icons-a-padlock-and-a-server-symb.webp\" alt=\"\" class=\"wp-image-2568\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.03.08-An-illustration-representing-secure-file-handling-in-web-development.-The-image-should-include-elements-like-file-icons-a-padlock-and-a-server-symb.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.03.08-An-illustration-representing-secure-file-handling-in-web-development.-The-image-should-include-elements-like-file-icons-a-padlock-and-a-server-symb-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.03.08-An-illustration-representing-secure-file-handling-in-web-development.-The-image-should-include-elements-like-file-icons-a-padlock-and-a-server-symb-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.03.08-An-illustration-representing-secure-file-handling-in-web-development.-The-image-should-include-elements-like-file-icons-a-padlock-and-a-server-symb-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.03.08-An-illustration-representing-secure-file-handling-in-web-development.-The-image-should-include-elements-like-file-icons-a-padlock-and-a-server-symb-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.03.08-An-illustration-representing-secure-file-handling-in-web-development.-The-image-should-include-elements-like-file-icons-a-padlock-and-a-server-symb-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>8.\u5b89\u5168\u7684 AJAX \u8acb\u6c42<\/strong><\/p><p>AJAX \u662f\u8b93\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\u66f4\u52d5\u614b\u7684\u597d\u65b9\u6cd5\uff0c\u4f46\u5fc5\u9808\u59a5\u5584\u4fdd\u8b77\u3002\u78ba\u4fdd\u6240\u6709 AJAX \u8acb\u6c42\u90fd\u9a57\u8b49\u4e86 nonce \u4e26\u6aa2\u67e5\u4f7f\u7528\u8005\u7684\u80fd\u529b\uff1a<\/p><pre class=\"wp-block-code\"><code>add_action('wp_ajax_my_action', 'my_ajax_handler')\uff1b\nfunction my_ajax_handler() {\n    check_ajax_referer('my_nonce', 'security')\uff1b\n    if (current_user_can('edit_posts')){\n        \/\/ \u8655\u7406\u8acb\u6c42\n    }\n    wp_die()\uff1b\n}<\/code><\/pre><p>\u70ba\u4e86\u78ba\u4fdd\u60a8\u7684\u5916\u639b\u5b89\u5168\uff0c\u8acb\u8a18\u5f97\u4fdd\u8b77\u5df2\u9a57\u8b49 (wp_ajax_) \u548c\u672a\u9a57\u8b49 (wp_ajax_nopriv_) \u7684 AJAX \u52d5\u4f5c\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.06.15-An-illustration-representing-secure-AJAX-requests-in-web-development.-The-image-should-include-symbols-like-arrows-representing-data-flow-a-computer-.webp\" alt=\"\" class=\"wp-image-2570\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.06.15-An-illustration-representing-secure-AJAX-requests-in-web-development.-The-image-should-include-symbols-like-arrows-representing-data-flow-a-computer-.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.06.15-An-illustration-representing-secure-AJAX-requests-in-web-development.-The-image-should-include-symbols-like-arrows-representing-data-flow-a-computer--600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.06.15-An-illustration-representing-secure-AJAX-requests-in-web-development.-The-image-should-include-symbols-like-arrows-representing-data-flow-a-computer--100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.06.15-An-illustration-representing-secure-AJAX-requests-in-web-development.-The-image-should-include-symbols-like-arrows-representing-data-flow-a-computer--300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.06.15-An-illustration-representing-secure-AJAX-requests-in-web-development.-The-image-should-include-symbols-like-arrows-representing-data-flow-a-computer--150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.06.15-An-illustration-representing-secure-AJAX-requests-in-web-development.-The-image-should-include-symbols-like-arrows-representing-data-flow-a-computer--768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>9.\u4fdd\u6301\u654f\u611f\u8cc7\u6599\u5b89\u5168<\/strong><\/p><p>\u5207\u52ff\u5c07\u654f\u611f\u8cc7\u6599\uff08\u4f8b\u5982 API \u91d1\u9470\uff09\u76f4\u63a5\u786c\u78bc\u5230\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\u4e2d\u3002\u76f8\u53cd\uff0c\u8acb\u4f7f\u7528 WordPress \u9078\u9805 API \u6216\u5728\u74b0\u5883\u8b8a\u6578\u4e2d\u5b89\u5168\u5730\u5132\u5b58\u5b83\u5011\uff1a<\/p><pre class=\"wp-block-code\"><code>update_option('my_plugin_api_key', sanitize_text_field($api_key))\uff1b<\/code><\/pre><p>\u5982\u6b64\u4e00\u4f86\uff0c\u654f\u611f\u8cc7\u8a0a\u5c31\u4e0d\u6703\u88ab\u96b1\u85cf\uff0c\u6f5b\u5728\u653b\u64ca\u8005\u4e5f\u4e0d\u6613\u53d6\u5f97\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.08.32-A-professional-illustration-representing-data-security-with-symbols-like-a-padlock-API-key-and-code-snippets.-The-image-should-convey-the-concept-o.webp\" alt=\"\" class=\"wp-image-2572\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.08.32-A-professional-illustration-representing-data-security-with-symbols-like-a-padlock-API-key-and-code-snippets.-The-image-should-convey-the-concept-o.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.08.32-A-professional-illustration-representing-data-security-with-symbols-like-a-padlock-API-key-and-code-snippets.-The-image-should-convey-the-concept-o-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.08.32-A-professional-illustration-representing-data-security-with-symbols-like-a-padlock-API-key-and-code-snippets.-The-image-should-convey-the-concept-o-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.08.32-A-professional-illustration-representing-data-security-with-symbols-like-a-padlock-API-key-and-code-snippets.-The-image-should-convey-the-concept-o-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.08.32-A-professional-illustration-representing-data-security-with-symbols-like-a-padlock-API-key-and-code-snippets.-The-image-should-convey-the-concept-o-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.08.32-A-professional-illustration-representing-data-security-with-symbols-like-a-padlock-API-key-and-code-snippets.-The-image-should-convey-the-concept-o-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>10.\u9075\u5faa\u6700\u5c0f\u7279\u6b0a\u539f\u5247<\/strong><\/p><p>\u53ea\u7d66\u4f7f\u7528\u8005\u548c\u7a0b\u5e8f\u6240\u9700\u7684\u6b0a\u9650\u3002\u5982\u679c\u67d0\u9805\u4efb\u52d9\u4e0d\u9700\u8981\u7ba1\u7406\u54e1\u6b0a\u9650\uff0c\u5c31\u4e0d\u8981\u4f7f\u7528\u3002\u9019\u9805\u539f\u5247\u6709\u52a9\u65bc\u9650\u5236\u5916\u6d29\u7684\u4f7f\u7528\u8005\u5e33\u6236\u53ef\u80fd\u9020\u6210\u7684\u640d\u5bb3\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.11.25-A-professional-illustration-representing-the-principle-of-least-privilege-in-security.-The-image-should-include-symbols-like-different-user-icons-pad.webp\" alt=\"\" class=\"wp-image-2573\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.11.25-A-professional-illustration-representing-the-principle-of-least-privilege-in-security.-The-image-should-include-symbols-like-different-user-icons-pad.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.11.25-A-professional-illustration-representing-the-principle-of-least-privilege-in-security.-The-image-should-include-symbols-like-different-user-icons-pad-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.11.25-A-professional-illustration-representing-the-principle-of-least-privilege-in-security.-The-image-should-include-symbols-like-different-user-icons-pad-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.11.25-A-professional-illustration-representing-the-principle-of-least-privilege-in-security.-The-image-should-include-symbols-like-different-user-icons-pad-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.11.25-A-professional-illustration-representing-the-principle-of-least-privilege-in-security.-The-image-should-include-symbols-like-different-user-icons-pad-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.11.25-A-professional-illustration-representing-the-principle-of-least-privilege-in-security.-The-image-should-include-symbols-like-different-user-icons-pad-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>11.\u9632\u79a6\u66b4\u529b\u653b\u64ca<\/strong><\/p><p>\u66b4\u529b\u653b\u64ca\u5f88\u5e38\u898b\uff0c\u5c24\u5176\u662f\u767b\u5165\u8868\u55ae\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 Wordfence \u7b49\u5916\u639b\u7a0b\u5f0f\u6216\u5be6\u4f5c\u60a8\u7684\u901f\u7387\u9650\u5236\u529f\u80fd\uff1a<\/p><pre class=\"wp-block-code\"><code>function limit_login_attempts() {\n    $ip_address = $_SERVER['REMOTE_ADDR']\uff1b\n    $attempts = get_transient('login_attempts_' . $ip_address)\uff1b\n\n    if ($attempts &gt;= 5) {\n        wp_die('Too many login attempts. Please try again later.')\uff1b\n    }\n\n    set_transient('login_attempts_' . $ip_address, $attempts + 1, 60 * 15); \/\/ \u6bcf 15 \u5206\u9418\u9650\u5236 5 \u6b21\u5617\u8a66\u3002\n}\nadd_action('wp_login_failed', 'limit_login_attempts')\uff1b<\/code><\/pre><p>\u9019\u500b\u7c21\u55ae\u7684\u7b56\u7565\u53ef\u4ee5\u5e6b\u52a9\u4fdd\u8b77\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\u514d\u65bc\u66b4\u529b\u653b\u64ca\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.27.04-An-illustration-representing-protection-against-brute-force-attacks-in-cybersecurity.-The-image-should-include-symbols-like-a-lock-a-login-form-and-.webp\" alt=\"\" class=\"wp-image-2574\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.27.04-An-illustration-representing-protection-against-brute-force-attacks-in-cybersecurity.-The-image-should-include-symbols-like-a-lock-a-login-form-and-.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.27.04-An-illustration-representing-protection-against-brute-force-attacks-in-cybersecurity.-The-image-should-include-symbols-like-a-lock-a-login-form-and--600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.27.04-An-illustration-representing-protection-against-brute-force-attacks-in-cybersecurity.-The-image-should-include-symbols-like-a-lock-a-login-form-and--100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.27.04-An-illustration-representing-protection-against-brute-force-attacks-in-cybersecurity.-The-image-should-include-symbols-like-a-lock-a-login-form-and--300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.27.04-An-illustration-representing-protection-against-brute-force-attacks-in-cybersecurity.-The-image-should-include-symbols-like-a-lock-a-login-form-and--150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.27.04-An-illustration-representing-protection-against-brute-force-attacks-in-cybersecurity.-The-image-should-include-symbols-like-a-lock-a-login-form-and--768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>12.\u8a18\u9304\u654f\u611f\u884c\u52d5<\/strong><\/p><p>\u8a18\u9304\u662f\u8ffd\u8e64\u53ef\u7591\u6d3b\u52d5\u7684\u5fc5\u8981\u689d\u4ef6\u3002\u5982\u679c\u4f7f\u7528\u8005\u8b8a\u66f4\u5916\u639b\u7a0b\u5f0f\u8a2d\u5b9a\u6216\u592a\u591a\u6b21\u767b\u5165\u5617\u8a66\u5931\u6557\uff0c\u60a8\u61c9\u8a72\u8a18\u9304\u9019\u4e9b\u4e8b\u4ef6\uff0c\u4ee5\u4fbf\u65e5\u5f8c\u9032\u884c\u5206\u6790\uff1a<\/p><pre class=\"wp-block-code\"><code>function log_action($message) {\n    $log_file = WP_CONTENT_DIR .'\/plugin_logs.txt'\uff1b\n    $current_time = current_time('mysql')\uff1b\n    file_put_contents($log_file, \"[$current_time] $message\\n\", FILE_APPEND)\uff1b\n}\n\nlog_action('Plugin settings changed by user ID ' . get_current_user_id())\uff1b<\/code><\/pre><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.29.34-An-illustration-representing-logging-sensitive-actions-in-web-development.-The-image-should-include-elements-like-a-logbook-a-clock-symbol-and-a-com.webp\" alt=\"\" class=\"wp-image-2575\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.29.34-An-illustration-representing-logging-sensitive-actions-in-web-development.-The-image-should-include-elements-like-a-logbook-a-clock-symbol-and-a-com.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.29.34-An-illustration-representing-logging-sensitive-actions-in-web-development.-The-image-should-include-elements-like-a-logbook-a-clock-symbol-and-a-com-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.29.34-An-illustration-representing-logging-sensitive-actions-in-web-development.-The-image-should-include-elements-like-a-logbook-a-clock-symbol-and-a-com-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.29.34-An-illustration-representing-logging-sensitive-actions-in-web-development.-The-image-should-include-elements-like-a-logbook-a-clock-symbol-and-a-com-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.29.34-An-illustration-representing-logging-sensitive-actions-in-web-development.-The-image-should-include-elements-like-a-logbook-a-clock-symbol-and-a-com-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.29.34-An-illustration-representing-logging-sensitive-actions-in-web-development.-The-image-should-include-elements-like-a-logbook-a-clock-symbol-and-a-com-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>13.\u63a8\u85a6\u7684\u5b89\u5168\u5916\u639b\u7a0b\u5f0f<\/strong><\/p><p>\u70ba\u4e86\u9032\u4e00\u6b65\u52a0\u5f37\u5916\u639b\u7a0b\u5f0f\u7684\u5b89\u5168\u6027\uff0c\u63a8\u85a6\u4e00\u4e9b\u5ee3\u53d7\u4fe1\u4efb\u7684\u5916\u639b\u7a0b\u5f0f\u3002 <strong>Wordfence<\/strong> \u548c <strong>Sucuri<\/strong> \u662f\u5f88\u597d\u7684\u9078\u64c7\u3002\u5b83\u5011\u63d0\u4f9b\u9632\u706b\u7246\u4fdd\u8b77\u3001\u60e1\u610f\u8edf\u9ad4\u6383\u63cf\u548c\u767b\u5165\u5b89\u5168\u7b49\u529f\u80fd\uff0c\u53ef\u4ee5\u63d0\u4f9b\u591a\u4e00\u5c64\u7684\u9632\u8b77\u3002<\/p><ul class=\"wp-block-list\"><li><strong>Wordfence<\/strong>:\u7aef\u9ede\u9632\u706b\u7246\u548c\u60e1\u610f\u8edf\u9ad4\u6383\u63cf\u3002<\/li>\n\n<li><strong>Sucuri<\/strong>:\u5b89\u5168\u7a3d\u6838\u3001\u60e1\u610f\u8edf\u9ad4\u5075\u6e2c\u548c DDoS \u4fdd\u8b77\u3002<\/li><\/ul><p>\u5c07\u9019\u4e9b\u529f\u80fd\u8207\u60a8\u5916\u639b\u7a0b\u5f0f\u7684\u5167\u5efa\u5b89\u5168\u529f\u80fd\u4e00\u8d77\u4f7f\u7528\uff0c\u53ef\u5efa\u7acb\u5f37\u5927\u7684\u9632\u79a6\u7cfb\u7d71\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.31.03-An-illustration-representing-WordPress-security-plugins.-The-image-should-include-elements-like-a-shield-a-WordPress-logo-and-security-symbols-such-.webp\" alt=\"\" class=\"wp-image-2576\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.31.03-An-illustration-representing-WordPress-security-plugins.-The-image-should-include-elements-like-a-shield-a-WordPress-logo-and-security-symbols-such-.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.31.03-An-illustration-representing-WordPress-security-plugins.-The-image-should-include-elements-like-a-shield-a-WordPress-logo-and-security-symbols-such--600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.31.03-An-illustration-representing-WordPress-security-plugins.-The-image-should-include-elements-like-a-shield-a-WordPress-logo-and-security-symbols-such--100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.31.03-An-illustration-representing-WordPress-security-plugins.-The-image-should-include-elements-like-a-shield-a-WordPress-logo-and-security-symbols-such--300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.31.03-An-illustration-representing-WordPress-security-plugins.-The-image-should-include-elements-like-a-shield-a-WordPress-logo-and-security-symbols-such--150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.31.03-An-illustration-representing-WordPress-security-plugins.-The-image-should-include-elements-like-a-shield-a-WordPress-logo-and-security-symbols-such--768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p>14.\u5b89\u5168\u7684 WooCommerce \u6574\u5408<\/p><p>WooCommerce \u5728\u7f8e\u570b\u548c\u6b50\u6d32\u975e\u5e38\u6d41\u884c\uff0c\u56e0\u6b64\u5982\u679c\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\u6574\u5408\u4e86 WooCommerce\uff0c\u8acb\u6b63\u78ba\u8655\u7406\u6240\u6709\u8cc7\u6599\u3002\u9a57\u8b49\u4e26\u6de8\u5316\u6bcf\u500b\u8f38\u5165\uff0c\u5c24\u5176\u662f\u5728\u8655\u7406\u8a02\u55ae\u6216\u4ed8\u6b3e\u8cc7\u8a0a\u6642\u3002\u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528 WooCommerce \u7684\u5167\u5efa\u529f\u80fd\u4f86\u5b89\u5168\u5730\u8655\u7406\u4ed8\u6b3e\u8cc7\u6599\u3002<\/p><p>\u4f8b\u5982\uff1a<\/p><pre class=\"wp-block-code\"><code>$order = wc_get_order($order_id)\uff1b\nif ($order) {\n    $total = $order-&gt;get_total()\uff1b\n    \/\/ \u5c0d\u8a02\u55ae\u57f7\u884c\u5b89\u5168\u64cd\u4f5c\n}<\/code><\/pre><p>\u5c0a\u91cd WooCommerce \u7684\u5b89\u5168\u5be6\u52d9\uff0c\u4e26\u78ba\u4fdd\u60a8\u8655\u7406\u7684\u4efb\u4f55\u5ba2\u6236\u8cc7\u6599\u7684\u5b89\u5168\u6027\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.33.28-An-illustration-representing-secure-integration-of-WooCommerce-in-WordPress-plugin-development.-The-image-should-include-symbols-like-a-shopping-cart.webp\" alt=\"\" class=\"wp-image-2577\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.33.28-An-illustration-representing-secure-integration-of-WooCommerce-in-WordPress-plugin-development.-The-image-should-include-symbols-like-a-shopping-cart.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.33.28-An-illustration-representing-secure-integration-of-WooCommerce-in-WordPress-plugin-development.-The-image-should-include-symbols-like-a-shopping-cart-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.33.28-An-illustration-representing-secure-integration-of-WooCommerce-in-WordPress-plugin-development.-The-image-should-include-symbols-like-a-shopping-cart-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.33.28-An-illustration-representing-secure-integration-of-WooCommerce-in-WordPress-plugin-development.-The-image-should-include-symbols-like-a-shopping-cart-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.33.28-An-illustration-representing-secure-integration-of-WooCommerce-in-WordPress-plugin-development.-The-image-should-include-symbols-like-a-shopping-cart-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.33.28-An-illustration-representing-secure-integration-of-WooCommerce-in-WordPress-plugin-development.-The-image-should-include-symbols-like-a-shopping-cart-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>15.\u4f7f\u7528\u591a\u56e0\u7d20\u9a57\u8b49 (MFA)<\/strong><\/p><p>\u555f\u7528\u591a\u56e0\u7d20\u9a57\u8b49 (MFA) \u662f\u589e\u52a0\u984d\u5916\u5b89\u5168\u5c64\u7d1a\u7684\u597d\u65b9\u6cd5\uff0c\u5c24\u5176\u662f\u5c0d\u65bc\u7ba1\u7406\u54e1\u5e33\u6236\u3002\u8a31\u591a\u5916\u639b\u7a0b\u5f0f\uff0c\u4f8b\u5982 <strong>\u96d9\u4eba<\/strong> \u6216 <strong>\u8c37\u6b4c\u9a57\u8b49\u5668<\/strong>\u60a8\u53ef\u4ee5\u5728 WordPress \u5b89\u88dd\u4e2d\u8f15\u9b06\u52a0\u5165 MFA\uff0c\u8b93\u653b\u64ca\u8005\u66f4\u96e3\u53d6\u5f97\u672a\u7d93\u6388\u6b0a\u7684\u5b58\u53d6\u6b0a\u9650\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.35.08-An-illustration-representing-multi-factor-authentication-MFA-in-WordPress-security.-The-image-should-include-symbols-like-a-smartphone-padlock-and.webp\" alt=\"\" class=\"wp-image-2578\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.35.08-An-illustration-representing-multi-factor-authentication-MFA-in-WordPress-security.-The-image-should-include-symbols-like-a-smartphone-padlock-and.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.35.08-An-illustration-representing-multi-factor-authentication-MFA-in-WordPress-security.-The-image-should-include-symbols-like-a-smartphone-padlock-and-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.35.08-An-illustration-representing-multi-factor-authentication-MFA-in-WordPress-security.-The-image-should-include-symbols-like-a-smartphone-padlock-and-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.35.08-An-illustration-representing-multi-factor-authentication-MFA-in-WordPress-security.-The-image-should-include-symbols-like-a-smartphone-padlock-and-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.35.08-An-illustration-representing-multi-factor-authentication-MFA-in-WordPress-security.-The-image-should-include-symbols-like-a-smartphone-padlock-and-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.35.08-An-illustration-representing-multi-factor-authentication-MFA-in-WordPress-security.-The-image-should-include-symbols-like-a-smartphone-padlock-and-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>16.\u91dd\u5c0d\u4e0d\u540c\u5340\u57df\u9032\u884c\u5b9a\u4f4d\u548c\u6e2c\u8a66<\/strong><\/p><p>\u5982\u679c\u60a8\u6253\u7b97\u63a5\u89f8\u570b\u969b\u53d7\u773e\uff0c\u5c07\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\u672c\u5730\u5316\u4e26\u78ba\u4fdd\u5b83\u80fd\u5728\u4e0d\u540c\u7684\u74b0\u5883\u4e2d\u904b\u4f5c\u662f\u975e\u5e38\u91cd\u8981\u7684\uff1a<\/p><ul class=\"wp-block-list\"><li><strong>\u652f\u63f4\u591a\u570b\u8a9e\u8a00<\/strong>:\u70ba\u4e86\u8b93\u60a8\u7684\u5916\u639b\u5bb9\u6613\u7ffb\u8b6f\uff0c\u8acb\u4f7f\u7528 WordPress \u7684\u672c\u5730\u5316\u51fd\u6578\uff0c\u4f8b\u5982 __() \u548c _e()\u3002<\/li>\n\n<li><strong>\u6642\u5340\u8655\u7406<\/strong>:\u78ba\u4fdd\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\u80fd\u6b63\u78ba\u8655\u7406\u4e0d\u540c\u7684\u6642\u5340\uff0c\u5c24\u5176\u662f\u6d89\u53ca\u6392\u7a0b\u7684\u6642\u5019\u3002<\/li><\/ul><p>\u5728\u4e0d\u540c\u7684\u8a9e\u8a00\u8a2d\u5b9a\u548c\u4f3a\u670d\u5668\u6642\u5340\u4e0b\u6e2c\u8a66\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\uff0c\u5c07\u53ef\u5354\u52a9\u60a8\u78ba\u4fdd\u8207\u5168\u7403\u4f7f\u7528\u8005\u7684\u76f8\u5bb9\u6027\u3002<\/p><p>\u6b64\u5916\uff0c\u5b83\u900f\u904e\u8ca0\u8cac\u4efb\u5730\u8655\u7406\u500b\u4eba\u8cc7\u6599\u3001\u63d0\u4f9b\u660e\u78ba\u7684\u540c\u610f\u9078\u9805\uff0c\u4ee5\u53ca\u5141\u8a31\u4f7f\u7528\u8005\u4f9d\u8981\u6c42\u522a\u9664\u6216\u532f\u51fa\u5176\u8cc7\u6599\uff0c\u78ba\u4fdd\u7b26\u5408 GDPR \u7684\u898f\u5b9a\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.36.52-An-illustration-representing-localization-and-multi-region-testing-for-WordPress-plugin-development.-The-image-should-include-symbols-like-a-globe-va.webp\" alt=\"\" class=\"wp-image-2579\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.36.52-An-illustration-representing-localization-and-multi-region-testing-for-WordPress-plugin-development.-The-image-should-include-symbols-like-a-globe-va.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.36.52-An-illustration-representing-localization-and-multi-region-testing-for-WordPress-plugin-development.-The-image-should-include-symbols-like-a-globe-va-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.36.52-An-illustration-representing-localization-and-multi-region-testing-for-WordPress-plugin-development.-The-image-should-include-symbols-like-a-globe-va-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.36.52-An-illustration-representing-localization-and-multi-region-testing-for-WordPress-plugin-development.-The-image-should-include-symbols-like-a-globe-va-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.36.52-An-illustration-representing-localization-and-multi-region-testing-for-WordPress-plugin-development.-The-image-should-include-symbols-like-a-globe-va-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.36.52-An-illustration-representing-localization-and-multi-region-testing-for-WordPress-plugin-development.-The-image-should-include-symbols-like-a-globe-va-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>17.\u914d\u7f6e WordPress \u4ee5\u7372\u5f97\u6700\u9ad8\u5b89\u5168\u6027<\/strong><\/p><p>\u9664\u4e86\u4fdd\u8b77\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\u5916\uff0c\u8a2d\u5b9a WordPress \u5c0d\u65bc\u6700\u5927\u7684\u5b89\u5168\u6027\u4e5f\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5efa\u8b70\uff1a<\/p><ul class=\"wp-block-list\"><li><strong>\u9650\u5236\u5b58\u53d6\u654f\u611f\u6a94\u6848<\/strong>:\u4f7f\u7528 .htaccess \u9650\u5236\u5b58\u53d6 wp-config.php \u7b49\u6a94\u6848\u3002<\/li>\n\n<li><strong>\u505c\u7528\u6a94\u6848\u7de8\u8f2f<\/strong>:\u5728 wp-config.php \u4e2d\u52a0\u5165\u9019\u4e00\u884c\uff0c\u9632\u6b62\u900f\u904e WordPress \u9762\u677f\u7de8\u8f2f\u6a94\u6848\uff1a<\/li><\/ul><pre class=\"wp-block-code\"><code>define('DISALLOW_FILE_EDIT', true)\uff1b<\/code><\/pre><ul class=\"wp-block-list\"><li><strong>\u9650\u5236\u767b\u5165\u5617\u8a66<\/strong>:\u4f7f\u7528\u5b89\u5168\u5916\u639b\u7a0b\u5f0f\u6216\u81ea\u8a02\u7a0b\u5f0f\u78bc\u4f86\u9650\u5236\u767b\u5165\u5617\u8a66\u7684\u6b21\u6578\u3002<\/li><\/ul><p><strong>18.\u4fdd\u6301 WordPress \u548c\u5916\u639b\u7a0b\u5f0f\u66f4\u65b0<\/strong><\/p><p>\u4fdd\u6301 WordPress\u3001\u4e3b\u984c\u548c\u5916\u639b\u7a0b\u5f0f\u66f4\u65b0\u5c0d\u5b89\u5168\u6027\u800c\u8a00\u81f3\u95dc\u91cd\u8981\uff0c\u9019\u5df2\u4e0d\u662f\u79d8\u5bc6\u3002\u66f4\u65b0\u901a\u5e38\u5305\u62ec\u5b89\u5168\u4fee\u88dc\u7a0b\u5f0f\uff0c\u56e0\u6b64\u8acb\u78ba\u4fdd\u6240\u6709\u6771\u897f\u90fd\u662f\u6700\u65b0\u7684\u3002<br>\u8003\u616e\u4f7f\u7528\u63d0\u4f9b\u81ea\u52d5\u66f4\u65b0\u7684\u8a17\u7ba1\u670d\u52d9\u4f9b\u61c9\u5546\uff0c\u4ee5\u78ba\u4fdd\u7db2\u7ad9\u7684\u5b89\u5168\u6027\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.40.34-An-illustration-representing-the-importance-of-keeping-WordPress-and-plugins-updated.-The-image-should-include-symbols-like-a-refresh-icon-a-shield-.webp\" alt=\"\" class=\"wp-image-2582\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.40.34-An-illustration-representing-the-importance-of-keeping-WordPress-and-plugins-updated.-The-image-should-include-symbols-like-a-refresh-icon-a-shield-.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.40.34-An-illustration-representing-the-importance-of-keeping-WordPress-and-plugins-updated.-The-image-should-include-symbols-like-a-refresh-icon-a-shield--600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.40.34-An-illustration-representing-the-importance-of-keeping-WordPress-and-plugins-updated.-The-image-should-include-symbols-like-a-refresh-icon-a-shield--100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.40.34-An-illustration-representing-the-importance-of-keeping-WordPress-and-plugins-updated.-The-image-should-include-symbols-like-a-refresh-icon-a-shield--300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.40.34-An-illustration-representing-the-importance-of-keeping-WordPress-and-plugins-updated.-The-image-should-include-symbols-like-a-refresh-icon-a-shield--150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.40.34-An-illustration-representing-the-importance-of-keeping-WordPress-and-plugins-updated.-The-image-should-include-symbols-like-a-refresh-icon-a-shield--768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>19.\u57f7\u884c\u5b89\u5168\u6e2c\u8a66<\/strong><\/p><p>\u5b9a\u671f\u7684\u5b89\u5168\u6e2c\u8a66\u6709\u52a9\u65bc\u5728\u653b\u64ca\u8005\u4e4b\u524d\u627e\u51fa\u5f31\u9ede\u3002\u5de5\u5177\u5982 <strong>WPScan<\/strong> \u53ef\u6709\u76ca\u65bc\u6b64\u76ee\u7684\uff1a<\/p><pre class=\"wp-block-code\"><code># \u6aa2\u67e5\u6f0f\u6d1e\u7684 WPScan \u6307\u4ee4\u7bc4\u4f8b\nwpscan --url https:\/\/example.com --api-token YOUR_API_TOKEN<\/code><\/pre><p>\u6b64\u5916\uff0c\u9032\u884c\u7a0b\u5f0f\u78bc\u6aa2\u95b1\u548c\u6ef2\u900f\u6e2c\u8a66\u53ef\u4ee5\u5e6b\u52a9\u60a8\u767c\u73fe\u5916\u639b\u7a0b\u5f0f\u78bc\u4e2d\u7684\u5f31\u9ede\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.42.22-An-illustration-representing-security-testing-for-WordPress-plugin-development.-The-image-should-include-elements-like-a-magnifying-glass-over-a-compu.webp\" alt=\"\" class=\"wp-image-2583\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.42.22-An-illustration-representing-security-testing-for-WordPress-plugin-development.-The-image-should-include-elements-like-a-magnifying-glass-over-a-compu.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.42.22-An-illustration-representing-security-testing-for-WordPress-plugin-development.-The-image-should-include-elements-like-a-magnifying-glass-over-a-compu-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.42.22-An-illustration-representing-security-testing-for-WordPress-plugin-development.-The-image-should-include-elements-like-a-magnifying-glass-over-a-compu-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.42.22-An-illustration-representing-security-testing-for-WordPress-plugin-development.-The-image-should-include-elements-like-a-magnifying-glass-over-a-compu-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.42.22-An-illustration-representing-security-testing-for-WordPress-plugin-development.-The-image-should-include-elements-like-a-magnifying-glass-over-a-compu-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.42.22-An-illustration-representing-security-testing-for-WordPress-plugin-development.-The-image-should-include-elements-like-a-magnifying-glass-over-a-compu-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><h2 class=\"wp-block-heading\">\u7e3d\u7d50<\/h2><p>\u5728\u958b\u767c WordPress \u5916\u639b\u7a0b\u5f0f\u6642\uff0c\u61c9\u6c38\u9060\u8003\u616e\u5b89\u5168\u6027\u3002\u9075\u5faa\u9019\u4e9b\u6700\u4f73\u5be6\u52d9\uff0c\u60a8\u5c07\u80fd\u5920\u66f4\u597d\u5730\u4fdd\u8b77\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\u53ca\u5176\u4f7f\u7528\u8005\u514d\u53d7\u5a01\u8105\u3002\u9019\u662f\u4e00\u500b\u6301\u7e8c\u7684\u904e\u7a0b\uff0c\u6240\u4ee5\u8acb\u6301\u7e8c\u5b78\u7fd2\u3001\u4e0d\u65b7\u66f4\u65b0\uff0c\u4e26\u601d\u8003\u5982\u4f55\u8b93\u60a8\u7684\u5916\u639b\u66f4\u5b89\u5168\u3002<\/p><p>\u4ee5\u5b89\u5168\u7b2c\u4e00\u7684\u601d\u7dad\u958b\u767c\u53ef\u8b93\u60a8\u5b89\u5fc3\uff0c\u4e26\u8207\u4f7f\u7528\u8005\u5efa\u7acb\u4fe1\u4efb\uff0c\u78ba\u4fdd\u4ed6\u5011\u53ef\u4ee5\u653e\u5fc3\u4f7f\u7528\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\u3002<\/p><p>\u7e3d\u7d50\u4e00\u4e0b\uff1a<\/p><ul class=\"wp-block-list\"><li>\u4f7f\u7528 nonces \u4e26\u9a57\u8b49\u8f38\u5165\u3002<\/li>\n\n<li>\u5b89\u5168\u8cc7\u6599\u5eab\u67e5\u8a62\u548c\u8f49\u7fa9\u8f38\u51fa\u3002<\/li>\n\n<li>\u5c0f\u5fc3\u8655\u7406\u6a94\u6848\u4e0a\u50b3\u3002<\/li>\n\n<li>\u5b89\u5168\u7684 AJAX \u8acb\u6c42\u3002<\/li>\n\n<li>\u78ba\u4fdd\u654f\u611f\u8cc7\u6599\u7684\u5b89\u5168\uff0c\u4e26\u9075\u5faa\u6700\u5c11\u7279\u6b0a\u539f\u5247\u3002<\/li>\n\n<li>\u9632\u7bc4\u66b4\u529b\u653b\u64ca\uff0c\u4e26\u8a18\u9304\u654f\u611f\u7684\u52d5\u4f5c\u3002<\/li>\n\n<li>\u4f7f\u7528\u5efa\u8b70\u7684\u5b89\u5168\u5916\u639b\u7a0b\u5f0f\u4e26\u555f\u7528 MFA\u3002<\/li>\n\n<li>\u91dd\u5c0d\u4e0d\u540c\u8a9e\u8a00\u3001\u6642\u5340\u548c GDPR \u5408\u898f\u6027\u9032\u884c\u6e2c\u8a66\u3002<\/li>\n\n<li>\u5b9a\u671f\u66f4\u65b0\u4e26\u57f7\u884c\u5b89\u5168\u6e2c\u8a66\u3002<\/li><\/ul><p>\u5be6\u65bd\u9019\u4e9b\u4f5c\u6cd5\uff0c\u60a8\u5c31\u80fd\u9806\u5229\u958b\u767c\u5b89\u5168\u53ef\u9760\u7684 WordPress \u5916\u639b\u7a0b\u5f0f\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.44.38-A-futuristic-high-tech-illustration-representing-WordPress-plugin-security-development.-The-image-should-include-symbols-like-shields-locks-code-sn.webp\" alt=\"\" class=\"wp-image-2584\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.44.38-A-futuristic-high-tech-illustration-representing-WordPress-plugin-security-development.-The-image-should-include-symbols-like-shields-locks-code-sn.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.44.38-A-futuristic-high-tech-illustration-representing-WordPress-plugin-security-development.-The-image-should-include-symbols-like-shields-locks-code-sn-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.44.38-A-futuristic-high-tech-illustration-representing-WordPress-plugin-security-development.-The-image-should-include-symbols-like-shields-locks-code-sn-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.44.38-A-futuristic-high-tech-illustration-representing-WordPress-plugin-security-development.-The-image-should-include-symbols-like-shields-locks-code-sn-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.44.38-A-futuristic-high-tech-illustration-representing-WordPress-plugin-security-development.-The-image-should-include-symbols-like-shields-locks-code-sn-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-14-11.44.38-A-futuristic-high-tech-illustration-representing-WordPress-plugin-security-development.-The-image-should-include-symbols-like-shields-locks-code-sn-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>","protected":false},"excerpt":{"rendered":"<p>\u5728\u5efa\u7acb WordPress \u5916\u639b\u7a0b\u5f0f\u6642\uff0c\u5b89\u5168\u6027\u61c9\u653e\u5728\u6700\u91cd\u8981\u7684\u4f4d\u7f6e\u3002WordPress \u5916\u639b\u901a\u5e38\u662f\u653b\u64ca\u8005\u7684\u4e3b\u8981\u76ee\u6a19\uff0c\u56e0\u70ba\u5b83\u5011...<\/p>","protected":false},"author":1,"featured_media":2605,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62,57],"tags":[232,230,231,229],"class_list":["post-1965","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-plugin-development","category-plugins-theme","tag-cross-site-scripting-prevention","tag-data-sanitization-and-validation","tag-multi-factor-authentication","tag-wordpress-plugin-security",""],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/posts\/1965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/comments?post=1965"}],"version-history":[{"count":9,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/posts\/1965\/revisions"}],"predecessor-version":[{"id":3185,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/posts\/1965\/revisions\/3185"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/media\/2605"}],"wp:attachment":[{"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/media?parent=1965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/categories?post=1965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/tags?post=1965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}