WordPress Toolbar Plugin

Checkout WordPress Toolbar Version 2.2 Release Blog.

This plugin is a result of day to day observations of my wordpress blog stat. I analyzed that 75% of my blog’s visitors were leaving my blog posts by clicking one of the out going links either to my code.google project pages or to an external source of information. However, I doubt how many of them were coming back to leave a comment or to bookmark/share my blog post on one of the social bookmarking sites. I can say this because, even I too forget to press the browser back button and visit the blog again.

However I observed that I was clicking the link back on stumble floating toolbars and facebook external links toolbar. And hence came WordPress Toolbar Plugin (upgrade to 2.0 with Admin Panel). In short:

download-wordpress-plugin

WordPress Toolbar is a unique plugin which will automatically enable a toolbar for all outgoing links from your blog post, similar to stumbleupon and facebook. Often the visitors on your blog clicks one of the outgoing link for more information. However, s/he often forgets to comment back or social bookmark your blog. WordPress toolbar will float on the top of all these outgoing links from your blog post, showing options for either visit back your blog post from where s/he came from, comment back on your blog, social bookmark you blog in one of the famous bookmarking sites and finally an option to leave this toolbar.

This is my first wordpress plugin and I have just got my subversion repository access on wordpress.org. I have checked in this version of plugin and you can download the same from the download link above. You can experience the wordpress toolbar by clicking this link: http://abhinavsingh.com . As you click this, you will see a brownish black toolbar floating at the top of the yahoo.com page using which either the users can come back to comment on this blog post or they can use one of the social bookmarking images to share this blog post.

Introductory Features of WordPress Toolbar:

  1. A link back to your blog home
  2. A link back to your blog post from where he visited the external link
  3. A comment back link to originating blog post
  4. Various social bookmarking links to share, promote and bookmark your blog post
  5. Finally a close button, with which he will exit the wordpress toolbar
  6. An admin panel to configure and customize all of the above options

How to install WordPress Toolbar:

  1. Before proceeding with this version 2.x, you should DEACTIVATE any active 1.x series plugin
  2. Remove /blog/toolbar.php which you must have copied while activating 1.x version
  3. Remove /blog/wp-content/plugins/wp-toolbar directory fully. You will no longer need this
  4. Download the plugin
  5. Extract the plugin into `/wp-content/plugins/wordpress-toolbar` directory
  6. You will see one directory named `extra` which contains required images and css (DO-NOT-TOUCH-THIS-FOLDER)
  7. You will see 2 files named: wp-toolbar.php and toolbar.php (DONT MOVE THEM ANYWHERE)
  8. Activate the plugin
  9. Go to WPAdmin => settings => `wordpress toolbar` and customize the toolbar
  10. Bingo!

Version Change logs:

  1. Version 2.0 : Version was upgraded since 2.0 is a complete overhaul from 1.x series. Specifically it allows you to do the following:
    • You can now use auto upgrade for future releases without caring to move the plugin files everytime
    • Admin panel allows you to fully customize your toolbar
    • You can now ever choose social icons of your choice to be displayed on the toolbar
    • Choose domains for which you don’t want to activate this plugin
    • Unlike 1.x series, 2.0 do not change the href=”” urls. Instead now it uses javascript onclick event to activate toolbar and hence taking care of your SEO needs
  2. Version 1.1 : Include emergency CSS and HTML Validation fixes for IE browsers
  3. Version 1.0 : The first release of wordpress toolbar

Planned Future Releases:

  1. Include support for wordpress blogs hosted on PHP4, currently they are facing issues
  2. Include an options for inserting target=”_blank” for all outgoing links
  3. Club Socialble plugin into wordpress toolbar – Since wordpress toolbar already consists of all the social networking favicons, you may want to have a similar copy for a different plugin. Hence one of the next releases will include support for inserting social icons on your blog
  4. Club Google Analytics plugin into wordpress toolbar – Currently wordpress toolbar plugin inserts a onclick=”” event for all out going links which enables the toolbar for the link. However if you are a user of Google Analytics Plugin, then you might face a few issues. Mainly because Google Analytics Plugin too tries to insert an onclick=”” event for all outgoing links. Which finally clashes with wordpress toolbar onclick=”” event. Clubing both will allow you to enjoy plus points of both the plugins.

Do leave a comment or any suggestion for improvement.

Programatically control your google mails using JAXL v 1.0.4

Google has released an API for almost all of their products including maps, feedburner and gadgets. However one of the API’s which every developer would have loved to make use of is “Google Mail API” which is still missing (available for premium google apps user only). Here in this post I would demonstrate how one can programatically control his/her google mails using JAXL without being a premium user of google mail account.

For those who have landed on this post straight and have little knowledge about what JAXL is “JAXL stands for Jabber XMPP Library and for fun you may call it Just Another XMPP Library. It is written in PHP and can be downloaded from http://code.google.com/p/jaxl“. To know more about JAXL, read the introductory post here. If you want to dig deep and know how JAXL works, read the gtalk case study here. Finally, after reading this post you may also want to check how you can fetch any social networking feed right into your gtalk messenger using JAXL.

Version 1.0.4 of JAXL included support for “Gmail Notification Extension of XMPP“. If you are a daily Gtalk user like me, then you have surely seen this extension in action. Just recall Gtalk notifying you of a new mail in your inbox, through a pop-up in the bottom right corner. Also those who see this in action everyday will agree with me that this notification comes even before the mail has actually appeared in you inbox. Simply because of the PUSH technology used by XMPP protocol.

