ฟงัก์ชันนี้ปล่อยไว้ก็ไม่ดีเท่าไหร่ครับ พวกที่ชอบ spam จะใช้ช่องทางนี้หละครับเพื่อที่จะเขียน HTML และใส่ลิงก์เว็บตนเองไปด้วย ตัวอย่างที่พบบ่อยนะครับ เช่น
1 | <a href="http://www.myspamsite.com/">นี่คือลิงก์ Spam ของตู</a> |
ถ้าคุณเจอแบบนี้แค่ตอบกลับเดียวก็พอไหว แต่ถ้าเจอแบบ เป็น 100 โพสผมคิดว่าคุณปวดหัวแน่นอน เราสามารถที่จะลบฟังก์ชัน HTML นี้ออกได้โดยการ Hack มาเริ่มกันเลยครับ
เปิดไฟล์ functions.php ของธีม /wp-content/themes/ธีมปัจจุบันคุณ/ ดูที่บรรทัดสุดท้ายแล้วหา ?> จากนั้นวางโค้ดนี้ด้านบน
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | function plc_comment_post( $incoming_comment ) { $incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']); $incoming_comment['comment_content'] = str_replace( "'", ''', $incoming_comment['comment_content'] ); return( $incoming_comment ); } function plc_comment_display( $comment_to_display ) { $comment_to_display = str_replace( ''', "'", $comment_to_display ); return $comment_to_display; } add_filter('preprocess_comment', 'plc_comment_post', '', 1); add_filter('comment_text', 'plc_comment_display', '', 1); add_filter('comment_text_rss', 'plc_comment_display', '', 1); add_filter('comment_excerpt', 'plc_comment_display', '', 1); |


Comments