Tag Archives: WordPress

Associating urls created with bit.ly API to your account

Recently while working on adding the feature to enter your own bit.ly API key to my Easy Retweet WordPress Plugin, I found out that by default all short urls created using bit.ly API (both REST and JavaScript API’s) are not associated with your account.

Upon further researching I found that there is an undocumented way of associating the urls created with your account. The undocumented way is to add an additional parameter called history with value 1 to the API URL.

Using the history parameter in bit.ly’s REST API

So for REST API, you have to use the following url.

http://api.bit.ly/shorten?version=2.0.1&longUrl=http://sudarmuthu.com&login=bitlyapidemo&apiKey=R_0da49e0a9118ff35f52f629d2d71bf07&format=json&history=1

If you are using PHP, then code would be

function get_bitly_shorturl($longurl) {
	$url = "http://api.bit.ly/shorten?version=2.0.1&login=bitlyapidemo&apiKey=R_0da49e0a9118ff35f52f629d2d71bf07&format=json&history=1" . "&longurl=$longurl";

	//using curl
	$curlObject = curl_init();
	curl_setopt($curlObject,CURLOPT_URL,$url);
	curl_setopt($curlObject,CURLOPT_RETURNTRANSFER,true);
	curl_setopt($curlObject,CURLOPT_HEADER,false);

	$result_json = curl_exec($curlObject);
	curl_close($curlObject);

	//decode JSON. Assumes that it is PHP5
	$result = json_decode($result_json);

	return $result['results'][shortUrl];
}

If you are going to use it in WordPress, then you can use the inbuilt WP_Http class instead of curl as suggested by Ozh. The following code shows you how it can be done in WordPress

function get_bitly_shorturl($longurl) {
	$url = "http://api.bit.ly/shorten?version=2.0.1&login=bitlyapidemo&apiKey=R_0da49e0a9118ff35f52f629d2d71bf07&format=json&history=1" . "&longurl=$longurl";

	//using WP_Http present in WordPress
	$request = new WP_Http;
	$result_json = $request->request($url);

	$result = json_decode($result_json);

	return $result['results'][shortUrl];
}

Using the history parameter in bit.ly’s JavaScript API

If you are using bit.ly’s JavaScript API, then it is not as straight forward as the REST API. Instead of using the provided shorten method, you have to use the low level call method.

The following code shows you how you can do it in JavaScript API.

BitlyClient.call('shorten', {'longUrl':'http://sudarmuthu.com', 'history':'1'}, 'BitlyCB.shortenResponse');

I am not sure why bit.ly is not associating the created shorturls automatically with your account, when you provide the API Key, it is the expected default behavior. Or at least they could have documented about this history variable in their API. I guess only someone from bit.ly can answer this. 🙂

Posted in API's/Mashup, JavaScript/jQuery, WordPress | Tagged , , | 8 Comments

Proper way to display logout link in WordPress

Recently, I was debugging an issue with logout for a friend who was running a WordPress blog. His theme had a logout button in the sidebar, which stopped working after he upgraded to the latest version of WordPress from a pretty old version.

After some debugging, I found that the nonce value was missing from the logout link. In older versions of WordPress, the nonce value was needed, but in newer versions, we need to pass the nonce value to perform the logout.

wp_logout_url

We need not append the nonce value manually, instead we can use build-in function wp_logout_url(). This function will automatically append the nonce value to the logout link.

If you want the user to be redirected to the current page he is viewing, after logging out, you can use the following code snippet.

<a href="<?php echo wp_logout_url();?>&redirect_to=<?php echo $_SERVER['REQUEST_URI']; ?>"><?php _e('Logout'); ?></a>

Posted in WordPress | Tagged , | 1 Comment

Posts By Tag 0.3

Just a quick note, to let you all know that I have updated my Posts By Tag WordPress Plugin to version 0.3

Features

The following are the changes in the new version

Improvements to caching

Now the Plugin caches the entire HTML generated by the widget, not just the query which is used to retrieve posts. This should improve the performance of the Plugin and will reduce some mill-seconds of your page load time, if you have enabled caching.

Turkish Translation

The credit for this goes to Yakup Gövler. I have checked in the Turkish .po and .mo files, in this release.

