<?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>Tim Van Wassenhove &#187; PHP</title>
	<atom:link href="http://www.timvw.be/category/information-technology/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.timvw.be</link>
	<description>The journey of a thousand miles begins with one step.</description>
	<lastBuildDate>Thu, 29 Jul 2010 17:07:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>WordPress: Import Blogroll from Sage</title>
		<link>http://www.timvw.be/wordpress-import-blogroll-from-sage/</link>
		<comments>http://www.timvw.be/wordpress-import-blogroll-from-sage/#comments</comments>
		<pubDate>Sat, 25 Aug 2007 20:54:15 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.timvw.be/wordpress-import-blogroll-from-sage/</guid>
		<description><![CDATA[Earlier today i exported the list with blogs i read from Sage and tried to import them into WordPress. Although all the entries had been processed but none of them appeared. Apparently you have to rename the xmlUrl attribute to htmlUrl in the OPML file. With Vim that&#8217;s as simple as &#8220;:%s/xmlUrl/htmlUrl/g&#8221;. Anyway, feel free [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier today i exported the list with blogs i read from <a href="http://sage.mozdev.org/">Sage</a> and tried to import them into <a href="http://wordpress.org">WordPress</a>. Although all the entries had been processed but none of them appeared. Apparently you have to rename the xmlUrl attribute to htmlUrl in the <a href="http://en.wikipedia.org/wiki/OPML">OPML</a> file. With Vim that&#8217;s as simple as &#8220;:%s/xmlUrl/htmlUrl/g&#8221;.</p>
<p>Anyway, feel free to see if you find anything interesting in the <a href="http://www.timvw.be/wp-links-opml.php">list of blogs i&#8217;m reading</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/wordpress-import-blogroll-from-sage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An example of why i don&#8217;t like the ext/filter API</title>
		<link>http://www.timvw.be/an-example-of-why-i-dont-like-extfilter/</link>
		<comments>http://www.timvw.be/an-example-of-why-i-dont-like-extfilter/#comments</comments>
		<pubDate>Wed, 27 Dec 2006 01:11:30 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.timvw.be/an-example-of-why-i-dont-like-extfilter/</guid>
		<description><![CDATA[Earlier this week i decided to experiment with the Filter functions. Here&#8217;s an example that illustrates why i think the API needs to be improved: &#60;?php $isgoodapi = filter_input(INPUT_GET, 'isgoodapi', FILTER_VALIDATE_BOOLEAN); if (is_null($isgoodapi)) { echo &#34;the 'isgoodapi' argument is missing.&#34;; } else if ($isgoodapi === FALSE) { echo &#34;The 'isgoodapi' argument must be a valid [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this week i decided to experiment with the <a href="http://be2.php.net/manual/en/function.filter-input.php">Filter</a> functions. Here&#8217;s an example that illustrates why i think the API needs to be improved:</p>
<pre class="brush: php;">&lt;?php
$isgoodapi = filter_input(INPUT_GET, 'isgoodapi', FILTER_VALIDATE_BOOLEAN);

if (is_null($isgoodapi)) { 
 echo &quot;the 'isgoodapi' argument is missing.&quot;;
} else if ($isgoodapi === FALSE) { 
 echo &quot;The 'isgoodapi' argument must be a valid boolean.&quot;; 
} else { 
 echo &quot;isgoodapi is: $isgoodapi.&quot;; 
}
?&gt;</pre>
<p>And now you request the page with ?isgoodapi=false. The obvious problem is the fact that the function returns multiple &#8216;sorts&#8217; of return values: Value of the requested variable on success, FALSE if the filter fails, or NULL if the variable_name variable is not set. If the flag FILTER_NULL_ON_FAILURE is used, it returns FALSE if the variable is not set and NULL if the filter fails.</p>
<p>The documentation for <a href="http://be2.php.net/manual/en/ref.filter.php">Filter Functions</a> says for FILTER_VALIDATE_BOOLEAN: Returns TRUE for &#8220;1&#8243;, &#8220;true&#8221;, &#8220;on&#8221; and &#8220;yes&#8221;, FALSE for &#8220;0&#8243;, &#8220;false&#8221;, &#8220;off&#8221;, &#8220;no&#8221;, and &#8220;&#8221;, NULL otherwise. So if you try with ?isgoodapi=konijn you would expect NULL but that isn&#8217;t the case either.</p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/an-example-of-why-i-dont-like-extfilter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate a menu with month names</title>
		<link>http://www.timvw.be/generate-a-menu-with-month-names/</link>
		<comments>http://www.timvw.be/generate-a-menu-with-month-names/#comments</comments>
		<pubDate>Sun, 03 Sep 2006 00:11:21 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.timvw.be/generate-a-menu-with-month-names/</guid>
		<description><![CDATA[I still see people building their calendar control or month (or day) picker with a hardcoded array of month (or day) names. With the use of strftime you can easily build a locale aware version. Here is an example: &#60;?php function SelectMonths($name = 'selectMonths', $id = 'selectMonths') { $current_month = date('n'); echo '&#60;select name=&#34;' . [...]]]></description>
			<content:encoded><![CDATA[<p>I still see people building their calendar control or month (or day) picker with a hardcoded array of month (or day) names. With the use of <a href="http://www.php.net/strftime">strftime</a> you can easily build a <a href="http://www.php.net/setlocale">locale aware</a> version. Here is an example:</p>
<pre class="brush: php;">&lt;?php
function SelectMonths($name = 'selectMonths', $id = 'selectMonths') {
 $current_month = date('n');
  
 echo '&lt;select name=&quot;' . $name .'&quot; id=&quot;' . $id . '&quot;&gt;';
 
 for ($i = 1; $i &lt; 13; ++$i) {
  echo '&lt;option value=&quot;' . $i . '&quot;';

  if ($i == $current_month) {
   echo ' selected';
  }

 $month_name = strftime('%B', mktime(0, 0, 0, $i, 1, 2006));

  echo '&gt;' . $month_name . '&lt;/option&gt;';
 }
 
 echo '&lt;/select&gt;';
}
?&gt;</pre>
<p>And now you can easily generate a localized menu:</p>
<pre class="brush: php;">&lt;?php
include('SelectMonths.php');

SelectMonths();

// Tested on a Windows host - Read the http://be.php.net/setlocale
setlocale(LC_TIME, 'dutch');
SelectMonths();
?&gt;</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/generate-a-menu-with-month-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic CSS with PHP</title>
		<link>http://www.timvw.be/dynamic-css-with-php/</link>
		<comments>http://www.timvw.be/dynamic-css-with-php/#comments</comments>
		<pubDate>Sun, 27 Aug 2006 00:13:40 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.timvw.be/dynamic-css-with-php/</guid>
		<description><![CDATA[Both html and css are simply text. Thus you should be able to generate css as easily as html with php. Now if you add a reference to the css.php file in your html (eg: &#60;link rel=&#8221;stylesheet&#8221; href=&#8221;http://example.com/css.php&#8221; type=&#8221;text/css&#8221; media=&#8221;screen&#8221; /&#62;) you&#8217;ll probably experience that your browser ignores the file. How is this possible? Here [...]]]></description>
			<content:encoded><![CDATA[<p>Both html and css are simply text. Thus you should be able to generate css as easily as html with php. Now if you add a reference to the css.php file in your html (eg: &lt;link rel=&#8221;stylesheet&#8221; href=&#8221;http://example.com/css.php&#8221; type=&#8221;text/css&#8221; media=&#8221;screen&#8221; /&gt;) you&#8217;ll probably experience that your browser ignores the file. How is this possible? Here is an example of a simple css.php file</p>

<pre class="brush: php;">body {
        background-color: &lt;?php echo 'yellow'; ?&gt;;
}</pre>

<p>Here is a simulation of what your browser recieves when it requests the file:</p>

<pre>
HTTP/1.1 200 OK
Date: Sat, 26 Aug 2006 23:36:21 GMT
Server: Apache/1.3.34 (Unix) PHP/4.4.2 mod_macro/1.1.2
X-Powered-By: PHP/4.4.2
Connection: close
Content-Type: text/html; charset=iso-8859-1

body {
        background-color: yellow;
}
</pre>

<p>Where did that content-type header come from? Well, php outputs a default content-type header (text/html) when you don&#8217;t set value explicitely. This means that your browser will try to interpret the file as html instead of css. Although it may seem weird, this behaviour is explicitely defined in <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.2.1">RFC 2616</a>.</p>

<p>So the solution is pretty simple: explicitely generate content-type header. Here is an example for css: (You&#8217;re smart enough to figure it out for csv, m3u, &#8230;)</p>

<pre class="brush: php;">&lt;?php header('Content-type: text/css');?&gt;
body {
  background-color: &lt;?php echo 'white'; ?&gt;
}
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/dynamic-css-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Allow a form to be posted only once</title>
		<link>http://www.timvw.be/allow-a-form-to-be-posted-only-once/</link>
		<comments>http://www.timvw.be/allow-a-form-to-be-posted-only-once/#comments</comments>
		<pubDate>Sat, 01 Apr 2006 22:51:40 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.timvw.be/allow-a-form-to-be-posted-only-once/</guid>
		<description><![CDATA[People can fill in a form and submit it. Then they can hit their back button, and choose to submit it again. Usually the second time this form is being posted, the values in that form aren&#8217;t valid anymore and thus corrupt the database. Most developpers i know try to work around this problem by [...]]]></description>
			<content:encoded><![CDATA[<p>People can fill in a form and submit it. Then they can hit their back button, and choose to submit it again. Usually the second time this form is being posted, the values in that form aren&#8217;t valid anymore and thus corrupt the database. 
Most developpers i know try to work around this problem by using the header function or the html meta tags to set the expiration date. However, this solution does not only limit the usability of a site, it simply does not work for visitors that have a browser that ignores the expiration date.</p>
<p>My solution for this problem is quite easy. For each entity in the database that can be updated by a form, we should add an attribute lastupdate. Now every time we build a form that contains data of that entity, we should also add an input of type hidden with the value of that lastupdate attribute. If the value of the lastupdate attribute in the database is more recent than the value of the posted lastupdate in the recieving script, then the posted values are invalid and this script should tell the user about this error. Offcourse, every time such an entity is updated, the lastupdate attribute of this entity should be updated too.</p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/allow-a-form-to-be-posted-only-once/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using cmd.exe</title>
		<link>http://www.timvw.be/using-cmdexe/</link>
		<comments>http://www.timvw.be/using-cmdexe/#comments</comments>
		<pubDate>Sat, 01 Apr 2006 00:30:07 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.timvw.be/using-cmdexe/</guid>
		<description><![CDATA[Earlier someone asked me how he could use windows cmd.exe with PHP. People run into trouble as soon as there are quotes needed because there are special characters (&#62;/&#038;()[]{}^=;!&#8217;+,`~ and &#60;space&#62;) in the command. I do it like this: &#60;?php $result = `&#34;&#34;c:\\my path\\prog.exe&#34; &#34;filename&#34;&#34;`; ?&#62; In case you have to do it often you [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier someone asked me how he could use <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true">windows cmd.exe</a> with PHP. People run into trouble as soon as there are quotes needed because there are special characters (&gt;/&#038;()[]{}^=;!&#8217;+,`~ and &lt;space&gt;) in the command. I do it like this:</p>
<pre class="brush: php;">&lt;?php
$result = `&quot;&quot;c:\\my path\\prog.exe&quot; &quot;filename&quot;&quot;`;
?&gt;</pre>
<p>In case you have to do it often you might want to wrap it into a little function like this:</p>
<pre class="brush: php;">&lt;?php 
function cmd($command, $arguments = null)
{
        $commandline = '';
        foreach(func_get_args() as $word) {
                $commandline .= '&quot;' . $word . '&quot; ';
        }
        $commandline = rtrim($commandline, ' ');
        $commandline = '&quot;' . $commandline . '&quot;';
        return `$commandline`;
}

// run blah.exe
cmd('blah.exe');

// run c:\my path\blah.exe with the arguments &quot;foo&quot; and &quot;bar bar&quot; 
cmd('c:\\my path\\blah.exe', 'foo', 'bar bar');
?&gt;</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/using-cmdexe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internationalizing strings with variables</title>
		<link>http://www.timvw.be/internationalizing-strings-with-variables/</link>
		<comments>http://www.timvw.be/internationalizing-strings-with-variables/#comments</comments>
		<pubDate>Sun, 19 Mar 2006 00:47:03 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.timvw.be/internationalizing-strings-with-variables/</guid>
		<description><![CDATA[Yesterday i wrote that you can use __($string, $domain) and _e($string, $domain) to internationalize a string with WordPress. I forgot to mention that if you use sprintf you can handle strings with variables too. An example: echo sprintf(__('There are %d monkeys in the %s'), $domain), $number, $location);]]></description>
			<content:encoded><![CDATA[<p>Yesterday i wrote that you can use __($string, $domain) and _e($string, $domain) to internationalize a string with <a href="http://www.wordpress.org">WordPress</a>. I forgot to mention that if you use <a href="http://www.php.net/sprintf">sprintf</a> you can handle strings with variables too. An example:</p>
<pre class="brush: php;">
echo sprintf(__('There are %d monkeys in the %s'), $domain), $number, $location);
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/internationalizing-strings-with-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding support for localization to a WordPress plugin</title>
		<link>http://www.timvw.be/adding-support-for-localization-to-a-wordpress-plugin/</link>
		<comments>http://www.timvw.be/adding-support-for-localization-to-a-wordpress-plugin/#comments</comments>
		<pubDate>Sun, 19 Mar 2006 00:34:29 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.timvw.be/adding-support-for-localization-to-a-wordpress-plugin/</guid>
		<description><![CDATA[WordPress uses GNU gettext, as explained in Translating WordPress and Writing a Plugin, for localization. I decided that my plugins should support l10n too. Here is how i realised it: I started with defining the WPLANG constant in my wp-config.php: define ('WPLANG', 'en_EN'); Then i changed the beginning of my localized plugin as following: &#60;?php [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress uses <a href="http://www.gnu.org/software/gettext/">GNU gettext</a>, as explained in <a href="http://codex.wordpress.org/Localizing_WordPress">Translating WordPress</a> and <a href="http://codex.wordpress.org/Writing_a_Plugin">Writing a Plugin</a>, for <a href="http://en.wikipedia.org/wiki/Software_localization">localization</a>. I decided that my plugins should support l10n too. Here is how i realised it:</p>

<p>I started with defining the WPLANG constant in my wp-config.php:</p>
<pre class="brush: php;">define ('WPLANG', 'en_EN');</pre>

<p>Then i changed the beginning of my localized plugin as following:</p>
<pre class="brush: php;">&lt;?php
/*
Plugin Name: WP-SpamFilter
Version: 0.4
Plugin URI: http://timvw.madoka.be/?p=533
Description: Mark the new comment as spam if the sender is in the spammers list.
Author: Tim Van Wassenhove &lt;timvw@users.sourceforge.net&gt;
Author URI: http://timvw.be
*/

// If this function does not exist it means that the file is accessed directly.
// Accessing this file directly is not allowed.
if (!function_exists('load_plugin_textdomain')) {
  exit;
}

load_plugin_textdomain('wp_spamfilter', 'wp-content/plugins/wp-spamfilter');
</pre>

<p>In wp-includes/wp-l10n.php you see that the result of this call is that the locale and the path are used to determine the mo-file to be loaded. Because this function uses ABSPATH it&#8217;s impossible to use dirname(__FILE__) as path parameter <img src='http://www.timvw.be/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>

<p>The _e($string, $domain) function echos a localized string and the __($string, $domain) function returns a localized string that you can use in function calls etc&#8230; Below you can see an example of the original version and the updated version with localization support: </p>
<pre class="brush: php;">
&lt;h2&gt;some string&lt;/h2&gt;
&lt;?php echo('some other string'); ?&gt;
</pre>

<pre class="brush: php;">
&lt;h2&gt;&lt;?php _e('some string', 'wp_spamfilter'); ?&gt;&lt;/h2&gt;
&lt;?php echo(__('some other string', 'wp_spamfilter')); ?&gt;
</pre>

<p>Then i used xgettext to extract all the strings that should be localized into wp_spamfilter-en_EN.po:</p>

xgettext &#8211;keyword=__ &#8211;keyword=_e &#8211;default-domain=wordpress &#8211;language=php *.php &#8211;output=wp_spamfilter-en_EN.po


<p>After that i editted the po file and i compiled a mo file with it using msgfmt:</p>

msgfmt wp_spamfilter-en_EN.po -o wp_spamfilter-en_EN.mo


<p>Once i had made sure that wp_spamfilter-en_EN.mo was readable by my webserver i was ready.</p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/adding-support-for-localization-to-a-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Plugin template for WordPress</title>
		<link>http://www.timvw.be/plugin-template-for-wordpress/</link>
		<comments>http://www.timvw.be/plugin-template-for-wordpress/#comments</comments>
		<pubDate>Sun, 19 Mar 2006 00:32:19 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.timvw.be/plugin-template-for-wordpress/</guid>
		<description><![CDATA[Today i&#8217;ve been cleaning up my code. All my plugins live in a directory %plugin_name% under the wp-content/plugins directory. Here is the code for %plugin_name%/%plugin_name%.php: &#60;?php /* Plugin Name: %plugin_name% Version: %plugin_version% Plugin URI: %plugin_uri% Description: %plugin_description% Author: %plugin_author_name% &#60;%plugin_author_mail%&#62; Author URI: %plugin_author_uri% */ // Direct access is not allowed. if (!function_exists('load_plugin_textdomain')) { exit; } [...]]]></description>
			<content:encoded><![CDATA[<p>Today i&#8217;ve been cleaning up my code. All my plugins live in a directory %plugin_name% under the wp-content/plugins directory. Here is the code for %plugin_name%/%plugin_name%.php:</p>
<pre class="brush: php;">&lt;?php
/*
Plugin Name: %plugin_name%
Version: %plugin_version%
Plugin URI: %plugin_uri%
Description: %plugin_description%
Author: %plugin_author_name% &lt;%plugin_author_mail%&gt;
Author URI: %plugin_author_uri%
*/

// Direct access is not allowed.
if (!function_exists('load_plugin_textdomain')) {
  exit;
} else {
  require('%plugin_name%.php');
  $plugin_name = substr(basename(__FILE__), 0, -4);

  // You can add optional parameters to the constructor, eg: the wpdb instance.
  $%plugin_class% = new %plugin_class%($plugin_name);
}
?&gt;</pre>

<p>Now it&#8217;s time to implement the %plugin_class%. Here is the template for %plugin_name%/%plugin_class%.php:</p>
<pre class="brush: php;">&lt;?php

class %plugin_class% {
  var $_plugin_name;

  var $_localization_domain;
  var $_localization_path;

  function %plugin_class%($plugin_name = '%plugin_name%') {
    $this-&gt;_plugin_name = $plugin_name;

    $this-&gt;_localization_domain = $plugin_name;
    $this-&gt;_localization_path = 'wp-content/plugins/' . $plugin_name;

    // You can add additional hooks and filters here.
    add_action('activate_' . $plugin_name . '/' . $plugin_name . '.php', array(&amp;$this, 'OnActivation'));
    add_action('admin_menu', array(&amp;$this, 'OnAdminMenu'));
}

  function OnAdminMenu() {
    load_plugin_textdomain($this-&gt;_localization_domain, $this-&gt;_localization_path);
    add_options_page(__('%plugin_name% Options', $this-&gt;_localization_domain), __('%plugin_name%', $this-&gt;_localization_domain), 'manage_options',$this-&gt;_plugin_name . '/' . $this-&gt;_plugin_name . '-options.php', array(&amp;$this, 'OnDisplayOptions'));
  }

  function OnDisplayOptions() {
    $%plugin_class% = &quot;&quot;;
    require( dirname(__FILE__) . '/' . $this-&gt;_plugin_name . '-options.php');
  }

  function OnActivation() {
    // This code is executed when the plugin is activated.
    // I prepend all my option names with $this-&gt;_plugin_name.
    add_option($this-&gt;_plugin_name . '_somevar', 'foo');
  }
}
?&gt;</pre>

<p>The code above requires that you create a %plugin_name%/%plugin_name%-options.php file to administrate the options. Here is the template for that file:</p>
<pre class="brush: php;">
&lt;?php
// Direct access is not allowed.
if (!isset($%plugin_class%)) {
  exit;
}                                                                                                                     

load_plugin_textdomain($%plugin_class%-&gt;_localization_domain, $%plugin_class%-&gt;_localization_path);

// Handle post action.
if ($_POST['stage'] == 'process') {
  // All the names of form variables start with %plugin_class%_plugin_name.
  if (isset($_POST[$%plugin_class%-&gt;_plugin_name . '_somevar'])) {
    // Do processing here.
  }
}

?&gt;
&lt;form method=&quot;post&quot; action=&quot;&quot;&gt;
  &lt;input type=&quot;hidden&quot; name=&quot;stage&quot; value=&quot;process&quot;/&gt;
  &lt;input type=&quot;text&quot; name=&quot;&lt;?php echo $%plugin_class%-&gt;_plugin_name . '_somevar'; ?&gt;&quot;/&gt;
  &lt;input type=&quot;submit&quot; value=&quot;&lt;?php _e('Submit', $%plugin_class%-&gt;_localization_domain); ?&gt;&quot;/&gt;
&lt;/form&gt;
</pre>

<p>The only thing that we still have to do is generate a po file with xgettext, translate it and compile a %plugin_name%/%plugin_name%-en_EN.mo file.</p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/plugin-template-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding an action when your plugin is activated</title>
		<link>http://www.timvw.be/adding-an-action-when-your-plugin-is-activated/</link>
		<comments>http://www.timvw.be/adding-an-action-when-your-plugin-is-activated/#comments</comments>
		<pubDate>Wed, 15 Mar 2006 00:47:58 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.timvw.be/adding-an-action-when-your-plugin-is-activated/</guid>
		<description><![CDATA[The WordPress documentation says that you have to call add_action(&#8216;activate_pluginurl&#8217;, &#8216;somefunction&#8217;) to trigger somefunction when your plugin is activated. Unfortunately i couldn&#8217;t find with what pluginurl should be replaced. After a bit of experimenting i&#8217;ve found that in wp-admin/plugins.php the following is called when a plugin is activated: do_action('activate_' . trim( $_GET['plugin'] )); So it [...]]]></description>
			<content:encoded><![CDATA[<p>The WordPress documentation says that you have to call add_action(&#8216;activate_pluginurl&#8217;, &#8216;somefunction&#8217;) to trigger somefunction when your plugin is activated. Unfortunately i couldn&#8217;t find with what pluginurl should be replaced. After a bit of experimenting i&#8217;ve found that in wp-admin/plugins.php the following is called when a plugin is activated:</p>

<pre class="brush: php;">
do_action('activate_' . trim( $_GET['plugin'] ));
</pre>

<p>So it appears that you simply have to use the path of your plugin relative to /wp-content/plugins. Eg: you have a plugin in /wp-content/plugins/wp-spamfilter/wp-spamfilter.php then you have to call add_action as following:</p>

<pre class="brush: php;">
add_action('activate_wp-spamfilter/wp-spamfilter.php', 'somefunction');
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/adding-an-action-when-your-plugin-is-activated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
