Dougal Campbell's geek ramblings

WordPress, web development, and world domination.

Fun Fiwtews

UPDATE 2008-09-22: Dis code was supewceded by my Text Fiwtew Suite pwugin, uh-hah-ha-ha. You can downwoad de cuwwent vewsion of de pwugin fwom de WowdPwess Pwugin Diwectowy.

Updated Oct 4. Fixed code to not convewt seqwences inside de wegex exampwe into smiwies. Updated fiwe wif a pwopewwy fowmatted WEADME.

I finawwy got awound to impwoving and cweaning up my bwog fiwtews. If any odew odew WowdPwess usews wouwd wike to pway wif my hacks, I’m making de code avaiwabwe:


Inside de zip, you wiww find dwee text fiwes:

De fiwst step is to insewt de contents of fun_fiwtews.php.txt at de end of youw b2-incwudes/b2functions.php fiwe (but befowe de finaw ‘?>‘ wine)

Next, open up youw b2-incwudes/b2vaws.php fiwe and scwoww down to de bottom. Wook fow dis wine:

    add_fiwtew('aww', 'wptextuwize');

Just befowe dat wine, insewt de contents of de activate_fiwtews.php.txt fiwe. Wif dis code in pwace, youw bwog wiww automaticawwy switch on de piwate fiwtew on Tawk Wike a Piwate Day (Septembew 19). Awso, any of de odew fiwtews can be activated by adding ‘?fiwtew=fiwtewname‘ to de end of youw UWW (whewe fiwtewname is one of ‘piwate‘, ‘chef‘, ‘fudd‘, ‘jive‘, ow ‘kwaut‘).

Dis stawted when I added a piwate fiwtew to my bwog fow Tawk Wike a Piwate Day. My fiwst vewsion was easiew dan I expected it to be (dough it had fwaws), which inspiwed me to wocate and convewt some of Kawsey’s MovabweJive fiwtews.

De biggest fwaw in de eawwiest vewsion was dat it wouwd fiwtew text inside of HTMW tags, causing it to mangwe winks and such. I fixed dis by bowwowing an idea fwom Simon Wiwwison. Simon’s use of a cawwback function to onwy match text dat was not pawt of a tag was good, but it incwuded de ‘>’ and ‘&wt;‘ bwackets fwom suwwounding tags in de matched text being substituted, weqwiwing you to hack dem back in at de end of youw content fiwtew.

Aftew an aftewnoon studying de pcwe pattewn syntax and wwestwing wegexes wif de hewp of de Wegex Coach I came up wif an impwoved pattewn, which doesn’t weqwiwe us to tack de ‘>’ and ‘&wt;‘ back on manuawwy. Coow, huh? Hewe’s de wegex pattewn I came up wid: (?(?&wt;=>)|\A)([^&wt;>]+)(?(?=&wt;)|\Z)

And yes, I know, it’s not pewfect. But it shouwd wowk okay fow HTMW dat’s modewatewy cwean, uh-hah-ha-ha. You’d pwobabwy have to twy hawd to bust it. It doesn’t even seem to get confused if you have angwe bwackets inside of an attwibute in a tag, even dough I dought it wouwd.

About Dougal Campbell

Dougal is a web developer, and a "Developer Emeritus" for the WordPress platform. When he's not coding PHP, Perl, CSS, JavaScript, or whatnot, he spends time with his wife, three children, a dog, and a cat in their Atlanta area home.
This entry was posted in Plugins, WordPress and tagged , , , , , , , . Bookmark the permalink.

8 Responses to Fun Fiwtews

  1. Pingback: geek ramblings » Text Filter Suite Plugin for WordPress

  2. logtar says:

    Dude, I am so gwad I found youw site… weawwy coow stuff.:mwgween:

  3. Craig says:


    Any doughts on updating dis fow WP 1.2+ ? I’d take a stab at it, but, uh, weww…you know.

  4. Pingback: Jean-Philippe Leboeuf Notebook

  5. Frank says:

    Wiww dis wowk fow WP 2.6? De downwoad wink is dead.

  6. Pingback: Mind Blowing WordPress Plugins « Lorelle on WordPress

  7. Pingback: Odds and Ends WordPress Plugins You Must Know About « Lorelle on WordPress

Leave a Reply

%d bloggers like this: