{"id":1363,"date":"2025-07-22T15:55:13","date_gmt":"2025-07-22T08:55:13","guid":{"rendered":"https:\/\/cuongnguyen.io.vn\/?p=1363"},"modified":"2025-07-22T15:55:13","modified_gmt":"2025-07-22T08:55:13","slug":"chong-spam-binh-luan-hieu-qua-trong-wordpress","status":"publish","type":"post","link":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/2025\/07\/22\/chong-spam-binh-luan-hieu-qua-trong-wordpress\/","title":{"rendered":"Ch\u1ed1ng Spam B\u00ecnh Lu\u1eadn Hi\u1ec7u Qu\u1ea3 Trong WordPress"},"content":{"rendered":"<h2 class=\"wp-block-heading\">T\u1ea1i sao c\u1ea7n ch\u1ed1ng spam b\u00ecnh lu\u1eadn trong WordPress?<\/h2>\n<p>N\u1ebfu b\u1ea1n \u0111ang qu\u1ea3n l\u00fd m\u1ed9t website WordPress, ch\u1eafc h\u1eb3n b\u1ea1n \u0111\u00e3 t\u1eebng g\u1eb7p t\u00ecnh tr\u1ea1ng b\u1ecb spam b\u00ecnh lu\u1eadn v\u1edbi c\u00e1c n\u1ed9i dung ch\u1ee9a:<\/p>\n<ul class=\"wp-block-list\">\n<li>Li\u00ean k\u1ebft qu\u1ea3ng c\u00e1o \u1ea9n (<code>http<\/code>,\u00a0<code>www<\/code>, ho\u1eb7c t\u00ean mi\u1ec1n\u00a0<code>.com<\/code>)<\/li>\n<li>T\u1eeb ng\u1eef nh\u1ea1y c\u1ea3m nh\u01b0 thu\u1ed1c k\u00edch d\u1ee5c, n\u1ed9i dung ch\u00ednh tr\u1ecb, c\u1edd b\u1ea1c\u2026<\/li>\n<li>Spam t\u1eeb bot t\u1ef1 \u0111\u1ed9ng, b\u00ecnh lu\u1eadn v\u00f4 ngh\u0129a<\/li>\n<li>S\u1ed1 \u0111i\u1ec7n tho\u1ea1i, m\u00e3 code l\u1ea1 ho\u1eb7c b\u00ecnh lu\u1eadn ch\u1ee9a k\u00fd t\u1ef1 b\u1ea5t th\u01b0\u1eddng<\/li>\n<\/ul>\n<p>Nh\u1eefng n\u1ed9i dung n\u00e0y kh\u00f4ng ch\u1ec9 l\u00e0m\u00a0<strong>x\u1ea5u giao di\u1ec7n website<\/strong>, m\u00e0 c\u00f2n\u00a0<strong>\u1ea3nh h\u01b0\u1edfng nghi\u00eam tr\u1ecdng \u0111\u1ebfn SEO<\/strong>, g\u00e2y gi\u1ea3m uy t\u00edn website v\u1edbi Google v\u00e0 ng\u01b0\u1eddi d\u00f9ng.<\/p>\n<p>B\u1ea1n ho\u00e0n to\u00e0n c\u00f3 th\u1ec3\u00a0<strong>ch\u1ed1ng spam b\u00ecnh lu\u1eadn WordPress<\/strong>\u00a0b\u1eb1ng c\u00e1ch ch\u00e8n \u0111o\u1ea1n m\u00e3 PHP chuy\u00ean d\u1ee5ng v\u00e0o file\u00a0<code>functions.php<\/code>\u00a0c\u1ee7a theme.<\/p>\n<h2 class=\"wp-block-heading\">Code ch\u1ed1ng spam b\u00ecnh lu\u1eadn WordPress (m\u1edbi nh\u1ea5t 2025)<\/h2>\n<p>D\u01b0\u1edbi \u0111\u00e2y l\u00e0 \u0111o\u1ea1n code\u00a0<strong>t\u1ef1 \u0111\u1ed9ng ch\u1eb7n b\u00ecnh lu\u1eadn ch\u1ee9a t\u00ean mi\u1ec1n, t\u1eeb kh\u00f3a nh\u1ea1y c\u1ea3m, s\u1ed1 \u0111i\u1ec7n tho\u1ea1i, bot spam<\/strong>:<\/p>\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers cbp-hl-loaded cbp-ff-loaded\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\">\n<pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><\/pre>\n<pre class=\"shiki nord\" tabindex=\"0\"><code><span class=\"line\">\/\/ Ch\u1eb7n spam b\u00ecnh lu\u1eadn n\u00e2ng cao<\/span>\n<span class=\"line\">add_filter('preprocess_comment', 'muathemewpgiare_advanced_comment_filter');<\/span>\n<span class=\"line\">function muathemewpgiare_advanced_comment_filter($commentdata) {<\/span>\n<span class=\"line\">    $content = strtolower($commentdata['comment_content']);<\/span>\n<span class=\"line\">    $bad_words = array('hack','c\u1edd b\u1ea1c');<\/span>\n\n<span class=\"line\">    foreach ($bad_words as $word) {<\/span>\n<span class=\"line\">        if (stripos($content, $word) !== false) {<\/span>\n<span class=\"line\">            wp_die('B\u00ecnh lu\u1eadn c\u1ee7a b\u1ea1n ch\u1ee9a n\u1ed9i dung kh\u00f4ng ph\u00f9 h\u1ee3p.');<\/span>\n<span class=\"line\">        }<\/span>\n<span class=\"line\">    }<\/span>\n\n<span class=\"line\">    if (preg_match('\/([a-z0-9\\-]+\\.)+(com|net|org|vn|xyz|shop|store|link|top)\\b\/i', $content)) {<\/span>\n<span class=\"line\">        wp_die('B\u00ecnh lu\u1eadn kh\u00f4ng \u0111\u01b0\u1ee3c ch\u1ee9a t\u00ean mi\u1ec1n.');<\/span>\n<span class=\"line\">    }<\/span>\n\n<span class=\"line\">    if (preg_match('\/\\d{10,}\/', $content)) {<\/span>\n<span class=\"line\">        wp_die('B\u00ecnh lu\u1eadn c\u1ee7a b\u1ea1n c\u00f3 v\u1ebb ch\u1ee9a s\u1ed1 \u0111i\u1ec7n tho\u1ea1i ho\u1eb7c m\u00e3 spam.');<\/span>\n<span class=\"line\">    }<\/span>\n\n<span class=\"line\">    if (preg_match('\/[^\\p{L}\\p{N}\\s.,!?@#\\$%\\^\\&amp;\\*\\(\\)\\-\\+=\\[\\]\\{\\}\\'\\\":;\\\/\\\\\\\\&lt;&gt;]+\/u', $content)) {<\/span>\n<span class=\"line\">        wp_die('B\u00ecnh lu\u1eadn c\u1ee7a b\u1ea1n c\u00f3 v\u1ebb kh\u00f4ng h\u1ee3p l\u1ec7.');<\/span>\n<span class=\"line\">    }<\/span>\n\n<span class=\"line\">    if (!empty($_POST['honeypot_check'])) {<\/span>\n<span class=\"line\">        wp_die('Ph\u00e1t hi\u1ec7n spam! Vui l\u00f2ng th\u1eed l\u1ea1i sau.');<\/span>\n<span class=\"line\">    }<\/span>\n\n<span class=\"line\">    return $commentdata;<\/span>\n<span class=\"line\">}<\/span>\n\n<span class=\"line\">add_action('comment_form', 'muathemewpgiare_add_honeypot_field');<\/span>\n<span class=\"line\">function muathemewpgiare_add_honeypot_field() {<\/span>\n<span class=\"line\">    echo '&lt;p style=\"display:none;\"&gt;&lt;label&gt;Kh\u00f4ng \u0111i\u1ec1n v\u00e0o \u0111\u00e2y&lt;input type=\"text\" name=\"honeypot_check\" value=\"\"&gt;&lt;\/label&gt;&lt;\/p&gt;';<\/span>\n<span class=\"line\">}<\/span>\n\n<span class=\"line\">add_action('init', 'muathemewpgiare_limit_comment_speed');<\/span>\n<span class=\"line\">function muathemewpgiare_limit_comment_speed() {<\/span>\n<span class=\"line\">    if (is_user_logged_in()) return;<\/span>\n<span class=\"line\">    if ($_SERVER['REQUEST_METHOD'] === 'POST' &amp;&amp; isset($_POST['comment'])) {<\/span>\n<span class=\"line\">        $last_time = isset($_COOKIE['mtwg_last_comment']) ? intval($_COOKIE['mtwg_last_comment']) : 0;<\/span>\n<span class=\"line\">        $now = time();<\/span>\n<span class=\"line\">        if ($now - $last_time &lt; 45) {<\/span>\n<span class=\"line\">            wp_die('B\u1ea1n \u0111ang b\u00ecnh lu\u1eadn qu\u00e1 nhanh. Vui l\u00f2ng ch\u1edd \u00edt nh\u1ea5t 45 gi\u00e2y.');<\/span>\n<span class=\"line\">        }<\/span>\n<span class=\"line\">        setcookie('mtwg_last_comment', $now, time() + 3600, COOKIEPATH, COOKIE_DOMAIN);<\/span>\n<span class=\"line\">    }<\/span>\n<span class=\"line\">}<\/span><\/code><\/pre>\n<\/div>\n<h2 class=\"wp-block-heading\">L\u1ee3i \u00edch khi d\u00f9ng gi\u1ea3i ph\u00e1p n\u00e0y<\/h2>\n<ul class=\"wp-block-list\">\n<li><strong>T\u0103ng b\u1ea3o m\u1eadt<\/strong>\u00a0website kh\u1ecfi spam t\u1ef1 \u0111\u1ed9ng.<\/li>\n<li><strong>T\u0103ng \u0111i\u1ec3m SEO<\/strong>\u00a0khi kh\u00f4ng c\u00f3 b\u00ecnh lu\u1eadn r\u00e1c.<\/li>\n<li><strong>T\u0103ng tr\u1ea3i nghi\u1ec7m ng\u01b0\u1eddi d\u00f9ng<\/strong>\u00a0v\u1edbi b\u00ecnh lu\u1eadn s\u1ea1ch, ch\u1ea5t l\u01b0\u1ee3ng.<\/li>\n<li>Kh\u00f4ng ph\u1ee5 thu\u1ed9c v\u00e0o plugin n\u1eb7ng n\u1ec1.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\">L\u01b0u \u00fd:<\/h2>\n<ul class=\"wp-block-list\">\n<li>N\u00ean c\u1eadp nh\u1eadt t\u1eeb kh\u00f3a nh\u1ea1y c\u1ea3m theo ch\u1ee7 \u0111\u1ec1 website.<\/li>\n<li>C\u00f3 th\u1ec3 k\u1ebft h\u1ee3p plugin nh\u01b0 Akismet, Antispam Bee n\u1ebfu c\u1ea7n ki\u1ec3m so\u00e1t m\u1ea1nh h\u01a1n.<\/li>\n<li>N\u1ebfu c\u1ea7n n\u00e2ng c\u1ea5p, b\u1ea1n c\u00f3 th\u1ec3 l\u01b0u log spam ho\u1eb7c t\u1ea1o\u00a0<strong>giao di\u1ec7n qu\u1ea3n l\u00fd t\u1eeb kh\u00f3a<\/strong>\u00a0trong admin.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>T\u1ea1i sao c\u1ea7n ch\u1ed1ng spam b\u00ecnh lu\u1eadn trong WordPress? N\u1ebfu b\u1ea1n \u0111ang qu\u1ea3n l\u00fd m\u1ed9t website WordPress, ch\u1eafc h\u1eb3n b\u1ea1n \u0111\u00e3 t\u1eebng g\u1eb7p t\u00ecnh tr\u1ea1ng b\u1ecb spam b\u00ecnh lu\u1eadn v\u1edbi c\u00e1c n\u1ed9i dung ch\u1ee9a: Li\u00ean k\u1ebft qu\u1ea3ng c\u00e1o \u1ea9n (http,\u00a0www, ho\u1eb7c t\u00ean mi\u1ec1n\u00a0.com) T\u1eeb ng\u1eef nh\u1ea1y c\u1ea3m nh\u01b0 thu\u1ed1c k\u00edch d\u1ee5c, n\u1ed9i dung ch\u00ednh tr\u1ecb, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1364,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,11],"tags":[39],"class_list":["post-1363","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chia-se","category-thiet-ke-website","tag-thiet-ke-website-wordpress"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/posts\/1363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/comments?post=1363"}],"version-history":[{"count":0,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/posts\/1363\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/media\/1364"}],"wp:attachment":[{"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/media?parent=1363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/categories?post=1363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/tags?post=1363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}