Wednesday, 11 June 2008
Bad Words Filter Plugin for FlatPress
To change the badwords in the comments entry to something like @#$?%! heh.. :)
here is the code
function plugin_bwfilter_comment($text) { $bws = array(‘fuck’,’shit’, ‘bitch’); // the words considered as bad! $rep = ‘@#$?%!’; // the replacement of all the badwords foreach ($bws as $bw) { if ($bw != ‘’) { $text = preg_replace(‘/’.$bw.‘/si’, ‘@#$?%!’, $text); } } return $text; } // we add the filter add_filter(‘comment_text’, ‘plugin_bwfilter_comment’, 1);
if you don’t like the trouble of just copy and paste the code well here’s my plugin download link. I’ve added a simple admin feature to add and delete the words you would like to filter ;)

