Browse Category


Plugin developer, Core contributor and support volunteer. Yeah, I’m a WordPress fan!

Add Twitter links to your WordPress posts

Want an easier way to add links to Twitter user pages? Here’s a quick solution.

Add the following code to your functions.php file within your theme folder…

Now, you simply need to simply specify a Twitter username within square brackets and it will be replaced with the same username, but now with a link to Twitter.

For example, add [@dartiss] to your post and it will display as @dartiss.

Decoding a WordPress Post Title

By default, get_the_title and the_title will return the title of the current post. It’s stored in the database in plain text, however, when returned using the aforementioned functions if appears to be encoded. This means that characters such as ampersands and apostrophes will be converted to equivalents that are more HTML friendly.

Unfortunately, passing, say, this title to Twitter, via the URL, causes problems. First you have to URL encode and the mixture of the HTML encoding and the URL encoding produces a mess that Twitter simply doesn’t cope with very well.

However, the standard HTML decoding in PHP didn’t seem to work 100% with, for example, apostrophes not being decoded. After much head scratching and some frustration I found that this was due to the parameters that I was using.

The following line will correctly decode the post title to plain text…

To then encode is to be passed via URL, then simply use this…

It seems obvious now 😉

Displaying Code in WordPress

I often have the need to display code within this blog – whether it’s JavaScript, PHP, XHTML or something else.

There are many plugins available that will display any such code in a nice manner – usually with syntax highlighting – but, as yet, I’ve been unable to find one that doesn’t fulfil my requirements. And personally, I don’t think my requirements are that much.

Showing the code in a fixed font, with a decent line wrapping facility and the ability to display spaces and/or tabs, I don’t think, is a big list of needs. That list doesn’t even include the ubiquitous syntax highlighting.

In the end I created a half-arsed version of my own. In fact, it’s not even a plugin – just simply some CSS for displaying the code in reasonable manner. Unfortunately, it doesn’t get around the line wrapping problem.

So, imagine my surprise to come across a plugin the other day that seemed to resolve all these problems. And it does Syntax Highlighting. I had some initial problems, which involved me having to move my aforementioned CSS, and then, with no further testing, I started busily converting my posts to the new system. Note, me specifically mentioning my lack of testing. Because, yes, after changing lots of pages and posts, I realised that it wouldn’t work with spaced or tabs, so all lines of code were aligned down the left hand side of the screen. Bah. And I can’t find a solution, so I’m in the process of putting it all back to how it was.

If ANYBODY knows a plugin that will do what I’m after, then please let me know!

WordPress Plugins and File Fetching

A number of my recent plugins have provided a facility to read files from other sites. However, errors were being reported by some users and so I attempted a change in one such plugin to address this.

Unfortunately, that didn’t quite work as I intended. Kind of. In this case, I swapped to using a different file routine, but one which now only works with PHP 5. So I’ve now published a newer version of the same plugin using another new method, and one that should now be compatible with PHP 4.

The problem here is that there are security implications with reading files externally, so there is a way for hosts to turn this ability off.

My new plugin, I suspect, doesn’t actually resolve this and there isn’t a great amount I can do about this – if your host has decided to prevent you from reading external files then, well, you’re stuffed. My host doesn’t, which might explain why I didn’t recognise the problem at first.

The file system I’ve used now, however, should allow you to specify local file names – at least that way files hosted by yourself should be readable. I’ve not tested it though, so feel free to provide feedback.

I’m now going to upgrade my other plugins with the same code process.

Change logs for WordPress plugins

The standard readme.txt for WordPress plugins has been updated to allow for changelogs. This is excellent news and has happened at just the right time – I’m currently updating my readme.txt files to reflect that my plugins are compatible with WordPress 2.8!

Therefore, and slowly for now, I’m updating all my plugin readme.txt files. The appropriate pages for each plugin on this site, however, will change only if/when a new release of a plugin is released.

Further WordPress upgrade issues

Since upgrading to 2.8 I’ve come across another issue. However, I’ve seen numerous people reporting the same problem after upgrades to previous WordPress versions, so I don’t think this is 2.8 specific.

Anyway, I couldn’t automatically update any of my plugins. I was getting an error along the lines of…

Could not copy file: /public_html/wp-content/upgrade/.....

This was also the error that stopped me from automatically updating WordPress as well. Anyway, the fix was simple – I used my FTP application to change the permissions on the upgrade folder. This seemed to cure it.

Firefox crashes when inserting WordPress image

Just had a problem with Firefox crashing out everytime I tried to insert an image into the post. It’s a bit weird as it was working only the other day.

