<?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>soderlind.no &#187; general</title>
	<atom:link href="http://soderlind.no/archives/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://soderlind.no</link>
	<description>I code for fun</description>
	<lastBuildDate>Wed, 01 Feb 2012 07:06:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Adding WP-PageNavi to the Yoko theme</title>
		<link>http://soderlind.no/archives/2012/01/31/adding-wp-pagenavi-to-the-yoko-theme/</link>
		<comments>http://soderlind.no/archives/2012/01/31/adding-wp-pagenavi-to-the-yoko-theme/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 15:13:51 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[wordpress theme]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=3167</guid>
		<description><![CDATA[I&#8217;m using the Yoko theme and WP-PageNavi here at soderlind.no Yoko is a modern three-column blog theme. A responsive layout optimizes the theme for mobile devices like tablet pcs and modern smartphones (the layout switches to a two- or one-column &#8230; <a href="http://soderlind.no/archives/2012/01/31/adding-wp-pagenavi-to-the-yoko-theme/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using the <a href="http://wordpress.org/extend/themes/yoko">Yoko theme</a> and <a href="http://wordpress.org/extend/plugins/wp-pagenavi/">WP-PageNavi</a> here at soderlind.no</p>
<p><a href="http://soderlind.no/wp-content/uploads/2012/01/wp-pagenavi-wide.png"><img class="aligncenter size-medium wp-image-3174" style="border: solid 1px #000000;" title="Positioning WP-PageNavi on a wide screen" src="http://soderlind.no/wp-content/uploads/2012/01/wp-pagenavi-wide-293x300.png" alt="" width="293" height="300" /></a><br />
<a href="http://soderlind.no/wp-content/uploads/2012/01/wp-pagenavi-narrow.png"><img class="aligncenter size-medium wp-image-3173" style="display: none;" title="Positioning WP-PageNavi on a screen 680px wide or less" src="http://soderlind.no/wp-content/uploads/2012/01/wp-pagenavi-narrow-230x300.png" alt="" width="230" height="300" /></a></p>
<blockquote><p><a href="http://www.elmastudio.de/wordpress-themes/yoko/">Yoko</a> is a modern three-column blog theme. A responsive layout optimizes the theme for mobile devices like tablet pcs and modern smartphones (the layout switches to a two- or one-column layout depending on the screen size the theme is viewed on).</p></blockquote>
<p><span id="more-3167"></span></p>
<p><strong>Here&#8217;s how I added WP-PageNavi:</strong></p>
<ol>
<li>Downloaded WP-PageNavi from the <a href="http://wordpress.org/extend/plugins/wp-pagenavi/">WordPress plugin directory</a></li>
<li>From the Yoko theme folder, copied author.php, category.php, index.php, search.php and tag.php to my <a href="http://www.elmastudio.de/wp-content/uploads/themes/yokochildthemefolder.zip">Yoko child theme</a> folder and <a href="http://wordpress.org/extend/plugins/wp-pagenavi/installation/">added wp_pagenavi();</a> to each file. I replaced
<pre class="brush: php; title: ; notranslate">
&lt;nav id=&quot;nav-below&quot;&gt;
	&lt;div class=&quot;nav-previous&quot;&gt;&lt;?php next_posts_link( __( '&lt;span class=&quot;meta-nav&quot;&gt;&amp;larr;&lt;/span&gt; Older posts', 'yoko' ) ); ?&gt;&lt;/div&gt;
	&lt;div class=&quot;nav-next&quot;&gt;&lt;?php previous_posts_link( __( 'Newer posts &lt;span class=&quot;meta-nav&quot;&gt;&amp;rarr;&lt;/span&gt;', 'yoko' ) ); ?&gt;&lt;/div&gt;
&lt;/nav&gt;
</pre>
<p>with</p>
<pre class="brush: php; title: ; notranslate">
&lt;nav id=&quot;nav-below&quot;&gt;
	&lt;div id=&quot;pagenavi&quot;&gt;&lt;?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?&gt;&lt;/div&gt;
&lt;/nav&gt;
</pre>
</li>
<li>Configured WP-PageNavi (in Settings -&gt; PageNavi)
<pre>Page Navigation Text

Text For Number Of Pages:    &lt;blank&gt;
Text For Current Page:       <strong>%PAGE_NUMBER%</strong>
Text For Page:               <strong>%PAGE_NUMBER%</strong>
Text For First Page:         <strong>1</strong>
Text For Last Page:          <strong>%TOTAL_PAGES%</strong>
Text For Previous Page:	     <strong>«</strong>
Text For Next Page:	     <strong>»</strong>
Text For Previous:           <strong>...</strong>
Text For Next:               <strong>...</strong>	

Page Navigation Options

Use pagenavi-css.css:        <strong>unchecked</strong>
Page Navigation Style:       <strong>Normal</strong>
Always Show Page Navigation: <strong>checked</strong>
Number Of Pages To Show:     <strong>5</strong>
Number Of Larger Page
Numbers To Show:             <strong>0</strong>
Show Larger Page Numbers
In Multiples Of:             <strong>10</strong></pre>
</li>
<li>Added the following to the style.css in my <a href="http://www.elmastudio.de/wp-content/uploads/themes/yokochildthemefolder.zip">Yoko child theme</a> folder:
<pre class="brush: css; title: ; notranslate">
.wp-pagenavi {
	clear: both;
	text-align:center;
	height:30px;
	padding-left: 22.507%;
}

@media screen and (max-width : 620px) {
	.wp-pagenavi {
		padding-left: 0;
	}
}

.wp-pagenavi a, .wp-pagenavi span, #pagenavi .page {
    border: 1px solid #BFBFBF;
    margin: 2px;
    padding: 3px 5px;
    text-decoration: none;
}
.wp-pagenavi a:hover, .wp-pagenavi span.current {
    border-color: #000000;
}
.wp-pagenavi span.current {
    font-weight: bold;
}
</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2012/01/31/adding-wp-pagenavi-to-the-yoko-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding custom headers to the WordPress plugin directory</title>
		<link>http://soderlind.no/archives/2012/01/10/adding-custom-headers-to-the-wordpress-plugin-directory/</link>
		<comments>http://soderlind.no/archives/2012/01/10/adding-custom-headers-to-the-wordpress-plugin-directory/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 20:34:57 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[wp-plugins]]></category>
		<category><![CDATA[custom header]]></category>
		<category><![CDATA[plugin directory]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=3090</guid>
		<description><![CDATA[As an experiment, Matt has turned on custom headers for the plugin directory. How to add a custom header: Make a 772×250 pixel jpeg or png In the plugin root directory, create a new directory &#8220;assets&#8221;: After you&#8217;ve created the &#8230; <a href="http://soderlind.no/archives/2012/01/10/adding-custom-headers-to-the-wordpress-plugin-directory/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://soderlind.no/wp-content/uploads/2012/01/custom-plugin-header.png"><img src="http://soderlind.no/wp-content/uploads/2012/01/custom-plugin-header-300x205.png" alt="" title="Custom plugin header" width="300" height="205" class="aligncenter size-medium wp-image-3125" /></a><br />
As an experiment, Matt has turned on <a href="http://wpdevel.wordpress.com/2011/12/21/been-giving-a-lot-of-thought-to-how/">custom headers for the plugin directory</a>.</p>
<p><span id="more-3090"></span><br />
<strong>How to add a custom header:</strong></p>
<ol>
<li>Make a 772×250 pixel jpeg or png</li>
<li>In the plugin root directory, create a new directory &#8220;assets&#8221;:
<pre class="brush: bash; light: true; title: ; notranslate">mkdir assets</pre>
<p>After you&#8217;ve created the assets directory, you should have the following directories in the plugin root:</p>
<pre class="brush: bash; highlight: [3]; title: ; notranslate">
$ ls -l
total 0
drwxr-xr-x  4 per  _www  136 Jan 11 22:19 assets
drwxr-xr-x  3 per  _www  102 Jan 11 19:57 branches
drwxr-xr-x  3 per  _www  102 Jan 11 19:57 tags
drwxr-xr-x  5 per  _www  170 Jan 11 19:59 trunk
</pre>
</li>
<li>Copy the 772×250 pixel jpeg or png to the assets directory:
<pre class="brush: bash; light: true; title: ; notranslate">cp my-custom-plugin-header.png assets/banner-772x250.png</pre>
</li>
<li>Add the assets directory to svn:
<pre class="brush: bash; light: true; title: ; notranslate">svn add assets</pre>
</li>
<li>Check it in:
<pre class="brush: bash; light: true; title: ; notranslate">svn ci -m 'Adding custom header'</pre>
</li>
</ol>
<p>I&#8217;ve added a custom header to four of my plugins, please have a look: <a href="http://wordpress.org/extend/plugins/lorem-shortcode/">lorem shortcode</a>, <a href="http://wordpress.org/extend/plugins/webputty/">WebPutty Helper</a>, <a href="http://wordpress.org/extend/plugins/wp-denyhost/">WP-DenyHost</a> and <a href="http://wordpress.org/extend/plugins/remove-comments-are-closed/">Remove &#8220;Comments are closed&#8221;</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2012/01/10/adding-custom-headers-to-the-wordpress-plugin-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modernizr 101</title>
		<link>http://soderlind.no/archives/2011/11/24/modernizr-101/</link>
		<comments>http://soderlind.no/archives/2011/11/24/modernizr-101/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 20:31:51 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=2962</guid>
		<description><![CDATA[.. or, why I like it. When developing for the web, I&#8217;ve always been a fan of checking for functionality using object detection, I NEVER try to detect which browser you are using. Modernizr does this much better that the other &#8230; <a href="http://soderlind.no/archives/2011/11/24/modernizr-101/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>.. or, why I like it.</p>
<p>When developing for the web, I&#8217;ve always been a fan of checking for functionality using <a href="http://www.quirksmode.org/js/support.html">object detection</a>, I NEVER try t<a href="http://www.quirksmode.org/js/detect.html">o detect which browser you are using</a>.</p>
<p><a href="http://www.modernizr.com/">Modernizr</a> does this much better that the other methods I&#8217;ve seen (and used).</p>
<p><span id="more-2962"></span></p>
<blockquote><p>Modernizr is a small JavaScript library that detects the availability of native implementations for next-generation web technologies, i.e. features that stem from the HTML5 and CSS3 specifications.</p>
<ol>
<li>It tests for over 40 next-generation features, all in a matter of milliseconds</li>
<li>It creates a JavaScript object (named <code>Modernizr</code>) that contains the results of these tests as boolean properties</li>
<li>It adds classes to the <code>html</code> element that explain precisely what features are and are <span style="color: #ff0000;">not</span> natively supported</li>
<li>It provides a script loader so you can pull in <a href="https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills">polyfills</a> to backfill functionality in old browsers</li>
</ol>
</blockquote>
<div>As stated above, Modernizr adds classes to the HTML tag, one per feature, pre-fixing the one that&#8217;s not supported in the browser with &#8220;no-&#8221;. This is the classes added to the HTML tag when I open a page in;</div>
<p><strong>Chrome 17.0.942.0 dev</strong>:</p>
<pre><span style="color: #008000;">&lt;html</span> <span style="color: #993300;">class=</span>" <span style="color: #0000ff;">js flexbox canvas canvastext webgl <span style="color: #ff0000;">no-touch</span> geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths</span>"<span style="color: #008000;">&gt;</span></pre>
<p><strong>Firefox 8.0.1</strong>:</p>
<pre><span style="color: #008000;">&lt;html</span> <span style="color: #993300;">class=</span>"<span style="color: #0000ff;"> js flexbox canvas canvastext webgl <span style="color: #ff0000;">no-touch</span> geolocation postmessage websqldatabase <span style="color: #ff0000;">no-indexeddb</span> hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths</span>"<span style="color: #008000;">&gt;</span></pre>
<p><strong>Safari 5.1.1 (7534.51.22)</strong>:</p>
<pre><span style="color: #008000;">&lt;html</span> <span style="color: #993300;">class</span>="<span style="color: #0000ff;">js flexbox canvas canvastext webgl <span style="color: #ff0000;">no-touch</span> geolocation postmessage no-websqldatabase indexeddb hashchange history draganddrop <span style="color: #ff0000;">no-websockets</span> rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients <span style="color: #ff0000;">no-cssreflections</span> csstransforms <span style="color: #ff0000;">no-csstransforms3d</span> csstransitions fontface video audio <span style="color: #ff0000;">no-localstorage</span> <span style="color: #ff0000;">no-sessionstorage</span> webworkers applicationcache svg inlinesvg smil svgclippaths</span>"<span style="color: #008000;">&gt;</span></pre>
<p><strong>IE9</strong></p>
<pre><span style="color: #008000;">&lt;html</span> <span style="color: #993300;">class</span>="<span style="color: #0000ff;">ie ie9 js <span style="color: #ff0000;">no-flexbox</span> canvas canvastext <span style="color: #ff0000;">no-webgl</span> <span style="color: #ff0000;">no-touch</span> geolocation postmessage <span style="color: #ff0000;">no-websqldatabase</span> <span style="color: #ff0000;">no-indexeddb</span> hashchange <span style="color: #ff0000;">no-history</span> draganddrop <span style="color: #ff0000;">no-websockets</span> rgba hsla multiplebgs backgroundsize <span style="color: #ff0000;">no-borderimage</span> borderradius boxshadow <span style="color: #ff0000;">no-textshadow</span> opacity <span style="color: #ff0000;">no-cssanimations</span> <span style="color: #ff0000;">no-csscolumns no-cssgradients no-cssreflections</span> csstransforms <span style="color: #ff0000;">no-csstransforms3d no-csstransitions</span> fontface video audio localstorage sessionstorage <span style="color: #ff0000;">no-webworkers no-applicationcache</span> svg inlinesvg smil svgclippaths</span>"<span style="color: #008000;">&gt;</span></pre>
<p>Lot&#8217;s of red for IE9, but this is not a &#8220;which brower is best&#8221; article, but how you can use Modernizr to give the user the experience expected which ever browser she is using today or tomorrow. Eg:</p>
<pre class="brush: css; title: ; notranslate">
.no-cssgradients .glossy { // Internet Explorer
    background: url(&quot;images/glossybutton.png&quot;);
}

.cssgradients .glossy {
    background-image: linear-gradient(top, #555, #333);
}
</pre>
<p>You can also use Modernizr to load the JavaScript <a href="https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills">libraries needed</a>:</p>
<pre class="brush: jscript; title: ; notranslate">
Modernizr.load({
  test: Modernizr.geolocation,
  yep : 'geo.js',
  nope: 'geo-polyfill.js'
});
</pre>
<p>A bit more advanced example</p>
<pre class="brush: jscript; title: ; notranslate">
// Give Modernizr.load a string, an object, or an array of strings and objects
Modernizr.load([
  // Presentational polyfills
  {
    // Logical list of things we would normally need
    test : Modernizr.fontface &amp;&amp; Modernizr.canvas &amp;&amp; Modernizr.cssgradients,
    // Modernizr.load loads css and javascript by default
    nope : ['presentational-polyfill.js', 'presentational.css']
  },
  // Functional polyfills
  {
    // This just has to be truthy
    test : Modernizr.websockets &amp;&amp; window.JSON,
    // socket-io.js and json2.js
    nope : 'functional-polyfills.js',
    // You can also give arrays of resources to load.
    both : [ 'app.js', 'extra.js' ],
    complete : function () {
      // Run this after everything in this group has downloaded
      // and executed, as well everything in all previous groups
      myApp.init();
    }
  },
  // Run your analytics after you've already kicked off all the rest
  // of your app.
  'post-analytics.js'
]);
</pre>
<p>Finally, to learn more about Modernizr and the philosophy behind it, you should watch this presentation by Faruk Ates, the creator of Modernizr:</p>
<p style="text-align: center;"><p><a href="http://soderlind.no/archives/2011/11/24/modernizr-101/"><em>Click here to view the embedded video.</em></a></p></p>
<p>Resources:</p>
<ul>
<li><a href="http://www.modernizr.com/docs/">Modernizr Documentation</a></li>
<li>A List Apart: <a href="http://www.alistapart.com/articles/taking-advantage-of-html5-and-css3-with-modernizr/">Taking Advantage of HTML5 and CSS3 with Modernizr</a></li>
<li>Web Designer Notebook: <a href="http://webdesignernotebook.com/css/how-to-use-modernizr/">How to use Modernizr</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2011/11/24/modernizr-101/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Front-end editor in WordPress 3.3 is easy</title>
		<link>http://soderlind.no/archives/2011/09/25/front-end-editor-in-wordpress-3-3/</link>
		<comments>http://soderlind.no/archives/2011/09/25/front-end-editor-in-wordpress-3-3/#comments</comments>
		<pubDate>Sun, 25 Sep 2011 10:47:31 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[wp-plugins]]></category>
		<category><![CDATA[Editor]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=1866</guid>
		<description><![CDATA[Thanks to the work done by Andrew Ozz et al., adding a front-end editor in WordPress 3.3 is very simple. Syntax: So the simplest one is: Want better control?: Don&#8217;t want the quick tags?: Or you can do: Notes (from &#8230; <a href="http://soderlind.no/archives/2011/09/25/front-end-editor-in-wordpress-3-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Thanks to the <a href="http://core.trac.wordpress.org/ticket/17144">work done by Andrew Ozz</a> et al., adding a front-end editor in WordPress 3.3 is very simple.</p>
<p>Syntax:</p>
<pre class="brush: php; title: ; notranslate">
wp_editor( $content, $editor_id, $settings = array() );

// default settings
$settings =   array(
	'wpautop' =&gt; true, // use wpautop?
	'media_buttons' =&gt; true, // show insert/upload button(s)
	'textarea_name' =&gt; $editor_id, // set the textarea name to something different, square brackets [] can be used here
	'textarea_rows' =&gt; get_option('default_post_edit_rows', 10), // rows=&quot;...&quot;
	'tabindex' =&gt; '',
	'editor_css' =&gt; '', // intended for extra styles for both visual and HTML editors buttons, needs to include the &lt;style&gt; tags, can use &quot;scoped&quot;.
	'editor_class' =&gt; '', // add extra class(es) to the editor textarea
	'teeny' =&gt; false, // output the minimal editor config used in Press This
	'dfw' =&gt; false, // replace the default fullscreen with DFW (needs specific css)
	'tinymce' =&gt; true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
	'quicktags' =&gt; true // load Quicktags, can be used to pass settings directly to Quicktags using an array()
);
</pre>
<p><span id="more-1866"></span><br />
So the simplest one is:</p>
<pre class="brush: php; title: ; notranslate">
echo '&lt;form action=&quot;&quot; method=&quot;post&quot; target=&quot;_blank&quot;&gt;';
wp_editor('&lt;p&gt;Some content&lt;/p&gt;', 'textarea01' );
echo '&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/form&gt;'
</pre>
<p>Want better control?:</p>
<pre class="brush: php; title: ; notranslate">
$settings = array(
	'wpautop' =&gt; true,
	'media_buttons' =&gt; false,
	'tinymce' =&gt; array(
		'theme_advanced_buttons1' =&gt; 'bold,italic,underline,blockquote,|,undo,redo,|,fullscreen',
		'theme_advanced_buttons2' =&gt; '',
		'theme_advanced_buttons3' =&gt; '',
		'theme_advanced_buttons4' =&gt; ''
	),
	'quicktags' =&gt; array(
		'buttons' =&gt; 'b,i,ul,ol,li,link,close'
	)
);

echo '&lt;form action=&quot;&quot; method=&quot;post&quot; target=&quot;_blank&quot;&gt;';
wp_editor('&lt;p&gt;Some more content&lt;/p&gt;', 'textarea02', $settings );
echo '&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/form&gt;';
</pre>
<p>Don&#8217;t want the quick tags?:</p>
<pre class="brush: php; title: ; notranslate">
$settings = array(
	'wpautop' =&gt; true,
	'media_buttons' =&gt; false,
	'tinymce' =&gt; array(
		'theme_advanced_buttons1' =&gt; 'bold,italic,underline,blockquote,|,undo,redo,|,fullscreen',
		'theme_advanced_buttons2' =&gt; '',
		'theme_advanced_buttons3' =&gt; '',
		'theme_advanced_buttons4' =&gt; ''
	),
	'quicktags' =&gt; false
);

echo '&lt;form action=&quot;&quot; method=&quot;post&quot; target=&quot;_blank&quot;&gt;';
wp_editor('&lt;p&gt;Some more content&lt;/p&gt;', 'textarea02', $settings );
echo '&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/form&gt;';
</pre>
<p>Or you can do:</p>
<pre class="brush: php; title: ; notranslate">
add_filter( 'teeny_mce_buttons',tinytiny_buttons);

$settings = array(&quot;teeny&quot;=&gt;true,'media_buttons' =&gt; false,'quicktags' =&gt; false);

echo '&lt;form action=&quot;&quot; method=&quot;post&quot; target=&quot;_blank&quot;&gt;';
wp_editor('&lt;p&gt;Some more content&lt;/p&gt;', 'textarea04', $settings );
echo '&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/form&gt;';

function tinytiny_buttons($buttons) {
	return array('bold', 'italic', 'underline', 'blockquote', 'separator', 'undo', 'redo', 'fullscreen');
}
</pre>
<p><strong>Notes</strong> (from the <a href="http://codex.wordpress.org/Function_Reference/wp_editor">codex</a>)</p>
<p>Note that the ID that is passed to the wp_editor() function can only be comprised of lower-case letters. No underscores, no hyphens. Anything else will cause the WYSIWYG editor to malfunction.</p>
<p>Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page</p>
<p><strong>More information</strong><br />
wp_editor() is located in <a href="http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/general-template.php#L1786">wp-includes/general-template.php</a><br />
The default settings are defined in <a href="http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/class-wp-editor.php#L31">wp-includes/class-wp-editor.php</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2011/09/25/front-end-editor-in-wordpress-3-3/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Upgraded to WordPress 3.2 and nothing worked (internal error &#8230;)</title>
		<link>http://soderlind.no/archives/2011/07/05/upgraded-to-wordpress-3-2-and-nothing-worked-internal-error/</link>
		<comments>http://soderlind.no/archives/2011/07/05/upgraded-to-wordpress-3-2-and-nothing-worked-internal-error/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 22:43:38 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=1784</guid>
		<description><![CDATA[Luckily I log all PHP errors and the error log told me where the error was (an old plugin I&#8217;ve forgotten to remove) .. phew To log errors, I have the following statement at the top of my wp-config.php:]]></description>
			<content:encoded><![CDATA[<p>Luckily I log all PHP errors and the error log told me where the error was (an old plugin I&#8217;ve forgotten to remove) .. phew</p>
<p>To log errors, I have the following statement at the top of my wp-config.php:</p>
<pre class="brush: php; title: ; notranslate">@ini_set('log_errors','On');
@ini_set('display_errors','Off');
@ini_set('error_log','/PATH/log/php_errors.'.date('Y-m-d').'.log');</pre>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2011/07/05/upgraded-to-wordpress-3-2-and-nothing-worked-internal-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Node.js</title>
		<link>http://soderlind.no/archives/2010/06/30/node-js/</link>
		<comments>http://soderlind.no/archives/2010/06/30/node-js/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 21:54:25 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[chat server]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=994</guid>
		<description><![CDATA[If you haven&#8217;t looked at Node.js, you should. Node.js is “evented I/O for V8 javascript”.  With Node.js (and its well documented api) you can write extremely high performance non-blocking event driven network servers in JavaScript. Here&#8217;s a simple chat server &#8230; <a href="http://soderlind.no/archives/2010/06/30/node-js/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
If you haven&#8217;t looked at <a href="http://nodejs.org/">Node.js</a>, you should. Node.js is “<a href="http://membership.thinkvitamin.com/library/javascript/nodejs/introduction">evented I/O</a> for V8 javascript”.  With Node.js (and its <a href="http://nodejs.org/api.html">well documented api</a>) you can write <a href="http://groups.google.com/group/nodejs/msg/afb6e7273042f90a">extremely high performance</a> non-blocking event driven network servers in JavaScript.
</p>
<p>
Here&#8217;s a simple chat server and client I wrote using Node.js, <a href="http://faye.jcoglan.com/">Faye</a> and the <a href="http://github.com/senchalabs/connect">Connect middleware</a>.
</p>
<p><span id="more-994"></span><br />
app.js (the chat server, run using <code><a href="http://github.com/extjs/Connect">connect</a> app.js -p 8080</code>):</p>
<pre class="brush: jscript; title: ; notranslate">
var Faye = require('./lib/faye-node');

var fayeServer = new Faye.NodeAdapter({
  mount:    '/faye',
  timeout:  45
});
var cometServer = {
    handle: function(req, res, next){
                  if (fayeServer.call(req, res)) return;

                  // Handle non-Faye requests
                  res.writeHead(200, {'Content-Type': 'text/plain'});
                  res.end('Hello, non-Faye request');
    }
};

module.exports = require('./lib/connect').createServer([
    { module: cometServer }
]);
</pre>
<p>client.html:</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;html&gt;
	&lt;head&gt;
		&lt;script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'&gt;&lt;/script&gt;
		&lt;script type=&quot;text/javascript&quot; src=&quot;http://localhost:8080/faye.js&quot;&gt;&lt;/script&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;
			$(document).ready(function() {
			    var client = new Faye.Client('http://localhost:8080/faye');
				// receive chat messages
				client.subscribe('/messages', function(message) {
					var p = $(&quot;&lt;div class='chat' style='display:block;'&gt;&lt;div class='content'&gt;&quot; + message.text + &quot;&lt;/div&gt;&lt;/div&gt;&quot;);
					$('#chats').append(p);
					$('#chats').scrollTop($('#chats').attr(&quot;scrollHeight&quot;));
				});
		    	// send message to the chat server
				$(&quot;#pubmsg&quot;).keyup(function(event) {
				  	if (event.keyCode == '13' || event.keyCode == undefined) {
				    	client.publish('/messages', {
						  text: $(&quot;#pubmsg&quot;).val()
						});
						$(&quot;#pubmsg&quot;).val(&quot;&quot;).focus();
				  	}
				});	

				$('#pubsend').click(function() {
				  $('#pubmsg').keyup();
				});
		    });
		&lt;/script&gt;
		&lt;style type=&quot;text/css&quot;&gt;
			#chats {
				width: 300px;
				height:200px;
				border: solid 1px #000;
				overflow:auto;
			}
		&lt;/style&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;div id=&quot;chats&quot;&gt;&lt;/div&gt;
		&lt;input type=&quot;text&quot; id=&quot;pubmsg&quot; value=&quot;&quot; style=&quot;width:296px;margin:0px&quot;/&gt; &lt;input type=&quot;button&quot; id=&quot;pubsend&quot; value=&quot;send&quot; /&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2010/06/30/node-js/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>radial navigation in html5</title>
		<link>http://soderlind.no/archives/2010/03/25/radial-navigation-in-html5/</link>
		<comments>http://soderlind.no/archives/2010/03/25/radial-navigation-in-html5/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 18:00:41 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=923</guid>
		<description><![CDATA[Sorry no IE  (might work in IE9 platform preview), so open these in a modern browser: DONUT™ &#8211; Radial Navigator ASK KEN™Visual Knowledge Browser]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://soderlind.no/wp-content/uploads/2010/03/radial-navigation.png"><img class="aligncenter size-medium wp-image-924" style="border: 1px solid #000;" title="radial-navigation" src="http://soderlind.no/wp-content/uploads/2010/03/radial-navigation-300x225.png" alt="" width="300" height="225" /></a></p>
<p>Sorry no IE  (might work in <a href="http://ie.microsoft.com/testdrive/">IE9 platform preview</a>), so open these in a modern browser:</p>
<ul>
<li><a href="http://quasipartikel.at/donut/">DONUT™ &#8211; Radial Navigator</a></li>
<li><a href="http://askken.heroku.com/">ASK KEN™Visual Knowledge Browser</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2010/03/25/radial-navigation-in-html5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress plugin template</title>
		<link>http://soderlind.no/archives/2010/03/04/wordpress-plugin-template/</link>
		<comments>http://soderlind.no/archives/2010/03/04/wordpress-plugin-template/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 10:21:45 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[wp-plugins]]></category>
		<category><![CDATA[admin_print_scripts]]></category>
		<category><![CDATA[author]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugins_url]]></category>
		<category><![CDATA[wp_enqueue_script]]></category>
		<category><![CDATA[wp_localize_script]]></category>
		<category><![CDATA[wp_print_scripts]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=873</guid>
		<description><![CDATA[UPDATE: As of WordPress 3.3, you shouldn&#8217;t use the wp_print_styles hook, I&#8217;ve updated the Adding JavaScript section below to reflect this change. You can create a personalized plugin template by using my WordPress Plugin Template Creator When I  rewrote my &#8230; <a href="http://soderlind.no/archives/2010/03/04/wordpress-plugin-template/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE</strong>: As of WordPress 3.3, <a href="http://wpdevel.wordpress.com/2011/12/12/use-wp_enqueue_scripts-not-wp_print_styles-to-enqueue-scripts-and-styles-for-the-frontend/">you shouldn&#8217;t use the wp_print_styles hook</a>, I&#8217;ve updated the <a href="#adding_javascript">Adding JavaScript</a> section below to reflect this change.</p>
<blockquote><p>You can create a personalized plugin template by using my <a href="http://soderlind.no/wordpress-plugin-template-creator/">WordPress Plugin Template Creator</a></p></blockquote>
<p>When I  rewrote my <a href="http://soderlind.no/archives/2008/04/18/wp-denyhost/">WP-DenyHost</a> plugin, I wanted to do it as fast as possible. Instead of reinventing the wheel (again), I googled after a plugin template and found a very good one at <a href="http://pressography.com/plugins/wordpress-plugin-template/">Pressography</a>. It had most of what I needed in a plugin template.</p>
<p><span id="more-873"></span></p>
<h3>Modifications to the Pressography plugin template</h3>
<p>I&#8217;ve made some changes to the Pressography plugin template and I have explained them below. Before you continue to read this article, you should view the video at <a href="http://pressography.com/plugins/wordpress-plugin-template/">Pressography</a>, it presents the idea behind the plugin template and how it works. You get the full source of my modified plugin template by using my <a href="http://soderlind.no/wordpress-plugin-template-creator/">WordPress Plugin Template Creator</a></p>
<p>Being able to use new functionality in WordPress, I&#8217;ve decided that my plugins will only support WordPress one <a href="http://en.wikipedia.org/wiki/Software_versioning#Incrementing_sequences">minor version</a> lower than the current i.e. the current is 2.9 and hence my plugins and this plugin template will only supports WordPress 2.8 and later.</p>
<h3>plugins_url()</h3>
<p>WordPress 2.8 extended the <a href="http://codex.wordpress.org/Function_Reference/plugins_url">plugins_url</a>() function which makes it easy to find the plugin location. In the plugin template constructor, I use plugins_url() to find the languages files and the plugin itself:</p>
<pre class="brush: php; gutter: false; title: ; notranslate">
function __construct(){
	//Language Setup
	$locale = get_locale();
	$mo = plugins_url(&quot;/languages/&quot; . $this-&gt;localizationDomain . &quot;-&quot;.$locale.&quot;.mo&quot;, __FILE__);
	load_textdomain($this-&gt;localizationDomain, $mo);

	//&quot;Constants&quot; setup
	$this-&gt;url = plugins_url(basename(__FILE__), __FILE__);
	$this-&gt;urlpath = plugins_url('', __FILE__);

	//Initialize the options
	$this-&gt;getOptions();

	//Actions
	add_action(&quot;admin_menu&quot;, array(&amp;$this,&quot;admin_menu_link&quot;));
	add_action('admin_enqueue_scripts', array(&amp;$this,'{plugin_slug}_script')); // or wp_enqueue_scripts or login_enqueue_scripts
	add_action(&quot;init&quot;, array(&amp;$this,&quot;{plugin_slug}_init&quot;));
}
</pre>
<p><a name="adding_javascript"></a></p>
<h3>Adding JavaScript</h3>
<p>I&#8217;ve done it and I still see plugin authors adding scripts using the wp_head function. There&#8217;s only one correct way of adding scripts, and that&#8217;s using <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script">wp_enqueue_script</a> via one of the script hooks (<del datetime="2012-01-10T19:23:36+00:00">admin_print_scripts, wp_print_scripts</del> <a href="http://wpdevel.wordpress.com/2011/12/12/use-wp_enqueue_scripts-not-wp_print_styles-to-enqueue-scripts-and-styles-for-the-frontend/">wp_enqueue_scripts, login_enqueue_scripts and admin_enqueue_scripts</a>). wp_enqueue_script makes sure that the script loads in the correct order and that a script is only loaded once (e.g. If another plugin has already loaded jQuery, my plugin will not load jQuery, but use the script already loaded).</p>
<p>I&#8217;ve added the <del datetime="2012-01-10T19:23:36+00:00">wp_print_scripts</del> admin_enqueue_scripts hook to the plugin template (see the constructor above). Use the wp_enqueue_scripts or login_enqueue_scripts if you want to load the script on the front-end or login page. The <del datetime="2012-01-10T19:23:36+00:00">wp_print_scripts</del> admin_enqueue_scripts hook adds the  {plugin_slug}_script function in which  I enqueue the scripts:</p>
<pre class="brush: php; gutter: false; title: ; notranslate">
function {plugin_slug}_script() {
	wp_enqueue_script('jquery'); // other scripts included with WordPress: http://tinyurl.com/y875age
	wp_enqueue_script('jquery-validate', 'http://ajax.microsoft.com/ajax/jquery.validate/1.6/jquery.validate.min.js', array('jquery'));
	wp_enqueue_script('{plugin_slug}_script', $this-&gt;url.'?{plugin_slug}_javascript', array('jquery-validate')); // load embedded javascript
	wp_localize_script( '{plugin_slug}_script', '{plugin_slug}_lang', array(
		'required' =&gt; __('Please enter a number.', $this-&gt;localizationDomain),
		'number'   =&gt; __('Please enter a number.', $this-&gt;localizationDomain),
		'min'	   =&gt; __('Please enter a value greater than or equal to 1.', $this-&gt;localizationDomain),
	));
}
</pre>
<p>wp_localize_script, in the code above, creates a JavaScript object that passes the language strings to the embedded JavaScript:</p>
<pre class="brush: jscript; gutter: false; title: ; notranslate">
&lt;script type='text/javascript'&gt;
/* CDATA[ */
var {plugin_slug}_lang = {
	required: &quot;Please enter a number.&quot;,
	number: &quot;Please enter a number.&quot;,
	min: &quot;Please enter a value greater than or equal to 1.&quot;
};
/* ]]&gt; */
&lt;/script&gt;
</pre>
<h3>Embedding JavaScript</h3>
<p>When I write my plugins I like to keep the code in one file, that&#8217;s why I also embed the JavaScript code:</p>
<pre class="brush: php; gutter: false; title: ; notranslate">
if (isset($_GET['{plugin_slug}_javascript'])) {

	Header(&quot;content-type: application/x-javascript&quot;);
	echo&lt;&lt;&lt;ENDJS
/**
* @desc {Full Plugin Name}
* @author {Author} - {URL}
*/

jQuery(document).ready(function(){
	jQuery(&quot;#{plugin_slug}_options&quot;).validate({
		rules: {
			{plugin_slug}_option1: {
				required: true,
				number: true,
				min: 1
			}
		},
		messages: {
			{plugin_slug}_option1: {
				// the {plugin_slug}_lang object is define using wp_localize_script() in function {plugin_slug}_script()
				required: {plugin_slug}_lang.required,
				number: {plugin_slug}_lang.number,
				min: {plugin_slug}_lang.min
			}
		}
	});
});

ENDJS;
}
</pre>
<p>Note: If you prefer to keep your JavaScript code in a separate file, you can add it by adding the following to {plugin_slug}_script:</p>
<pre class="brush: php; gutter: false; highlight: [5]; title: ; notranslate">
function {plugin_slug}_script() {
	if (is_admin()){ // Only run when in wp-admin. Other conditional tags at http://codex.wordpress.org/Conditional_Tags
		wp_enqueue_script('jquery'); // other scripts included with WordPress: http://tinyurl.com/y875age
		wp_enqueue_script('jquery-validate', 'http://ajax.microsoft.com/ajax/jquery.validate/1.6/jquery.validate.min.js', array('jquery'));
		wp_enqueue_script('{plugin_slug}_script', $this-&gt;urlpath.'/myscript.js', array('jquery)); //load your script
		wp_localize_script( '{plugin_slug}_script', '{plugin_slug}_lang', array(
			'required' =&gt; __('Please enter a number.', $this-&gt;localizationDomain),
			'number'   =&gt; __('Please enter a number.', $this-&gt;localizationDomain),
			'min'	   =&gt; __('Please enter a value greater than or equal to 1.', $this-&gt;localizationDomain),
		));
	}
}
</pre>
<h3>WordPress Plugin Template Creator</h3>
<p>While writing this article, I decided to create a tool that will create a personalized plugin template. The <a href="http://soderlind.no/wordpress-plugin-template-creator/">WordPress Plugin Template Creator</a> takes your input, creates the necessary slugs and returns a personalized plugin template you can build your own plugin with.</p>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2010/03/04/wordpress-plugin-template/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>When .LESS is more</title>
		<link>http://soderlind.no/archives/2010/03/04/when-less-is-more/</link>
		<comments>http://soderlind.no/archives/2010/03/04/when-less-is-more/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 22:01:06 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=864</guid>
		<description><![CDATA[Curious? 4GuysFromRolla has a nice article about .LESS btw, if you&#8217;re not doing ASP.NET, you can create css from .less by using the command line compiler: dotless.Compiler.exe -m Styles.less Styles.css]]></description>
			<content:encoded><![CDATA[<pre class="brush: css; title: ; notranslate">
@the-border: 1px;
@base-color: #111;

#header {
	color: @base-color * 3;
	border-left: @the-border;
	border-right: @the-border * 2;
}

#footer {
	color: (@base-color + #111) * 1.5;
}

ul
{
	list-style-type: none;
	height: 30px;

	li
	{
		float: left;
		padding-right: 15px;

		a
		{
			padding: 5px;
			display: block;
			color: black;
			text-decoration: none;
		}

		a:hover
		{
			background-color: @menu_color - #222;
		}
	}
}
</pre>
<p>Curious? 4GuysFromRolla has a nice <a href="http://www.4guysfromrolla.com/articles/030310-1.aspx">article about .LESS</a></p>
<p>btw, if you&#8217;re not doing ASP.NET, you can create css from .less by using the command line compiler:</p>
<pre><span style="color: #993366;"><strong>dotless.Compiler.exe -m Styles.less Styles.css</strong></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2010/03/04/when-less-is-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery 101: Adding unobtrusive ajax to your existing form page</title>
		<link>http://soderlind.no/archives/2010/02/25/jquery-101-adding-unobtrusive-ajax-to-your-existing-form-page/</link>
		<comments>http://soderlind.no/archives/2010/02/25/jquery-101-adding-unobtrusive-ajax-to-your-existing-form-page/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 17:50:48 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=787</guid>
		<description><![CDATA[Using jQuery and the form and validate plugins, it is simple to add  unobtrusive ajax to your existing form page 1, Modify your existing form page Add &#60;input type="hidden" name="isAjax" id="isAjax" value="0" /&#62; to your form. This field will tell the &#8230; <a href="http://soderlind.no/archives/2010/02/25/jquery-101-adding-unobtrusive-ajax-to-your-existing-form-page/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Using <a href="http://jquery.com/">jQuery</a> and the <a href="http://jquery.malsup.com/form/">form</a> and <a href="http://docs.jquery.com/Plugins/Validation">validate</a> plugins, it is simple to add  <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript">unobtrusive</a> ajax to your existing form page</p>
<p><strong>1, Modify your existing form page</strong></p>
<ol>
<li>Add <code>&lt;input type="hidden" name="isAjax" id="isAjax" value="0" /&gt;</code> to your form. This field will tell the processing script, process_input.php in my example, if the values in the form were submitted using ajax or as an ordinary form submit, defaulting to isAjax = 0 (false).</li>
<li>Add <code>class="required"</code> to the fields that requires input</li>
<li>Add the <code>&lt;div id="result"&gt;&lt;/div&gt;</code> where you want the ajax output</li>
</ol>
<pre class="brush: xml; title: ; notranslate">
&lt;form id=&quot;form1&quot; name=&quot;form1&quot; method=&quot;post&quot; action=&quot;process_input.php&quot;&gt;
	&lt;input type=&quot;hidden&quot; name=&quot;isAjax&quot; id=&quot;isAjax&quot; value=&quot;0&quot; /&gt;
	Name: &lt;input type=&quot;text&quot; name=&quot;name&quot; class=&quot;required&quot; id=&quot;name&quot; value=&quot;&quot; /&gt; &lt;br /&gt;
	&lt;input type=&quot;submit&quot; name=&quot;submit&quot; id=&quot;submit&quot; value=&quot;submit&quot; /&gt;
&lt;/form&gt;
&lt;div id=&quot;result&quot;&gt;&lt;/div&gt;
</pre>
<p><span id="more-787"></span><br />
<strong>2, update your process_input.php code</strong></p>
<p>The process_input.php, uses the value in isAjax to decide how output is displayed</p>
<pre class="brush: php; html-script: false; title: ; notranslate">
&lt;?php
if ($_POST['isAjax']) {
	// out will be return, using ajax, to the calling form page
	echo &quot;Hello &quot; . $_POST['name'];
} else {
	// no javascript, this page will do the output
	echo &quot;&lt;h1&gt;Welcome&lt;/h1&gt;&quot;;
	echo $_POST['name'];
}
?&gt;
</pre>
<p><strong>3, Add the jQuery code</strong></p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://github.com/malsup/form/raw/master/jquery.form.js?v2.38&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.microsoft.com/ajax/jquery.validate/1.6/jquery.validate.min.js&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
jQuery(document).ready(function(){        // wait until the page is loaded before executing the jQuery code
    var v = $(&quot;#form1&quot;).validate({        // enable form validation
        submitHandler: function(form) {
            $(&quot;#isAjax&quot;).val(1),          // set the hidden input isAjax to 1 (true)
                $(form).ajaxSubmit({      // submit the form using ajax
                    target: &quot;#result&quot;     // put output from process_input.php into &lt;div id=&quot;result&quot;&gt;&lt;/div&gt;
                });
        }
    });
});
&lt;/script&gt;
</pre>
<p><strong>Here&#8217;s the complete form page</strong></p>
<pre class="brush: jscript; title: ; notranslate">
&lt;head&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://github.com/malsup/form/raw/master/jquery.form.js?v2.38&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.microsoft.com/ajax/jquery.validate/1.6/jquery.validate.min.js&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
jQuery(document).ready(function(){
	var v = $(&quot;#form1&quot;).validate({
		submitHandler: function(form) {
			$(&quot;#isAjax&quot;).val(1),
			$(form).ajaxSubmit({
				target: &quot;#result&quot;
			});
		}
	});
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form id=&quot;form1&quot; name=&quot;form1&quot; method=&quot;post&quot; action=&quot;process_input.php&quot;&gt;
	&lt;input type=&quot;hidden&quot; name=&quot;isAjax&quot; id=&quot;isAjax&quot; value=&quot;0&quot; /&gt;
	Name: &lt;input type=&quot;text&quot; name=&quot;name&quot; class=&quot;required&quot; id=&quot;name&quot; value=&quot;&quot; /&gt; &lt;br /&gt;
	&lt;input type=&quot;submit&quot; name=&quot;submit&quot; id=&quot;submit&quot; value=&quot;submit&quot; /&gt;
&lt;/form&gt;
&lt;div id=&quot;result&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2010/02/25/jquery-101-adding-unobtrusive-ajax-to-your-existing-form-page/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