If you are willing to do translation for the Plugin, use the pot file to create the .po files for your language and let me know. I will add it to the Plugin after giving credit to you.

Update

You can download the latest version of the Plugin form its home page. It is an optional update and doesn’t change anything in the front-end.

Feedback

As usual, if you have any feedback, queries or questions, feel free and leave a comment.

Posted in Plugin Releases | Tagged , , | 4 Comments

Easy Retweet now supports creating shorturls using your own bit.ly API key

I have added some new features and fixed a couple of bugs to my Easy Retweet Plugin after the recent update.

Specifying your own bit.ly API Key

Now you can specify your own bit.ly API key to create shorturls and associate them to your own bit.ly account, instead of using the build-in default account.

The main use of this feature is that, now you can track the clicks and stats for these shorturls from your bit.ly account dashboard. But be warned that, once option is enabled, the Plugin will create shorturl for all posts in your blog. Your bit.ly account might become a mess, if you have large number of posts in your blog.

Screenshot

The following is the screenshot of the admin UI with the new features

easy-retweet-new-settings

Download

You can download the latest version of the Plugin from the Plugin’s homepage.

Feedback

Please keep the feedback coming and if you want me to add any new features or find a bug, please leave a comment.

Vote for the Plugin

If you have used this Plugin and like it, please vote it and help me win the WordPress Plugin competition.

Posted in Plugin Releases | Tagged , , | 6 Comments

Time to update. WordPress 2.8.3 have been released

The title says it all. WordPress 2.8.3 have been released and it’s time to click your update button one more time.

WordPress 2.8.3 fixes the privilege escalation issues, which was not fixed properly in WordPress 2.8.1, which affects blogs that have multiple authors, with some of them having limited access to screens in the admin UI.

Since it is a security release, it is highly recommended that you update. Happy updating 😉

Posted in WordPress | Tagged | 2 Comments

Help me win the WordPress Plugin competition

As you would have probably known by now, I am participating in the WordPress Plugin competition and have submitted 5 Plugins for it. (Not sure if it is the highest by an individual and also if they have a prize for it 😉 )

The following are the list of Plugins that I have released for the competition, with their description and voting url.

Easy Retweet

Easy ReTweet is a WordPress Plugin, which let’s you add retweet or Tweet this buttons for your WordPress posts, together with the retweet count.

Geo Mark

Geo Mark is a WordPress Plugin which will automatically locate Geo information in your WordPress posts using Yahoo Placemaker and YQL API’s.

Posts By Tag

Posts by Tag WordPress Plugin, provides sidebar widgets which can be used to display posts from a specific set of tags in the sidebar.

WP IRC

Well WP-IRC Plugin can fetch the number of users online in any IRC channel and can be scheduled to auto refresh it every x.minutes.

Tweetbacks Helper

Tweetbacks Helper is a helper Plugin for Tweetbacks Plugin to help it detect more tweets.

So if you have used any of these Plugins and like it, then please do vote for them at the Plugin Competition blog and help me win the competition. 🙂

I am planning to continue develop them and so if you have any feedback/comments or feature requests then do leave a comment in the particular Plugin’s page.

Posted in WordPress | Tagged , , | 8 Comments

Helper Plugin for Tweetbacks

Tweetbacks is a great Plugin created by Yoast, which can be used to retrieve tweets about your blog posts from Twitter and import them as comments in your WordPress blog.

This Plugin automatically populates the short urls of your blog posts permalink from a couple of url shortening services like tinyurl, isgd, snipr etc. But since I am planning to use my own url shortening service I wanted an interface, where I can add my own short urls.

More over, Tweetbacks uses the built-in Pseudo cron of WordPress to schedule tweet retrievals. I wanted to get away with this since it might increase the page load time. Instead I wanted to use the built-in crontab in my server, hosted at Linode.

Tweetbacks Helper Plugin

So the result is my new Tweetbacks Helper WordPress Plugin. 🙂

Tweetbacks Helper Plugin can be used to disable/enable Tweetbacks scheduler or the cron scheduler. It also provides a url which can be pinged from my crontab.

 

In the write post page, this Plugin adds a small box on the right hand side with the list of short urls which Tweetbacks has found. There is a also a provision by which other short urls can be added.

 

Download

You can download the Plugin from the Plugins homepage.

Translation

