How do I censor certain words in blog and post titles? I see the place for "comment" blacklists but is there an application for blogs and posts?
How do I censor certain words in blog and post titles? I see the place for "comment" blacklists but is there an application for blogs and posts?
You would have to add a plugin that does a string replace filter on the post title or body.
Floating somewhere around here is a quick snippet for an untitled posts plugin/hack that I put up several months ago. You could use that as a guide, and then find the right filters/actions to tie into.
There is a link for a how to write a plugin with a basic example that does exactly what you are asking for. The author writes it during the screencast and explains how it works.
http://txfx.net/files/wp-movies/001-your-first-wp-plugin.mov
Richard
Cool movie, mysorehead.
You probably have more than one word in mind to censor:
<?php
/*
Plugin Name: Fix bad words.
*/
function fix_bad_words($text) {
$bad_words = array(
'bad' => "%#$!%$",
'bad word' => "%#$!%$",
'worse word' => "%#$!%$",
'very bad wordÂ' => "%#$!%$",
'much more badder word' => "%#$!%$",
'anything' => "%#$!%$",
'really' => "%#$!%$",
);
foreach ($bad_words as $bad_word => $fix)
$text = str_replace($bad_word, $fix, $text);
return $text;
}
add_filter('the_title', 'fix_bad_words');
add_filter('the_content', 'fix_bad_words');
add_filter('comment_text', 'fix_bad_words');
?>
Thanks to all! I think this may be the answer.
Can you list some examples of very bad words please? I'm not sure I understand what the concept is.
Riiiiiiiiiiight....
LOL
You aren't "that" innocent, Doc.
WHY WON'T ANYONE HELP ME?!?!?!?!?
<slap> lol