<?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>Cheap Premium WordPress Themes &#124; Theme Sphere &#187; Tutorials</title>
	<atom:link href="http://themesphere.com/category/tutorials/feed" rel="self" type="application/rss+xml" />
	<link>http://themesphere.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 18 Jun 2009 12:13:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Integrate Twitter to WordPress Blog Comments</title>
		<link>http://themesphere.com/twitter-wordpress-comments.html</link>
		<comments>http://themesphere.com/twitter-wordpress-comments.html#comments</comments>
		<pubDate>Mon, 20 Apr 2009 15:37:49 +0000</pubDate>
		<dc:creator>Haris</dc:creator>
				<category><![CDATA[Social Media Optimization]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[smo]]></category>
		<category><![CDATA[turorials]]></category>

		<guid isPermaLink="false">http://themesphere.com/?p=254</guid>
		<description><![CDATA[Twitter is the most important tool in the social media industry today. Everyone is looking for a way to get connected with the tweeps at Twitterville.
As a blogger, you can connect to your commenters by letting them share their Twitter profile when they comment on your blog.
Wouldn&#8217;t it be cool if the commenter provides URL [...]]]></description>
			<content:encoded><![CDATA[<p>Twitter is the most important tool in the social media industry today. Everyone is looking for a way to get connected with the <a href="http://bloggingbits.com/twitter-glossary-terms-words">tweeps at Twitterville</a>.</p>
<p>As a blogger, you can connect to your commenters by letting them share their Twitter profile when they comment on your blog.</p>
<p>Wouldn&#8217;t it be cool if the commenter provides URL to their twitter profile in the <strong>website URL field</strong>, and you can add a link to a cute little icon with &#8220;Follow Me!&#8221; text right next to their comment?</p>
<p>So today, I&#8217;ll teach you how to add that kind of functionality to your WordPress blog.</p>
<p><span id="more-254"></span></p>
<p>I&#8217;m going to use the <a href="http://wefunction.com/2008/07/freebie-twitter-icons-illustration/">cute twitter icon</a> offered by <a href="http://wefunction.com">Function</a> to demonstrate this technique.</p>
<p><strong>1.</strong> Download the icon pack and add it to the images directory of your theme.</p>
<p><strong>2.</strong> Now, we need to check if the URL in the comment URL field is linking to a twitter <strong>profile</strong>. We will do this by using regex.</p>
<p>Add the following code under the callback function of comments if you&#8217;re using wordpress 2.7 or under the comments foreach loop if you&#8217;re using wordpress 2.6.</p>
<p>If you&#8217;re using wordpress 2.7, add the following code below <code>$GLOBALS['comment'] = $comment;</code> line.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">        <span style="color: #000088;">$link</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_author_url</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$match_twitter</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/(.*)(twitter)\.com\/(.*)/i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$link</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'twitter'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	  <span style="color: #000088;">$link_to_twitter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>3.</strong> $link_to_twitter variable will be true if the comment URL contains twitter profile URL. We can use the value of $link_to_twitter variable to add markup for twitter icon if it returns true. Following is an example of how I used $link_to_twitter variable to add twitter icon below the comment author name if it returns true.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">        &lt;p class=&quot;author_name&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_author_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/p&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$link_to_twitter</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
        &lt;p class=&quot;author_name twitter&quot;&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_author_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/imgs/twitter_48.png&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>4.</strong> Now you can style the markup depending on your design.</p>
<p>I used the above example on <a href="http://themesphere.com/flexis-wordpress-theme.html">Flexis</a> (this feature comes pre-installed in Flexis). The screenshot below shows the outcome of the this technique.</p>
<p><img src="http://themesphere.com/wp-content/uploads/2009/04/twitter.png" alt="twitter" title="twitter" width="602" height="403" class="alignnone size-full wp-image-270" /></a></p>
<p><em><br />
<strong><a href="http://feeds2.feedburner.com/themesphere">Subscribe to RSS updates for more Tips and Updates.</a></strong></em></p>
<p><em>This post is written by Muhammad Haris. You can follow him on twitter <a href="http://twitter.com/mharis">@mharis</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://themesphere.com/twitter-wordpress-comments.html/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>
