<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>iSynergy Webdesign Blog &#187; Tutorials &#8211; iSynergy Webdesign Blog</title>
	<atom:link href="http://www.isynergywebdesign.com/blog/category/web-design/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.isynergywebdesign.com/blog</link>
	<description>The Official iSynergy Webdesign Blog</description>
	<lastBuildDate>Tue, 18 Jan 2011 17:50:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>jQuery Tutorial: Rotating CSS using setInterval</title>
		<link>http://www.isynergywebdesign.com/blog/web-design/tutorials/jquery-tutorial-rotating-css-using-setinterval/</link>
		<comments>http://www.isynergywebdesign.com/blog/web-design/tutorials/jquery-tutorial-rotating-css-using-setinterval/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 18:54:09 +0000</pubDate>
		<dc:creator>Jack</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.isynergywebdesign.com/blog/?p=119</guid>
		<description><![CDATA[jQuery is essentially a web designer’s dream. It’s a javascript library that makes it easy to write javascript code for web designers (at least that’s the way I see it). It’s built to be similar in structure to the way cascading stylesheets (CSS) are written. We here at iSynergy Webdesign use jQuery quite often to [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p><a href="http://jquery.com/">jQuery</a> is essentially a web designer’s dream. It’s a javascript library that makes it easy to write javascript code for web designers (at least that’s the way I see it). It’s built to be similar in structure to the way cascading stylesheets (CSS) are written. We here at iSynergy Webdesign use jQuery quite often to do many scripting events and effects.</p>
<p>What we’ll be doing today is setting an auto rotating CSS that swaps out after a certain amount of time. This effect can be used for a variety of things, such as changing the background along with some text styles.</p>
<p>See an example of the <a href="http://www.isynergywebdesign.com/test/rotatingcss/">jQuery rotating CSS using setInterval</a>.</p>
<p><span id="more-119"></span></p>
<p>In this example, we’ll be rotating 3 CSS files (style1.css, style2.css, and style3.css). To start off, we’ll need to set our first CSS onload.</p>
<pre><code>&lt;link href="styles/style1.css" rel="stylesheet" id="stylesheet" /&gt;</code></pre>
<p>For the above code, please note that I added an id attribute. This is important because this will be the anchor reference for what we’ll be doing in a little bit.</p>
<p>Now, within the header still, but after the call of the jQuery library script (see <a href="http://docs.jquery.com/How_jQuery_Works">How jQuery Works</a>), we’ll start our script.</p>
<pre><code>var interval
$(document).ready(function() {
	var r = Math.floor(Math.random()*3+1);
	$("#stylesheet").attr({href : "styles/style"+r+".css"});
	interval = setInterval("getCSS()", 5000);// 5 secs between requests
});
var currentStyle = $("#stylesheet").attr("href");</code></pre>
<p>First we want to set a variable for the interval via var interval. This will be used a little bit below to call the function to swap the CSS after a certain amount of time.</p>
<p>After that, we’ll want to set the ready event that waits for the document to load before executing the script:</p>
<pre><code>$(document).ready(function() {

//

});</code></pre>
<p>Within that, the next few lines are where the script truly begins. The first line sets a variable to randomize a number. The count used to randomize can be altered by changing the digit that is represented by 3 within our code. We are using 3 in this case because that’s how many stylesheets we have. Feel free to change that for your personal needs.</p>
<p>The next line references the stylesheet anchor (the id we set earlier) and changes the href attribute to our randomized stylesheet. This way, a different stylesheet can be loaded each time the page is loaded.</p>
<p>The last line within the ready event is our timer. It calls a function, getCSS, every 5 seconds (represented by 5000 milliseconds). The amount of time can be changed by altering the milliseconds. We’ve set it on a short timer so it’s easier to see the effect.</p>
<p>After we close the ready event, we want to store the current stylesheet in a variable, which is represented by the last line. This variable will be used later when we rotate the stylesheet.</p>
<p>Now, we’ll write out our getCSS function, which will do the actual stylesheet rotation.</p>
<pre><code>function getCSS() {
	if (currentStyle == "styles/style1.css") {
		$("#stylesheet").attr({href : "styles/style2.css"});
		currentStyle = "styles/style2.css";
	} else if (currentStyle == "styles/style2.css") {
		currentStyle = $("#stylesheet").attr({href : "styles/style3.css"});
		currentStyle = "styles/style3.css";
	} else {
		currentStyle = $("#stylesheet").attr({href : "styles/style1.css"});
		currentStyle = "styles/style1.css";
	}
}</code></pre>
<p>We’ve added in an if statement so that when we rotate the stylesheet, we won’t rotate in a new stylesheet that is the exact one as the current stylesheet (because then, no change will be visible). So we do a check to see what the currentStyle variable (which stores what the current stylesheet href attribute is) is at the moment. If it is style1.css, then we swap in style2.css. After that, we set the new currentStyle variable to style2.css. Rinse and repeat until we’re done setting all 3 instances. That’s it.</p>
<p>The final script should look like the following (nested within a script tag):</p>
<pre><code>&lt;script type="text/javascript"&gt;
var interval
$(document).ready(function() {
	var r = Math.floor(Math.random()*3+1);
	$("#stylesheet").attr({href : "styles/style"+r+".css"});
	interval = setInterval("getCSS()", 5000);// 5 secs between requests
});
var currentStyle = $("#stylesheet").attr("href");

function getCSS() {
	if (currentStyle == "styles/style1.css") {
		$("#stylesheet").attr({href : "styles/style2.css"});
		currentStyle = "styles/style2.css";
	} else if (currentStyle == "styles/style2.css") {
		currentStyle = $("#stylesheet").attr({href : "styles/style3.css"});
		currentStyle = "styles/style3.css";
	} else {
		currentStyle = $("#stylesheet").attr({href : "styles/style1.css"});
		currentStyle = "styles/style1.css";
	}
}
&lt;/script&gt;</code></pre>
<p>One caveat for IE that is not related to the above script, if you intend on setting a background that spans the entire browser and swapping that background using the above script, you’ll need to add a few lines to your CSS to make sure the swap gets the intended effects. Mainly:</p>
<pre><code>html { height: 100%; overflow: auto; margin: 0 }

body { height: 100%; overflow: auto; margin: 0 }</code></pre>
<p>IE doesn’t seem to understand the dimensions for html and body unless it’s explicitly declared. As such, when the CSS rotation occurs, the effect doesn’t translate to the entire body of the page and only to the parts that have dimensions declared. The above should fix that problem.</p>
<p>Edit 2010/12/01: There seems to be a loading problem on some browsers (notably FireFox) that causes the page to display without any styles when it is rotating to a new CSS file. As such, we can get around this problem by pre-loading the CSS file. One method is detailed here: <a href="http://www.phpied.com/preload-cssjavascript-without-execution/">Preload CSS/JavaScript without execution</a>. We&#8217;ve also updated our test files with the preload script.</p>
<p><a href="http://www.isynergywebdesign.com/test/rotatingcss/rotatingcss.zip">Download jQuery rotating CSS using setInterval</a> (zip containing all example files from above).</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.isynergywebdesign.com/blog/web-design/tutorials/jquery-tutorial-rotating-css-using-setinterval/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>HTML Validation for Sociable WordPress Plug-In</title>
		<link>http://www.isynergywebdesign.com/blog/web-design/tutorials/html-validation-for-sociable-wordpress-plug-in/</link>
		<comments>http://www.isynergywebdesign.com/blog/web-design/tutorials/html-validation-for-sociable-wordpress-plug-in/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 16:12:24 +0000</pubDate>
		<dc:creator>Jack</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.isynergywebdesign.com/blog/?p=109</guid>
		<description><![CDATA[Once again, another post about the Sociable WordPress plug-in, which has, apparently, been taken over by a group called BlogPlay. This time, it&#8217;s about HTML Validation. If you use the sociable plugin, you&#8217;ll notice that it doesn&#8217;t validate if you use it on category post lists or any page that compiles a list of posts. [...]<h3>Related posts:</h3><ol>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-and-tracking-in-wordpress-sociable-plug-in/' rel='bookmark' title='URL Shortening and Tracking in WordPress: Sociable Plug-in'>URL Shortening and Tracking in WordPress: Sociable Plug-in</a></li>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-sociable-plugin-3-5-1/' rel='bookmark' title='URL Shortening &#8211; Sociable Plug-In 3.5.1'>URL Shortening &#8211; Sociable Plug-In 3.5.1</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Once again, another post about the <a href="http://wordpress.org/extend/plugins/sociable/">Sociable WordPress plug-in</a>, which has, apparently, been taken over by a group called <a href="http://blogplay.com/sociable-for-wordpress/">BlogPlay</a>. This time, it&#8217;s about HTML Validation. If you use the sociable plugin, you&#8217;ll notice that it doesn&#8217;t validate if you use it on category post lists or any page that compiles a list of posts. This is because the link uses an id rather than a class to identify the link. Valid HTML does not allow duplicate ids. As such, having multiple sets of sociable links on a page invalidates the page. There&#8217;s an easy fix to this, which was already incorporated into the previous <a href="http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-and-tracking-in-wordpress-sociable-plug-in/">URL Shortening and Google Tracking modifications</a> we did. However, I forgot to mention that part and how to do it. This post, hopefully, will rectify that oversight.</p>
<p>Using Sociable 3.5.1, if you look within the file, sociable.php, on line 777, note the following string of code:</p>
<pre><code>$link .= ' id="'.esc_attr(strtolower(str_replace(" ", "", $sitename))).'" ';</code></pre>
<p>Simply change the &#8220;id&#8221; to &#8220;class&#8221; and voila, it&#8217;s fixed. Your final code should look like this:</p>
<pre><code>$link .= ' class="'.esc_attr(strtolower(str_replace(" ", "", $sitename))).'" ';</code></pre>
<p>That should validate now and work just as it did before.</p>
<p>Note: If you modified the sociable.php, then the line number where the code appears may be different, simple do a search of the line of code to find where it is located.</p>
<p>That&#8217;s it. You&#8217;re done.</p>
<h3>Related posts:</h3><ol>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-and-tracking-in-wordpress-sociable-plug-in/' rel='bookmark' title='URL Shortening and Tracking in WordPress: Sociable Plug-in'>URL Shortening and Tracking in WordPress: Sociable Plug-in</a></li>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-sociable-plugin-3-5-1/' rel='bookmark' title='URL Shortening &#8211; Sociable Plug-In 3.5.1'>URL Shortening &#8211; Sociable Plug-In 3.5.1</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.isynergywebdesign.com/blog/web-design/tutorials/html-validation-for-sociable-wordpress-plug-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>URL Shortening &#8211; Sociable Plug-In 3.5.1</title>
		<link>http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-sociable-plugin-3-5-1/</link>
		<comments>http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-sociable-plugin-3-5-1/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 18:05:36 +0000</pubDate>
		<dc:creator>Jack</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[social media]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://www.isynergywebdesign.com/blog/?p=94</guid>
		<description><![CDATA[Back in August, we wrote a little tutorial on how to update the Sociable WordPress plugin by Joost de Valk to use a URL shortener and add Google Tracking. We&#8217;ve updated our download for the recent release of 3.5.1. To download the latest package: sociable-bitly-mod-3.5.1 See the original post here: URL Shortening and Tracking in [...]<h3>Related posts:</h3><ol>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-and-tracking-in-wordpress-sociable-plug-in/' rel='bookmark' title='URL Shortening and Tracking in WordPress: Sociable Plug-in'>URL Shortening and Tracking in WordPress: Sociable Plug-in</a></li>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/html-validation-for-sociable-wordpress-plug-in/' rel='bookmark' title='HTML Validation for Sociable WordPress Plug-In'>HTML Validation for Sociable WordPress Plug-In</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Back in August, we wrote a little tutorial on how to update the <a href="http://wordpress.org/extend/plugins/sociable/">Sociable</a> WordPress plugin by <a href="http://yoast.com/">Joost de Valk</a> to use a URL shortener and add Google Tracking. We&#8217;ve updated our download for the recent release of 3.5.1.</p>
<p>To download the latest package: <a href='http://www.isynergywebdesign.com/blog/wp-content/uploads/2009/08/sociable-bitly-mod-3.5.1.zip'>sociable-bitly-mod-3.5.1</a></p>
<p>See the original post here: <a href="http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-and-tracking-in-wordpress-sociable-plug-in/">URL Shortening and Tracking in WordPress: Sociable Plug-in</a></p>
<h3>Related posts:</h3><ol>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-and-tracking-in-wordpress-sociable-plug-in/' rel='bookmark' title='URL Shortening and Tracking in WordPress: Sociable Plug-in'>URL Shortening and Tracking in WordPress: Sociable Plug-in</a></li>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/html-validation-for-sociable-wordpress-plug-in/' rel='bookmark' title='HTML Validation for Sociable WordPress Plug-In'>HTML Validation for Sociable WordPress Plug-In</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-sociable-plugin-3-5-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing WordPress Multibox Plugin</title>
		<link>http://www.isynergywebdesign.com/blog/web-design/tutorials/fixing-wordpress-multibox-plugin/</link>
		<comments>http://www.isynergywebdesign.com/blog/web-design/tutorials/fixing-wordpress-multibox-plugin/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 18:01:19 +0000</pubDate>
		<dc:creator>Jack</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[video overlay]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://www.isynergywebdesign.com/blog/?p=81</guid>
		<description><![CDATA[The WordPress Multibox Plugin is another great plugin for WordPress. We don&#8217;t use it here on the official iSynergy Webdesign blog, but we do use it in a few other implementations for clients. It&#8217;s great because, unlike most lightbox effects, it works with things other than images. It can add overlay effects to videos, pdfs, [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://wordpress.org/extend/plugins/wordpress-multibox-plugin/">WordPress Multibox Plugin</a> is another great plugin for WordPress. We don&#8217;t use it here on the official iSynergy Webdesign blog, but we do use it in a few other implementations for clients. It&#8217;s great because, unlike most lightbox effects, it works with things other than images. It can add overlay effects to videos, pdfs, and any other web-based content.</p>
<p>However, there&#8217;s a minor problem with the multibox.js script. It appears to break within Firefox when the overlay effect is placed on only 1 object on the page (which happens quite often in individual posts). It has to do with the playNextButton and playPreviousButton objects that show up in slideshow mode. When there&#8217;s only 1 object with the overlay effect, the two buttons become undefined and end up breaking the overlay script.</p>
<p>To fix this, we&#8217;ll have to modify the js file within the plugin. Depending on which mootools version you&#8217;re using for the plugin, go into the plugin folder and navigate to either mtv111 (for mootools 1.11) or mtv120 (for mootools 1.2) and open either the multibox.js (for mootools 1.11) or multibox-1.3.1.js(for mootools 1.2).</p>
<p><span id="more-81"></span></p>
<p>For multibox.js, find line 95. For multibox-1.3.1.js, find line 97. Note the following lines of code:</p>
<pre><code>if(this.options.slideshow) {
	this.playPreviousButton = new Element('div').addClass('MultiBoxPlayPrevious').injectInside(this.controls).addEvent('click', this.playprevious.bind(this));
	this.playNextButton = new Element('div').addClass('MultiBoxPlayNext').injectInside(this.controls).addEvent('click', this.playnext.bind(this));
}
</code></pre>
<p>Essentially, the playPreviousButton and playNextButton elements aren&#8217;t created unless the slideshow option is on. This is the culprit that causes the undefined that occurs later in the script.</p>
<p>Now to actually fix this problem, for multibox.js, find line 115, for multibox-1.3.1.js, find line 118. The lines correspond to the following code:</p>
<pre><code>this.playNextButton.setStyle('display', 'none');
this.playPreviousButton.setStyle('display', 'none');
</code></pre>
<p>To fix the problem, we&#8217;ll just nest the above code within an if statement that is the same as the one used to create the elements to begin with. Our final bit of code should look like this:</p>
<pre><code>if(this.options.slideshow) {
	this.playNextButton.setStyle('display', 'none');
	this.playPreviousButton.setStyle('display', 'none');
}
</code></pre>
<p>So essentially, if it&#8217;s not in slideshow mode, we won&#8217;t create the elements and we won&#8217;t call the elements later, either. That&#8217;s it.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.isynergywebdesign.com/blog/web-design/tutorials/fixing-wordpress-multibox-plugin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>URL Shortening and Tracking in WordPress: Sociable Plug-in</title>
		<link>http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-and-tracking-in-wordpress-sociable-plug-in/</link>
		<comments>http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-and-tracking-in-wordpress-sociable-plug-in/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 18:57:33 +0000</pubDate>
		<dc:creator>Jack</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[social media]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://www.isynergywebdesign.com/blog/?p=69</guid>
		<description><![CDATA[The Sociable WordPress plug-in is a great extension and we use it here at the official iSynergy Webdesign blog, but it&#8217;s still missing a few key features. Tracking One key feature is the ability to track the data of how many shares are made through sociable. Using Google Analytics, it&#8217;s possible to set up event [...]<h3>Related posts:</h3><ol>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-sociable-plugin-3-5-1/' rel='bookmark' title='URL Shortening &#8211; Sociable Plug-In 3.5.1'>URL Shortening &#8211; Sociable Plug-In 3.5.1</a></li>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/html-validation-for-sociable-wordpress-plug-in/' rel='bookmark' title='HTML Validation for Sociable WordPress Plug-In'>HTML Validation for Sociable WordPress Plug-In</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://wordpress.org/extend/plugins/sociable/">Sociable</a> WordPress plug-in is a great extension and we use it here at the official iSynergy Webdesign blog, but it&#8217;s still missing a few key features.</p>
<h3>Tracking</h3>
<p>One key feature is the ability to track the data of how many shares are made through sociable. Using <a href="http://www.google.com/analytics">Google Analytics</a>, it&#8217;s possible to set up event tracking as a means to keep tabs on the data.</p>
<p>To do this, go into the sociable plug-in folder and open the social.php file in a text editor. Go to line 703 or look for the following code (for 3.4.4):</p>
<pre><code>$link .= " href=\"javascript:window.location='".urlencode($url)."';\" title=\"$description\">";</code></pre>
<p>or the following (For 3.5.1 and 3.5.2):</p>
<pre><code>$link .= " href=\"".$url."\" title=\"$description\">";</code></pre>
<p>Add the following into the anchor tag:</p>
<pre><code> onclick=\"pageTracker._trackEvent('Sociable', 'Shared Link', '".$title."');\"</code></pre>
<p>The code should look like this after (for 3.4.4):</p>
<pre><code>$link .= " href=\"javascript:window.location='".urlencode($url)."';\" title=\"$description\" onclick=\"pageTracker._trackEvent('Sociable', 'Shared Link', '".$title."');\">";</code></pre>
<p>Or like this (for 3.5.1 or 3.5.2):</p>
<pre><code>$link .= " href=\"".$url."\" title=\"$description\" onclick=\"pageTracker._trackEvent('Sociable', 'Shared Link', '".$title."');\">";</code></pre>
<p>And that&#8217;s it. As long as you have Google Analytics set up on the page already, it should start tracking events for sociable links.</p>
<p>Note: you can find event tracking in Google Analytics under: Content > Event Tracking</p>
<p><span id="more-69"></span></p>
<h3>URL Shortening</h3>
<p>Another key feature is the ability to use a URL shortener other than <a href="http://totally.awe.sm/">awe.sm</a>. The problem with awe.sm is that it&#8217;s in beta and it isn&#8217;t publicly open to everyone. You have to apply and hope to be accepted in order to use it. URL shorteners are essential to some of the sociable links, such as Twitter, which limit the amount of characters you can use in the share message. So how can we get a URL shortener to work other than using awe.sm?</p>
<p>Well, I&#8217;ve found and adapted a way to use a URL shortener by way of <a href="http://bit.ly">bit.ly</a>. I&#8217;m basing this off a topic from <a href="http://wordpress.org/support/topic/291638#post-1145969">here</a>. Much the same as that post, it requires modifications to the sociable plug-in. Which essentially means that the con of this modification is that it won&#8217;t work if you update the sociable plug-in with another official release in the future. However, it may not be too difficult to get it working again after an update. Just a few copy and pasting here and there. Anyway, the following is how to get it done:</p>
<p>Go into the sociable plug-in folder and look for the sociable.php file. Open it and search for the following line of code:</p>
<pre><code>$sociable_known_sites = Array(</code></pre>
<p>Under that array is a list of all the social sites that sociable supports. From here, you can pick and choose any of the social sites and replace the url string with the following:</p>
<pre><code>'url' => $sociablepluginpath.'bitly.php?url=PERMALINK&#038;title=TITLE&#038;blogname=BLOGNAME&#038;socialsite=[SOCIAL SITE]',</code></pre>
<p>Be sure to replace [SOCIAL SITE] with the name of the social site that is associated with the string.</p>
<p>Now, create a new file called bitly.php in the sociable plug-in folder and paste in the following:</p>
<pre><code>$url = $_GET['url'];
$excerpt = $_GET['excerpt'];
$blogname = $_GET['blogname'];
$title = $_GET['title'];
$sociablesite = $_GET['socialsite'];

// Ondemand function to generate dynamic bit.ly urls
function getBitlyUrl($url) {
    // fill up this 2 lines below with your login and api key
    $bitlylogin = '[BITLY LOGIN]';
    $bitlyapikey= '[BITLY API KEY]';

    // you dont need to change below this line
    $bitlyurl = file_get_contents('http://api.bit.ly/shorten?version=2.0.1&#038;longUrl='.$url.'&#038;login='.$bitlylogin.'&#038;apiKey='.$bitlyapikey);  

    $bitlycontent = json_decode($bitlyurl,true);

    $bitlyerror = $bitlycontent["errorCode"];

    if ($bitlyerror == 0){
        $bitlyurl = $bitlycontent["results"][$url]["shortUrl"];
    }
    else $bitlyurl = $url;

    return $bitlyurl;
}</code></pre>
<p>Be sure to replace [BITLY LOGIN] and [BITLY API KEY] with the appropriate credentials (you can acquire them from <a href="http://bit.ly">bit.ly</a> once you create an account).</p>
<p>Next, below the above code, add in the following:</p>
<pre><code>if ($sociablesite == 'Twitthis') {
	header('Location: http://twitter.com/home?status='.$title.'%20-%20'.getBitlyUrl($url));
	exit;
} elseif ($sociablesite == 'Twitter') {
	header('Location: http://twitter.com/home?status='.$title.'%20-%20'.getBitlyUrl($url));
	exit;
}</code></pre>
<p>Note the following code:</p>
<pre><code>$sociablesite == 'Twitter'</code></pre>
<p>The &#8216;Twitter&#8217; and &#8216;Twitthis&#8217; needs to be the same exact word/phrase as the word/phrase that was used to replace [SOCIAL SITE] within the sociable.php file.</p>
<p>If you want to do it for other supported sites, all you have to do is duplicate the elseif statement and replace the $sociablesite variable and the location with the matching url from the sociable.php array.</p>
<p>[UPDATED 02/18/2010]</p>
<p>You can download the completed files here:<br />
3.5.2 &#8211; <a href='http://www.isynergywebdesign.com/blog/wp-content/uploads/2009/08/sociable-bitly-mod-3.5.2.zip'>sociable-bitly-mod-3.5.2</a><br />
3.5.1 &#8211; <a href='http://www.isynergywebdesign.com/blog/wp-content/uploads/2009/08/sociable-bitly-mod-3.5.1.zip'>sociable-bitly-mod-3.5.1</a><br />
3.4.4 &#8211; <a href='http://www.isynergywebdesign.com/blog/wp-content/uploads/2009/08/sociable-bitly-mod-3.4.4.zip'>sociable-bitly-mod-3.4.4</a></p>
<p>The above set of files also includes the modifications from <a href="http://www.isynergywebdesign.com/blog/web-design/tutorials/html-validation-for-sociable-wordpress-plug-in/">HTML Validation for Sociable WordPress Plug-In</a>.</p>
<p>[END UPDATE]</p>
<p>It contains both the modified sociable.php file (including google tracking) and the completed bitly.php file. It&#8217;s also only set up for a few select sites (BarraPunto, email, Facebook, FriendFeed, Identi.ca, Ping.fm, Techmeme, and Twitthis/Twitter). Some of the social sites (Digg, StumbleUpon) don&#8217;t work with bit.ly or disallow the use of shortened URLs, so it may not be advisable to set up bit.ly for them. However, the bitly.php file contains all the sites, so, you can set it up to use bit.ly if you want. All you have to do is find the site you want in sociable.php and replace the url string with the modified url string from above.</p>
<p><strong>Important Note</strong>: The provided bitly.php has a placeholder for the [BITLY LOGIN] and [BITLY API KEY]. You will need to enter your own credentials for this to work.</p>
<h3>Related posts:</h3><ol>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-sociable-plugin-3-5-1/' rel='bookmark' title='URL Shortening &#8211; Sociable Plug-In 3.5.1'>URL Shortening &#8211; Sociable Plug-In 3.5.1</a></li>
<li><a href='http://www.isynergywebdesign.com/blog/web-design/tutorials/html-validation-for-sociable-wordpress-plug-in/' rel='bookmark' title='HTML Validation for Sociable WordPress Plug-In'>HTML Validation for Sociable WordPress Plug-In</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.isynergywebdesign.com/blog/web-design/tutorials/url-shortening-and-tracking-in-wordpress-sociable-plug-in/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

