2007 Round-up
Monday
Dec 31, 2007
In keeping with the blogging tradition I am taking a quick round up of 2007. I’ve left it to the last minute because this blog was pretty much an end of year thing anyway.
It has been a bit of whirlwind so far.
I started the blog in October on the back of an idea (not mine), a plugin wizzard. It was a big success. In fact it was the most successful thing I have ever done.
I wasn’t sure I would have the legs to carry the blog beyond that point. I love WordPress but I knew that I didn’t want to go down the route of being a review-monkey, a showcaser, or someone who went back to the very first principles. I have fallen into these traps at points, and finding content hasn’t always been as easy as I had hoped it would be, but knew it wouldn’t be. I think I’ve done OK so far though.
I knew from the start I wanted to release some plugins. I have developed and linked to one or two in the past but these were things I was doing anyway. This time I decided to do it properly.
It has been rewarding seeing the download stats, particularly for Fun with Sidebar Tabs. It has also been educational. I have seen other comment lists filled with comments about plugins not working, but never realised how much work it can be. A few times I have updated the plugin and found to my dismay that I had made a mistake, that my SVN client had skipped a file (I’m still not entirely sure about it but I’m getting there) or that I just hadn’t done a very good job of testing.
I have also suffered the fate of someone too keen on their ideas. I have developed at least one plugin, a form builder plugin that I am using on my site, only to discover that what I thought was a basic comment form plugin is actually the most comprehensive plugin ever devised by man. That would be CForms II. I am still using my own plugin and may release it in future, we’ll just see what happens in 2008.
To date I have had more comments, more visits and more subscribers than I have had at any point on other blogs (except for my photoblog and that is only subscribers). I know I need to try harder still in 2008 to build on the success so far, but I reckon 2007 was a good year.
I’m going to end with one of my favourite photos of 2007. See you in 2008.
Andy.

