<?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"
	>

<channel>
	<title>TekTok</title>
	<atom:link href="http://tektok.romagazin.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://tektok.romagazin.net</link>
	<description>Talk about tech</description>
	<pubDate>Thu, 25 Sep 2008 17:14:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>How to &#8212; Programming a WordPress Sidebar Widget Plugin</title>
		<link>http://tektok.romagazin.net/2008/07/29/how-to-programming-a-wordpress-sidebar-widget-plugin/</link>
		<comments>http://tektok.romagazin.net/2008/07/29/how-to-programming-a-wordpress-sidebar-widget-plugin/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 09:18:33 +0000</pubDate>
		<dc:creator>Alin M.</dc:creator>
		
		<category><![CDATA[WordPress Plugins/Widgets]]></category>

		<guid isPermaLink="false">http://tektok.romagazin.net/?p=4</guid>
		<description><![CDATA[A friend of mine recently asked me to take a look at some code that he&#8217;d written and see if I could get it to work. I&#8217;m not going to tell you what was wrong with his code, but I will tell you that in the process of troubleshooting the code I got the idea [...]]]></description>
			<content:encoded><![CDATA[<p>A friend of mine recently asked me to take a look at some code that he&#8217;d written and see if I could get it to work. I&#8217;m not going to tell you what was wrong with his code, but I will tell you that in the process of troubleshooting the code I got the idea for this post. Let&#8217;s look at how we can make a full, working WordPress sidebar widget.</p>
<p>There are at least two ways to make a sidebar widget in WordPress. The first is to create a file in the &#8220;wp-content/plugins&#8221; directory and activate the widget as a regular plug-in, and second is to write the code in the &#8220;functions.php&#8221; file included with your WordPress theme. I have used both and they both work just fine. I will use the first method here just because I regard sidebar widgets to be WordPress plugins.</p>
<p>I encourage you to work through this so that at the end you will have your fully functional WordPress sidebar widget. I&#8217;m going to call our widget &#8220;Your Lucky Number.&#8221; That is, the widget will pick a random number from a certain interval and display it to the reader.</p>
<p>So, look up the &#8220;wp-content/plugins&#8221; directory in your WorPress installation and in it create a new &#8220;lucky_number_widget&#8221; directory, which will contain a &#8220;lucky_number_widget.php&#8221; file, as you see in the photo below.</p>
<p><img class="alignnone size-full wp-image-5" src="http://tektok.romagazin.net/files/2008/07/lucky-number-files.gif" alt="WordPress tutorial -- file path" width="255" height="151" /></p>
<p>The file that you just created will contain all the code needed for our little widget. At the top of this file put the following code:</p>
<pre id="code-1918" class="php">

&lt;?php
/*
Plugin Name: Lucky Number Sidebar Widget
Plugin URI: http://tektok.romagazin.net
Description: This widget picks a lucky number
Author: Your name here
Version: 1.0
Author URI: http://tektok.romagazin.net
*/
?&gt;
</pre>
<p>In PHP, that&#8217;s called a comment block. That is, a block of text, between &#8220;/*&#8221; and &#8220;*/&#8221;, that has no meaning in PHP; it is only meaningful to humans. However, that kind of comment block, placed at the top of a PHP file, which resides in the &#8220;plugins&#8221; directory, has a very important significance to the WordPress platform. It tells WordPress that this file contains a plugin for the platform. As a consequence, WordPress will give you an opportunity to activate the plugin in the administration panel. If you don&#8217;t put this comment block as it appears in the above code, you will not be able to activate the plugin, therefore you won&#8217;t be able to use it. After you&#8217;ve saved the file, go to your admin control panel and click on &#8220;plugins;&#8221; you should see something similar to this picture:</p>
<p><a href="http://tektok.romagazin.net/files/2008/07/plugins-table.gif" target="_blank"><img class="alignnone size-medium wp-image-6" src="http://tektok.romagazin.net/files/2008/07/plugins-table-300x94.gif" alt="WordPress Plugins Table" width="300" height="94" /></a></p>
<p>OK, now it&#8217;s time we created the code that drives our widget. Put the following code right below the comment block:</p>
<pre id="code-1919" class="php">

function lucky_number_widget($args){
extract($args);

echo $before_widget;
echo $before_title . &#039;Your lucky number is:&#039; . $after_title;

echo &#039;&lt;p style=&quot;font-size: 5em&quot;&gt;&#039; . rand(1, 20) . &#039;&lt;/p&gt;&#039;;
echo $after_widget;
}
</pre>
<p>In the above code: line 01 defines the function that will be called every time our WordPress widget is displayed in our blog. Line 02 is a little tricky for those who are new to PHP. Please read about the <a title="extract - Manual" href="http://us2.php.net/extract" target="_blank">PHP extract</a> function if you need to learn about it. To keep this tutorial short, I will only say that when the widget has to be displayed in the sidebar, WordPress calls our function with an associative array as parameter ($args). This array has the keys before_widget, after_widget, before_title and after_title and their corresponding values are string representations of HTML tags. extract transforms the key-value pairs in actual PHP variables, just as we would define $var = &#8217;some string&#8217;;. The rest of the code is simple: it just echoes those values in the order they are meant to be echoed. Line 07 displays a random number between 1 and 20 inclusive within a HTML paragraph. That&#8217;s your lucky number!</p>
<h3>Activate the plugin</h3>
<p>Having coded all the functionality of our widget, we now have to write a function that WordPress will call when it loads the active plugins. This function will register our sidebar widget with the WordPress platform, so that it appears in the &#8220;Available Widgets&#8221; list under &#8220;Design-&gt;Widgets&#8221; menu.</p>
<pre id="code-1920" class="php">

function init_lucky_number_widget(){
//this function is called when WordPress loads the plugins
register_sidebar_widget(&#039;Lucky Number Widget&#039;, &#039;lucky_number_widget&#039;);
}
</pre>
<p>Just drop the above code in our file right below the lucky_number_widget() function. <a title="WordPress Widgets API" href="http://codex.wordpress.org/Plugins/WordPress_Widgets_Api" target="_blank">Read more about register_sidebar_widget()</a>.</p>
<p>One more line of code and then you&#8217;ll be able to see results. Under the function init_lucky_number_widget() type the following line of code:</p>
<pre id="code-1921" class="php">

add_action(&#039;plugins_loaded&#039;, &#039;init_lucky_number_widget&#039;);
</pre>
<p>Now save the file and go to your WordPress control panel. Click on &#8220;plugins&#8221; and then click &#8220;Activate&#8221; for &#8220;Lucky Number Sidebar Widget.&#8221; Click on &#8220;Design&#8221; and then on &#8220;Widgets&#8221; under it. You should see something like this:</p>
<p><img class="alignnone size-full wp-image-7" src="http://tektok.romagazin.net/files/2008/07/available-widgets.gif" alt="After activating the widget" width="498" height="401" /></p>
<p>Click the &#8220;Add&#8221; link next to its name and look to the right in the &#8220;Current Widgets&#8221; list. After you arrange it in the position you want, you should see something like this:</p>
<p><img class="alignnone size-full wp-image-8" src="http://tektok.romagazin.net/files/2008/07/current-widgets.gif" alt="Current Widgets" width="335" height="460" /></p>
<p>Click &#8220;Save&#8221; under the list. If you have a widgetized WordPress theme, you should see your widget appear on the sidebar of your blog. It should appear similar to how it appears on the sidebar of this blog; that&#8217;s your lucky number. If you don&#8217;t know what to do with it, look at my lottery widget and maybe it&#8217;ll help you hit the jackpot :-).</p>
<p>Congratulations! You&#8217;ve just created your first working WordPress sidebar widget. Next time, we will look at how to enhance it. We&#8217;ll write the code that allows us to modify the range of the lucky number or maybe something else. Until then, drop me a comment; tell me how it went. If you encountered problems, by all means, throw them my way. We&#8217;ll get it working!</p>






	<a rel="nofollow" target="_blank" href="mailto:?subject=How%20to%20--%20Programming%20a%20WordPress%20Sidebar%20Widget%20Plugin&amp;body=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F29%2Fhow-to-programming-a-wordpress-sidebar-widget-plugin%2F" title="E-mail this story to a friend!"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="javascript:window.print();" title="Print this article!"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/printer.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F29%2Fhow-to-programming-a-wordpress-sidebar-widget-plugin%2F" title="Technorati"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F29%2Fhow-to-programming-a-wordpress-sidebar-widget-plugin%2F&amp;title=How%20to%20--%20Programming%20a%20WordPress%20Sidebar%20Widget%20Plugin" title="Digg"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F29%2Fhow-to-programming-a-wordpress-sidebar-widget-plugin%2F&amp;title=How%20to%20--%20Programming%20a%20WordPress%20Sidebar%20Widget%20Plugin" title="Google"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F29%2Fhow-to-programming-a-wordpress-sidebar-widget-plugin%2F&amp;t=How%20to%20--%20Programming%20a%20WordPress%20Sidebar%20Widget%20Plugin" title="Facebook"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F29%2Fhow-to-programming-a-wordpress-sidebar-widget-plugin%2F&amp;title=How%20to%20--%20Programming%20a%20WordPress%20Sidebar%20Widget%20Plugin" title="del.icio.us"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://blogsvine.com/submit.php?url=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F29%2Fhow-to-programming-a-wordpress-sidebar-widget-plugin%2F" title="Blogsvine"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/blogsvine.png" title="Blogsvine" alt="Blogsvine" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://tektok.romagazin.net/2008/07/29/how-to-programming-a-wordpress-sidebar-widget-plugin/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Should I Buy the New iPhone?</title>
		<link>http://tektok.romagazin.net/2008/07/24/should-i-buy-the-new-iphone/</link>
		<comments>http://tektok.romagazin.net/2008/07/24/should-i-buy-the-new-iphone/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 23:15:30 +0000</pubDate>
		<dc:creator>Alin M.</dc:creator>
		
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://tektok.romagazin.net/?p=3</guid>
		<description><![CDATA[A year ago I was able to resist the initial launch of the iPhone because I was in the middle of a 2-year contract with T-Mobile. This time, however, resisting it proves to be a little harder; the new iPhone 3G is a lot less expensive than its predecessor and promises 3G capability, which any [...]]]></description>
			<content:encoded><![CDATA[<p>A year ago I was able to resist the initial launch of the iPhone because I was in the middle of a 2-year contract with T-Mobile. This time, however, resisting it proves to be a little harder; the new iPhone 3G is a lot less expensive than its predecessor and promises 3G capability, which any intense user would like to have.  Moreover, my contract with T-Mobile has expired and I&#8217;am quietly paying by the month until I decide to make a move.</p>
<p>But going for the iPhone 3G isn&#8217;t such a no-brainer as some might think. Not for me, anyway. I&#8217;ll tell you why. First because when I signed the 2-year contract with T-Mobile I got the T-Mobile Wing for free through letstalk.com. They even shipped it to me free of charge. All I had to do was to fill out an online form and a couple of days later I found it in my mail box. That&#8217;s a savings of at least $200 plus the convenience of having it come to me as opposed to going to the store and standing in line for it.</p>
<p>Second, I don&#8217;t see that much of a difference in the feature pack. I read my email almost exclusively on my phone, I browse the Internet on my phone whenever I can&#8217;t use the laptop. (I still prefer a big screen for browsing the Internet. The websites that I use regularly don&#8217;t display quite the same on the cellphone screen.) I can read/write Word, Excel and PowerPoint documents (a feature that the iPhone doesn&#8217;t have) and I can do anything that you are expected to be able to do on a cellphone. Oh yea, I also listen to music on my phone ;). So, why should I get the iPhone?</p>
<p>And then there is this crazy idea that the new iPhone works only on the AT&amp;T network. Even if you unlock it, there are so many people that report that as soon as you upgrade the firmware you&#8217;ll have to unlock it again and re-install all the applications that are not &#8220;kosher&#8221; to Apple. Do I really need this aggravation? I&#8217;ve had my T-Mobile Wing unlocked in Romania when I traveled there last year and now I can use the phone with any SIM card with all functionality intact. I remember I paid a guy $10 to unlock my phone; however, someone told me that T-Mobile customer service will give you the unlock code for free (I didn&#8217;t try it, though) &#8212; supposedly all you have to do is call them. Again, why get stuck with the iPhone on AT&amp;T?</p>
<p>There! I&#8217;ve worked up enough courage to say something against the Apple hype machine. I know I&#8217;m not alone in thinking this way. One thing: I welcome comments especially when the authors disagree with me, but please stop short of using objectionable language. There is nothing uglier that a person who resorts to ugly language. Now, let&#8217;s disagree.</p>






	<a rel="nofollow" target="_blank" href="mailto:?subject=Should%20I%20Buy%20the%20New%20iPhone%3F&amp;body=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F24%2Fshould-i-buy-the-new-iphone%2F" title="E-mail this story to a friend!"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="javascript:window.print();" title="Print this article!"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/printer.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F24%2Fshould-i-buy-the-new-iphone%2F" title="Technorati"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F24%2Fshould-i-buy-the-new-iphone%2F&amp;title=Should%20I%20Buy%20the%20New%20iPhone%3F" title="Digg"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F24%2Fshould-i-buy-the-new-iphone%2F&amp;title=Should%20I%20Buy%20the%20New%20iPhone%3F" title="Google"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F24%2Fshould-i-buy-the-new-iphone%2F&amp;t=Should%20I%20Buy%20the%20New%20iPhone%3F" title="Facebook"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F24%2Fshould-i-buy-the-new-iphone%2F&amp;title=Should%20I%20Buy%20the%20New%20iPhone%3F" title="del.icio.us"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://blogsvine.com/submit.php?url=http%3A%2F%2Ftektok.romagazin.net%2F2008%2F07%2F24%2Fshould-i-buy-the-new-iphone%2F" title="Blogsvine"><img src="http://tektok.romagazin.net/wp-content/plugins/sociable/images/blogsvine.png" title="Blogsvine" alt="Blogsvine" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://tektok.romagazin.net/2008/07/24/should-i-buy-the-new-iphone/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
