• Okay, so I currently have a censor installed. Here is the current code:

    <?php
    /*
    *	Plugin Name: Censor
    *    	Plugin URI:
    *   	Description: Filters offencive language.
    * 	Author:
    * 	Author URI:
    * 	Version: 1.0
    *
    *
    *	This program is free software; you can redistribute it and/or modify
    *	it under the terms of the GNU General Public License as published by
    *	the Free Software Foundation; either version 2 of the License, or
    *	(at your option) any later version.
    *
    *	This program is distributed in the hope that it will be useful,
    *	but WITHOUT ANY WARRANTY; without even the implied warranty of
    *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    *	GNU General Public License for more details.
    *
    *	You should have received a copy of the GNU General Public License
    *	along with this program; if not, write to the Free Software
    *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
    
    function profanity_comment_filter($content) {
    
    // Add more words below, follow the structure that you already see, and make sure to increment the number.
    
    $patterns[0] = 'fuck';
    $patterns[1] = 'shit';
    $patterns[2] = 'bitch';
    $patterns[3] = 'bastered';
    $patterns[4] = 'ass';
    $patterns[5] = 'cock';
    $patterns[6] = 'cunt';
    $patterns[7] = 'a$$';
    $patterns[8] = '@s$';
    $patterns[9] = 'fuk';
    $patterns[10] = 'a$s';
    $patterns[11] = '@$$';
    $patterns[12] = 'moron';
    $patterns[13] = 'retard';
    $patterns[14] = 'hell';
    $patterns[15] = 'sex';
    $patterns[16] = 'sexual';
    $patterns[17] = 'drug';
    $patterns[18] = 'crack';
    $patterns[19] = 'nicotine';
    $patterns[20] = 'marijuana';
    $patterns[21] = 'smoke';
    $patterns[22] = 'alcohal';
    $patterns[23] = 'tobacco';
    $patterns[24] = 'hump';
    $patterns[25] = 'condum';
    $patterns[26] = 'tampon';
    
    $finalremove=$content;
    $piece_front="";
    $piece_back="";
    $piece_replace="[censor]";
    
        for ($x=0; $x < count($patterns); $x++) {
    
        $safety=0;
    
            while(strstr(strtolower($finalremove),strtolower($patterns[$x]))) {
            # find &amp; remove all occurrence
    
            $safety=$safety+1;
            if ($safety >= 100000) { break; }
    
            $occ=strpos(strtolower($finalremove),strtolower($patterns[$x]));
            $piece_front=substr($finalremove,0,$occ);
            $piece_back=substr($finalremove,($occ+strlen($patterns[$x])));
            $finalremove=$piece_front . $piece_replace . $piece_back;
            } # while
    
        }
    	return $finalremove;
    }
    add_filter('comment_text','profanity_comment_filter');
    ?>

    As you can see, I manually enter the curse words to be censored. The problem is, when someone posts something with a bad word inside it, such as “class” it appears on my blog as “cl[censor]”. Is there another code I can add to that file to make a special “always allow” list? Thanks in advance!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Help creating a censor “allow” list!’ is closed to new replies.