The pot file is available with the Plugin. If you are willing to do translation for the Plugin, use the pot file to create the .po files for your language and let me know. I will add it to the Plugin after giving credit to you.

Feedback

Please keep the feedback coming and if you want me to add any new features or find a bug, please leave a comment.

Vote for the Plugin

If you have used this Plugin and like it, please vote it at the Plugin Competition Blog to help me win the WordPress Plugin competition.

Posted in Plugin Releases | Tagged , , | 2 Comments

Display number of people online in an IRC channel in WordPress sidebar

Time for one more WordPress Plugin from me. 😉

I wrote this Plugin some time ago to be used in proto.in but was never got time to release it to the outside world. The code was sitting in my disk for sometime, and the WordPress Plugin competition motivated me to dust of the code, update and release it.

Well WP-IRC Plugin (for lack of a better name 😉 ) can fetch the number of users online in any IRC channel and can be scheduled to auto refresh it every x minutes.

The count thus fetched can be displayed in the sidebar of your blog using a sidebar widget provided by the Plugin.

You can also allow users to subscribe to email alerts like, “alert me after x number of people has come online”.

Screenshot

Download

You can download the Plugin as a zip file from the Plugin’s Homepage.

Feedback

Please keep the feedback coming and if you want me to add any new features or find a bug, please leave a comment.

Vote for the Plugin

If you have used this Plugin and like it, please vote it at the Plugin Competition Blog to help me win the WordPress Plugin competition.

Posted in Plugin Releases | Tagged , , | 7 Comments

One more way of adding retweet buttons to posts in WordPress

I have added some more new features to the Easy Retweet Plugin after the recent update.

Support for shortcode

Easy Retweet Plugin now supports shortcodes. Now you can place the retweet button anywhere (and even within) in the post. All you have to do is just to include the following shortcode, where you want the button to be displayed.

[ easy-retweet ]

The above shortcode will be replaced with the retweet button when the post is rendered. Cool hah? 🙂

Adding prefix to the Twitter message

The other new feature is that, now you can specify any text as prefix for the Twitter message. You can add your own twitter username or any other message that you wanted to be prefixed.

The following is the screenshot of the admin UI with this feature.

easy-retweet-new-settings-ui

Apart from this I have also made some performance improvements to the Plugin, which will work behind the scenes.

Download

You can download the latest version of the Plugin from the Plugin’s homepage.

Feedback

Please keep the feedback coming and if you want me to add any new features or find a bug, please leave a comment. By the way Easy Retweet Plugin was featured in this week’s episode of WordCast. Thank you guys.

Vote for the Plugin

If you have used this Plugin and like it, please vote it at the Plugin Competition Blog to help me win the WordPress Plugin competition.

Posted in Plugin Releases | Tagged , , | 2 Comments

Display posts from a set of tags in the sidebar

Recently I was looking for ways to display posts from a specific set of tags in the sidebar.

I preferred a sidebar widget rather than making changes directly to the theme files, because if I am using a widget I don’t need to remember to make the change again when choosing a different theme.

A quick search didn’t yield any results which made me to write my own Plugin and thus the Posts By Tag WordPress Plugin was born.

Features

Posts By Tag Plugin provides a sidebar widget (using the new Widget API provided in WordPress 2.8) which can be configured to display posts from a set of tags in the sidebar. You can have multiple widgets with different set of tags configured for each one of them.

Each widget allows you to choose

  • The set of tags whose posts should be displayed
  • The number of posts to be displayed.
  • Option to enable post excerpts to be displayed with post titles.
  • Option to display post thumbnail if present.

Caching

The Plugins caches the posts of each widget separately, and issues database queries only when needed. This will reduce the amount of database queries involved for each page load and will therefore be light on your server.

Screenshot

Tag Posts Widget Settings

Download

You can download the Plugin from the Plugin’s home page. After downloading the zip file, extract it and upload the contents to the wp-content directory. Activate the Plugin from the Plugins page and you should see a new widget called “Tag Posts” in the widgets pages.

Feedback

As usual try out the Plugin and do let me know if you have any feedback, queries or comments.

PS: I am using the built-in tags auto-complete script used in the Write Post page. I will write a separate post explaining how to integrate tags auto-complete script in your Plugins.

Posted in Plugin Releases | Tagged , , , | 5 Comments