<?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>Orange Cabin</title>
	<atom:link href="http://blog.orangecabin.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.orangecabin.com</link>
	<description>Blog of a freelance programmer</description>
	<lastBuildDate>Mon, 16 Nov 2009 16:39:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>IOError &#8220;Access is denied&#8221; installing gem using netbeans</title>
		<link>http://blog.orangecabin.com/2009/10/ioerror-access-is-denied-installing-gem-using-netbeans/</link>
		<comments>http://blog.orangecabin.com/2009/10/ioerror-access-is-denied-installing-gem-using-netbeans/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 15:48:08 +0000</pubDate>
		<dc:creator>Pan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.orangecabin.com/2009/10/ioerror-access-is-denied-installing-gem-using-netbeans/</guid>
		<description><![CDATA[Well I got this trying to install gem using Netbeans on Windows:
&#34;ERROR:&#160; While executing gem &#8230; (IOError) Access is denied&#34;
It cost me ours to figure out what was the problem.&#160; Netbeans was trying to write to local ruby gems directory which is likely to on the system disk and is protected by Windows. The solution [...]]]></description>
			<content:encoded><![CDATA[<p>Well I got this trying to install gem using Netbeans on Windows:</p>
<p>&quot;ERROR:&#160; While executing gem &#8230; (IOError) Access is denied&quot;</p>
<p>It cost me ours to figure out what was the problem.&#160; Netbeans was trying to write to local ruby gems directory which is likely to on the system disk and is protected by Windows. The solution is simple:</p>
<p>Just run Netbeans “As Administrator”. I suppose you know how to do this since many program would have similar problem. In the case you are not sure, please right click you Netbeans startup icon and choose “Run as administrator” on the dialog.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.orangecabin.com/2009/10/ioerror-access-is-denied-installing-gem-using-netbeans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to tell if Linux is 32 or 64 bit</title>
		<link>http://blog.orangecabin.com/2009/07/how-to-tell-is-my-linux-32-or-64-bit/</link>
		<comments>http://blog.orangecabin.com/2009/07/how-to-tell-is-my-linux-32-or-64-bit/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 16:05:31 +0000</pubDate>
		<dc:creator>Pan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[trivial]]></category>

		<guid isPermaLink="false">http://blog.orangecabin.com/2009/07/how-to-tell-is-my-linux-32-or-64-bit/</guid>
		<description><![CDATA[Sometimes you want to tell if your Linux installation is 32 bit or 64 bit.
Short story:
just type this:
getconf LONG_BIT
 
&#160;
Longer story:
You can also type
uname –m
if it is x86_64, then it is 64bit.
cat /proc/cpuinfo doesn’t work in this case, because what it shows is about CPU. 32bit linux can run on 64bit CPU.
They should make this [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you want to tell if your Linux installation is 32 bit or 64 bit.</p>
<p>Short story:</p>
<p>just type this:</p>
<p>getconf LONG_BIT</p>
<p> <span id="more-112"></span>
<p>&#160;</p>
<p>Longer story:</p>
<p>You can also type</p>
<p>uname –m</p>
<p>if it is x86_64, then it is 64bit.</p>
<p>cat /proc/cpuinfo doesn’t work in this case, because what it shows is about CPU. 32bit linux can run on 64bit CPU.</p>
<p>They should make this more obvious.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.orangecabin.com/2009/07/how-to-tell-is-my-linux-32-or-64-bit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tacking multiple domains using Google Analytics</title>
		<link>http://blog.orangecabin.com/2009/07/tacking-multiple-domains-using-google-analytics/</link>
		<comments>http://blog.orangecabin.com/2009/07/tacking-multiple-domains-using-google-analytics/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 14:37:59 +0000</pubDate>
		<dc:creator>Pan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.orangecabin.com/2009/07/tacking-multiple-domains-using-google-analytics/</guid>
		<description><![CDATA[If you have two or more domains / sites, it is a headache to track all of them using Google Analytics. Yes you can track 10 sites using 10 profiles, but you lost the whole picture. Here is how to track multiple domains using a single profile (so-called cross domains tracking).
 
Basically you have to [...]]]></description>
			<content:encoded><![CDATA[<p>If you have two or more domains / sites, it is a headache to track all of them using Google Analytics. Yes you can track 10 sites using 10 profiles, but you lost the whole picture. Here is how to track multiple domains using a single profile (so-called cross domains tracking).</p>
<p> <span id="more-80"></span>
<p>Basically you have to do two tricks: a) modifying the google tracking js b)creating a custom filter to make the results more readable.</p>
<p>Let’s suppose you own two sites, <a href="http://www.orangecabin.com">www.orangecabin.com</a> and <a href="http://www.google.com">www.google.com</a></p>
<h3><strong>Step 1 : Create profile</strong> </h3>
<p align="left">You have to decide which domain is the primary domain,&#160; and create a normal profile for it as usual. Since <a href="http://www.orangecabin.com">www.orangecabin.com</a> is more important (I hope so), you use it. It really doesn’t matter which one you use.</p>
<h3>Step 2 : Customize tracking js</h3>
<p>Now google show you the tracking javascript you are supposed to add to your site. Copy the js, save it to a file and edit it to something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">var</span> gaJsHost <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;https:&quot;</span> <span style="color: #339933;">==</span> document.<span style="color: #660066;">location</span>.<span style="color: #660066;">protocol</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">&quot;https://ssl.&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://www.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span>unescape<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;%3Cscript src='&quot;</span> <span style="color: #339933;">+</span> gaJsHost <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> pageTracker <span style="color: #339933;">=</span> _gat._getTracker<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;UA-4966487-9&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// tracking multiple domains</span>
pageTracker._setDomainName<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pageTracker._setAllowLinker<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pageTracker._setAllowHash<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
pageTracker._trackPageview<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span>err<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>These lines are added:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// tracking multiple domains</span>
pageTracker._setDomainName<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>none<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pageTracker._setAllowLinker<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pageTracker._setAllowHash<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You will use this js instead of the original one.</p>
<h3>Step 3 : Create a custom filter</h3>
<p>The customized js is enough for google to collect information for all domains, but it won’t handle domain names correctly, <a href="http://www.google.com/index.html">www.google.com/index.html</a> and <a href="http://www.orange.com/index.html">www.orange.com/index.html</a> will be reported as the same page. So you have to add a custom filter. If you don’t know what it is, don’t worry just follow me.</p>
<p>Return to the profile list,&#160; find the newly created profile and click edit</p>
<p><a href="http://blog.orangecabin.com/wp-content/uploads/2009/07/multiple_domains_in_google_analytics_step_3_1.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="multiple_domains_in_google_analytics_step_3_1" border="0" alt="multiple_domains_in_google_analytics_step_3_1" src="http://blog.orangecabin.com/wp-content/uploads/2009/07/multiple_domains_in_google_analytics_step_3_1_thumb.jpg" width="600" height="71" /></a> </p>
<p>Find “Add Filter” on the new page</p>
<p><a href="http://blog.orangecabin.com/wp-content/uploads/2009/07/multiple_domains_in_google_analytics_step_3_2.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="multiple_domains_in_google_analytics_step_3_2" border="0" alt="multiple_domains_in_google_analytics_step_3_2" src="http://blog.orangecabin.com/wp-content/uploads/2009/07/multiple_domains_in_google_analytics_step_3_2_thumb.jpg" width="594" height="250" /></a> </p>
</p>
<p>Click “Add Filter”, Create it using these parameters:</p>
<p><strong>Filter Name</strong>: MultipleDomains </p>
<p><b>Filter Type</b>: Custom filter &gt; Advanced </p>
<p><b>Field A</b>: Hostname </p>
<p><b>Extract A</b>: (.*) </p>
<p><b>Field B</b>: Request URI </p>
<p><b>Extract B</b>: (.*) </p>
<p><b>Output To</b>: Request URI </p>
<p><b>Constructor</b>: /$A1$B1</p>
<p>as shown on this image:</p>
<p><a href="http://blog.orangecabin.com/wp-content/uploads/2009/07/multiple_domains_in_google_analytics_step_3_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="multiple_domains_in_google_analytics_step_3_3" border="0" alt="multiple_domains_in_google_analytics_step_3_3" src="http://blog.orangecabin.com/wp-content/uploads/2009/07/multiple_domains_in_google_analytics_step_3_3_thumb.png" width="542" height="390" /></a></p>
<p>Click save changes.</p>
<p><strong>The next time you create another multiple-domain profile, you can reuse this filter instead of creating one.</strong></p>
<h3>step 4 add your customized js to your sites</h3>
<p>&#160;</p>
<p>That is it. Once you have enough data, you can get some report like this:</p>
<p><a href="http://blog.orangecabin.com/wp-content/uploads/2009/07/multiple_domains_in_google_analytics_step_42.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="multiple_domains_in_google_analytics_step_4" border="0" alt="multiple_domains_in_google_analytics_step_4" src="http://blog.orangecabin.com/wp-content/uploads/2009/07/multiple_domains_in_google_analytics_step_4_thumb2.jpg" width="531" height="199" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.orangecabin.com/2009/07/tacking-multiple-domains-using-google-analytics/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Install ruby 1.9 on Windows using zip binary</title>
		<link>http://blog.orangecabin.com/2009/05/install-ruby-1-9-on-windows-using-zip-binary/</link>
		<comments>http://blog.orangecabin.com/2009/05/install-ruby-1-9-on-windows-using-zip-binary/#comments</comments>
		<pubDate>Sat, 30 May 2009 11:39:35 +0000</pubDate>
		<dc:creator>Pan</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.orangecabin.com/?p=48</guid>
		<description><![CDATA[Update:  This post is outdated. All in one installer for 1.9 is out now, you should use it if you need 1.9 on windows. Get it here http://rubyforge.org/frs/?group_id=167
Ruby has &#8220;all-in-one&#8221; installer for Windows, but it is outdated. As of May 2009, Ruby 1.9.1 is released, the installer is still 1.8.6. If you want the latest [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:  This post is outdated. All in one installer for 1.9 is out now, you should use it if you need 1.9 on windows. Get it here </strong><a href="http://rubyforge.org/frs/?group_id=167"><strong>http://rubyforge.org/frs/?group_id=167</strong></a></p>
<p>Ruby has &#8220;all-in-one&#8221; installer for Windows, but it is outdated. As of May 2009, Ruby 1.9.1 is released, the installer is still 1.8.6. If you want the latest version, you need the zip package. But the zip package is missing zlib.dll, libeay32.dll, ssleay32.dll and readline.dll . Here is how to install it on windows.<span id="more-48"></span></p>
<h3>Download the file</h3>
<p>First you download the 1.9 package from <a href="http://www.ruby-lang.org/en/downloads/">http://www.ruby-lang.org/en/downloads/</a><br />
Choose &#8220;Ruby 1.9 xxx binary&#8221; instead of &#8220;Ruby xxx Installer&#8221;.</p>
<h3>Install it</h3>
<p>Just Unpack the zip to c:\ruby.<br />
Then add c:\ruby\bin to windows PATH.<br />
Open a windows command console and type<br />
<code>gem update --system</code><br />
Oops, it is broken! The binary is missing some dll files.</p>
<h3>Let us fix it</h3>
<h4>zlib</h4>
<p>Download zlib windows binary from<br />
<a href="http://gnuwin32.sourceforge.net/packages/zlib.htm">http://gnuwin32.sourceforge.net/packages/zlib.htm</a></p>
<p>unzip the package, then find a file named &#8220;zlib1.dll&#8221;.<br />
Copy &#8220;zlib1.dll&#8221; to your ruby\bin directory AND rename it to zlib.dll<br />
What the heck?! Why renaming it? Because ruby source code reference the dll as zlib.dll. It is common to use alias like this on Linux. Ruby source was coded on Linux.</p>
<h4>openssl</h4>
<p>Download openssl windows binary from<br />
<a href="http://gnuwin32.sourceforge.net/packages/openssl.htm">http://gnuwin32.sourceforge.net/packages/openssl.htm</a><br />
Unzip it.<br />
Find &#8220;libeay32.dll&#8221;, copy to ruby\bin. Don&#8217;t rename it.<br />
Find &#8220;libssl32.dll&#8221;, copy to ruby\bin and rename it to ssleay32.dll</p>
<h4>readline</h4>
<p>Download readline windows binary from<br />
<a href="http://gnuwin32.sourceforge.net/packages/readline.htm">http://gnuwin32.sourceforge.net/packages/readline.htm</a><br />
Unzip it.<br />
Find &#8220;readline5.dll&#8221;, copy to ruby\bin and rename it to readline.dll</p>
<h4>Done</h4>
<p>That is all. Now type<br />
<code>gem update --system</code><br />
then<br />
<code>gem install rails</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.orangecabin.com/2009/05/install-ruby-1-9-on-windows-using-zip-binary/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>WordPress 2.7 Plugin tutorial : First Plugin in 20 lines</title>
		<link>http://blog.orangecabin.com/2009/05/wordpress-2-7-plugin-tutorial-first-plugin-in-20-lines/</link>
		<comments>http://blog.orangecabin.com/2009/05/wordpress-2-7-plugin-tutorial-first-plugin-in-20-lines/#comments</comments>
		<pubDate>Sat, 30 May 2009 05:06:24 +0000</pubDate>
		<dc:creator>Pan</dc:creator>
				<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.orangecabin.com/?p=3</guid>
		<description><![CDATA[WordPress doesn&#8217;t provide an &#8220;Hello world&#8221;  plugin tutorial. There are some links to 3rd party tutorials,  but those samples are years old and doing stuff in old way.
It doesn&#8217;t have to be that complex. I will demonstrate how to create a simple plugin in 20 lines, the plugin can add some HTML to page footer [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress doesn&#8217;t provide an &#8220;Hello world&#8221;  plugin tutorial. There are some links to 3rd party tutorials,  but those samples are years old and doing stuff in old way.</p>
<p>It doesn&#8217;t have to be that complex. I will demonstrate how to create a simple plugin in 20 lines, the plugin can add some HTML to page footer and/or post. <span id="more-3"></span> This is an &#8220;Hello World&#8221;, so I won&#8217;t explain the plugin framework in detail but I will cover essential concepts.<br />
<em>This tutorial is for (newbie) plugin developers,  it won&#8217;t explain how to use WP and how to code PHP. </em></p>
<h3>Creating a plugin</h3>
<p>Create a directory &#8220;simple-add-to-footer&#8221; under wp-content/plugins, then create a file &#8220;simple-add-to-footer.php&#8221;. Add this code to the newly created page.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: Simple Add To Footer
Plugin URI: http://localhost/wordpress/
Description: Add HTML snippets to posts and/or page footer.
It is a plugin tutorial using latest plugin API of WP2.7+
Version: 0.1
Author: me
Author URI: http://blog.orangecabin.com/
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This is called &#8220;Standard Plugin Information&#8221;, you can read more about it on  <a href="http://codex.wordpress.org/Writing_a_Plugin">http://codex.wordpress.org/Writing_a_Plugin</a>.  That is all it needs to be a valid plugin. Now this &#8220;plugin&#8221; can be activated like other plugins.</p>
<h3>Adding something interesting</h3>
<p>OK it does nothing till now. Please add this after the plugin info.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_footer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'simple_add_to_footer_wp_footer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> simple_add_to_footer_wp_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div&gt;Hello world! '</span><span style="color: #339933;">.</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blogname'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>If you activated the plugin now, you can see it print something in the page footer.  </p>
<h3>What is &#8220;action&#8221;</h3>
<p>Here goes some theory : &#8220;action&#8221; is one type of the extension points of WordPress, that means you extend an action to do something to WordPress.<br />
add_action is &#8220;the interface&#8221; between wordpress and your plugin. The 1st parameter &#8220;wp-footer&#8221; is a simple action which is called to produce page footer. The 2nd parameter is name of you function. And you do what you need in that function.<br />
simple_add_to_footer_wp_footer calls get_option(&#8217;blogname&#8217;). It is a WordPress defined API to get blog options, like blog name. </p>
<h3>Filter &#8211; another type of extension point</h3>
<p>Now add this to the file</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'simple_add_to_footer_the_content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> simple_add_to_footer_the_content<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;div&gt;I am '</span><span style="color: #339933;">.</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Reload your blog page, now you can see it adds some info to the post.<br />
Filter is another type of extension point. Instead of echo something directly, you get a parameter ($content) from WordPress and you can manipulate it, like upper case or something.</p>
<h3>Conclusion</h3>
<p>That is all. Here is what we have now:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: Simple Add To Footer
Plugin URI: http://localhost/wordpress/
Description: Add HTML snippets to posts and/or page footer.
It is a plugin tutorial using latest plugin API of WP2.7+
Version: 0.1
Author: me
Author URI: http://blog.orangecabin.com/
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
*/</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_footer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'simple_add_to_footer_wp_footer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> simple_add_to_footer_wp_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div&gt;Hello world! '</span><span style="color: #339933;">.</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blogname'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">' &lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'simple_add_to_footer_the_content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> simple_add_to_footer_the_content<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;div&gt; I am '</span><span style="color: #339933;">.</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You can download source code here: <a href='http://blog.orangecabin.com/wp-content/uploads/2009/05/simple-add-to-footer_0.1.zip'>simple-add-to-footer_0.1</a><br />
OK I know it is not really useful. But this plugin can be easily extend to do interesting stuff, like inserting arbitrary HTML code to page footer. To do that, you need a page for the plugin user to type the HTML they want to insert. The next post will explain how to do that easily using latest WordPress plugin API.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.orangecabin.com/2009/05/wordpress-2-7-plugin-tutorial-first-plugin-in-20-lines/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