Update: Fun with Sidebar Tabs
Sunday
Dec 30, 2007
I have just uploaded an update to the Fun with Sidebar Tabs plugin.
This addresses the points that have been raised so far such as wanting to have more than one tabbed sidebar; you can now have up to nine, the spacing above the sidebar, this should be resolved but may depend on other CSS running in a particular theme.
It also resolves the problem with rendering in Opera, it should now work as well in Opera as everything else.
As always, any problems or suggestions let me know.
Re-Tooling
Friday
Dec 28, 2007
Things are a little quiet on these pages at the moment as I am spending a few days doing two things: 1. watching series one of The Wire which I got for Christmas, and 2: Spending some time to consider the theme this site is using in more detail than I had the time for when I first threw it together.
As part of number two I came across an old page from Smiley Cat about a comment design showcase.
The actual show case can be found at Elements of Design.
The site also features headline typography, comment forms, pull quotes, and more so it is a good resource if you’re struggling for a little inspiration.
Creating Custom URLs
Monday
Dec 24, 2007
It was pretty interesting to look back over a plugin I wrote, and thought was pretty good, more than a year ago. This was before I started considering releasing plugins properly and therefore taking steps to become proficient. It really highlighted to me how far I had come. One of things that I found was that to create a custom URL I had disassembled the way WordPress does it internally, and copied that. I completely missed the right way of doing it. So that is what I am going to explain here.
Note, I assume that you are familiar with writing plugins in general.
First, what do I mean by custom URLs?
Look at the address used by my tool, Fun with Plugins: http://www.wp-fun.co.uk/wizzards/fun-with-plugins/
What this URL does is to convert that to http://www.wp-fun.co.uk?wizzards=fun-with-plugins. This is used by WordPress to compile a list of variables that are made available through the WP_Query object.
I promise it will make a bit more sense in a minute.
So, lets say you wanted to create a photoblog. You want the URL for each image to be YOURBLOG/image/name and you will use a custom page in your template to display them: images.php.
In your plugin you will need four hooks:
- init
- generate_rewrite_rules
- query_vars
- template_redirect
When init is called you will need to flush the rewrite rules. The rewrite rules tell WordPress what to do with each part of the URL. Flushing them tells WordPress to recalculate those rules.
add_action('init', 'flush_rewrite_rules'); function flush_rewrite_rules() { global $wp_rewrite; $wp_rewrite->flush_rules(); }
When the rules are flushed WordPress will recalculate them. When it does that it will call the action - generate_rewrite_rules giving us the opportunity to add a new one:
add_action('generate_rewrite_rules', 'add_rewrite_rules'); function add_rewrite_rules( $wp_rewrite ) { $new_rules = array( 'image/(.+)' => 'index.php?image=' . $wp_rewrite->preg_index(1) ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; }
Next we need to tell WordPress to gather the image variable so we can make use it through the query object.
add_filter('query_vars', 'add_query_vars'); function add_query_vars( $qvars ){ $qvars[] = 'image'; return $qvars; }
Having done this the variable is available to check through $wp_query, like this:
add_action('template_redirect', array(&$this, 'template_redirect_intercept')); function template_redirect_intercept(){ global $wp_query; if ( $wp_query->get('image') ) { if (file_exists( TEMPLATEPATH . '/images.php' )) { include( TEMPLATEPATH . '/images.php' ); exit; } } }
$wp_query->get(’image’) will return false if the second part of the URL, the image name, hasn’t been entered or the image name if it has. You would use this return value in your custom page to figure out what it is you need to display there.
Making best use of your categories
Sunday
Dec 23, 2007
Wayne Liew has written a post about making best use of the categories on your blog. He makes the point that the new year is a perfect time to take a look at your categories, that may have expanded significantly over the years, and clear them out.
I have been doing something like this today. I have just migrated a blog that was running on an old version of WordPress and part of that meant re-writing a plugin I wrote more than a year ago.
This plugin is designed to allow posts to be displayed that fall into two categories; for example:
A wine blog might well sort wines according to region, California, France, New Zealand, etc. and within that into red, white, rose, sparkling, etc.
having a URL that will filter according to two categories, i.e. /categories/California/red/ seems to make a lot of sense in this situation.
It was written for a specific blog and so I stopped at two, but in reality there is no reason why it shouldn’t allow three, or even four categories.
It is possible to use subcategories to achieve this kind of thing, however, it can start to get complicated.
If anyone is interested in obtaining a copy of the plugin, then let me know and I will make it available. In the meantime I am interested to learn what kinds of category structures you are using on your own blog. Mine is fairly straightforward at the moment but I am considering using multiple category filters, asides, and a few other things in 2008.
How do you do it?
Tuesday
Dec 18, 2007
A few days ago I released a plugin that caused a problem for a few people that used it. It turned off the WYSIWYG editor in the post screen. I haven’t been able to replicate the problem, and I hope my update resolved it, but aside from this it gave me a pretty healthy reminder that people use tools in different ways.
When I write my posts I type the HTML manually. In fact I often write in Notepad first and just paste it in. Apart from my first few posts I have never used any WYSIWYG editor; I have probably been conditioned to think in code and so the editors just don’t do it for me.
This means it is easy for me to forget that the option even exists.
I would like you to tell me how you write your posts. The poll is below:
[poll=3]
If you have established a particular workflow, e.g. write in notepad then paste in, then it would be cool to share it with the class.
Thank you.
Fun with Google Charts
Saturday
Dec 15, 2007
A few days ago Google released their Charting API which provides a relatively easy method for producing charts on the fly. Over the past few days I have been producing a WordPress plugin that uses this API to make and save charts.

This plugin is in the early stages of development but It does work, in some cases very well, in others not so well. I probably won’t be able to do much more on it until next weekend and so I thought I would let you all have a look, and tell me if I am on the right lines, and what doesn’t work the way you would expect.
The Google Charts API is deceptively simple to use. The complication is in figuring out what you actually want it to show. I have tried to take as much of that out of the equation.
I don’t intend this to be a power tool in any way. But as a quick and simple plugin I think it is a nice start. Let me know what you think.
Fun with Google Charts 0.1.1 Alpha
To install it just unzip into your plugins directory. Then visit GChart under the Write tab.
How to use a newer version of a script in a WordPress plugin
Friday
Dec 14, 2007
In the plugin I am working on at the moment I wanted to use Prototype 1.6, but WordPress, currently at least, includes version 1.5. So I set about find out how best to do this.
I could have just included it again, but that didn’t seem like the best idea to me. To have one script overriding an other is unlikely to be efficient.
This is what I came up with. First a check to find out if the version currently included is lower than 1.6. Obviously if a newer version is included I don’t want to remove that as it may cause problems.
If it is then it is de-registered and the version included with the plugin is registered.
There may be an official way of achieving this, but I couldn’t find one.
if ( $wp_scripts->scripts['prototype']->ver < 1.6 ) { //replace prototype with version 1.6 wp_deregister_script( 'prototype' ); wp_enqueue_script('prototype', '/wp-content/plugins/plugin-path/prototype.js', NULL , 1.6); }
What’s Coming Up
Friday
Dec 14, 2007
I’ve been a little pre-occupied over the last few days and so haven’t posted as much as I would have liked. This really is just a post to let you know that I haven’t gotten bored with the whole thing but have been working on some stuff which will be coming soon.
In the next day or so I will be releasing a new plugin. I think it is the most interesting one I have developed so far, but I will keep the details under my hat for the moment.
Following on from my request for code to create Zip files, which thanks to Janis I now have, I will be updating the Fun With Plugins wizzard to include a zip download with all the necessary files and folders.
I will be releasing my first theme. It is based on an idea, and a theme I have used before on one of my own blogs, but I will be rewriting it all, and giving it a few interesting twists. This should be of interest to minimalism fans.
I am working on a series of posts about using object oriented PHP to help develop large plugins.
And finally, I will be starting work on a new wizzard.for the Wordpress Plugin Framework, a framework designed to simplify the creation of WordPress plugins.
These are the things I have planned so far, but I would really like to know if you think there is anything else you would like to read about. I am open to any and all suggestions so let me know.
In the meantime, happy Winterval one and all.
Hopes for the future
Tuesday
Dec 11, 2007
I am quite looking forward to Wordpress 2.4, not because of any features but because of the promised redesigned admin interface.
I haven’t heard much more about it than that, so perhaps my enthusiasm is misplaced but I think it is about time for a core redesign of the admin section.
I am hoping for a simplification of the underlying HTML; I would love to see a minimalist (html wise) approach, using simple label-control pairs instead of multiple nested divs, fieldsets and legends, but that may be too much of a change given the number of plugins out there that may rely on the existing CSS.
I expect it will be a decorative change only, but I can hope.
Update It looks like we’ll have to wait a little longer for the admin update. 2.4 will be skipped, and 2.5 will be released around March 08.
