If you use Twitter, WordPress, and the digest feature from Alex King’s Twitter Tools together for linkblogging, you’ve probably seen your posts getting cluttered up with unreadable links like http://bit.ly/blrD2i. That’s OK for one tweet at a time, but it can get ugly for a whole list.
This plugin hooks into the Twitter Tools digests and calls out to replace those short URLs.
- It follows redirects to update the post with the final URL.
- It tries to retrieve the title from the remote site and use it for the link text.
- If it can’t retrieve the title, it will use the hostname.
- If it can’t connect to the remote site within a few seconds, it will leave the link unchanged.
Download the latest version:
ktv-twitter-tools-nicelinks-0.9.zip
Known Issues
- It doesn’t try to convert character sets, so if you link to a page using a different charset, the title may end up messed up.
- In testing, I noticed duplicate digests popping up a bit more often than usual. I don’t know if the time spent calling out to remote sites is contributing to a race condition or if it’s a coincidence.
- No attempt is made to alter or shorten the title. It should be safe from XSS attacks because Twitter Tools runs the tweet through WordPress’ character filter after this runs, and it should be safe from broken HTML because it stops as soon as it hits another tag, regardless of whether it’s the end of the title or something else. But some websites do use very long titles, which can lead to unwieldy links. At least they’ll be more readable than http://bit.ly/9MhKVv.
Requirements
- Requires Alex King’s Twitter Tools.
- Requires PHP 5.
- Requires curl support for PHP.
- No configuration needed.
History:
- 0.9: Initial Release – October 17, 2010
See also: Twitter Tools Skip FB Plugin.
Ooooh … I have just the blog to try this with (my MMO one). An excellent idea — I love using bit.ly, for example, to do quick tweets and aggregate data for the blog, but I remain mildly concerned about the long-term health of any of the link-shorteners. This should make the Net better.
Thank you! I’m glad I could help!
[…] Plugin: Twitter Tools Nice Links | K-Squared Ramblings – Great idea! […]
Quick question: I’d prefer not to have the full title show up in the TT digest. My ideal would be just print “Link” and have the title show up as the alt/title tooltip, i.e.,
{a href=”underlying url” title=”full title or whatever we can glean”}Link{/a}
Making for neater digests and less conflicting verbiage in the digest, but still allowing folks to see what the link is going to.
I think it would be something like:
return ‘[~~url=’ . $finalURL . ‘[~~tit=’ . $title . ‘~~]’ . ‘Link’ . ‘/~~/’
and then earlier do a
str_replace ‘[~~tit’ for ‘” title=”‘
for the second $post_data = str_replace
Does that look right?
Worked like a champ (curly quote mangling above notwithstanding) (see http://hill-kleerup.org/blog/2010/12/13/tweets-from-2010-12-13.html).
Cool! Do you mind if I incorporate that into an updated version?
Certainly! I’ll send you a clean/non-curly-quoted copy of what I did.