<?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>Blog.Project13.pl &#187; php</title>
	<atom:link href="http://www.blog.project13.pl/index.php/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blog.project13.pl</link>
	<description>The Blog of a Coder</description>
	<lastBuildDate>Sun, 05 Feb 2012 02:28:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Tweets in WordPress; same timeline but skip in rss feed</title>
		<link>http://www.blog.project13.pl/index.php/project13/938/tweets-in-wordpress-same-timeline-but-skip-in-rss-feed/</link>
		<comments>http://www.blog.project13.pl/index.php/project13/938/tweets-in-wordpress-same-timeline-but-skip-in-rss-feed/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 22:00:56 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[Project13]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=938</guid>
		<description><![CDATA[Hi guys, todays post is about yet another fun and small hack, namely: Having twitter posts (tweets) to be displayed right along all wordpress blog posts (posts) in the same timeline (wordpress main view). しかし!!! As my blog is being listed on http://www.dworld.pl/Blogsfera (and for other obvious reasons) I didn&#8217;t want all my tweets to [...]]]></description>
			<content:encoded><![CDATA[<p>Hi guys, todays post is about yet another fun and small hack, namely: Having twitter posts (tweets) to be displayed right along all wordpress blog posts (posts) in the same timeline (wordpress main view). <strong><acronym title="but (in japanese)">しかし</acronym>!!!</strong></p>
<p>As my blog is being listed on <a href="http://www.dworld.pl/Blogsfera" onclick="urchinTracker('/outgoing/www.dworld.pl/Blogsfera?referer=');">http://www.dworld.pl/Blogsfera</a> (and for other obvious reasons) I didn&#8217;t want all my tweets to be translated &#8220;1 to 1&#8243; to plain old blog posts since this would cause each of my tweets (which can be silly sometimes (but quite <strong>rarely!</strong>)) to land on dworld, which they obviously shouldn&#8217;t as it&#8217;s only an place for Java/Development oriented posts. Also I&#8217;d rather they&#8217;d take less space, and would skip all the categories/tags &#8211; it&#8217;s all in the tweet, so why repeat it again and again?</p>
<p>So&#8230; let&#8217;s start by importing tweets into wordpress. There&#8217;s an great plugin for that, and it&#8217;s called <strong><a href="http://skinju.com/wordpress/tweet-import" onclick="urchinTracker('/outgoing/skinju.com/wordpress/tweet-import?referer=');">Tweet Import</a> by skinju</strong>. Just install it and set it up to fetch your tweet&#8217;s at an regular basis. Ok, we&#8217;re done with step 1 &#8211; but neither are the current tweets smaller or ommitted in the rss feed. Let&#8217;s start by filtering them out from the rss feed:</p>
<p>Open up the file <em><strong>/wp-content/themes/default/functions.php </strong></em>and go to the end of the file, we&#8217;ll add an filter here. Please note that in step 1 you should have created an &#8220;twitter&#8221; category all tweets should be marked with. Let&#8217;s assume this category has an ID of 131, then the following code would do the filtering for us:</p>
<div class="geshi no php">
<div class="head">//add at end of file</div>
<ol>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span> ?php</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// filter out twitter posts from feed</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> exclude_category<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span> is_feed<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="coMULTI">/* || is_home()*/</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;set_query_var<span class="br0">&#40;</span><span class="st0">&#39;cat&#39;</span><span class="sy0">,</span> <span class="st0">&#39;-131&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">add_filter<span class="br0">&#40;</span><span class="st0">&#39;pre_get_posts&#39;</span><span class="sy0">,</span> <span class="st0">&#39;exclude_category&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>It&#8217;s a very nice trick, and it&#8217;s <a href="http://zeo.my/exclude-category-in-wordpress/" onclick="urchinTracker('/outgoing/zeo.my/exclude-category-in-wordpress/?referer=');">explained more in detail here</a>. The code is really simple, so no explaining here and let&#8217;s go and tune our view (<strong>yup, the RSS feed is already fixed!</strong>).</p>
<p>To setup our view to work a little different for tweets than for posts, well have to edit: <em><strong>/wp-content/themes/maze/index.php</strong></em> so open it up in your favourite editor and add such an if statement inside an post&#8217;s while statement:</p>
<div class="geshi no php">
<div class="head">//add the 2nd line, the rest is just here for the ease of locating the right place</div>
<ol>
<li class="li1">
<div class="de1">&nbsp; <span class="sy0">&lt;</span> ?php <span class="kw1">while</span> <span class="br0">&#40;</span>have_posts<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">:</span> the_post<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw2">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span> ?php <span class="kw1">if</span> <span class="br0">&#40;</span>in_category<span class="br0">&#40;</span><span class="st0">&#39;twitter&#39;</span><span class="br0">&#41;</span> <span class="sy0">==</span> <span class="kw2">false</span><span class="br0">&#41;</span><span class="sy0">:</span> <span class="co1">//display post?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span>div id<span class="sy0">=</span><span class="st0">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span><span class="sy0">&gt;&lt;/</span>div<span class="sy0">&gt;</span></div>
</li>
</ol>
</div>
<p>Ok, with this done let&#8217;s write the else part&#8230;</p>
<div class="geshi no php">
<div class="head">//the else for the above if</div>
<ol>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span> ?php <span class="kw1">else</span><span class="sy0">:</span> <span class="co1">//display tweet ?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span>div id<span class="sy0">=</span><span class="st0">&quot;tweet-&lt;?php the_ID(); ?&gt;&quot;</span> style<span class="sy0">=</span><span class="st0">&quot;padding: 15px 15px 0 0&quot;</span><span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span>div style<span class="sy0">=</span><span class="st0">&quot;background:none repeat scroll 0 0 #262626; font-size:12px; font-weight:normal; line-height:12px; margin:0 30px 10px 0; padding:5px 5px 5px 10px;&quot;</span><span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span> ?php the_content<span class="br0">&#40;</span><span class="st0">&#39;Read More&#8230;&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw2">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;/</span>div<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span>div<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;Tweeted by <span class="sy0">&lt;</span>a href<span class="sy0">=</span><span class="st0">&quot;http://www.twitter.com/ktosopl&quot;</span><span class="sy0">&gt;@</span>ktosopl<span class="sy0">&lt;/</span>a<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">@</span> <span class="sy0">&lt;</span>a href<span class="sy0">=</span><span class="st0">&quot;&lt;?php $key=&quot;</span>tweetimport_twitter_post_uri<span class="st0">&quot;; echo get_post_meta($post-&gt;ID, $key, true); ?&gt;&quot;</span><span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span> ?php <span class="re1">$key</span><span class="sy0">=</span><span class="st0">&quot;tweetimport_date_imported&quot;</span><span class="sy0">;</span> <span class="kw3">echo</span> get_post_meta<span class="br0">&#40;</span><span class="re1">$post</span><span class="sy0">-&gt;</span><span class="me1">ID</span><span class="sy0">,</span> <span class="re1">$key</span><span class="sy0">,</span> <span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw2">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;/</span>a<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="sy0">&lt;/</span>div<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;/</span>div<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span> ?php <span class="kw1">endif</span> <span class="co1">//end display mode if?&gt;</span></div>
</li>
</ol>
</div>
<p><em>(You can complain about the in line css styling if you want later, I know it&#8217;s bad but this wordpress theme is a mess anyways&#8230; ;-))</em> Let&#8217;s have a look at the more important parts of this code part. You&#8217;ll notice that I&#8217;m using some weird <strong>get_post_meta()</strong> function. It&#8217;s an method that fetches additional information that each post CAN but doesn&#8217;t have to have. And as the TweetImport plugin does fill an post with a lot of useful tweet data, such as post time and tweet url &#8211; that&#8217;s what I&#8217;m fetching here. The rest should be quite self explanatory, there are bit&#8217;s of hardcoded &#8220;ktosopl&#8221; in there but hey &#8211; it&#8217;s just my blog and I&#8217;m a busy person ;-)</p>
<p>Hope you found this post interesting and maybe you&#8217;ll implement the same thing on your blogs&#8230;? :-)<br />
Cheers!</p>
<p>PS: Oh, and if your interested in talking on one of your upcomming JavaCamps &#8211; feel free to contact me or anyone from the <a href="http://www.java.pl" onclick="urchinTracker('/outgoing/www.java.pl?referer=');"><strong>java.pl</strong></a> team, we&#8217;re looking forward to hearing from you. The nearest meeting will probably be organized around 23&#8242;th or 6&#8242;th&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/project13/938/tweets-in-wordpress-same-timeline-but-skip-in-rss-feed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Toggle Syntax Highlighting in vim</title>
		<link>http://www.blog.project13.pl/index.php/coding/159/syntax-highlighting-in-vim/</link>
		<comments>http://www.blog.project13.pl/index.php/coding/159/syntax-highlighting-in-vim/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 15:42:14 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[gnu]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[webdeveloper]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=159</guid>
		<description><![CDATA[Just a quick vim tip today&#8230; Have you been coding/fixing stuff on the server over ssh using vim? I sure have, but was always wondering why the vim on my server wouldn&#8217;t highlight php&#8230; The solution is: :syntax on Whoa, 2 words, not 2 letters like usually! Thats pretty long for vim ain&#8217;t it? ;-)]]></description>
			<content:encoded><![CDATA[<p>Just a quick vim tip today&#8230; Have you been coding/fixing stuff on the server over ssh using vim? I sure have, but was always wondering why the vim on my server wouldn&#8217;t highlight php&#8230; The solution is:<strong><br />
</strong></p>
<p><strong>:syntax on</strong></p>
<p>Whoa, 2 words, not 2 letters like usually! Thats pretty long for vim ain&#8217;t it? ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/coding/159/syntax-highlighting-in-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

