WordPress: Twitter Friendly Links Plugin. Stage Two

Missed the beta? No problemo! Just a flashback – the plugin transforms permalinks on your blog into short fancy links within your own domain name: https://konstantin.blog/wordpress/plugins/twitter-friendly-links/ into a short and Twitter friendly https://konstantin.blog/712 similar to what TinyURL does, remember?

I’ve updated the plugin a couple of hours ago to version 0.2. The new key features are the “Twitter Stuff” form in your edit post page, with the shortlink and an example of the message to Twitter, with a link that takes you directly to Twitter with the predefined text not more than 140 characters. Very handy indeed.

Here’s the plugin page by the way: Twitter Friendly Links and don’t forget to check out the screenshots!

Next. You might have noticed that I got a new line just under the tags list in every post – shortlink. I’ve added a function to the plugin called twitter_link() which returns the short link for a post when used within the loop. Here’s my code snippet in single.php:

if (function_exists("twitter_link")) {
    echo 'Shortlink: <a href="'.twitter_link().'">'.twitter_link().'</a>';

Make sure you use the function_exists() function to check before using, otherwise you’ll get an error message if for some reason the plugin is missing or deactivated (if you’re a Theme developer for instance).

One more thing. Most of you know Joost de Valk and his Sociable plugin. There’s a TwitThis button which takes you to Twitter.com and the predefined tweet text is simply the permalink of your post. Digging his well-written php code I managed to add my own button called Twitter, that does the same, but the predefined text is the title of the current post plus the shortlink, all trimmed to 140 characters.

So here’s my version of sociable.php (just replace the one in your plugin). Changes are on lines 518-522, 631-650 and 681. Please do not use this version of sociable.php unless you use the Twitter Friendly Links plugin, cause I haven’t written any checks before using the functions. Joost might consider this extension then polish it off in the next updates. The Twitter button may then be chosen from the Sociable section in your WordPress Settings.

8 thoughts on “WordPress: Twitter Friendly Links Plugin. Stage Two

  1. Twitted by kovshenin

  2. Twitted by mimojito

Comments are closed.