List Drafts Widget

Updated: Monday, 8th March 2010

Advance warning: I've finally got round to redoing this widget using the Widget API introduced in WordPress 2.8. Thought I'd better do it before a WordPress update breaks it. There will be an update here and probably a new post when the new version is available.

A long time ago[1], I unleashed on the world my first (and so far only) WordPress plugin: List Draft Posts. It’s a simple thing that lists the titles of any posts that you’ve started on but not yet posted. Simple is the only kind of coding I can generally manage, so it’s stayed simple, the only bit of sophistication being a form to control the layout it uses[2]. But it works for me, and it’s possible that one or two of the 239 people who’ve downloaded it from the WordPress plugin repository might be using it[3].

But it did lack one thing: it couldn’t be used as a WordPress widget. Well, there are ways of using a special widget to run a plugin’s function, but that’s not the same thing, is it? Having started to move my site to widgets, I decided to learn how to turn my own simple plugin into a widget, and started searching.

And that was a bit tricky at first. Some documentation I found assumed rather too much in the way of coding knowledge, and missed out some details that would be needed if you actually wanted your widget to work. But after a while, I found a post by Kaf: My Widget – example WordPress Widget. This, together with some changes suggested in the comments enabled me to get to work. After a lot of fiddling, tweaking, head-scratching, editing, re-editing and muttering, I managed to create a new version of List Draft Posts that is entirely widgety. Someone who knows how to code could probably make a version that would work as either a plugin or a widget, but for now I’m going to leave it as two separate versions.

As a standard widget, it doesn’t need much configuration – you can enter a heading to go above the list of posts, and a description for any draft posts that don’t have titles. It outputs its stuff in an unordered list below the heading:

<ul>
<li>A post I need to finish</li>
<li>Another post I've started</li>
</ul>

I’m going to play with it a bit more, make sure it doesn’t break anything, then submit it to the repository. If anyone desperately wants it before then, leave a comment, and I’ll make it available by some means or other.

Update: You can now get the widget from the official repository: List Drafts Widget

[1] In internet time
[2] And that lacks a lot of sophistication itself
[3] Hi guys :wave:

| Post a comment or leave a trackback.
  1. Hey, I’m about to add the PHP for List Draft Posts on my sidebar, but it would be nice to have the widget you mentioned. Have you released it yet? I think I’d be willing to install it on my site if it seems to work for you. Thx.

    AlanGalangalan@gmail Wednesday, 23rd July 2008 at 7:01. Reply to AlanGalangalan@gmail
  2. It’s now available from this site (until such a time as the official plugin directory catches up with itself).

    see here

    Les Wednesday, 23rd July 2008 at 7:53. Reply to Les
  3. hi. Thanks for plugin

    perfect.

    Regards

    baron Sunday, 27th July 2008 at 15:49. Reply to baron
  4. Hi Less,

    And thank you for your plugin, very “simple” and usefull !
    I just wonder if it’s possible to put in the darft posts list the name of the author of the post, like this for example :
    “Postx (Mô)
    Post y (Marie)”
    … And so on ?
    Thank you very much if you know, and… Thank you in any case (sorry for my english, I’m french… As you obviously see !)

    Maître Mô Wednesday, 2nd December 2009 at 9:30. Reply to Maître Mô
    1. I’m sure it could be done – next time I do some work on the plugin, I’ll try to add that.

      Les Wednesday, 2nd December 2009 at 19:05. Reply to Les
      1. Tank you very much !

        Maître Mô Thursday, 3rd December 2009 at 16:18. Reply to Maître Mô

Trackbacks and Pingbacks

  1. Trackback from Leonaut.com

    List Drafts Widget…

    List Drafts is a simple sidebar widget which outputs a list of the titles of all posts currently saved as drafts. Users can set the title of the widget, and add a label to be used for all untitled drafts. You can now have a list of forthcoming items as…


Leave a reply

:yes: :yawn: :wink: :wave: :wales: :wah: :unreal: :uhoh: :twisted: :tongue: :smile: :sleepy: :slap: :sick: :shock: :sad: :rolleyes: :rofl: :rant: :pig: :oops: :no: :neutral: :music: :monster: :lol: :huh: :grin: :evil: :evil2: :coffee: :eek: :duh: :drool: :dizzy: :crazy: :cool: :clap: :cheesy: :bow: :bouncy: :angry: :???: :!!!: