Blog entries tagged with "wordpress"

A brand new site in 8 hours

Friday, October 23rd, 2009 at 10:53pm

Three days ago I became the webmaster of the Waverley Camera Club. Tonight I rolled out a brand new site that combined the existing static content with existing posts from an external blogspot blog.

Around about 8 hours of effort. Most of that was working my way through the migrated posts to both sort out better categories and to remove garbage markup that screwed up the rendering.

I also hadn’t planned to release the site so soon, but my testing/experimentation was going so well that it would have been a shame not do.


By using WordPress and making the decision that I would just assemble the pieces, I avoid writing code.

I chose WordPress for two reasons. One is that I am familiar with it and two that I knew it would be suitable for what we need the site to do at the moment. In the future I know it won’t be suitable if we proceed with some of the ideas that have been talked about.

Once I knew I would be using the latest version of WordPress my next decision to make would be how the site looked. To avoid the hassle of designing and then building a theme, I turned to the Free WordPress Themes directory. I wasn’t there for long as there were a couple of possibilities in the featured themes list. After running them by another committee member I decided to go with Pixel. The deciding factor was the info box at the top of the sidebar where we could put the club’s logo.

It was at this point that I started the largest task: importing the existing posts from blogspot. That specific task was easy using the import tool. What took time was going through each of the 140 posts to set a new category and to check that the post would render. I couldn’t believe how much crap had been added by blogspot. The biggest issue was badly nested divs, but second to that was the apparent random application of fonts and colours.

In the midst of this work I also played around with the widgets to customise what was in the sidebar and footer. It was only once there was content that widgets such as recent posts would make sense. This also allowed me to add the credit to the footer which is part of the conditions of the free hosting for non-profits. If it weren’t for the widgets my approach would have been to edit the theme.

But that isn’t to say that I have not modified the theme. Although the theme was working quite nicely, there were a couple of niggles. One was that in the header the tag line was too dark to be read, and another was that an empty box was showing below posts that would contain tags, if we were going to use them.

A while ago I read about WordPress theme inheritance where you can selectively override parts of another theme. So that’s what I did and my only changes were two CSS statements, one to change the text colour and another to hide the tag box. I later added a 404.php to give a slightly better not found page.

And that’s mostly it, except for some additional plugins that are quite nice to have:

Of course there is still content to migrate from the old site and it hasn’t yet had any real use. But that is for later.

Tagged with: , ,

Contributing back to wp-lifestream

Sunday, March 8th, 2009 at 05:09pm

I have just finished sorting through the changes I have made to my install of the wp-lifestream plugin and have posted some patches to the support forum:

Hopefully they are incorporated back into the plugin.

Tagged with: , ,

Sorting in PHP is extra effort … and there is no spaceship

Monday, March 2nd, 2009 at 10:47pm

Tonight I have been hacking in PHP on wp-lifestream in order to get grouped events ordered by time. I say hacking because there is a lot of PHP I don’t know and I don’t fully know how wp-lifestream is arranged.

When I first looked into sorting the grouped events my initial thought was to do it when the group was rendered. However that involved sorting data structures, so I decided that it would be easier to perform the sort when they were retrieved from the database. This is the change I made, and I thought it had worked.

Earlier today I found that while it worked when a feed was refreshed, it didn’t work when the group was updated after an event was deleted through the interface (I uploaded one too many photos to Flickr, which I later remved). So I had to turn back to the rendering code.

A var_dump() (Perl people should think Data::Dumper) later I knew what I was dealing with: an array of associative arrays that represented each item in the group. The relevant keys being date (in seconds since epoch) and title.

If this were perl it would be an array of hashrefs and I would have sorted it like this:

@events =
    sort { $a->{'date'} <=> $b->{'date'} || lc $a->{'title'} cmp lc $b->{'title'} } 

Not so in PHP:

  • PHP sort functions sort the array in place instead of returning a new list
  • The more advanced PHP sort functions take a callback to use instead of a block
  • I’m not using PHP 5.3 so there are no closures yet, but at least anonymous functions can be created with create_function()
  • PHP does not have a spaceship operator (<=> for numerical comparison), even though there are equivalents of cmp (strcmp, strcasecmp).

