nuzzaci External Links; a Wordpress plugin
Background, similar to wikipedia.org, I have a small icon next to all links that will take you away from this site. Up until now I’ve been using a javascript function that I wrote and posted back in December 2006 to find all external links and add the icon. It’s quite a flaky and… ugly script, so I though it would be a good idea to revisit the issue and give it another go.
Thoughts, first I though I would just use the brilliant jQuery javascript library and turn my 10+ lines into 4. This might be a method many would recommend and suggest, but similar to when I approached the “Flickr images are a bit to wide” issue with the nuzzaci Width Watchers plugin, I thought — why not do it server side?
Solution, So, let me present the nuzzaci External Links wordpress plugin. It fairly straight forward.
This plugin will look through your posts before they get displayed and either modify the existing class attribute or create a class attribute with the value external to all links that don’t link within the current domain name. It will ignore all links without http:// and all links where the node is an image. This plugin doesn’t touch the database.
View the script here, and download it here
(the 4 line javascript solution using jQuery can be found here).
Instructions, Download the file, upload it to your plugin folder, log on to your admin section and activate it. Before you see any visual difference on the external links you’ll need to define how you want the class ‘external’ to look like. Here’s an example how you get all external links to look like wikipedia’s external links.
I’m using wordpress 2.0.5, but don’t see why this plugin shouldn’t work on all versions.
Version History
- v 0.1, Launch.
