Second More Useless Plugin
Bored again which seems to be the usual for the summer I sat down with one purpose in mind: To write another plugin. Didn't really matter to me if it was useful or not I just wanted to write another one. I decided to ask my friend Pete who snarkily replied "Write one that randomly inserts horse pr0n[1] in your blog." to which I immediately replied "not horse pr0n, ASCII pr0n!" which probably made him choke on his drink and immediately remember rule 34. But this made me think to myself: Why not a random plugin?
So I did just that, I wrote a random plugin. One so useless that I don't think I'm even going to activate it on my blog save for days like April Fools Day. The plugin chooses at random a word from each post using the the_content hook and censors it out with <censored>. Funny huh? This will ignore html tags so it won't break links and things like that. The code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <? /* Plugin Name: Random Censor Plugin URI: http://www.bemasher.net/ Description: Picks a common word at random from posts at display and replaces with <censor>. Ignores urls and other semi-important things. Version: 0.01 Author: BeMasher Author URI: http://www.bemasher.net/ */ function random_censor($content) { $oldcontent = $content; $content = preg_replace("/<[^<]+?>/", "", $content); preg_match_all("/\b\w+\b/", $content, $words); $word = $words[0][rand(0, sizeof($words[0]))]; $oldcontent = preg_replace("/\b$word\b/i", " <censored> ", $oldcontent); return $oldcontent; } add_filter("the_content", "random_censor"); ?> |
- Mind you this is a joke, relating to the fact that horse pr0n happens to rank pretty high on the list of strange things on the internet. [↩]

