Improve WordPress Twitter Tools hashtag detection

I’m currently using Twitter Tools (a WordPress plugin) for the sidebar on this blog. I noticed that it doesn’t detect all hashtags correctly and subsequently every second hashtag wouldn’t be converted to a correct link to Twitter. Fortunately Stockoverflow saved the day again with some nice suggestions about the best RegEx for hashtags. So here is my quick’n’dirty fix (for Version 2.4 of Twitter Tools):

$tweet = preg_replace_callback(
  , create_function(

The highlighted line contains the new RegEx which should detect hashtags almost exactly as on itself. I suspect the same problem might exist for matching usernames, but so far I hadn’t problems with it and you know the old wisdom, don’t fix what ain’t broke 😉

This entry was posted in development and tagged , , . Bookmark the permalink.