Last month, I released a patch for the FlashTextFormatter WordPress plugin to use Geoff Stern’s SWFObject script. If you’re unaware, the plugin is designed to color code with a Flash component. It’s pretty cool.
[ftf w=480 h=60]var greeting:String = “Hello, Galaxy!”;[/ftf]
Today, I enhanced it to display the code in plain-text if JavaScript is disabled. I should have done this in the first place, but I wasn’t very familar with WordPress PHP code. After some tinkering around, I got things all fixed up. Grab the plugin and try it out! You can view the source of this page to see the output. It’s pretty standard SWFObject-based code though.
That’s very nice – what does the code look like on the admin side of things? Is it added automatically?
Also, my code blocks are code tags with pre tags inside (sometimes), would I be able to customize the output of the text version?
In WordPress, you can type your code like this:
The plugin will remove any html tags (WordPress likes to add extra line breaks and things), and it places the code within pre tags. I should probably use code tags as well, since it’s for code. I believe the only customization options are for the width and height. Maybe the language definitions include more options. I’m not the original developer. I merely patched the plugin to display SWFs via SWFObject so that IE users didn’t have to click twice.
Great mod, but my concern with this plugin is it makes printing code from the page impossible. How would you implement an alternate stylesheet combined with the SWFObject that allows the text and not the SWF to show up when the user prints the page?
Oh man, that’s a tough one. I don’t think a stylesheet would do it. Maybe you could add a print mode to your posts. Make the address look like this: http://your-blog/post/?print=true. The script will detect when the print variable is true and know to skip the SWF.
Pingback: aron / philipp development blog / FlashTextFormatter plugin for wordpress