How to remove spam links in your comment area!

Version: 11.4b
Revision: 5 Build 11

How to remove spam links in your comment area!


For those who had big problems with your next neighbours, your evil spammers. You could pretty much disable the entire link! However, this tactics will also disable legit links. So, my advice is, you got to think and make a decision. But, if you look at the good side, your blog will eventually be safer against link farms and code injection.

1.] Login to your Cpanel and locate your WordPress directory.
2.] Find your theme directory and open this file: “functions.php”
3.] Copy these codes and place them inside. But, don’t forget your PHP tags!

<?php
function plc_comment_post( $incoming_comment ) {
	$incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);
	$incoming_comment['comment_content'] = str_replace( "'", '&apos;', $incoming_comment['comment_content'] );
	return( $incoming_comment );
}

function plc_comment_display( $comment_to_display ) {
	$comment_to_display = str_replace( '&apos;', "'", $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);
?>

Notes: when this code is active, it will immediately stripped every HTML code and convert them into plain text. In other terms, the actual links will be visible. But, they are un-clickable. This would make your blog a lot safer from unwanted code – injections or modifications from cyber – criminals.

Copyrighted By Lair360

Comments are closed.