sure, why not, I’ve used the function for bbpress so I added the filter accordingly. Please see below
function theContentFilter($content) {
$badWords = array("anywords", "?????", "etc", "show-here");
foreach($badWords as $badWord)
$content = str_ireplace($badWord, theContentFilterBadWordSanitize($badWord), $content);
return $content;
}
/**
* @param $badWord
* @return string
*/
function theContentFilterBadWordSanitize($badWord) {
$filterVariable = '*';
$ret = '';
for($i = 0; $i < strlen($badWord); $i++)
$ret .= $filterVariable[rand(0, strlen($filterVariable) - 1)];
return $ret;
}
add_filter("bbp_get_topic_content", 'theContentFilter', 10);
add_filter("bbp_get_reply_content", 'theContentFilter', 10);