<?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>Dimuthu's Blog &#187; wordpress</title>
	<atom:link href="http://www.dimuthu.org/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dimuthu.org</link>
	<description>Waiting for your comments</description>
	<lastBuildDate>Wed, 07 Jul 2010 12:42:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<image>
  <link>http://www.dimuthu.org</link>
  <url>http://www.dimuthu.org/favicon.ico</url>
  <title>Dimuthu's Blog</title>
</image>
		<item>
		<title>WordPress Database &#8211; Relationship with Tags, Catagories and Posts</title>
		<link>http://www.dimuthu.org/blog/2008/12/20/wordpress-database-relationship-with-tags-catagories-and-posts/</link>
		<comments>http://www.dimuthu.org/blog/2008/12/20/wordpress-database-relationship-with-tags-catagories-and-posts/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 16:11:39 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[catgoary]]></category>
		<category><![CDATA[posts]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[taxonomy]]></category>
		<category><![CDATA[term]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=825</guid>
		<description><![CDATA[WordPress has a very simple database schema. And it is well documented. You can access the complete description of the wordpress core database from here, http://codex.wordpress.org/Database_Description. Anyway first time I looked at the database I was confused with the term and the term_taxonomy table, why we need two tables for term and taxonomies. In fact [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress has a very simple database schema. And it is well documented. You can access the complete description of the wordpress core database from here, <a href="http://codex.wordpress.org/Database_Description">http://codex.wordpress.org/Database_Description</a>.</p>
<p>Anyway first time I looked at the database I was confused with the term and the term_taxonomy table, why we need two tables for term and taxonomies. In fact in wordpress, the table &#8216;posts&#8217; is associated with the table &#8216;term_taxonomy&#8217; and not the table &#8216;term&#8217; itself. In the term taxonomy table the terms are associated to a link category, post category or a tag. So the associations of posts to a tag or category is something like this.</p>
<div id="attachment_828" class="wp-caption alignnone" style="width: 510px"><a href="http://www.dimuthu.org/wp-content/uploads/2008/12/wp_term_post_association.jpeg"><img class="size-full wp-image-828" title="wp_term_post_association" src="http://www.dimuthu.org/wp-content/uploads/2008/12/wp_term_post_association.jpeg" alt="wp_term_post association" width="500" height="136" /></a><p class="wp-caption-text">wp_term_post association</p></div>
<p>So in a case you try querying for posts with a given tag it will be like this. (Note that I have skipped the optional database table prefix which is by default &#8216;wp_&#8217;)</p>
<pre class="sql"><span style="font-weight: bold; color: #993333;">SELECT</span> post_title,
       post_content,
       post_date
<span style="font-weight: bold; color: #993333;">FROM</span> posts p,
     terms t,
     term_relationships r,
     term_taxonomy tt
<span style="font-weight: bold; color: #993333;">WHERE</span> p.post_status=<span style="color: #ff0000;">'publish'</span> <span style="font-weight: bold; color: #993333;">AND</span>
      tt.taxonomy = <span style="color: #ff0000;">'post_tag'</span> <span style="font-weight: bold; color: #993333;">AND</span>
      p.id=r.object_id <span style="font-weight: bold; color: #993333;">AND</span>
      r.term_taxonomy_id=tt.term_taxonomy_id <span style="font-weight: bold; color: #993333;">AND</span>
      tt.term_id = t.term_id <span style="font-weight: bold; color: #993333;">AND</span> t.name <span style="font-weight: bold; color: #993333;">LIKE</span> ?</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/12/20/wordpress-database-relationship-with-tags-catagories-and-posts/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Write an Adsense Widget for your WordPress Blog on Your Own</title>
		<link>http://www.dimuthu.org/blog/2008/10/17/write-an-adsense-widget-for-your-wordpress-blog-on-your-own/</link>
		<comments>http://www.dimuthu.org/blog/2008/10/17/write-an-adsense-widget-for-your-wordpress-blog-on-your-own/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 20:17:20 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[adsense]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=484</guid>
		<description><![CDATA[It is really easy to write a widget to the wordpress blog. So I thought of writing my own widget to show Google ads in my Blog. Here is how I did it. First generate the JavaScript code for your adsense account from the Google Adsense Page. You can do this by sigining in to [...]]]></description>
			<content:encoded><![CDATA[<p>It is really easy to write a widget to the wordpress blog. So I thought of writing my own widget to show Google ads in my Blog. Here is how I did it.</p>
<ol>
<li>First generate the JavaScript code for your adsense account from the Google Adsense Page. You can do this by sigining in to the Dashboard of Adsense from <a href="https://www.google.com/adsense/">https://www.google.com/adsense/</a>. Then click the &#8220;Adsense Setup&#8221; tab and follow the wizard.</li>
<li>Inside the &#8220;wp-content/plugins&#8221; directory of your WordPress installation create a file for your plugin. (Say myadsense_widget.php)</li>
<li>Then first write the code that should be appeared in your widget.  In this case you can just echo the the code provide by the Google. Anyway In order to make your widget complaint with the current theme, you have to use the code similar to the following.
<pre class="php"><span style="font-style: italic; color: #808080;">// the function for the widget</span>
<span style="font-weight: bold; color: #000000;">function</span> widget_myadsense<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$args</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
	<span style="font-style: italic; color: #808080;">// being aware of the theme</span>
	<a href="http://www.php.net/extract"><span style="color: #000066;">extract</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$args</span><span style="color: #66cc66;">)</span>;
	<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$before_widget</span>;
	<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$before_title</span> . <span style="color: #ff0000;">"Google Adsense"</span>. <span style="color: #0000ff;">$after_title</span>;

	<span style="font-style: italic; color: #808080;">// here you just echo the code provided by the google </span>
	<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> &lt;&lt;&lt;GOOGLE_JS
		&lt;!-- in this space you have to copy paste
                the code provided by the google--&gt;
GOOGLE_JS;

	<span style="font-style: italic; color: #808080;">// again being aware of the theme</span>
	<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$after_widget</span>;
<span style="color: #66cc66;">}</span></pre>
</li>
<li> Then write the code to register the above function as a widget with the following piece of code.
<pre class="php"><span style="font-style: italic; color: #808080;">// initiating widget</span>
<span style="font-weight: bold; color: #000000;">function</span> myadsense_init<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
	register_sidebar_widget<span style="color: #66cc66;">(</span>__<span style="color: #66cc66;">(</span><span style="color: #ff0000;">'My Adsense'</span><span style="color: #66cc66;">)</span>, <span style="color: #ff0000;">'widget_myadsense'</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>

<span style="font-style: italic; color: #808080;">// adding the action</span>
add_action<span style="color: #66cc66;">(</span><span style="color: #ff0000;">"plugins_loaded"</span>, <span style="color: #ff0000;">"myadsense_init"</span><span style="color: #66cc66;">)</span>;</pre>
</li>
<li> We are almost done here, But don&#8217;t forget you can mention your information as the widget plugin author with a  comment similar to the following template.
<pre class="php"><span style="font-style: italic; color: #808080;">/*
Plugin Name: MyAdsense
Plugin URI: http://dimuthu.org
Description: Adsense Plugin for my blog
Author: Dimuthu Gamage
Version: 0.1
Author URI: http://dimuthu.org
*/</span></pre>
</li>
<li> That is all you have to code. Now just go the Plugins section of the wordpress from your Dashboard and enable the plugin (&#8220;myadsesne&#8221;) you just created.</li>
<li> Go to the Design-&gt;Widget section and add your Widget to the Sidebar and click &#8220;Save Changes&#8221;. And go to your blog URL and make sure that the Ads are shown in there.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/10/17/write-an-adsense-widget-for-your-wordpress-blog-on-your-own/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make your WordPress Blog a Web Service in Few Steps</title>
		<link>http://www.dimuthu.org/blog/2008/08/11/make-your-wordpress-blog-a-web-service-in-few-step/</link>
		<comments>http://www.dimuthu.org/blog/2008/08/11/make-your-wordpress-blog-a-web-service-in-few-step/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 03:03:35 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[DataServices]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[data services]]></category>
		<category><![CDATA[DataService]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Steps]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=90</guid>
		<description><![CDATA[With PHP DataServices it is just a matter of putting a little configuration php file to make your database available as a web service. I only needed few minutes to make a simple web service from my blog after figuring out my wordpress database structure, http://wpbits.wordpress.com/2007/08/08/a-look-inside-the-wordpress-database/. In this guide, I m exposing the title, date [...]]]></description>
			<content:encoded><![CDATA[<p>With PHP DataServices it is just a matter of putting a little configuration php file to make your database available as a web service. I only needed few minutes to make a simple web service from my blog after figuring out my wordpress database structure, <a href="http://wpbits.wordpress.com/2007/08/08/a-look-inside-the-wordpress-database/">http://wpbits.wordpress.com/2007/08/08/a-look-inside-the-wordpress-database/.</a> In this guide, I m exposing the title, date and the content of each of my blog for my service, But you can extend this more the way you prefer.</p>
<ol>
<li>Download and install <a href="http://wso2.org/downloads/wsf/php">WSF/PHP 1.3.2</a> and <a href="http://labs.wso2.org/wsf/php/downloads/DataServices/DataServices.zip">PHP Data Services Library.</a> If WSF/PHP 2.0 released by the time you are reading this, (it is to be released in this week), you only need to install WSF/PHP, since the DataServices library is packed with WSF/PHP from 2.0.</li>
<li>Drop the following file (Say WordPressService.php) in to any of your web server document directories.
<pre><span style="font-weight: bold; color: #000000;">&lt;?php</span>

<span style="font-style: italic; color: #808080;">// Make sure you put the DataService.php in your include path</span>
<span style="color: #b1b100;">require_once</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"wso2/DataServices/DataService.php"</span><span style="color: #66cc66;">)</span>;

<span style="font-style: italic; color: #808080;">// database configuraitons</span>
<span style="font-style: italic; color: #808080;">// you have to set your database configurations in here..</span>
<span style="font-style: italic; color: #808080;">// These entries can be copy and past from the wp-config.php in your wordpress installation</span>

<span style="color: #0000ff;">$config</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>
<span style="color: #ff0000;">"db"</span> =&gt; <span style="color: #ff0000;">"mysql"</span>,
<span style="color: #ff0000;">"username"</span>=&gt;DB_USER,
<span style="color: #ff0000;">"password"</span>=&gt; DB_PASSWORD,
<span style="color: #ff0000;">"dbname"</span>=&gt;DB_NAME,
<span style="color: #ff0000;">"dbhost"</span>=&gt;DB_HOST<span style="color: #66cc66;">)</span>;
<span style="font-style: italic; color: #808080;">// output format, plese check the API from http://wso2.org/wiki/display/wsfphp/API+for+Data+Services+Revised</span>
<span style="color: #0000ff;">$outputFormat</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"resultElement"</span> =&gt; <span style="color: #ff0000;">"Posts"</span>,
<span style="color: #ff0000;">"rowElement"</span> =&gt; <span style="color: #ff0000;">"post"</span>,
<span style="color: #ff0000;">"elements"</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span> <span style="color: #ff0000;">"title"</span> =&gt; <span style="color: #ff0000;">"post_title"</span>,
<span style="color: #ff0000;">"content"</span> =&gt; <span style="color: #ff0000;">"post_content"</span>,
<span style="color: #ff0000;">"date"</span> =&gt; <span style="color: #ff0000;">"post_date"</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

<span style="font-style: italic; color: #808080;">// sql statment to execute, note that I assume the table prefix is wp_ (so the table name is wp_posts)</span>
<span style="font-style: italic; color: #808080;">// just check $table_prefix variable in the wp-config.php of your wordpress installation</span>
<span style="color: #0000ff;">$sql</span>=<span style="color: #ff0000;">"select post_title, post_content, post_date from wp_posts where post_status='published'"</span>;

<span style="font-style: italic; color: #808080;">// operations is consist of inputFormat (optional), outputFormat(required), sql(sql), input_mapping(optional)</span>
<span style="color: #0000ff;">$operations</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"getPosts"</span>=&gt;array<span style="color: #66cc66;">(</span><span style="color: #ff0000;">"outputFormat"</span>=&gt;<span style="color: #0000ff;">$outputFormat</span>, <span style="color: #ff0000;">"sql"</span>=&gt;<span style="color: #0000ff;">$sql</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #0000ff;">$my_data_service</span> = <span style="font-weight: bold; color: #000000;">new</span> DataService<span style="color: #66cc66;">(</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"config"</span>=&gt;<span style="color: #0000ff;">$config</span>,<span style="color: #ff0000;">"operations"</span>=&gt;<span style="color: #0000ff;">$operations</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

<span style="color: #0000ff;">$my_data_service</span>-&gt;<span style="color: #006600;">reply</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="font-weight: bold; color: #000000;">?&gt;</span></pre>
</li>
<li>It is all. Just access the above file from a web browser, you see your service is hosted. Here is the endpoint for my service. <a href="http://ws.dimuthu.org/blog/WordPressService.php">http://ws.dimuthu.org/blog/WordPressService.php</a>. Since I m using WSF/PHP latest svn, I m able to retrieve the wsdl automatically from <a href="http://ws.dimuthu.org/blog/WordPressService.php?wsdl">http://ws.dimuthu.org/blog/WordPressService.php?wsdl</a>. Please wait for WSF/PHP 2.0 release for ?wsdl feature.</li>
<li>To verify whether your service deployed correctly, you may need to write a simple test client. Yea I too wrote one. Since I have the wsdl generated, I just needed to generate the code for the client from the wsdl using wsdl2php tool. There is an online version of the tool in the wsf/php demo site. Here is the generated code for my client, <a href="http://labs.wso2.org/wsf/php/wsdl2phptool.php?wsdl_url=http%3A%2F%2Fws.dimuthu.org%2Fblog%2FWordPressService.php%3Fwsdl">http://labs.wso2.org/wsf/php/wsdl2phptool.php?wsdl_url=http%3A%2F%2Fws.dimuthu.org%2Fblog%2FWordPressService.php%3Fwsdl</a>. I added the following code to the TODO section in handling response,
<pre>    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">(</span><a href="http://www.php.net/is_array"><span style="color: #000066;">is_array</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$response</span>-&gt;<span style="color: #006600;">post</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
        <span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$response</span>-&gt;<span style="color: #006600;">post</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$post</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

            <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">"&lt;h2&gt;"</span>.<span style="color: #0000ff;">$post</span>-&gt;<span style="color: #006600;">title</span> . <span style="color: #ff0000;">" - "</span>.<span style="color: #0000ff;">$post</span>-&gt;<span style="color: #006600;">date</span>.<span style="color: #ff0000;">"&lt;/h2&gt;"</span>;
            <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">"&lt;p&gt;"</span>;
            <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$post</span>-&gt;<span style="color: #006600;">content</span>;
            <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">"&lt;/p&gt;"</span>;

            <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">"&lt;hr/&gt;"</span>;
        <span style="color: #66cc66;">}</span>
    <span style="color: #66cc66;">}</span></pre>
<p>Check my Web Service client for the above service here, <a href="http://ws.dimuthu.org/blog/WordPressClient.php">http://ws.dimuthu.org/blog/WordPressClient.php</a>.</li>
</ol>
<p>Now I can call for my blog from any web service enabled platform.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/08/11/make-your-wordpress-blog-a-web-service-in-few-step/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
