Geek On The Mountain


Live Post Preview 1.0


Jun 02

Posted: under General.

After discussing the issue that I mentioned the other day regarding some modification that I did to an existing WordPress plugin with it’s author, I have decided to release my changes as a new plugin.

Live Post Preview is a WP plugin that alows you to preview your post in real time as you type it. It’s based on Live Comment Preiview which allows you to view your comment in real time as you type it. It was a pretty easy conversion from one to the other, I must admit.

It’s Thursday now (by the clock, anyways) and I started playing with this on like Sunday. I’ve just now finished. My changes may have been minor, but my efforts weren’t for sure….

First of all, I had to learn about plugins and how things worked and stuff in order to understand enough about what was going on to make the new plugin work. Then, I changed the names of variables and functions so that the naming would make sense in the new context (and to avoid naming conflicts within PHP). Then…..well, then nothing. Then it wouldn’t work. Technically, then I spent hours looking over the code, learning more about how it worked and event handling and crap and it still didn’t work. Then I started over from scratch, modifying the original plugin again. This time it worked just great and in a quarter of the time I’d spent attempting to debug my last screwup…. I’m still not sure what I did wrong (some minor syntax error could fail to create an error and just cause the whole thing to not work though…sucks). I should really diff the screwed up copy and the good copy and see what I get..

Then I setup hosting on dev.wp-plugins.org and then I had to learn about wiki formating and version control in order to get everything setup right. Then I had to write a post about it and then I had to have bad grammar and start every sentance with then just for fun…

Then So that took some time. It’s safe to say that I learned a lot. I still have a lot of stuff I want to look over about versioning. I’m not completely sure what I’m doing just yet, but it seems like cool stuff really.

The nicely ironic part about the whole thing is that in the process of doing this, I discovered two built-in ways of previewing a post without having to publish it first. First of all, Jeff, author of Live Comment Preview, recommended just saving the post as “private” and then viewing it. It will show up on your site only to you as that way (and WP knows that you’re you via cookies so there’s no messing around with authentication at all). This is probably the 100% best way to preview a post because you’ll see it exactly as it would look to anyone else. That is, using the correct stylsheet and surroundings (theme).

The second way that I found is that if you click on the “save and continue editing” button, WP will generate a preview at the bottom of the screen. (it does this for all posts that have been saved) Of course, you don’t get to see it in the correct context, but it’s a preview none-the-less.

To me, the preview is just important so I can confirm that I haven’t made any errors that do something silly like, make half the post into a link or bold or something. I also like to verify that my links work. Most of my posts don’t have pictures, but of course it’s useful to see how the layout will look when I do. I’ll just stick with the live preview for now… :)

Another interesting tidbit that I picked up on is that virtually any plugin made for WP has to be GPL’d since WP is. Makes sense, I just never thought about it before. How handy.

Comments (37)