WP Plugins and Widgets For Wordpress 2.1+

WP Polite-ifier Plugin for Swearing

January 21st, 2008 by Elliott Back

politifier.png

What is WP Polite-ifier?

WP Politifier enforces a certain level of politeness in your comments, replacing recognized swear words with acronym’ed asterisks.

Since I also believe in freedom of speech, the original text is preserved in the title attribute, visible on mouseover. However, it solves the immediate problem of keeping my comments and blog “family safe,” at least at first glance. It also has SEO benefits for publishers running Adsense who want to maintain high-quality text without swearing or cursing in it.

The badwords list is editable through the administrative interface, and kept in a text file in the same directory.

Example:

politifier-example.png

Download:

Please download politeifier.zip from the official Wordpress Extend site, which will always host the latest and greatest version of this plugin. To install, drop badwords.txt and the wp-politeifier.php into your Wordpress plugins directory and activate in the administrative interface.

Update:

Mike Smullin suggested a patch which fixes a bug where the badwords.txt file is unable to be located. This has been fixed.

Tagged with:

43 Responses to “WP Polite-ifier Plugin for Swearing”

  1. Matt says:

    I’m still experiencing trouble with the location of the badwords.txt file. I installed the plugin by uploading the zip file to wordpress to let it install the plug-in and it returns the following errors in the comments:
    [code]
    Warning: file(/home/bluestak/public_html/motherhoodstress.com/wp-content/plugins/badwords.txt) [function.file]: failed to open stream: No such file or directory in /home/bluestak/public_html/motherhoodstress.com/wp-content/plugins/polite-ifier/wp-politeifier.php on line 31

    Warning: Invalid argument supplied for foreach() in /home/bluestak/public_html/motherhoodstress.com/wp-content/plugins/polite-ifier/wp-politeifier.php on line 34[/code]

  2. AVLution says:

    Can you edit so that the mouse over effect is removed?

    • This would make a good enhancement as an option.

    • Noel says:

      You can do this with JQuery.

      Not sure how the code will show up in this comment… but just put this link before your tag in your header.php file of your theme…

      Then put this directly above your tag.
      It has to be the last thing before that tag!

      // WP jQuery compatibility
      var $j = jQuery.noConflict();
      $j(function(){
      jQuery(‘ATTRIBUTE HERE’).removeAttr(“title”);
      });

      Change the “ATTRIBUTE HERE” text to whatever you want to hide the mouse-over titles on. A link span or div class etc.

      Hope that helps!

  3. G says:

    I am working on a buddypress plugin and using your plugin as a bad word filter on comments. Everything seems fine, its just on profile’s activity tab it shows every bad word very clearly.. lol

    Any suggestions?

    Thanks

  4. Tyla Dorning says:

    Hi

    Im getting these two error with the plugin:

    Warning: file(/usr/www/users/kokstaa/wp-content/plugins/badwords.txt) [function.file]: failed to open stream: No such file or directory in /usr/www/users/kokstaa/wp-content/plugins/polite-ifier/wp-politeifier.php on line 31

    When I tried to replace line 34 with the above help from other users I got another error.

    Warning: Invalid argument supplied for foreach() in /usr/www/users/kokstaa/wp-content/plugins/polite-ifier/wp-politeifier.php on line 34

    Please could you help, Im using this for a scholl website and its quite important for them.

  5. Loli says:

    Let me try it:

    **** *****

  6. Roy says:

    opps sorry its on line 30.

    Great plug in – been meaning to write something along the lines for a while

    Thank You

  7. Roy says:

    This plug in works fine with 2.9.2. Just open the php file and edit line 34, the plug in looks in the root of your plug in directory. add the polite-ifier after the plug in dir.


    $name = ABSPATH . "wp-content/plugins/polite-ifier/badwords.txt";

  8. It might be a nice upgrade to using an an admin screen for this and have a check box there to turn on and off the mouse over, then you could also have a text box for the “acronym” to replace the foul words with what ever is in that admin text box. Another thing I think might be cool is to have a check box for turning on and off the dotted underline and maybe also the same option for a strike through line rather than the underline….

    I added code to make it strike a line through the “Acronym” that was pretty easy but options from an admin screen would smooth the user issues.

    Just a couple of thoughts from a different perspective, thanks for the plugin. I like it.

  9. Anthony says:

    Unfortunately this ***** isn’t working for me. It reported back some errors on lines 31 and 34. ****

    Just testing the sware sensor, otherwise please help.

  10. Dan says:

    I want to see this work. So what the ****? Gee, I hope it really doesn’t say ******* on the screen.

  11. Sweet idea! Does the plugin still work? I was goign to manually go thru my blog.

  12. Cao says:

    I had an older version of wordpress and it worked fine, but now I’m on 2.8 and it no longer works. :( Please update the plugin for wordpress users on more current versions of wordpress

  13. function politeify_callback($matches){
    return ‘‘ . substr_replace ($matches[1], ‘@#$?%’, 2, -2) . ‘‘;
    }

    Here is a variation that deletes the middle of the word and leaves the first and last 2 letters and you can fill the middle with the characters you want.

    Line 31 and 32 and there is no guarantee ore even a suggestion that I know what I’m doing… I just play with the code sometimes.

  14. itsmb says:

    hello.

    will this plugin censor words in old posts and comments? or just new ones after the plugin has been activated?

    • itsmb says:

      Never mind :)

      i just found out how:

      simply add :

      add_filter(‘the_content’, ‘politeify’, 19);

      to the plugin code…

      this will polite-ifi the posts also…

  15. Novac says:

    What’s the update in version 1.2?

  16. [...] in your comments, replacing recognized swear words with acronym’ed asterisks… …..read more Download Plugin! Version 1.1 Last Updated: March 29, 2008 Plugin Owner: Elliott Back [...]

  17. kramer says:

    First off thanks for the nice plugin. I’ve taken it and changed it so the text file could be edited directly from wordpresss and choose whether or not the original text displays. If you would like to see it let me know.

  18. DS says:

    I have a question. Can this plug-in be changed in such a way that it will change the words \\**** you// into, for example, \\thank you// ?

  19. Sebasian says:

    damn ******* great plugin :-) thanx

  20. nitro2k01 says:

    Well, it’s overall hard to filter the word *** as a prefix since it appears as a component in many words, like “massive bass assassin”.
    But on the other I think it’s fair to assume that any word containing **** is “bad”. This could easily be implemented with a regex looking something like this:
    /(^|\W)(\w*****\w*)($|\W)/i
    I’m actually surprised that the f word slipped through the filter when I added tard to it.

  21. Elliott Back says:

    I agree, nitro2k01, but it’s hard to find prefixes / substrings that won’t be bad for other words. For example, ***.

    A better approach would use statistical analysis (n-gram markov) to identify swearing “You *** hole” from legit talk “Dangle a carrot in front of an ***.”

  22. nitro2k01 says:

    Oh, that test didn’t work out too well. Perhaps it would be an idea to filter all words with eg idiot or **** in them? Support for regex patterns perhaps?

  23. nitro2k01 says:

    (Test)
    Hey you idiotic fucktard!

    But honestly I don’t think word filtering is the way to go. The problem is what the person is trying to say, not which words they’re using. It’s perfectly possible to insult someone badly without using swearing. I honestly don’t see the problems Americans see with swearing.

    If people swear in your blog comments, it’s probably because you wrote something that provoke people to do it. Choose to write about something else, or delete the whole comment. (You’re likely not going to like the rest of it anyway)

    Just my two cents.

  24. test says:

    i try the **** plugin
    fuc*k? *****? runninginabastardandblablablalool

    Okay if it work i install it on my blog!

  25. Matthew says:

    oops, that first code line (the one to be replaced) should be

    return '' . str_pad("", strlen($matches[1]), "*") . '';

  26. Matthew says:

    If you don’t want the acronym to show up either, find the line:

    return '' . str_pad("", strlen($matches[1]), "*") . '';

    and change it to

    return str_pad("", strlen($matches[1]), "*");

  27. Wes says:

    great plugin :-)

  28. Dave Miller says:

    If you just replace line 30 with the following, it can be put into a directory like any normal plugin instead of cluttering up the plugins folder with files like badwords.txt.

    $name = dirname(__FILE__) . "/badwords.txt";

    You can also replace str_pad(...) with the clearer str_repeat("*", strlen($matches[1]))

    Thanks for this plugin!

  29. DM says:

    This plugin 2.5 compliant?

  30. fucking test says:

    Testing if the name tag is also edited out

  31. connor says:

    i have your plugin installed and activated, but it isnt working – (see corusa.com and make a comment), it posts the bad comment

  32. Elliott Back says:

    It’s ok, that’s why I give you a screenshot :)

  33. test says:

    lol sorry about that. figured you were using the plugin on this site. whoops.

  34. test says:

    this is a ******* test, you *******

  35. Joshua says:

    Hello, this plugin is really good.
    Is there a way to replace a specific bad word for a word I choose?
    Maybe adding a little code.
    Please help me.

  36. James says:

    Awesome plugin although i would like to actually not have the option for mouse over is that easy to edit in the original setup ? cause i don’t want a mouse over effect either so yea.

  37. anon says:

    THANK YOU! great idea!

  38. Sam says:

    great plugin. but the mouse over effect should not be there. cuz what is the actual reason for this plugin?

Leave a Reply

Powered by WP Hashcash

Search Posts


Categories

Blogroll

WP Hashcash

  • By Elliott Back
  • 969607 spam comments blocked out of 19389 human comments. 98.04% of your comments are spam!

Admin

Links

Feeds