Anyway, a search found that the fault lies with Google Gears. Disabling it fixes the problem.

Social Bookmarking in WordPress

At the time of writing this post you’ll probably notice (and it has been there a while) a “ShareThis” option at the bottom of each post and page. This allows readers to share the details on one of many Social Bookmarking sites using the popular ShareThis service 1.

Unfortunately, using a third party such as this does present problems. First of all it’s not the smallest 2 and it does rely heavily on JavaScript, which causes problems if you want to add a share facility in a news feed. They also spend a lot of the time trying to further push their service, adding on facilities you may now want and constantly trying to get the user to sign up. Not only that, but to be all things to all sites, it present a very long list of  bookmark possibilities. If anything, this is more than likely going to confuse the amateur user.

And, back to the technical downsides, you’re often reliant on third party apps to provide the bookmarking system on your site, which limits what you can do. Well, it’s either that or learn their API.

The BBC uses it’s own method and that’s to simply present a few of the most popular – it doesn’t use JavaScript, just simple images and links to the resultant bookmarking sites. And, because it doesn’t use JavaScript, you can stick the same details on the bottom of your news feeds. So, you lose access to some of the less popular bookmarking services – is that a great problem? They often come with their own bookmarklets and plugins anyway.

So, over the coming weeks you will find the ShareThis plugin being replaced with seperate bookmarking options. Yes, I will be writing this as a plugin which I will then publish – it will integrate Simple Twitter Link and Simple Facebook Link as well. But I digest

Here, simply because I had to compile them anyway, are the URLs required for some of the more popular social bookmarking services…

Delicious –[url]&title=[title]
Digg –[url]&title=[title]
Diigo –[url]&title=[title]
Facebook –[url]&t=[title]
Fark –[url]&h=[title]
reddit –[url]&title=[title]
StumbleUpon –[url]&title=[title]

In all cases, replace [url] with the URL and [title] with, erm, the title.

  1. and, as always, other such services exist elsewhere![]
  2. as in terms of code size and, therefore, the speed of your site[]

Writing WordPress plugins – what I’ve learnt

On January 28th of this year I made available my first WordPress plugin – Simple AdSense Insert. I now have 6 in my portfolio, with another 2 about to be published. And in this short amount of time I’ve already learnt a few things.

  1. Users don’t talk to you much, unless something isn’t working. Not that it’s a bad thing – I’ve been able to tweak instructions and even create new versions of my plugins thanks to this kind of response. However, I’d love to hear about what people would like to see in the way of improvements or even new plugins!
  2. Users don’t donate 😉 So I’ll just have to keep trying to make my money from advertising!
  3. Niche products aren’t so popular. I’ve created plugins for Wakoopa, TheThingsIWant and Readbag, but all have failed to do well. However, those for Twitter, Adsense and PayPal are doing a lot, lot better.

To demonstrate my last point, here is a graphical representation of how many people have downloaded my current plugins…


Pretty conclusive. Having said that, some of those result are scewed because of the length of time the plugins have been made available. So let’s change the results to represent the number of downloads over the days the plugin has been available…

Graph 2

Wow, that makes a huge different to my code embed plugin – the only one of the popular ones that isn’t somehow linked to another product.

In this case it’s popular, well, because it’s not linked to another service and it’s filling a role that doesn’t currently exist. When I wanted to put some code into my posts I couldn’t find a plugin to do it. There was one but the author kept the download to his site 1 and insisted on your email address (for sending you emails at a later time all about his other great stuff) before letting you know how to download it.

And this is it – populariting comes through one of two things.

  1. A link to a service – money making or social networking – that’s rather popular
  2. Being unique and providing a service that people are looking for

Now all I need to do is think of that one plugin that ticks both boxes. Of course, if you have an idea, I’m happy to hear your views!

  1. if it’s not on the WordPress plugins site it won’t automatically inform you when a new version is available[]

Improving WordPress Search : Update

A couple of months ago, I talked about improving the search facility built into WordPress. However, soon after, I also mentioned problems I was having with the plugin Search Unleashed.

Sadly the plugin is no better and I’ve had it disabled all this time.

The friend that I originally researched this all for reported, however, that Search Unleashed was not reporting by relevance after all. Since then I’ve seen details on Better Search, an alternative plugin that (supposedly) does provide relevance-based results. I’d try it out and report back back but after my initial activation, I deactivated it again. Rather than build upon your existing search template, it uses its own. So, by default, the search page doesn’t even look like your theme – you have to start the layout, etc, from scratch. That’s not something I’d like to do unless I really wanted to use the plugin. And I’m not that fussed.

But if anybody else does give it a go, please let me know!