Compatibility: Twitter Tools & Twitter Friendly Links

Due to many requests for twitter friendly links in the Twitter Tools plugin by Alex King I’ve decided to take a look. Alex King surely did a great job in his plugin by leaving a filter which I could use in my plugin without touching the sources of Twitter Tools.

The toughest thing was to find this great wordpress function called url_to_postid() which takes a wordpress URL and tries to convert it into a suitable post ID. It isn’t documented in the codex and I had no idea what keywords to use to find it through Google (was looking for permalink to post id, permalink to id. I’ve highlighted these so that other peeps could find it faster than I did).

Now I’ve got a new function available in my plugin:

echo permalink_to_twitter_link($permalink);

And of course I’ve added an option called “Twitter Tools fix” in the Settings page of the Twitter Friendly Links plugin to let you fellows decide whether you want cool short links or those nasty long ones. I ran a couple of tests on a testing Twitter account, seemed to work fine for me. Comments and suggestions are welcome as usual ;)

The fix was introduced in version 0.3.2. The AJAX/jQuery pagination was also fixed in this release. Available in the WordPress plugin directory.

Cheers!

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.

14 comments

    • Tweet? No there weren't any changes to the API as far as I know.. Are you talking about the Twitter Tools plugin? Or is it Twitter Friendly Links? I'm not responsible for the former one ;)

    • I just sent the mail out to you, so it should arrive in a few minutes.

      About shortlink / shorturl -> as long as there's no 'de-facto' standard about that I'm not sure if it's worth fighting about such details, as long as we start using something so that we can get rid of tinyurl & co ;)

      Probably it should be up to the clients who use the stuff to understand both variations anyway. At least for a start. It's not too difficult to look for both ;)

    • Got your e-mail, thanks. Couldn't reply though, delivery failed :) Good work you have there, though I'm not sure the action that goes to 'wp' is okay. I did it in 'template_redirect' that fires just before anything is echoed out, to make sure the Link: header goes last.

      And I also did a couple of checks for is_single() or is_page() and $pages_enabled to make sure the short link doesn't go everywhere.

      Oh, and rel canonical and rev canonical are also included in 0.3.4.

      Thanks for your hard work :)

    • Yes, of course. I made a seperate section in the options page called Link Relations. I'll stick to what's written in the shortlink specification on the google pages for now. Like you said before, there's no need to support both styles on server as long as the client does.

  • Any luck getting a fix for WP-Redirection, which is another popular plugin? I get "404" errors reported in that all the time and the logs have to be cleared or wordpress slows down considerably… Second, if not, is there a way to deactivate the plugin and still have folks who click on the short URL, get to the post, or is that something that I have to do for each post in HTAcess? IE, is there a regex that you can think of that would help with this? Perhaps it could be added to HTAccess or to wordpress database to prevent both of these plugins and any other 404 error plugins from detecting it? The convention that I am using is the default, which is http://www.site.com/postid – Lastly, could this be that I have force trailing slash set up elsewhere? Becuase the 404 errors that I am receiving are not for http://www.site.com/postid, but rather for http://www.site.com/postid/ Thanks in advance.