<?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>Nicolas Kuttler &#187; development</title>
	<atom:link href="http://www.nkuttler.de/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nkuttler.de</link>
	<description>WordPress Services, IT Services</description>
	<lastBuildDate>Wed, 28 Jul 2010 23:49:18 +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>wp_enqueue_style, versioning and conditional CSS comments</title>
		<link>http://www.nkuttler.de/2010/07/28/wordpress-style-version-conditional-comments/</link>
		<comments>http://www.nkuttler.de/2010/07/28/wordpress-style-version-conditional-comments/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 13:00:28 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress theme]]></category>
		<category><![CDATA[wp_enqueue_style]]></category>

		<guid isPermaLink="false">http://nkuttler.wordpress-server.de/?p=1796</guid>
		<description><![CDATA[I like to enqueue my CSS styles because it has the benefit of adding a version string. A link like style.css?ver=0.7 is useful because it will force visitors to download an updated style.css when the version number is increased. Here&#8217;s what I currently use in my functions.php: if &#40; !is_admin&#40;&#41; &#41; &#123; $theme = get_theme&#40; [...]]]></description>
			<content:encoded><![CDATA[<p>I like to enqueue my CSS styles because it has the benefit of adding a version string. A link like <code>style.css?ver=0.7</code> is useful because it will force visitors to download an updated <code>style.css</code> when the version number is increased. Here&#8217;s what I currently use in my <code>functions.php</code>:<span id="more-1796"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #000088;">$theme</span>  <span style="color: #339933;">=</span> get_theme<span style="color: #009900;">&#40;</span> get_current_theme<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    wp_register_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'your-style'</span><span style="color: #339933;">,</span> get_bloginfo<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'stylesheet_url'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$theme</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Version'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    wp_enqueue_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'your-style'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I don&#8217;t really like the <code>get_theme()</code> line, but I am not aware of a better way to get the version info. What&#8217;s good about that line is that it gets the version of the current child theme, if you&#8217;re using one.</p>
<p>One problem with enqueuing styles is that most themes need one or two additional CSS files inside conditional comments for a certain browser. <a href="http://www.andrewnacin.com/">Nacin</a> pointed me to a solution:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #000088;">$theme</span>  <span style="color: #339933;">=</span> get_theme<span style="color: #009900;">&#40;</span> get_current_theme<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    wp_register_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'your-style'</span><span style="color: #339933;">,</span> get_bloginfo<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'stylesheet_url'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$theme</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Version'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wp_styles'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_data</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'your-style'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'conditional'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'lte IE 8'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    wp_enqueue_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'your-style'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>See also the relevant <a href="http://core.trac.wordpress.org/ticket/10891">discussion on trac</a>. Using this could lead to script concatenation problems in the WordPress core (which doesn&#8217;t concern a theme developer) and if a website uses plugins like <a href="http://wordpress.org/extend/plugins/wp-minify/">wp-minify</a>. So you probably only want to use this in your own themes, not public ones.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2010/07/28/wordpress-style-version-conditional-comments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress is stupid</title>
		<link>http://www.nkuttler.de/2010/07/13/wordpress-is-stupid/</link>
		<comments>http://www.nkuttler.de/2010/07/13/wordpress-is-stupid/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 15:00:28 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://nkuttler.wordpress-server.de/?p=1823</guid>
		<description><![CDATA[In case you haven&#8217;t been aware of this, WordPress core developers think that potentially breaking thousands of links on thousands of sites is an accepatable edge case. Here&#8217;s a great summary of what has been said. I have another equally stupid pet bug. Basically, a CSS file can break core functionality which can lead to [...]]]></description>
			<content:encoded><![CDATA[<p>In case you haven&#8217;t been aware of this, WordPress core developers think that <a href="http://core.trac.wordpress.org/ticket/13583">potentially breaking thousands of links on thousands of sites</a> is <a href="http://lists.automattic.com/pipermail/wp-hackers/2010-July/032858.html">an accepatable edge case</a>. Here&#8217;s a <a href="http://justintadlock.com/archives/2010/07/08/lowercase-p-dangit">great summary</a> of what has been said.<span id="more-1823"></span></p>
<p>I have another <a href="http://core.trac.wordpress.org/ticket/14243">equally stupid</a> pet bug. Basically, a CSS file can break core functionality which can lead to bugs in plugins like my <a href="http://www.nkuttler.de/2008/10/07/theme-switch-and-preview-plugin/">theme switching</a> plugin. It&#8217;s a rather rare bug but the sloppiness of the coding is on the same level.</p>
<p>I have a code-centric blog. I post a lot of code, and of course readers post code themselves from time to time. Of course WordPress has to <a href="http://www.nkuttler.de/2010/06/08/wp_nav_menu-wordpress-3-0/#comment-2202">mess with comments as well</a>. I realize that removing potential XSS code is a good security measure. But seriously. Do <strong>not</strong> delete any content before it goes into the database (besides SQL sanitization). I can&#8217;t even recover that comment now.</p>
<p>Wordpress rant over <img src='http://www.nkuttler.de/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2010/07/13/wordpress-is-stupid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to add support for navigation menus to your WordPress theme</title>
		<link>http://www.nkuttler.de/2010/06/08/wp_nav_menu-wordpress-3-0/</link>
		<comments>http://www.nkuttler.de/2010/06/08/wp_nav_menu-wordpress-3-0/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 15:00:50 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress theme]]></category>
		<category><![CDATA[wp_nav_menu]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de/?p=1613</guid>
		<description><![CDATA[The new navigation menus system in WordPress 3.0 looks promising, but in my opinion it&#8217;s not very usable yet. Anyway, here&#8217;s one way to add navigation menus to your theme while maintaining backward compatibility: In your theme&#8217;s functions.php add something like the following code: 1 2 3 4 5 6 7 8 9 10 11 [...]]]></description>
			<content:encoded><![CDATA[<p>The new <a href="http://codex.wordpress.org/Appearance_Menus_SubPanel">navigation menus</a> system in WordPress 3.0 looks promising, but in my opinion it&#8217;s not very usable yet. Anyway, here&#8217;s one way to add navigation menus to your theme while maintaining backward compatibility:</p>
<p>In your theme&#8217;s <code>functions.php</code> add something like the following code:<span id="more-1613"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mytheme_addmenus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	register_nav_menus<span style="color: #009900;">&#40;</span>
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'main_nav'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'The Main Menu'</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mytheme_addmenus'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mytheme_nav<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_nav_menu'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
        wp_nav_menu<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'menu=main_nav&amp;container_class=pagemenu&amp;fallback_cb=mytheme_nav_fallback'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">else</span>
        mytheme_nav_fallback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mytheme_nav_fallback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    wp_page_menu<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'show_home=Start&amp;menu_class=pagemenu'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>In line 1 we add support for the navigation menus. The <code>mytheme_nav()</code> function is what you will use in the theme to display the menu. Inside that function we check if <code>wp_nav_menu()</code> exists, that means if we&#8217;re running WordPress 3.0 (or later). If not we&#8217;ll use the fallback function <code>mytheme_nav_fallback()</code>.</p>
<p>Notice that the fallback also gets called if no navigation menus have been created in the admin area. That&#8217;s what the <code>fallback_cb</code> parameter on line 4 does.</p>
<p>To keep the HTM markup and the CSS consistent you&#8217;ll have to use the <code>container_class</code> parameter on <code>wp_nav_menu</code> but the <code>menu_class</code> parameter for <code>wp_page_menu</code>.</p>
<p>In your template use the following code to use your new custom function:</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> mytheme_nav<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>Resources</h3>
<ul>
<li><a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu">wp_nav_menu() reference</a></li>
<li><a href="http://codex.wordpress.org/Template_Tags/wp_page_menu">wp_page_menu() reference</a></li>
<li><a href="http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus">Informative article on nav menus by Justin Tadlock</a></li>
</ul>
<a name="wptoc_0_0_0"></a><h2>Ramblings</h2>
<p>What&#8217;s good about the new menu system:</p>
<ul>
<li>Total control over what appears in the menu</li>
<li>You can add posts, pages, categories and tags in the menu</li>
<li>Very nice drag and drop interface</li>
</ul>
<p>What&#8217;s bad:</p>
<ul>
<li>You will have to teach your users how to use the system properly.</li>
<li>If you create new pages they won&#8217;t be added to your existing menu (except for top level pages).</li>
<li>You can not control your page menus through the navigation menus interface. I think it is&#8230; very very odd that WordPress doesn&#8217;t have a simple drag-and-drop interface to arrange pages.</li>
<li>The previous point means that the new menu system is useless unless you update your theme.</li>
<li>The <code>wp_nav_menu()</code> call is inconsistent with the existing <code>wp_page_menu()</code> function.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2010/06/08/wp_nav_menu-wordpress-3-0/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Nesting WordPress loops</title>
		<link>http://www.nkuttler.de/2010/05/30/wordpress-loop-inside-a-loop/</link>
		<comments>http://www.nkuttler.de/2010/05/30/wordpress-loop-inside-a-loop/#comments</comments>
		<pubDate>Sun, 30 May 2010 13:01:47 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress loop]]></category>
		<category><![CDATA[WordPress theme]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de/?p=1559</guid>
		<description><![CDATA[Sometimes it&#8217;s useful to put a WordPress loop inside another loop. To do this you&#8217;ll have to create a new WP_Query object, as in this example: $my_query = new WP_Query&#40; &#34;cat=3&#34; &#41;; if &#40; $my_query-&#62;have_posts&#40;&#41; &#41; &#123; while &#40; $my_query-&#62;have_posts&#40;&#41; &#41; &#123; $my_query-&#62;the_post&#40;&#41;; the_content&#40;&#41;; &#125; &#125; $GLOBALS&#91;'post'&#93; = $GLOBALS&#91;'wp_query'&#93;-&#62;post; Restoring $post is necessary because $post->comment_status [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it&#8217;s useful to put a WordPress loop inside another loop. To do this you&#8217;ll have to create a new <code>WP_Query</code> object, as in this example:<span id="more-1559"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   <span style="color: #000088;">$my_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;cat=3&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           the_content<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: #009900;">&#125;</span>
   <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>  <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wp_query'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #339933;">;</span></pre></div></div>

<p>Restoring <code>$post</code> is necessary because <code>$post->comment_status</code> of the post in the outer loop can be wrong after running the inner loop. That was the only problem I found, by I prefer to restore <code>$post completely</code> just to be sure. WordPress 3.0 has a function <code>wp_reset_postdata()</code> that you can use to restore <code>$post</code>.</p>
<p>I use this technique to show an &#8220;excerpt cloud&#8221; in a post using a <a href="http://codex.wordpress.org/Shortcode_API">shortcode</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2010/05/30/wordpress-loop-inside-a-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get WordPress comments outside of WordPress</title>
		<link>http://www.nkuttler.de/2010/04/14/get-wordpress-comments-outside-of-wordpress/</link>
		<comments>http://www.nkuttler.de/2010/04/14/get-wordpress-comments-outside-of-wordpress/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 13:34:12 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[Custom Loop]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp-load.php]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de/?p=1453</guid>
		<description><![CDATA[Sometimes you want to access WordPress content outside of WordPress. There are various pages that explain how to this and it&#8217;s really easy to do as well. What I tried to do was a little different though, I wanted to print comments outside of WordPress. To my surprise wp_list_comments() didn&#8217;t output anything inside my custom [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you want to access WordPress content outside of WordPress. There are various pages that explain how to this and it&#8217;s really easy to do as well. What I tried to do was a little different though, I wanted to print comments outside of WordPress.</p>
<p>To my surprise <code>wp_list_comments()</code> didn&#8217;t output anything inside my custom loop. It turned out that <code>$wp_query-&gt;comments</code> was <code>NULL</code>, which I think is rather odd. I would have expected it to be defined like in a normal loop inside WordPress. However, the fix is trivial:<br />
<span id="more-1453"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'approve'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ASC'</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comments</span> <span style="color: #339933;">=</span> get_comments<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$args</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    wp_list_comments<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    comment_form<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><code>comment_form()</code> is a WordPress 3.0 feature by the way, so you may not want to use it yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2010/04/14/get-wordpress-comments-outside-of-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using git for WordPress development</title>
		<link>http://www.nkuttler.de/2009/11/07/using-git-for-wordpress-development/</link>
		<comments>http://www.nkuttler.de/2009/11/07/using-git-for-wordpress-development/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 14:34:55 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de/?p=1274</guid>
		<description><![CDATA[git is a powerful revision control system. It is a distributed system. This means that you can commit, create branches or tags on your local hard drive without any network connection. Read more about git on the project&#8217;s website, there&#8217;s also great documentation there. If you write WordPress plugins and want them to be published [...]]]></description>
			<content:encoded><![CDATA[<p><tt>git</tt> is a powerful revision control system. It is a <strong>distributed</strong> system. This means that you can commit, create branches or tags on your local hard drive without any network connection. Read more about git on the project&#8217;s <a href="http://git-scm.com/">website</a>, there&#8217;s also great documentation there.<span id="more-1274"></span></p>
<p>If you write WordPress plugins and want them to be published on the <a href="http://wordpress.org/extend/plugins/">WordPress plugins page</a> you have to use <tt>svn</tt> which can be painful once you&#8217;re used to <tt>git</tt>.</p>
<p>Fortunately, <tt>git</tt> can interact with <tt>svn</tt> via <tt>git-svn</tt>. Here&#8217;s a list of the commands you will need to use.</p>

<div class="wp_syntax"><div class="code"><pre class="git" style="font-family:monospace;">git svn init -s http://svn.wp-plugins.org/your_plugin</pre></div></div>

<p><strong>Update</strong>:<br />
The <code>git svn init + git svn fetch</code> takes forever on the WordPress repository. Instead, use <code>svn log http://svn.wp-plugins.org/your_plugin</code> to get the correct revision number and <code>git svn clone http://svn.wp-plugins.org/your_plugin -rYOURREVISION</code>.</p>
<p>This will initialize a local <tt>git</tt> repository. Inside the repository, use</p>

<div class="wp_syntax"><div class="code"><pre class="git" style="font-family:monospace;">git svn fetch
git gc
git branch -a</pre></div></div>

<p>The first command will take a few minutes and fetch all tags, branches etc. from the <tt>svn</tt> repository. The second command cleans up your git repository. This will significantly reduce it&#8217;s size. The last command will list all branches, local and remote. To track the remote trunk in a local branch use</p>

<div class="wp_syntax"><div class="code"><pre class="git" style="font-family:monospace;">git checkout -b svn-trunk trunk</pre></div></div>

<p><tt>svn-trunk</tt> is just the name the local branch gets in this example, you can use anything you like.</p>
<p>A normal workflow usually looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git checkout <span style="color: #660033;">-b</span> newbranch <span style="color: #666666; font-style: italic;"># create a local branch that you edit</span>
... edit ...
git commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Added awesome new feature&quot;</span> <span style="color: #660033;">-a</span>
git checkout svn-trunk
git merge newbranch
git <span style="color: #c20cb9; font-weight: bold;">svn</span> dcommit</pre></div></div>

<p>These commands create a local branch where you can try new things. Commit the changes to your local branch. Then check out the local svn-trunk branch that tracks the remote WordPress repository, merge the changes from newbranch. Then rebase the svn branch to the subversion trunk. The last command will update the remote <tt>svn</tt> trunk, assuming you really named your local trunk branch <tt>svn-trunk</tt>. As we&#8217;re talking about WordPress plugins you&#8217;ll want to tag your commit so that older versions of your plugin can still be downloaded.</p>

<div class="wp_syntax"><div class="code"><pre class="git" style="font-family:monospace;">git svn tag version</pre></div></div>

<p>This will create the tag in the remote <tt>svn</tt> repository. It looks like this is only possible since <tt>git</tt> 1.6.1. For Debian Lenny systems you&#8217;ll need <tt>git</tt> from <a href="http://backports.org/">backports.org</a> for this to work.</p>
<p>This should get you started with <tt>git</tt> and WordPress plugin development. Please do read the <tt>git</tt> documentation for more details, as <tt>git-svn</tt> has some limitations: Only use the described workflow if you&#8217;re the only commiter and work with one git repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2009/11/07/using-git-for-wordpress-development/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Shortcodes,  include CSS and JS only on the correct blog pages</title>
		<link>http://www.nkuttler.de/2009/10/21/shortcodes-include-css-and-js-only-on-the-correct-blog-pages/</link>
		<comments>http://www.nkuttler.de/2009/10/21/shortcodes-include-css-and-js-only-on-the-correct-blog-pages/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 10:23:43 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de/?p=1245</guid>
		<description><![CDATA[Not too long ago I wanted to add a new plugin to my blog. During various tests I noticed something quite shocking: at least one of the plugins insisted on loading it&#8217;s CSS and jquery on every page of my blog. A little more testing showed me that many plugins do the same. That&#8217;s not [...]]]></description>
			<content:encoded><![CDATA[<p>Not too long ago I wanted to add a new plugin to my blog. During various tests I noticed something quite shocking: at least one of the plugins insisted on loading it&#8217;s CSS <strong>and</strong> jquery on every page of my blog. A little more testing showed me that many plugins do the same.<span id="more-1245"></span></p>
<p>That&#8217;s not good. Yes, jquery is lightweigt, CSS files aren&#8217;t big, but that&#8217;s not a good reason for making every visitor download them. I did some research and it doesn&#8217;t look like anybody wrote about a solution yet, so here&#8217;s one way. Usually, you would add an action to <tt>wp_print_styles</tt> or <tt>wp_print_scripts</tt> that does something like this:</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_print_styles'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'yourplugin_include_css'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> yourplugin_include_css<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: #000088;">$csslink</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Instead, try this:</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_print_styles'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'yourplugin_include_css'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> yourplugin_include_css<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Check if shortcode exists in page or post content</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'[yourshortcode]'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$csslink</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>That&#8217;s it. Please don&#8217;t add custom javascript or CSS on each and every page of my blog.</p>
<p><strong>Update</strong>: See <a href="http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/">this excellent post</a> for an improved solution.</p>
<p><strong>Update 2</strong>: <a href="http://scribu.net/wordpress/optimal-script-loading.html">The best solution for loading JavaScript so far</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2009/10/21/shortcodes-include-css-and-js-only-on-the-correct-blog-pages/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating a valid WordPress theme</title>
		<link>http://www.nkuttler.de/2009/09/12/creating-a-valid-wordpress-theme/</link>
		<comments>http://www.nkuttler.de/2009/09/12/creating-a-valid-wordpress-theme/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 10:02:07 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress theme]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de//?p=484</guid>
		<description><![CDATA[Recently, I&#8217;ve been checking out some of the blogs that link back to me because they use one of my plugins. And it seems like a lot of them are using buggy, incorrect templates. It looks like many WordPress theme developers don&#8217;t read the theme development checklist. Another fine document that some developers seem to [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve been checking out some of the blogs that <a href="http://siteexplorer.search.yahoo.com/">link back to me</a> because they use one of my plugins. And it seems like a lot of them are using buggy, incorrect templates. It looks like many WordPress theme developers don&#8217;t read the <a href="http://codex.wordpress.org/Theme_Development_Checklist">theme development checklist</a>.<span id="more-484"></span></p>
<p>Another fine document that some developers seem to ignore is the list of <a href="http://codex.wordpress.org/Theme_Development#Plugin_API_Hooks">plugin API hooks</a>. Please, read that section, and <strong>include these hooks</strong> in your template! Some plugins <b>need</b> that API hook to work at all. My surprisingly popular <a href="http://www.nkuttler.de/nksnow/">snowstorm plugin</a> for example certainly does.</p>
<p>While you&#8217;re at it, think about how you want to style, for example, the <tt>wp_footer()</tt> call. When I visit pages that give me a backlink through that call, sometimes the backlink is displayed in very odd places and with weird colors.</p>
<p>Finally, although it has already been said on the pages I linked to, <strong> get the <a href="http://codex.wordpress.org/Theme_Development_Checklist#.22Theme_Unit_Tests.22">theme unit tests</a></strong> and use them! It&#8217;s quite embarassing for a designer to release buggy WordPress templates.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2009/09/12/creating-a-valid-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Git clone, ssh: Could not resolve hostname</title>
		<link>http://www.nkuttler.de/2009/04/06/git-clone-ssh-could-not-resolve-hostname/</link>
		<comments>http://www.nkuttler.de/2009/04/06/git-clone-ssh-could-not-resolve-hostname/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 15:06:58 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de//?p=764</guid>
		<description><![CDATA[Now this was annoying. I tried a git clone ssh://user@my.host:/path/to/repository and it failed with Initialized empty Git repository in /current/path/repository/.git/ ssh: Could not resolve hostname my.host:: Name or service not known fatal: The remote end hung up unexpectedly The solution was rather easy, see man 1 git-clone. A valid git URL looks like this: ssh://[user@]host.xz/path/to/repo.git/ [...]]]></description>
			<content:encoded><![CDATA[<p>Now this was annoying. I tried a <tt>git clone ssh://user@my.host:/path/to/repository</tt> and it failed with</p>
<pre>
Initialized empty Git repository in /current/path/repository/.git/
ssh: Could not resolve hostname my.host:: Name or service not known
fatal: The remote end hung up unexpectedly
</pre>
<p><span id="more-764"></span><br />
The solution was rather easy, see <tt>man 1 git-clone</tt>. A valid git URL looks like this:</p>
<pre>
ssh://[user@]host.xz/path/to/repo.git/
</pre>
<p>Don&#8217;t try to use paths as ports. <tt>git</tt> isn&#8217;t <tt>scp</tt>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2009/04/06/git-clone-ssh-could-not-resolve-hostname/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HTML forms and onclick/onfocus</title>
		<link>http://www.nkuttler.de/2008/09/20/html-forms-and-onclickonfocus/</link>
		<comments>http://www.nkuttler.de/2008/09/20/html-forms-and-onclickonfocus/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 08:34:39 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[onclick]]></category>
		<category><![CDATA[onfocus]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[Webdesign]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de//?p=17</guid>
		<description><![CDATA[When you use HTML forms it is often desirable to pre-fill some input fields. Your idea could be that you want to give your visitors some clue to what they&#8217;re supposed to fill in.This looks nice, for example: When the user clicks into the field you&#8217;ll want to remove the clue. The obvious way to [...]]]></description>
			<content:encoded><![CDATA[<p>When you use HTML forms it is often desirable to pre-fill some input fields. Your idea could be that you want to give your visitors some clue to what they&#8217;re supposed to fill in.<span id="more-17"></span>This looks nice, for example:</p>
<form>
<input type="text" value="Your email" /></form>
<p>When the user clicks into the field you&#8217;ll want to remove the clue. The obvious way to do this is to add an onclick JavaScript command:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;this.value=''&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your email&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<form>
<input onclick="this.value=''" type="text" value="Your email" /></form>
<p>The user can still access the input field through other means than clicking. He can use the tab key for example. That&#8217;s why usually the onfocus event is more useful:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">onfocus</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;this.value=''&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your email&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<form>
<input onfocus="this.value=''" type="text" value="Your email" />
</form>
<p>This seems to work nicely. However there&#8217;s still a problem. When a user fills in his email address, reads a little more on your site and clicks the input field again, his address will be removed again! So to make sure this doesn&#8217;t happen we add a little check for the content of the field:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your email&quot;</span> <span style="color: #000066;">onfocus</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;if (this.value == 'Your email') {this.value=''}&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<p>And here it is:</p>
<form>
<input type="text" value="Your email" onfocus="if (this.value == 'Your email') {this.value=''}" />
</form>
<a name="wptoc_0_0_0"></a><h2>Restore default value if nothing is entered</h2>
<p>Ok, now this is working. However, when your visitor decides not to input any data, the field stays empty. If you have no label for the input he or she might forget what the field was for. We fix this by restoring the default value when the input field is left:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your email&quot;</span> <span style="color: #000066;">onblur</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;if(this.value == '') { this.value='Your email'}&quot;</span> <span style="color: #000066;">onfocus</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;if (this.value == 'Your email') {this.value=''}&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<form>
<input type="text" value="Your email" onblur="if(this.value == '') { this.value='Your email'}" onfocus="if (this.value == 'Your email') {this.value=''}" />
</form>
<p>Thanks to Ray for his example linked in the comments.</p>
<a name="wptoc_0_0_1"></a><h2>Select onclick</h2>
<p>But sometimes this isn&#8217;t the best solution. It could be more desirable to highlight the content of the input field if you&#8217;re offering some kind of search. The user may not want to start a new search but to modify the existing one.</p>
<p>By highlighting the input field the user can choose to either empy it by starting to type or to modify it by using the arrow keys.</p>
<form>
<input onfocus="this.select()" type="text" value="Your previous searcj" />
</form>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">onfocus</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;this.select()&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your previous searcj&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<a name="wptoc_0_0_2"></a><h2>Dynamic input color</h2>
<p>This is a little advanced. Let&#8217;s assume you want the default value to be in a different color and change it onclick. This is one working solution:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;color: #f00&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your email&quot;</span> <span style="color: #000066;">onblur</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;if(this.value == '') { this.style.color='#f00'; this.value='Your email'}&quot;</span> <span style="color: #000066;">onfocus</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;if (this.value == 'Your email') {this.style.color='#0f0'; this.value=''}&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<form>
<input style="color: #f00" type="text" value="Your email" onblur="if(this.value == '') { this.style.color='#f00'; this.value='Your email'}" onfocus="if (this.value == 'Your email') {this.style.color='#0f0'; this.value=''}" />
</form>
<p>Keep in mind that this might create problems when you reload the page. Some browsers will remember the value of the input field, and the color will be different even though the field does not contain the default value. Fixing that is beyond the scope of this post. See <tt>onload</tt> and domready events.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2008/09/20/html-forms-and-onclickonfocus/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>
