In this article, I’m going to show you how to write a simple plugin that adds a new widget to WordPress. We’ll be using the new WP_Widget class, which is the newest method but means that the widget will only work in WordPress 2.8+. I know that 2.8 isn’t actually out yet, but it will be soon and there’s no sense in learning the old method.
The widget we’ll be creating will display upcoming posts (scheduled posts). A lot of sites schedule posts to automatically publish at a specific time, helping them keep a steady flow of articles. I know that I use this trick on Web Developer News and Attackr, and I’ll use it on this site as soon as I get some more articles written. Since the articles are already there and ready to be posted, why not tease them and give your readers something to look forward to? That’s exactly what this widget will do.
I’ll keep this short. There was a meeting in IRC for WordPress developers yesterday. The quick summary is that you can expect the release of 2.8 on June 10th, 2009. However, while that’s what so many people are asking, that wasn’t the exciting part! Stay tuned for news about WordPress 2.9.
The next version of WordPress is due out soon (probably in early May), and one of the most exciting new things in WordPress 2.8 is the re-worked widgets admin. The vast majority of the complaints I received about the WordPress 2.5 admin redesign, were about the widget admin page. First, you could no longer add widgets using drag and drop. Instead they added the ever annoying “add” link, which would instantly add the widget to the bottom of the current sidebar. The other thing was that if you had a widget configured just how you wanted, and you needed to remove it for even a couple minutes, you would lose all the settings and have to re-do them all. Unfortunately, this seemingly backwards progress held on through versions 2.6 and 2.7 of WordPress as well. However, this page has undergone a complete redesign for 2.8. The real question is, does it make up for lost time? In order to try to answer this, I set up WordPress 2.8 on a development version of Xavisys.com.