Kontactr WordPress plugin

My friend, Shankar Ganesh, is involved with Kontactr which provides an easy way for people to let others contact them. After some talk with my friend about implementing it as a plugin on the WordPress side, today I am going to do a quick post on Kontactr implementation on WordPress. Its very basic at the moment but I just wanted to show that adapting it to be a WordPress plugin is certainly very easy.

<?php
/*
Plugin Name: Kontactr WordPress Plugin
Plugin URI: http://blog.ashfame.com/?p=880
Description: Provides a shortcode which you can use to embed Kontactr form in your page
Author: Ashfame
Author URI: http://blog.ashfame.com/
License: GPL
Usage: [kontactr id=78523] in a post or page and <?php echo do_shortcode('[kontactr id=78523]'); ?> in your theme anywhere
*/

add_shortcode ( 'kontactr', 'kontactr_handler' );

function kontactr_handler( $atts, $content = null )
{
	extract( shortcode_atts( array(
		"id" => 0
		), $atts ));

	if ( $id == 0 )
		return;
	else
	{
		$output = '<script type="text/javascript"> id = '.$id.'; </script>
			<script type="text/javascript" src="http://kontactr.com/wp.js"></script>';
		return $output;
	}
}
?>

You would need to take your ID from your Kontactr account, and then use it as follows:

 [kontactr id=78523] 

78523 is my ID. So replace it with your own.

You can also use this shortcode anywhere in the theme as

 <?php echo do_shortcode('[kontactr id=78523]'); ?> 

Download Kontactr WordPress plugin

If you have any questions, ask them in the comments section.