1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Wordpress] - Get rid of HTML in comments | Dont get Spammed!

Discussion in 'Web Design' started by xfernanx, Sep 24, 2010.

  1. xfernanx

    xfernanx BANNED BANNED

    Joined:
    May 22, 2010
    Messages:
    88
    Likes Received:
    28
    [Wordpress] - Get rid of HTML in comments | Dont get Spammed!

    Just paste the code below into your functions.php file.
    Code:
    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);
    Enjoy ;)