{"id":28893,"date":"2024-11-25T12:18:26","date_gmt":"2024-11-25T04:18:26","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28893\/"},"modified":"2024-11-25T12:18:26","modified_gmt":"2024-11-25T04:18:26","slug":"%e8%a7%a3%e5%86%b3wordpress%e8%a2%ab%e7%be%a4%e5%8f%91%e5%9e%83%e5%9c%be%e8%af%84%e8%ae%ba%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28893\/","title":{"rendered":"\u89e3\u51b3WordPress\u88ab\u7fa4\u53d1\u5783\u573e\u8bc4\u8bba\u7684\u95ee\u9898"},"content":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;<strong>wordpress\u5efa\u7ad9\u6559\u7a0b<\/strong>\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u89e3\u51b3wordpress\u88ab\u7fa4\u53d1\u5783\u573e\u8bc4\u8bba\u7684\u95ee\u9898\u7684\u65b9\u6cd5\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5eb8e86ea589a655.jpg\" class=\"aligncenter\" title=\"\u89e3\u51b3WordPress\u88ab\u7fa4\u53d1\u5783\u573e\u8bc4\u8bba\u7684\u95ee\u9898\u63d2\u56fe\" alt=\"\u89e3\u51b3WordPress\u88ab\u7fa4\u53d1\u5783\u573e\u8bc4\u8bba\u7684\u95ee\u9898\u63d2\u56fe\" \/><\/p>\n<p>\u6211\u4eec\u5f88\u591a\u7f51\u53cb\u90fd\u6709\u53cd\u9988\u5230WordPress\u5efa\u7ad9\u8fc7\u7a0b\u4e2d\u53d1\u73b0\u540e\u53f0\u8bc4\u8bba\u6bcf\u5929\u90fd\u4f1a\u6709\u5f88\u591a\u5783\u573e\u8bc4\u8bba\uff0c\u800c\u4e14\u770b\u4f3c\u8fd9\u4e9b\u8bc4\u8bba\u90fd\u662f\u975e\u4eba\u5de5\u7fa4\u53d1\u7684\u3002\u786e\u5b9e\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u9047\u5230\u5f88\u591a\u88ab\u8f6f\u4ef6\u7fa4\u53d1\u7684\u5783\u573e\u8bc4\u8bba\uff0c\u6bd4\u5982\u770b\u5230\u6709\u5f88\u591a\u82f1\u6587\u7559\u8a00\u3002\u8fd9\u4e9b\u4fe1\u606f\u4f1a\u589e\u52a0\u6211\u4eec\u6bcf\u5929\u7684\u5220\u9664\u65f6\u95f4\u6210\u672c\uff0c\u540c\u65f6\u5bf9\u4e8e\u7f51\u7ad9\u4e5f\u662f\u4e0d\u597d\u7684\u3002\u6211\u4eec\u6709\u6ca1\u6709\u529e\u6cd5\u53bb\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u5462\uff1f<\/p>\n<p>\u6211\u4eec\u53ef\u80fd\u8f83\u591a\u7684\u65b9\u6cd5\u5c31\u662f\u589e\u52a0\u8bc4\u8bba\u9a8c\u8bc1\uff0c\u9700\u8981\u5728\u8bc4\u8bba\u7684\u65f6\u5019\u8f93\u5165\u9a8c\u8bc1\u7801\u6216\u8005\u5176\u4ed6\u7684\u9a8c\u8bc1\u673a\u5236\uff0c\u8fd9\u4e9b\u4e5f\u662f\u4e0d\u9519\u7684\u529e\u6cd5\u3002\u5728\u4eca\u5929\uff0c\u6211\u4eecWordPress\u8bfe\u5802\u9700\u8981\u4ecb\u7ecd\u7684\u5c31\u662f\u901a\u8fc7\u4e24\u6bb5\u4ee3\u7801\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5c4f\u853d\u8fd9\u4e9b\u8bc4\u8bba\u5185\u5bb9\u3002<\/p>\n<p>\u7b2c\u4e00\u3001\u8bc4\u8bba\u5185\u5bb9\u9700\u8981\u4e2d\u6587<\/p>\n<p>\u6211\u4eec\u5728\u8bc4\u8bba\u4e2d\u770b\u5230\u7684\u90fd\u662f\u82f1\u6587\u6216\u8005\u5176\u4ed6\u8bed\u8a00\uff0c\u6ca1\u6709\u4e2d\u6587\u3002\u90a3\u6211\u4eec\u5c31\u5fc5\u987b\u8bc4\u8bba\u5185\u5bb9\u4e2d\u6709\u4e2d\u6587\u3002<\/p>\n<pre>\/\/&nbsp;\u8bc4\u8bba\u4e2d\u9700\u8981\u6709\u4e2d\u6587&nbsp;cnwper.com\nfunction&nbsp;wp_refused_spam_comments($comment_data)&nbsp;{\n$pattern&nbsp;=&nbsp;'\/[\u4e00-\u9fa5]\/u';\n$jpattern&nbsp;=&nbsp;'\/[\u3041-\u3093]+|[\u30a1-\u30f4]+\/u';\nif&nbsp;(!preg_match($pattern,&nbsp;$comment_data['comment_content']))&nbsp;{\nerr(__('\u8bc4\u8bba\u4e2d\u9700\u8981\u6709\u4e00\u4e2a\u6c49\u5b57\uff01'));\n}\nif&nbsp;(preg_match($jpattern,&nbsp;$comment_data['comment_content']))&nbsp;{\nerr(__('\u4e0d\u80fd\u6709\u65e5\u6587\uff01'));\n}\nreturn&nbsp;($comment_data);\n}\nadd_filter('preprocess_comment',&nbsp;'wp_refused_spam_comments');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7b2c\u4e8c\u3001\u7981\u6b62\u8bc4\u8bba\u4e2d\u6709\u94fe\u63a5<\/p>\n<p>\u5f88\u591a\u4eba\u5230\u535a\u5ba2\u8bc4\u8bba\u7559\u8a00\uff0c\u90fd\u662f\u4e3a\u4e86\u63a8\u5e7f\u7f51\u7ad9\u7684\uff0c\u6211\u4eec\u7981\u6b62\u94fe\u63a5\u5c31\u6ca1\u6709\u591a\u5c11\u4eba\u6765\u53d1\u8bc4\u8bba\u4e86\u3002<\/p>\n<pre>\/\/\u7981\u6b62\u53d1\u94fe\u63a5&nbsp;cnwper.com\nfunction&nbsp;wp_comment_post(&nbsp;$incoming_comment&nbsp;)&nbsp;{\n$http&nbsp;=&nbsp;'\/[href=\"|rel=\"nofollow\"|http:\/\/|]\/u';\nif(preg_match($http,&nbsp;$incoming_comment['comment_content']))&nbsp;{\nerr(&nbsp;\"\u7981\u6b62\u53d1\u94fe\u63a5\u5730\u5740\uff01\"&nbsp;);\n}\nreturn(&nbsp;$incoming_comment&nbsp;);\n}\nadd_filter('preprocess_comment',&nbsp;'wp_comment_post');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5c31\u8fd9\u4e48\u7b80\u5355\uff0c\u5c06\u4e24\u6bb5\u4ee3\u7801\u6dfb\u52a0\u5230\u5f53\u524dWordPress\u4e3b\u9898\u4e2d\u7684Functions.php\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u66f4\u591aWordPress\u6280\u672f\u6587\u7ae0\uff0c\u8bf7\u8bbf\u95ee\u680f\u76ee\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u89e3\u51b3WordPress\u88ab\u7fa4\u53d1\u5783\u573e\u8bc4\u8bba\u7684\u95ee\u9898\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;wordpress\u5efa\u7ad9\u6559\u7a0b\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u89e3\u51b3wordpress\u88ab\u7fa4\u53d1\u5783\u573e\u8bc4\u8bba\u7684\u95ee\u9898\u7684\u65b9\u6cd5\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01 \u6211\u4eec\u5f88\u591a\u7f51\u53cb\u90fd\u6709\u53cd\u9988\u5230WordPress\u5efa\u7ad9\u8fc7\u7a0b\u4e2d\u53d1\u73b0\u540e\u53f0\u8bc4\u8bba\u6bcf\u5929\u90fd\u4f1a\u6709\u5f88\u591a\u5783\u573e\u8bc4\u8bba\uff0c\u800c\u4e14\u770b\u4f3c\u8fd9\u4e9b\u8bc4\u8bba\u90fd\u662f\u975e\u4eba\u5de5\u7fa4\u53d1\u7684\u3002\u786e\u5b9e\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u9047\u5230\u5f88\u591a\u88ab\u8f6f\u4ef6\u7fa4\u53d1\u7684\u5783\u573e\u8bc4\u8bba\uff0c\u6bd4\u5982\u770b\u5230\u6709\u5f88\u591a\u82f1\u6587\u7559\u8a00\u3002\u8fd9\u4e9b\u4fe1\u606f\u4f1a\u589e\u52a0\u6211\u4eec\u6bcf\u5929\u7684\u5220\u9664\u65f6\u95f4\u6210\u672c\uff0c\u540c\u65f6\u5bf9\u4e8e\u7f51\u7ad9\u4e5f\u662f\u4e0d\u597d\u7684\u3002\u6211\u4eec\u6709\u6ca1\u6709\u529e\u6cd5\u53bb\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u5462\uff1f \u6211\u4eec\u53ef\u80fd\u8f83\u591a\u7684\u65b9\u6cd5\u5c31\u662f\u589e\u52a0\u8bc4\u8bba\u9a8c\u8bc1\uff0c\u9700\u8981\u5728\u8bc4\u8bba\u7684\u65f6\u5019\u8f93\u5165\u9a8c\u8bc1\u7801\u6216\u8005\u5176\u4ed6\u7684\u9a8c\u8bc1\u673a\u5236\uff0c\u8fd9\u4e9b\u4e5f\u662f\u4e0d\u9519\u7684\u529e\u6cd5\u3002\u5728\u4eca\u5929\uff0c\u6211\u4eecWordPress\u8bfe\u5802\u9700\u8981\u4ecb\u7ecd\u7684\u5c31\u662f\u901a\u8fc7\u4e24\u6bb5\u4ee3\u7801\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5c4f\u853d\u8fd9\u4e9b\u8bc4\u8bba\u5185\u5bb9\u3002 \u7b2c\u4e00\u3001\u8bc4\u8bba\u5185\u5bb9\u9700\u8981\u4e2d\u6587 \u6211\u4eec\u5728\u8bc4\u8bba\u4e2d\u770b\u5230\u7684\u90fd\u662f\u82f1\u6587\u6216\u8005\u5176\u4ed6\u8bed\u8a00\uff0c\u6ca1\u6709\u4e2d\u6587\u3002\u90a3\u6211\u4eec\u5c31\u5fc5\u987b\u8bc4\u8bba\u5185\u5bb9\u4e2d\u6709\u4e2d\u6587\u3002 \/\/&nbsp;\u8bc4\u8bba\u4e2d\u9700\u8981\u6709\u4e2d\u6587&nbsp;cnwper.com function&nbsp;wp_refused_spam_comments($comment_data)&nbsp;{ $pattern&nbsp;=&nbsp;&#8216;\/[\u4e00-\u9fa5]\/u&#8217;; $jpattern&nbsp;=&nbsp;&#8216;\/[\u3041-\u3093]+|[\u30a1-\u30f4]+\/u&#8217;; if&nbsp;(!preg_match($pattern,&nbsp;$comment_data[&#8216;comment_content&#8217;]))&nbsp;{ err(__(&#8216;\u8bc4\u8bba\u4e2d\u9700\u8981\u6709\u4e00\u4e2a\u6c49\u5b57\uff01&#8217;)); } if&nbsp;(preg_match($jpattern,&nbsp;$comment_data[&#8216;comment_content&#8217;]))&nbsp;{ err(__(&#8216;\u4e0d\u80fd\u6709\u65e5\u6587\uff01&#8217;)); } return&nbsp;($comment_data); } add_filter(&#8216;preprocess_comment&#8217;,&nbsp;&#8216;wp_refused_spam_comments&#8217;); \u767b\u5f55\u540e\u590d\u5236 \u7b2c\u4e8c\u3001\u7981\u6b62\u8bc4\u8bba\u4e2d\u6709\u94fe\u63a5 \u5f88\u591a\u4eba\u5230\u535a\u5ba2\u8bc4\u8bba\u7559\u8a00\uff0c\u90fd\u662f\u4e3a\u4e86\u63a8\u5e7f\u7f51\u7ad9\u7684\uff0c\u6211\u4eec\u7981\u6b62\u94fe\u63a5\u5c31\u6ca1\u6709\u591a\u5c11\u4eba\u6765\u53d1\u8bc4\u8bba\u4e86\u3002 \/\/\u7981\u6b62\u53d1\u94fe\u63a5&nbsp;cnwper.com function&nbsp;wp_comment_post(&nbsp;$incoming_comment&nbsp;)&nbsp;{ $http&nbsp;=&nbsp;&#8216;\/[href=&#8221;|rel=&#8221;nofollow&#8221;|http:\/\/|]\/u&#8217;; if(preg_match($http,&nbsp;$incoming_comment[&#8216;comment_content&#8217;]))&nbsp;{ err(&nbsp;&#8220;\u7981\u6b62\u53d1\u94fe\u63a5\u5730\u5740\uff01&#8221;&nbsp;); } return(&nbsp;$incoming_comment&nbsp;); } add_filter(&#8216;preprocess_comment&#8217;,&nbsp;&#8216;wp_comment_post&#8217;); \u767b\u5f55\u540e\u590d\u5236 \u5c31\u8fd9\u4e48\u7b80\u5355\uff0c\u5c06\u4e24\u6bb5\u4ee3\u7801\u6dfb\u52a0\u5230\u5f53\u524dWordPress\u4e3b\u9898\u4e2d\u7684Functions.php\u6587\u4ef6\u4e2d\u3002 \u66f4\u591aWordPress\u6280\u672f\u6587\u7ae0\uff0c\u8bf7\u8bbf\u95ee\u680f\u76ee\uff01 \u4ee5\u4e0a\u5c31\u662f\u89e3\u51b3WordPress\u88ab\u7fa4\u53d1\u5783\u573e\u8bc4\u8bba\u7684\u95ee\u9898\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-28893","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=28893"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28893\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}