So why would you in first place be interested in accessing your google mails programatically. A quick thought on this brings me to the following real life scenarios:

  • Suppose your are out of vacation and you want to set a custom auto-reply message for your family and friends, while you want to set a general out-of-office message for your colleagues. The limitation in gmail is that you can’t really do this. Further in this post, I will show you how can you achieve this using JAXL.
  • Suppose you are a google app user and your company has organized an online programming contest. Further you want to mail each question to the contestants only if they has answered the previous question. JAXL provide you a way to access key information about your incoming mails like: sender email id, subject, number of threads in the mail, time at which mail was sent, mail url and mail snippet. Which is enough for you to code a bot which can check for incoming mail and then send in next question to the contestant who sent this mail
    1. Further there can be a thousand use cases where you would you like to have such a control over you google mails but before discussing them, lets see a demonstration on how can we use JAXL to achieve this.

      Sending Custom Auto-Reply Mails using JAXL
      Along with extendable functions like eventMessage() and eventPresence(), JAXL’s latest version now also provide another extendable function called eventNewEMail(). So everytime you receive a new mail(s) in your google account, the control is passed to this function along with all informations about the incoming mails.

      Various data passed to this function are:

      • $total: Tells you about total number of unread mails.
      • $thread: The thread id of all the unread threads. Note: In Gmail you have threads in your inbox which can contain more than a single mail.
      • $url: The mail.google.com url for the new mail
      • $participation: This can be 0, 1 or 2. 0 indicates that you have not participated, 1 indicates that you are one of the many recipients and 2 indicates that you are the sole recipient for messages in this thread
      • $message: The number of messages in the thread. For instance you can have more than one unread mail in a thread.
      • $date: A timestamp of the most recent unread message, in milliseconds since the UNIX epoch
      • $senders: Email Id of all the senders in the current thread
      • $labels: Label if any to which this mail thread belongs to
      • $subject: The subject of the mail threads
      • $snippet: The mail snippet of the incoming mail

      So thats a lot of information really, with which we can automate things to a certain extent. Lets see how I use it to send custom auto-reply mails when I am out on vacation. Here is the extendable jaxl class for gmail:

      jaxl4gmail.class.php (Download)

        /* Include PHP Mailer Class */
        include_once("class.phpmailer.php");
      
        /* Include XMPP Class */
        include_once("xmpp.class.php");
      
        class JAXL extends XMPP {
      
          /* Define custom mail groups */
          var $family = array("mom@gmail.com","dad@gmail.com");
          var $colleague = array("boss@company.com","manager@company.com");
      
          /* Define custom mail subject and message */
          var $familySubject = "Hi, Will get back to you";
          var $familyMessage = "Hey, I am currently out on vacation at my grannies house in Delhi. I will return back home by next monday.
      Reach out to me at +91-987654321.

      With Love,
      Abhinav Singh"; /* Define custom mail subject and message */ var $colleagueSubject = "[Auto-Reply] Out of Office"; var $colleagueMessage = "Hi, I am on vacation in my village with very limited access to internet and phone. I will return back home by next monday.

      Regards,
      Abhinav Singh"; function eventMessage($fromJid, $content, $offline = FALSE) { } function eventPresence($fromJid, $status, $photo) { } function eventNewEMail($total,$thread,$url,$participation,$messages,$date,$senders,$labels,$subject,$snippet) { // We only want to send auto-reply message to latest sender $sender = $senders[0]; // Check if the user lie in any category, and send appropriate mail if(in_array($sender["address"],$this->family)) { $mail = new PHPMailer(); $mail->From = "youremailid@gmail.com"; $mail->FromName = "Your Name"; $mail->Subject = $this->familySubject; $mail->MsgHTML($this->familyMessage."

      Powered by Jaxl http://code.google.com/p/jaxl"); $mail->IsHTML(true); $mail->AddAddress($sender["address"],$sender["name"]); if(!$mail->Send()) $this->logger->logger("Error occured while sending mail to ".$sender["address"]); else $this->logger->logger("Mail sent successfully to ".$sender["address"]); } else if(in_array($sender["address"],$this->colleague)) { $mail = new PHPMailer(); $mail->From = "youremailid@gmail.com"; $mail->FromName = "Your Name"; $mail->Subject = $this->colleagueSubject; $mail->MsgHTML($this->colleagueMessage."

      Powered by Jaxl http://code.google.com/p/jaxl"); $mail->IsHTML(true); $mail->AddAddress($sender["address"],$sender["name"]); if(!$mail->Send()) $this->logger->logger("Error occured while sending mail to ".$sender["address"]); else $this->logger->logger("Mail sent successfully to ".$sender["address"]); } else { // Do nothing, will handle later on $this->logger->logger("No handler for this email id..."); } } function setStatus() { print "Setting Status...n"; $this->sendStatus("Available"); print "Requesting new mails...n"; $this->getNewEMail(); print "Donen"; } }

      The only variables you would like to change in above class are:

      1. $family : An array of email id of your family member
      2. $colleague : An array of email id of your colleagues
      3. $familySubject : Subject with which you want to send mails to your family members
      4. $familyMessage : Mail message which you want to send to you family
      5. $colleagueSubject : Subject with which you want to send mails to your colleagues
      6. $colleagueMessage : Mail message which you want to send to you colleagues

      For further customization, you may want to add more groups and their respective subjects and messages.

      Further you may want to create your own custom bots using JAXL for one of the other use case described above. Join official JAXL Google Group for future updates and enhancements.

      Do let me know if you build any custom bot using JAXL, I will be more than happy to list your bot on official JAXL google code page.

      Enjoy!