This is what I ended up with:

    create_function('$a,$b', '
        if ( $a["date"] == $b["date"] )
            return strcasecmp( $b["title"], $a["title"] );
        return ( $b["date"] < $a["date"] ) ? -1 : 1;

To me the logic is all messed up. Because there is no <=>, it needs a == comparison first. In the usort examples this returned 0, but gave me a convenient place to call strcasecmp() for the secondary sort. But that is breaking one sort into two statements and mixing in the other sort. It works and appears to be the PHP way of doing things, but it looks wrong to me.

(And yes, create_function() takes a string. Shudder…)

Tagged with: , , , ,

My life in a stream

Thursday, February 26th, 2009 at 11:23pm

A few minutes ago I changed the home of to display the output of Lifestream for WordPress, the plugin that I have been playing around with for the last week. Previously the home page was the same as the blog index except for the addition of a Flickr badge across the top.

Despite not saying anything, I have had a look at other lifestream plugins. I returned to the first one I tried because it was easy to install, it worked and it has active development. I am also planning to send in some patches for the couple of bugs that I have fixed so far.

Of the big list I initially gave, some were me not understanding the functionality correctly (the iBox stuff), some were actual bugs, some were changes to other things and some I am going to live with for now.

The changes I have made are:

  • Reverted back to an earlier version of SimplePie, the RSS parser, as I traced the problem with the Amazon wishlist back to the latest devel version. I submitted a bug report with them.
  • Modified the FeedBurner plugin to also check for ?direct=1 in the URL so the links to my own posts were not redirected through FeedBurner. (The main reason for this was because FeedBurner seems to be playing up – sometimes with URLs and sometimes with the original URLs, but not the most recent posts)
  • The timezone setting for the plugin let you choose an offset from -12 to +12 (displaying adjusted time in a drop down), but that is not an offset from epoch, it is an offset from the server time. My server is in -8 while I am in +11. That is an offset of +19, yet when I chose the correct time of day it gave my -5. So all events were a day out. I tweaked the settings page to adjust the offsets based on the server zone (-4 to +20 instead) which fixed that.
  • In the rendering code I needed to apply the offset where it works out if it should display ‘Today’ or ‘Tomorrow’ instead of the actual date.
  • The code that groups all of the events for a day also needed the offset added as it was done using the SQL DATE() function which (again) uses the (MySQL) server timezone.
  • Added ordering to grouped events (so they show the same as how I added them)
  • I added LibraryThing as a feed.

I still have other changes planned, but these got me to a point where I was happy to use it on the home page.

One major change that I would like to do is to change the Flickr feed to use the Flickr API instead of just the RSS feed. A limitation of the RSS is that it is only the 20 most recent items. The other night I added 67 photos from the photo walk. Initially it was showing 40 items because the feed refreshed during the upload, but now it only shows 20 because I readded the feed and it lost the history. The API wouldn’t have that limitation: my photos page (that has been there for a while, but I don’t link to it from anywhere) uses the API to get all the photos that I have uploaded. And as you can see it also gets set information that might be good to include.

Tagged with: , , , ,

Trying out a lifestream plugin

Thursday, February 19th, 2009 at 11:11pm

As well as creating some accounts, I spend most of the evening playing around with a lifestream plugin for WordPress. Although I found a couple of different options I decided to play around with the first one I came across: Lifestream for WordPress.

Installing the plugin was pretty simple and it was jut as easy to create a new (temporary) page for it. (The redundant heading is because my theme isn’t really setup for pages)

Here are my thoughts so far (version 0.93b):

  • It automatically setup the blog feed, but as I use FeedBurner the URLs that it links to are the FeedBurner ones, not mine. It does redirect back, but it would be nice if the real URL was visible. (A list of user agents to exclude on the FeedBurner plugin is a solution for this)
  • It was nice to be able to specify my own favicon as the image for my blog feed (or any feed).
  • I might want to have more info about each post shown, tags or maybe an excerpt.
  • Adding Delicious and Flickr was straightfoward.
  • As was my Amazon wishlist after I found out that you need to get the link to the RSS feed when you are not logged in to Amazon.
  • The Amazon links end up at a 400 error page in Firefox, and doesn not work at all in IE7.
  • I would expect items that are grouped together to still be in date order, they are not.
  • I installed the iBox plugin to see what functionality that gave. It is funky, but I would probably not use it.
  • The iBox functionality does not want to turn off. No matter what the ‘Enable iBox’ option is set to, it always uses it.
  • The timezones are broken. I have told it my current time, yet right now it is saying ‘Yesterday’ for items from earlier today.
  • It was easy to add support for LibraryThing – I copied how the Amazon worked (from RSS feed) and just had to change the regex to extract the thumbnail url.
  • As well as grouping not being in order they seem to be missing items. I have LibraryThing added twice, one with grouping and the other without. On January 16 I added 19 books. When grouped only 8 books are shown, when not grouped all 19 books are shown.
  • I’m not sure if I want items grouped by “same day”. What happens if I bookmark some links in the morning and then another batch in the evening. Will they all be grouped together? I would want them in two groups – ie grouped if within 1 hour of each other.
  • I’m not sure if I like the phrasing of the labels. Instead of “Added an item to their wishlist on Amazon” I would prefer something less third person like “Item added to Amazon wishlist”.

I shall keep playing with this plugin, as well as looking at the others.

Update: A major problem now is that the two most recent posts (this one included) are not being picked up by this plugin. They are definitely in the RSS feed. Not good.

Tagged with: , , , ,

Upgrading to WordPress 2.5.1

Saturday, May 10th, 2008 at 05:41pm

For quite some time my preference has been to wait until the first maintenance release of something before using it. I have found that being an early adopter for something that I just want to use can be extra work, even if it is just having to upgrade again the to maintenance release.

Once I heard that there would be native tag support in WordPress 2.3 I wanted to upgrade to that, but the talk of what would be available in WordPress 2.5 made me want to wait for that. Two weeks ago when 2.5.1 came out I knew it was time to start looking into upgrading.

Last weekend I jumped in and upgraded, where I am using WordPress as a publishing system, to 2.5.1. This was reasonably straightforward as I, when setting it up at the start of the year, kept my customisations within the theme and plugins. As with all changes I tested it out first on my local server before performing the change on the live sites.

Based on this success I started looking into upgrading this site. Because I was using the now redundant Ultimate Tag Warrior and had made some non standard customisations I expected it to be more work.

And it was.

After some research and experimentation during the week I was ready to upgrade the live site this afternoon. Which, as you are reading this, was successful.

So what did I do?

  • Update the WordPress files (and remove ones that are no longer needed).
  • Update FeedSmith, Markdown, Subscribe to Comments and WP-Cache to the latest versions.
  • Clean up my own plugin to link to other posts (heavily based on Easy Post-to-Post Links).
  • Export live database and import into local server (changing two options to have local hostname).
  • Run the upgrade script.
  • Import the tags from UltimateTagWarrior through admin interface.
  • Replace UTW_* calls in my theme to equivalent core functions. (I did briefly try out the UTW Theme Compatibility Thing plugin but decided against it)
  • Double check all settings
  • Test.
  • Test.
  • Upload files to live server.
  • Run the upgrade script.
  • Import the tags from UltimateTagWarrior through admin interface.
  • Double check all settings
  • Test.

Which brings us to now and I am happy with the upgrade and can move onto something else in my long list. One of which is running more of this site through WordPress instead of the current mix of WordPress, static files and the custom code for my computer collection.

Tagged with: , ,

The ultimate spam comment

Thursday, September 6th, 2007 at 07:43pm

Ever since I enabled comments I have been using the Akismet Plugin to combat spam which has been remarkably successful:

  • Around 1,000 comments are identified as spam per fortnight.
  • One or two comments are marked for moderation per week, all except one has been handled by clicking the ‘recheck queue for spam’ button.
  • One comment slips through a month that I need to manually remove and mark as spam.

Today the following comment slipped through:

hello , my name is Richard and I know you get a lot of spammy comments , I can help you with this problem . I know a lot of spammers and I will ask them not to post on your site. It will reduce the volume of spam by 30-50% .In return Id like to ask you to put a link to my site on the index page of your site. The link will be small and your visitors will hardly notice it , its just done for higher rankings in search engines. Contact me icq ________ or write me __________ , i will give you my site url and you will give me yours if you are interested. thank you

I was speechless…

Tagged with: , , ,

Notification of followup comments

Tuesday, March 6th, 2007 at 09:24pm

After I got my first legitimate comment I started to wonder how they would know if I responded with another comment.

A short time later I found Subscribe to Comments which does exactly what I want. If the commenter checks the notify box they will be emailed whenever there is a followup comment.

Tagged with: , ,

Comments are encouraged

Wednesday, February 28th, 2007 at 10:50pm

As of today is is now possible to leave comments on these posts.

The advantage of using an existing tool for my blog is that all I needed to do to enable comments was to turn on the appropriate option and to copy over (and modify) the appropriate part of the default theme into my custom theme. There was also some effort involved to remove the comment functionality when I first setup the theme but that was a long time ago.

In contrast I would have needed to spend a considerable amount of time building the functionality if I had opted to write everything from scratch. Score one for the first B in bend/buy/build.

(Time will tell if anyone leaves a comment, let alone reads any of these posts…)

Tagged with: , ,

How much memory does WordPress need?

Monday, October 9th, 2006 at 09:57pm

Over the past weekend I undertook the next step in rebuilding my linux boxes which was to perform a fresh install and moving services over. As expected installing Ubuntu went smoothly with the first issue arising when setting up the local copy of this site.

Getting apache, php and mysql installed was pretty trivial as I just selected the appropriate packages for installation. After getting used to how the apache configuration files are arranges I quickly had two virtualhosts defined, one for my internal site and another for this site, and I copied the files and databases over.

The snag came when I tried to load up this site and all I got was a blank page. At first all I could find about this issue talked about mysql not loading properly but I knew that wasn’t my issue as the code I had written from scratch that talks to the database was working fine. Eventually I found a reference to the php memory limit. At first I doubled it from 8MB to 16MB. No luck. I tried looking again for other solutions until I thought of doubling it again to 32MB. It was now working.

After a bit of trial an error I found that I needed the memory limit to be at least 26MB for WordPress and the plugins I use to load (but I left the limit at 32MB). Does it use this much memory for every single request and then throw it away at the end? Hmmm…

Tagged with: , ,

Being self-referential

Sunday, July 23rd, 2006 at 08:05pm

A few weeks ago I droped the day of the month from the permalink structure of this blog as I realised that I would have to post multiple times every single day for it to be any use.

Although I added a rewrite rule to accomodate the existing links I realised that as the majority of links to my posts were from other posts I had made and those should not depend on the rewrite rule. What I needed was a shortcut in making these links that automatically used the current permalink and also simplify my current process of copying and pasting both the url and title of the relevant post.

A google search later and I had found the Easy Post-to-Post Links WordPress plugin. Unfortunately this created the links with the title of the post, not the contextual form that I use.

After upgrading to the latest version the other day I looked into it again and this time I came across AutoLink which is a much more powerfull plugin that lets me use contextual links as I have been as it picks up a special url scheme.

However when I tried to play around with this one I couldn’t get it running on my local server (I need to update the PHP installation as it does run fine on my paid host) I opted for a compromise which was to adopt the syntax used by AutoLink for post to post links but rewrite the Easy Post-to-Post plugin to do what I want.

One of the many items on my list is to update my local host so that it is running the same versions as my paid host and once I have done that I expect I will give AutoLink another try. My immediate need is to not require the rewrite rule for any internal links.

Tagged with: , ,

Taking a plunge

Friday, July 21st, 2006 at 09:33pm

This evening I upgraded this blog to the latest version of WordPress in under twenty minutes with most of that time waiting for the new files to upload. How did I do it so quickly? By spending over three hours on Tuesday evening upgrading the copy of this site that I run at home and finding the issues there.

As well as upgrading WordPress I also needed to upgrade to the latest version of Ultimate Tag Warrior which has also given me a working tag cloud.

The reasoning behind upgrading was not to upgrade for the sake of it, instead it was the bar that I imposed before moving an a couple of ideas I was considering. Ideally I will look into some of them over the coming weekend.

Tagged with: , ,

A tag based blog

Thursday, December 8th, 2005 at 10:25pm

Many months ago I came across a blog post about how to make wordpress tag based in a similar form to With my OSDC posts this week I have finally started to add tags and this evening I added in the display of the tags for each post and the display of all the tags in the side navigation bar.

Now I need to find the time (yes, more of it) to go through my past posts and add sensible tags. I shall see how things go…

Tagged with: ,

WordPress based blog

Sunday, May 1st, 2005 at 10:16pm

The new month brings change as this weekend I finally got around to migrating my blog over from my homegrown solution to WordPress as I mused about back in March.

The biggest task involved in the migration was the creation of a theme so the look and feel of the blog could largely remain the same. The biggest change is that there is now a sidebar on all the blog related pages with links to the monthly archives. This has also been the most painful task as although the WordPress templating system may use PHP it does not relate to any half decent programming practives. Each ‘tag’ in the templates is actually a PHP function and some of them print a string, some of them return a string, and some of them have an argument to say whether they print or return. Don’t get me started on everything being global…

At first I thought I would have to write some code from scratch to migrate the existing entries into the WordPress tables but I was pleasantly surprised when I found that WordPress comes with a RSS import script. I did have to modify the RSS generator in my old blog to both include all entries as well as the complete text of each entry but that was fairly trivial which allowed my to discover a bug in the import script. WordPress stores two dates with each entry, the date in GMT/UTC and the date with the desired offset, and in the import script these were back to front which meant that all my posts were imported with a date twenty hours different. This was fairly straightforward to correct and I suppose that I should contribute my changes so no one else has this problem.

The final task involved in the migration was to insert some rewrite rules to redirect requests for my old blog over to the new one. Initially I was going to lookup the old style 12 digit time/date string in the database to determine the exact url to redirect to but I realised that they were wrong anyway because of when I changed back from daylight savings (I’m not going to bother with that in the future) so instead I just extract the date and redirect to the appropriate day archive. The only time this will fall down will be when I posted close to midnight…

My next task (well the next task related to my blog) is to get the trackback functionality up and running and after that are investigations into the numerous plugins that are available…

Tagged with: ,

Five day weekend… what to do?

Thursday, March 24th, 2005 at 09:43pm

Due to Good Friday, Easter Monday and Easter Tuesday all being university holidays I am now facing a five day weekend. Although I will end up sleeping or watching movies for most of it I might as well entertain the delusion that I might get something constructive done.

These things may be:

  • Actually visit a number of bike shops in order to find a replacement as my current bike is getting very worn out.
  • Move a signifigant number of items from my computer collection in order to be able to paint the room they currently occupy.
  • Finish creating a WordPress template that mimics the look of this blog so I can migrate to it.
  • Something else…

Tagged with: , ,

Not Invented Here (NIH)

Friday, March 11th, 2005 at 08:25pm

Today I came to the realisation that I am currently afflicted by NIH syndrome with respect to this very blog. Yesterday I was talking about how I was planning to modify this hacked together blog system in order to have more transparent URLs. This is just one of the features that I was planning to add.

For a while I have known about WordPress, an open source PHP and MySQL based blog system, which actually has all the features I was planning. So why should I spend my time writing something from scratch when I could simple take an existing system and adjust it to my needs? Good question…

Tagged with: ,