<?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; wp-plugins</title>
	<atom:link href="http://soderlind.no/archives/category/wp-plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://soderlind.no</link>
	<description>I code for fun</description>
	<lastBuildDate>Thu, 10 May 2012 08:57:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Date and Time Picker field for Advanced Custom Fields</title>
		<link>http://soderlind.no/archives/2012/03/09/time-picker-field-for-advanced-custom-fields/</link>
		<comments>http://soderlind.no/archives/2012/03/09/time-picker-field-for-advanced-custom-fields/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 17:19:31 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[wp-plugins]]></category>
		<category><![CDATA[acf]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=3213</guid>
		<description><![CDATA[This is an add-on for the Advanced Custom Fields WordPress plugin, that allows you to add a Date and Time Picker field type. Changlog: 1.2.0 Updated jquery-ui-timepicker-addon.js to the latest version (1.0.0) and added localization support. 1.1.1 Fixed a small &#8230; <a href="http://soderlind.no/archives/2012/03/09/time-picker-field-for-advanced-custom-fields/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://soderlind.no/wp-content/uploads/2012/03/acf_time_picker-1.1.011.png"><img class="aligncenter size-medium wp-image-3248" title="Date and Time Picker" src="http://soderlind.no/wp-content/uploads/2012/03/acf_time_picker-1.1.011-300x160.png" alt="" width="300" height="160" /></a></p>
<p>This is an add-on for the <a href="http://www.advancedcustomfields.com/">Advanced Custom Fields</a> WordPress plugin, that allows you to add a Date and Time Picker field type.</p>
<p><span id="more-3213"></span></p>
<h3>Changlog:</h3>
<ul>
<li>1.2.0 Updated jquery-ui-timepicker-addon.js to the latest version (1.0.0) and added <a href="#localization">localization</a> support.</li>
<li>1.1.1 Fixed a small bug</li>
<li>1.1 Change name to Date and Time Picker to reflect the new option to select between Date and Time picker or Time Picker only. Thanks to Wilfrid for point this out (not sure why I didn&#8217;t include it in 1.0)</li>
<li>1.0: Initial version</li>
</ul>
<p><strong>Latest version</strong>: <a href="http://soderlind.no/download/acf_time_picker.zip">http://soderlind.no/download/acf_time_picker.zip</a></p>
<p><strong>Prerequisite:</strong> <a href="http://wordpress.org/extend/plugins/advanced-custom-fields/">Advanced Custom Fields WordPress plugin</a> installed and activated.</p>
<h3>Installation:</h3>
<ol>
<li>Extract <a href="http://soderlind.no/download/acf_time_picker.zip">http://soderlind.no/download/acf_time_picker.zip</a> in your theme folder (WordPress child theme is supported).<br />
After you have extracted the file, you should have the following subdirectories in your theme folder:</p>
<pre>acf_time_picker
	 |____ css
	 | |____ images
	 |____ js
         |____ lang</pre>
</li>
<li>Add the following to your themes functions.php (functions.php in a WordPress child theme is supported):
<pre class="brush: php; title: ; notranslate">
&lt;?php
   if(function_exists('register_field')) {
	 register_field('acf_time_picker', dirname(__File__) . '/acf_time_picker/acf_time_picker.php');
   }
?&gt;
</pre>
</li>
</ol>
<h3>Create a Time Picker field:</h3>
<ul>
<li>Time Picker:<br />
<a href="http://soderlind.no/wp-content/uploads/2012/03/acf_time_picker-1.1.021.png"><img class="alignnone size-medium wp-image-3250" title="Time Picker" src="http://soderlind.no/wp-content/uploads/2012/03/acf_time_picker-1.1.021-300x100.png" alt="" width="300" height="100" /></a></li>
<li>Add the Date and Time Picker:<br />
<a href="http://soderlind.no/wp-content/uploads/2012/03/acf_time_picker-1.1.03.png"><img class="alignnone size-medium wp-image-3244" title="Select Date and Time Picker" src="http://soderlind.no/wp-content/uploads/2012/03/acf_time_picker-1.1.03-300x180.png" alt="" width="300" height="180" /></a></li>
<li>Set the date and time format:<br />
<a href="http://soderlind.no/wp-content/uploads/2012/03/acf_time_picker-1.1.04.png"><img class="alignnone size-medium wp-image-3245" title="Set date and time format" src="http://soderlind.no/wp-content/uploads/2012/03/acf_time_picker-1.1.04-300x238.png" alt="" width="300" height="238" /></a></li>
</ul>
<h3>Retrieving Time Picker values</h3>
<ul>
<li>To get a general understanding on how to retrieve values from ACF, see the <a href="http://www.advancedcustomfields.com/docs/code-examples/">examples</a> in the <a href="http://www.advancedcustomfields.com/docs/getting-started/">ACF Documentation</a>.</li>
<li>Here&#8217;s how I retrieve that values from the example in the screen shot (note, the example is using the <a href="http://www.advancedcustomfields.com/add-ons/repeater-field/">repeater field</a>):<br />
<a href="http://soderlind.no/wp-content/uploads/2012/03/field_name.png"><img class="alignnone size-medium wp-image-3273" title="Retrieving Time Picker values using the Field Names" src="http://soderlind.no/wp-content/uploads/2012/03/field_name-300x199.png" alt="" width="300" height="199" /></a></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$rows = get_field('tasks'); // 'tasks' is the repeater field name
if($rows)
{
	echo '&lt;ul&gt;';

	foreach($rows as $row)
	{
		echo '&lt;li&gt;task = ' . $row['task'] . ', start = ' . $row['start'] .', start = ' . $row['end'] .'&lt;/li&gt;';
	}

	echo '&lt;/ul&gt;';
}
?&gt;
</pre>
</li>
</ul>
<p><a name="localization"></a></p>
<h3>Localization:</h3>
<p>Part of the localization is done automatically based on <a href="http://codex.wordpress.org/Installing_WordPress_in_Your_Language">WPLANG</a> in wp-config.php, but you have to translate rest of the text:</p>
<ol>
<li>In acf_time_picker/lang, copy acf_time_picker.po to acf_time_picker-<a href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_16.html#Country-Codes">countrycode</a>_<a href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_15.html#Language-Codes">LANGUAGECODE</a>.po e.g: acf_time_picker-no_NB.po</li>
<li>Edit the file using <a href="http://www.poedit.net/">poedit</a> or its like, and save the .mo file in acf_time_picker/lang</li>
</ol>
<p><strong>How the translation is done:</strong></p>
<p>I found a really nice routine at <a href="http://www.renegadetechconsulting.com/tutorials/jquery-datepicker-and-wordpress-i18n">Renegade Tech Consulting</a> (currently unavailable, but a copy is available in <a href="http://webcache.googleusercontent.com/search?q=cache:LG5-wdUYzZUJ:www.renegadetechconsulting.com/tutorials/jquery-datepicker-and-wordpress-i18n&amp;hl=en&amp;prmd=imvns&amp;strip=0">google cache</a>) that I use to grab some of the localized text from WordPress:</p>
<pre class="brush: php; title: ; notranslate">
$timepickerArgs = array(
    'closeText'             =&gt; __('Done',$this-&gt;localizationDomain),
    'currentText'           =&gt; __('Today',$this-&gt;localizationDomain),
    'prevText'              =&gt; __('Prev',$this-&gt;localizationDomain),
    'nextText'              =&gt; __('Next',$this-&gt;localizationDomain),
    'monthNames'            =&gt; $this-&gt;strip_array_indices( $wp_locale-&gt;month ),
    'monthNamesShort'       =&gt; $this-&gt;strip_array_indices( $wp_locale-&gt;month_abbrev ),
    'monthStatus'           =&gt; __( 'Show a different month', $this-&gt;localizationDomain ),
    'showMonthAfterYear'    =&gt; false,
    'dayNames'              =&gt; $this-&gt;strip_array_indices( $wp_locale-&gt;weekday ),
    'dayNamesShort'         =&gt; $this-&gt;strip_array_indices( $wp_locale-&gt;weekday_abbrev ),
    'dayNamesMin'           =&gt; $this-&gt;strip_array_indices( $wp_locale-&gt;weekday_initial ),
    'showWeek'              =&gt; false,
    'weekHeader'            =&gt; __('Wk',$this-&gt;localizationDomain),
    'firstDay'              =&gt; get_option( 'start_of_week' ),
    'isRTL'                 =&gt; $wp_locale-&gt;is_rtl(),
    'timeText'              =&gt; __('Time',$this-&gt;localizationDomain),
    'hourText'              =&gt; __('Hour',$this-&gt;localizationDomain),
    'minuteText'            =&gt; __('Minute',$this-&gt;localizationDomain),
    'secondText'            =&gt; __('Second',$this-&gt;localizationDomain),
    'millisecText'          =&gt; __('Millisecond',$this-&gt;localizationDomain),
    'timezoneText'          =&gt; __('Time Zone',$this-&gt;localizationDomain),
);

// Pass the array to the enqueued JS
wp_localize_script( 'timepicker', 'timepicker_objectL10n', $timepickerArgs );

function strip_array_indices( $ArrayToStrip ) {
    foreach( $ArrayToStrip as $objArrayItem) {
        $NewArray[] =  $objArrayItem;
    }
    return( $NewArray );
}
</pre>
<h3>Credit:</h3>
<pre>Time Picker field for Advanced Custom Fields  uses the <a href="http://trentrichardson.com/examples/timepicker/">jQuery timepicker addon</a>
By: Trent Richardson [http://trentrichardson.com]
Version 1.0.0
Last Modified: 02/05/2012

Copyright 2012 Trent Richardson
Dual licensed under the MIT and GPL licenses.

http://trentrichardson.com/Impromptu/GPL-LICENSE.txt

http://trentrichardson.com/Impromptu/MIT-LICENSE.txt</pre>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2012/03/09/time-picker-field-for-advanced-custom-fields/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>WordPress plugin: Remove &#8220;Comments are closed&#8221;</title>
		<link>http://soderlind.no/archives/2012/01/11/wordpress-plugin-remove-comments-are-closed/</link>
		<comments>http://soderlind.no/archives/2012/01/11/wordpress-plugin-remove-comments-are-closed/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 03:55:59 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[wp-plugins]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[l10n]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=3098</guid>
		<description><![CDATA[On posts where comments are closed, the plugin will remove the text &#8216;Comments are closed.&#8217; The plugin supports any languages/text domains, and will remove the text from themes and plugins. Prerequisite: Since the plugin is filtering gettext, your theme/plugin must &#8230; <a href="http://soderlind.no/archives/2012/01/11/wordpress-plugin-remove-comments-are-closed/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://soderlind.no/wp-content/uploads/2012/01/banner-772x250-e1326317189640-300x153.png" alt="" title="banner-772x250" width="300" height="153" class="aligncenter size-medium wp-image-3119" /></p>
<p>On posts where comments are closed, the plugin will remove the text &#8216;Comments are closed.&#8217; The plugin supports any languages/text domains, and will remove the text from themes and plugins. </p>
<p>Prerequisite: Since the plugin is <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext">filtering gettext</a>, your theme/plugin must be <a href="http://wp.smashingmagazine.com/2011/12/29/internationalizing-localizing-wordpress-theme/">localized</a>.</p>
<p>The plugin is available in the <a href="http://wordpress.org/extend/plugins/remove-comments-are-closed/">WordPress plugin directory</a></p>
<p><span id="more-3098"></span><br />
<strong>Plugin source code:</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/*
Plugin Name: Remove &quot;Comments are closed&quot;
Plugin URI: http://soderlind.no/archives/2012/01/11/wordpress-plugin-remove-comments-are-closed/
Description: On posts where comments are closed, the plugin will remove the text 'Comments are closed.' The plugin supports any languages/text domains, and will remove the text from themes and plugins.
Author: Per Soderlind
Version: 1.2
Author URI: http://soderlind.no/
*/

add_filter('gettext', 'ps_remove_comments_are_closed', 20, 3);

function ps_remove_comments_are_closed($translated_text, $untranslated_text, $domain) {
    if ( $untranslated_text == 'Comments are closed.' ) {
        return '';
    }
    return $translated_text;
}
?&gt;
</pre>
<p><strong>Changelog:</strong></p>
<ul>
<li>1.2 removed unnecessary code</li>
<li>1.1 initial public release</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2012/01/11/wordpress-plugin-remove-comments-are-closed/feed/</wfw:commentRss>
		<slash:comments>10</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>WordPress and WebPutty</title>
		<link>http://soderlind.no/archives/2011/12/20/wordpress-and-webputty/</link>
		<comments>http://soderlind.no/archives/2011/12/20/wordpress-and-webputty/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 22:24:53 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[wp-plugins]]></category>
		<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[CDN]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[syntax-highlighting CSS editor]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=3035</guid>
		<description><![CDATA[I&#8217;ve written a simple plugin that allows you to modify your WordPress sites using WebPutty. So what&#8217;s WebPutty? WebPutty is a simple CSS editing and hosting service. WebPutty gives you a syntax-highlighting CSS editor you can use from anywhere, the &#8230; <a href="http://soderlind.no/archives/2011/12/20/wordpress-and-webputty/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://soderlind.no/wp-content/uploads/2011/12/webputty07.png"><img class="aligncenter size-medium wp-image-3036" title="Modify the style" src="http://soderlind.no/wp-content/uploads/2011/12/webputty07-300x225.png" alt="" width="300" height="225" /></a><br />
I&#8217;ve written a simple <a href="http://wordpress.org/extend/plugins/webputty/">plugin</a> that allows you to modify your WordPress sites using <a href="http://www.webputty.net/">WebPutty</a>.</p>
<p><span id="more-3035"></span><br />
<strong>So what&#8217;s WebPutty?</strong></p>
<pre style="padding-left: 30px;"><a href="http://www.webputty.net/">WebPutty</a> is a simple CSS editing and hosting service.
WebPutty gives you a syntax-highlighting CSS editor you can use from anywhere, the power of <a href="http://sass-lang.com/">SCSS</a> and <a href="http://compass-style.org/">Compass</a>, a side-by-side preview pane, and instant publishing with minification, compression, and automatic cache control.</pre>
<p>There&#8217;s a <a href="http://youtu.be/FNaN789JsUc?hd=1">video at YouTube</a></p>
<p><strong>Integration</strong>:<br />
In WordPress, add the WebPutty integration code to your theme, or add it using my plugin. The integration code looks like:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;//webputty.commondatastorage.googleapis.com/[KEY].css&quot; /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
(function(w,d){
	if(w.location!=w.parent.location||w.location.search.indexOf('__preview_css__')&gt;-1){
		var t=d.createElement('script');
		t.type='text/javascript';
		t.async=true;
		t.src='http://www.webputty.net/js/[KEY]';
		(d.body||d.documentElement).appendChild(t);
	}
})(window,document);
&lt;/script&gt;
</pre>
<p><strong>Plugin installtion and activation:</strong></p>
<ol>
<li>The plugin is available in the <a href="http://wordpress.org/extend/plugins/webputty/">WordPress Plugin Directory</a></li>
<li>Install and activate it.</li>
<li>Go to Settings -&gt; WebPutty Helper and add the integration code from <a href="http://www.webputty.net/">WebPutty</a> (see images below)</li>
</ol>
<p><strong>Integrating WebPutty and WordPress using my plugin:</strong><br />

<a href='http://soderlind.no/archives/2011/12/20/wordpress-and-webputty/wepbutty01/' title='Add a new site'><img width="100" height="100" src="http://soderlind.no/wp-content/uploads/2011/12/wepbutty01-100x100.png" class="attachment-thumbnail" alt="Add a new site" title="Add a new site" /></a>
<a href='http://soderlind.no/archives/2011/12/20/wordpress-and-webputty/webputty02/' title='Add name and URL'><img width="100" height="100" src="http://soderlind.no/wp-content/uploads/2011/12/webputty02-100x100.png" class="attachment-thumbnail" alt="Add name and URL" title="Add name and URL" /></a>
<a href='http://soderlind.no/archives/2011/12/20/wordpress-and-webputty/webputty03/' title='Get code'><img width="100" height="100" src="http://soderlind.no/wp-content/uploads/2011/12/webputty03-100x100.png" class="attachment-thumbnail" alt="Get code" title="Get code" /></a>
<a href='http://soderlind.no/archives/2011/12/20/wordpress-and-webputty/webputty04/' title='Copy the code'><img width="100" height="100" src="http://soderlind.no/wp-content/uploads/2011/12/webputty04-100x100.png" class="attachment-thumbnail" alt="Copy the code" title="Copy the code" /></a>
<a href='http://soderlind.no/archives/2011/12/20/wordpress-and-webputty/webputty05/' title='Insert the code'><img width="100" height="100" src="http://soderlind.no/wp-content/uploads/2011/12/webputty05-100x100.png" class="attachment-thumbnail" alt="Insert the code" title="Insert the code" /></a>
<a href='http://soderlind.no/archives/2011/12/20/wordpress-and-webputty/webputty06/' title='Reload the page at WebPutty'><img width="100" height="100" src="http://soderlind.no/wp-content/uploads/2011/12/webputty06-100x100.png" class="attachment-thumbnail" alt="Reload the page at WebPutty" title="Reload the page at WebPutty" /></a>
<a href='http://soderlind.no/archives/2011/12/20/wordpress-and-webputty/webputty07/' title='Modify the style'><img width="100" height="100" src="http://soderlind.no/wp-content/uploads/2011/12/webputty07-100x100.png" class="attachment-thumbnail" alt="Modify the style" title="Modify the style" /></a>
</p>
<p><strong>Change log:</strong><br />
0.0.1: Initial version</p>
<p><strong>Todo:</strong></p>
<ul>
<li>Add option to remove local styles</li>
<li>Anything else? Please add your wishes as a comment below</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2011/12/20/wordpress-and-webputty/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><br />
I&#8217;ve also added several examples in the <a href="#comments">comments below</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>55</slash:comments>
		</item>
		<item>
		<title>Fade away and hide the WordPress 3.1 Admin Bar</title>
		<link>http://soderlind.no/archives/2011/02/25/fade-away-wordpress-admin-bar/</link>
		<comments>http://soderlind.no/archives/2011/02/25/fade-away-wordpress-admin-bar/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 17:25:41 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[wp-plugins]]></category>
		<category><![CDATA[WordPress Admin Bar]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=1747</guid>
		<description><![CDATA[Instead of disabling the WordPress 3.1 Admin Bar, use this plugin, based on Codrops Fixed Fade Out Menu, to fade away the WordPress Admin Bar when you scroll down the page. The plugin is availeable in the WordPress Plugin Directory &#8230; <a href="http://soderlind.no/archives/2011/02/25/fade-away-wordpress-admin-bar/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Instead of disabling the WordPress 3.1 Admin Bar, use this plugin,  based on <a href="http://tympanus.net/Tutorials/FixedFadeOutMenu/">Codrops Fixed Fade Out Menu</a>,  to <a href="http://screencast.com/t/13NEaWQBV">fade away the WordPress Admin Bar</a> when you scroll down the page. <strong>The plugin is availeable in the <a href="http://wordpress.org/extend/plugins/pers-fade-away-wp-admin-bar/">WordPress Plugin Directory</a></strong></p>
<p><span id="more-1747"></span></p>
<p><strong>Changelog</strong>:</p>
<ul>
<li>1.0.1 &#8211; Thanks to @TheFrosty, added is_admin_bar_showing()</li>
<li>1.0.0 &#8211; initial release</li>
</ul>
<p><strong>Source:</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/*
Plugin Name: PerS Fade Away WordPress Admin Bar
Plugin URI: http://soderlind.no/archives/2011/02/25/fade-away-wordpress-admin-bar/
Description: Fade away the WordPress Admin Bar when you scroll down the page.
Version: 1.0.1
Author: PerS
Author URI: http://soderlind.no
*/

/*
Change log:
	1.0.1 - Thanks to @TheFrosty, added is_admin_bar_showing()
    1.0.0 - initial release
*/

if (!class_exists('ps_pers_fade_wp_admin_bar')) {
    class ps_pers_fade_wp_admin_bar {
		var $url = '';
		function __construct(){
			$this-&gt;url = plugins_url(basename(__FILE__), __FILE__);
			add_action('wp_print_scripts', array(&amp;$this,'ps_pers_fade_wp_admin_bar_script'));
		}
		function ps_pers_fade_wp_admin_bar_script() {
				if (is_admin_bar_showing()) {
					wp_enqueue_script('jQuery('); // other scripts included with WordPress: http://tinyurl.com/y875age
					wp_enqueue_script('ps_pers_fade_wp_admin_bar_script', $this-&gt;url.'?ps_pers_fade_wp_admin_bar_javascript'); // embed javascript, see end of this file
				}
			}
	} //End Class
} //End if class exists statement

if (isset($_GET['ps_pers_fade_wp_admin_bar_javascript'])) {
	//embed javascript
	Header(&quot;content-type: application/x-javascript&quot;);
	echo&lt;&lt;&lt;ENDJS
/**
* @desc PerS Fade Away WP Admin Bar
* @author PerS - http://soderlind.no
*/
// Script from http://tympanus.net/codrops/2009/12/11/fixed-fade-out-menu-a-css-and-jquery-tutorial/
jQuery(document).ready(function(){
		jQuery(window).scroll(function(){
			var scrollTop = jQuery(window).scrollTop();
			if(scrollTop != 0)
				jQuery('#wpadminbar').stop().animate({'opacity':'0.2'},400);
			else
				jQuery('#wpadminbar').stop().animate({'opacity':'1'},400);
		});

		jQuery('#wpadminbar').hover(
			function (e) {
				var scrollTop = jQuery(window).scrollTop();
				if(scrollTop != 0){
					jQuery('#wpadminbar').stop().animate({'opacity':'1'},400);
				}
			},
			function (e) {
				var scrollTop = jQuery(window).scrollTop();
				if(scrollTop != 0){
					jQuery('#wpadminbar').stop().animate({'opacity':'0.2'},400);
				}
			}
		);
});

ENDJS;

} else {
	if (class_exists('ps_pers_fade_wp_admin_bar')) {
    	$ps_pers_fade_wp_admin_bar_var = new ps_pers_fade_wp_admin_bar();
	}
}
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2011/02/25/fade-away-wordpress-admin-bar/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SimpleModal Janrain Engage</title>
		<link>http://soderlind.no/archives/2010/12/03/simplemodal-janrain-engage/</link>
		<comments>http://soderlind.no/archives/2010/12/03/simplemodal-janrain-engage/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 21:01:15 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[wp-plugins]]></category>
		<category><![CDATA[facebook connect]]></category>
		<category><![CDATA[JanRain]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[rpx]]></category>
		<category><![CDATA[SimpleModal]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=1123</guid>
		<description><![CDATA[Images: Login Register Welcome back SI Captcha SimpleModal Janrain Engage adds Janrain Engage (aka rpx) to your SimpleModal Login Download the plugin from the WordPress Plugin Directory If you like and use the plugin, please rate it (if you feel it deserves less &#8230; <a href="http://soderlind.no/archives/2010/12/03/simplemodal-janrain-engage/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">
<p style="text-align: center;"><a href="http://soderlind.no/wp-content/uploads/2010/12/screenshot-1.png"><img class="aligncenter size-medium wp-image-1178" title="Login with your account at an identity provider or your local account" src="http://soderlind.no/wp-content/uploads/2010/12/screenshot-1-300x142.png" alt="" width="300" height="142" /></a></p>
<p style="text-align: center;">Images: <a title="Login with your account at an identity provider or your local account" href="http://soderlind.no/wp-content/uploads/2010/12/screenshot-1.png" class="colorbox-link">Login</a> <a title="Register using your account at an identity provider or create a local account" href="http://soderlind.no/wp-content/uploads/2010/12/screenshot-2.png" class="colorbox-link">Register</a> <a title="Easy login for returning users" href="http://soderlind.no/wp-content/uploads/2010/12/screenshot-3.png" class="colorbox-link">Welcome back</a> <a title="Integrated with SI Captcha" href="http://soderlind.no/wp-content/uploads/2010/12/screenshot-4.png" class="colorbox-link">SI Captcha</a></p>
<p>SimpleModal Janrain Engage adds <a href="http://wordpress.org/extend/plugins/rpx/">Janrain Engage</a> (aka rpx) to your <a href="http://wordpress.org/extend/plugins/simplemodal-login/">SimpleModal Login</a></p>
<p><strong>Download the plugin from the <a href="http://wordpress.org/extend/plugins/simplemodal-janrain-engage/screenshots/">WordPress Plugin Directory</a></strong></p>
<p>If you like and use the plugin, <a href="http://wordpress.org/extend/plugins/simplemodal-janrain-engage/">please rate it</a> (if you feel it deserves less than 5 stars, please tell me why in the comment field below, and I&#8217;ll try to make it better)</p>
<p><span id="more-1123"></span></p>
<div><strong>Changelog</strong></div>
<div>
<ul>
<li>1.2.9 Bugfix, fixed bad path to language file. Many thanks to vinoowijn1 for pointing out this bug.</li>
<li>1.2.8 Bugfix (removed the spinner/loading icon)</li>
<li>1.2.7 Fixed bug that prevented using LinkedIn and Twitter as a identity provider. My bad, many thanks to mattp and Robert for pointing out this bug.</li>
<li>1.2.5 Added &#8220;set modal width&#8221; in the settings page + minor bug fixes</li>
<li>1.2.0 I should have read the Janrain Engage doc a litle better, discovered a paramenter for the inline widget and &#8220;had&#8221; to rewrite the plugin. Now you can change the heading above the Janrain Engage widget using the ps_simplemodal_janrain_engage.pot file</li>
<li>1.1.1 Minor style fix</li>
<li>1.1.0 Added language support for the Janrain Engange embedded widget and updated the ps_simplemodal_janrain_engage.pot file</li>
<li>1.0.0 Initial release</li>
</ul>
</div>
<div><strong>Requirements</strong></div>
<div id="_mcePaste">
<ul>
<li>PHP: 5.2.x or newer</li>
<li><a href="http://wordpress.org/extend/plugins/simplemodal-login/">SimpleModal Login</a>
<ul>
<li>Install and test. I try not to mess with the css (see below), so you should be able to <a href="http://wordpress.org/extend/plugins/simplemodal-login/faq/">add your own theme</a>. The only modification I do to the css is:
<pre class="brush: css; title: ; notranslate">.simplemodal-container, #simplemodal-login-container {width:$m_width; height:auto;} // $m_width is set using the plugins settings page
.simplemodal-container form, #simplemodal-login-container form {overflow:auto;}
.simplemodal-login-credit {width:90%; padding-top:4px; text-align:center; bottom:0;}</pre>
</li>
</ul>
</li>
<li><a href="http://wordpress.org/extend/plugins/rpx/">Janrain Engage</a>
<ul>
<li>Install and test. Don&#8217;t forget to add your Engage API key.</li>
</ul>
</li>
</ul>
</div>
<div id="_mcePaste"><strong>Manual Installation</strong></div>
<div id="_mcePaste">
<ul>
<li>Upload the files to wp-content/plugins/simplemodal-janrain-engage/</li>
<li>Activate the plugin</li>
</ul>
</div>
<div><strong>Automatic Installation</strong></div>
<div id="_mcePaste">
<ul>
<li>On your WordPress blog, open the Dashboard</li>
<li>Go to Plugins-&gt;Install New</li>
<li>Search for &#8220;SimpleModal Janrain Engage&#8221;</li>
<li>Click on install to install SimpleModal Janrain Engage</li>
</ul>
</div>
<p><strong>Localization</strong></p>
<p>The Janrain Engage embedded widget support several languages. The SimpleModal Janrain Engange plugin will try to set the language for the embedded Janrain Engage widget based on your <a href="http://codex.wordpress.org/WordPress_in_Your_Language">locale</a>. If the plugin doesn&#8217;t find a match, it will use the fallback language set by you in the plugin settings page.</p>
<div>
<div>
<ul>
<li>In Settings -&gt; SimpleModal Janrain Engage, set the fallback language for the Janrain Engage widget. Default is English.</li>
<li>Translate the login/register/reset password form, by using the included ps_simplemodal_janrain_engage.pot file in the wp-content/plugins/simplemodal-janrain-engage/languages folder</li>
</ul>
</div>
</div>
<div><strong>Download</strong></div>
<p>The plugin is available in the <a href="http://wordpress.org/extend/plugins/simplemodal-janrain-engage/screenshots/">WordPress Plugin Directory</a></p>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2010/12/03/simplemodal-janrain-engage/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>[lorem] shortcode</title>
		<link>http://soderlind.no/archives/2010/11/17/lorem-shortcode/</link>
		<comments>http://soderlind.no/archives/2010/11/17/lorem-shortcode/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 22:47:19 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[wp-plugins]]></category>
		<category><![CDATA[lorem ipsum]]></category>
		<category><![CDATA[wordpress shortcode]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=1110</guid>
		<description><![CDATA[Images: Shortcode, Nested shortcode, Example, Lightbox I needed dummy text for a blog I&#39;m working on, and since I like to code I wrote a simple plugin I&#39;d like to share, you&#39;ll find it &#160;in the WordPress Plugin Directory &#160; &#8230; <a href="http://soderlind.no/archives/2010/11/17/lorem-shortcode/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://soderlind.no/wp-content/uploads/2010/11/screenshot-0.png"><img alt="" class="aligncenter size-medium wp-image-1246" src="http://soderlind.no/wp-content/uploads/2010/11/screenshot-1-300x225.png" style="width: 300px; height: 225px;" title="lorem shortcode" /></a></p>
<p style="text-align: center;">Images: <a href="http://soderlind.no/wp-content/uploads/2010/11/screenshot-0.png">Shortcode</a>, <a href="http://soderlind.no/wp-content/uploads/2010/11/screenshot-1.png">Nested shortcode</a>, <a href="http://soderlind.no/wp-content/uploads/2010/11/screenshot-2.png">Example</a>, <a href="http://soderlind.no/wp-content/uploads/2010/11/screenshot-3.png">Lightbox</a></p>
<p>I needed dummy text for a blog I&#39;m working on, and since I like to code I wrote a simple plugin I&#39;d like to share, you&#39;ll find it &nbsp;in the <a href="http://wordpress.org/extend/plugins/lorem-shortcode/">WordPress Plugin Directory</a></p>
<p><span id="more-1110"></span></p>
<p>&nbsp;</p>
<p style="margin: 1em 0px;"><strong>Plugin</strong>: You&rsquo;ll find the plugin at&nbsp;<a href="http://wordpress.org/extend/plugins/lorem-shortcode/" style="color: rgb(0, 85, 153); outline-style: none;">http://wordpress.org/extend/plugins/lorem-shortcode/</a></p>
<p style="margin: 1em 0px;"><strong>Installation</strong>:&nbsp;<a href="http://downloads.wordpress.org/plugin/delicious-tagroll-shortcode.zip" style="color: rgb(0, 85, 153); outline-style: none;">Download the plugin</a>&nbsp;and save it in wp-content/plugins (remember to activate in Plugins) or wp-content/mu-plugins or install it from inside WordPress in Plugins-&gt;Add New (search for &ldquo;lorem shortcode&rdquo;)</p>
<p style="margin: 1em 0px;"><strong>Usage</strong>:&nbsp;<a href="http://soderlind.no/wp-content/uploads/2010/11/screenshot-0.png" rel="lightbox[584]" style="color: rgb(0, 85, 153); outline-style: none;" title="Adding the shortcode to a Page">Add the shortcode to a Page</a>. The plugin contains two shortcodes, [lorem] and [loremimage], the [loremimage] shortcode <a href="http://soderlind.no/wp-content/uploads/2010/11/screenshot-1.png"><strong>can</strong> be nested</a> in the [lorem] shortcode. Supported parameters, all are optional:</p>
<p style="margin: 1em 0px 1em 40px;"><strong>[lorem]</strong></p>
<p>&nbsp;</p>
<ul>
<li style="margin: 1em 0px 1em 40px;">p=&quot;3&quot; Number of paragraphs. Default is 5</li>
<li style="margin: 1em 0px 1em 40px;">l=&quot;7&quot;, Number of lines per paragraph. Default is 3</li>
<li style="margin: 1em 0px 1em 40px;">align=&quot;right&quot; This tells how you&#39;d like to allign a nested shortcode. There are two alternatives, left or right. Default is right</li>
</ul>
<p style="margin: 1em 0px 1em 40px;"><strong>[loremimage]</strong></p>
<p style="margin: 1em 0px 1em 40px;">The loremimage is created using&nbsp;&nbsp;<a href="http://dummyimage.com/ ">http://dummyimage.com/</a>, and hence the shortcode supports the same parameters as&nbsp;&nbsp;<a href="http://dummyimage.com/ ">http://dummyimage.com/</a></p>
<ul>
<li style="margin: 1em 0px 1em 40px;">size=&quot;400&#215;400&quot; Image size. Default is 300&#215;200.</li>
<li style="margin: 1em 0px 1em 40px;">text=&quot;lorem ipsum&quot; Default is empty.</li>
<li style="margin: 1em 0px 1em 40px;">fgcolor=&quot;fff&quot; Image foreground color. Default is &quot;ccc&quot;.</li>
<li style="margin: 1em 0px 1em 40px;">bgcolor=&quot;ccc&quot;&nbsp;Image foreground color. Default is&nbsp;&nbsp;&quot;eee&quot;.</li>
<li style="margin: 1em 0px 1em 40px;">format=&quot;png&quot;, Image format. Default is &quot;png&quot;.&nbsp;</li>
</ul>
<p style="margin: 1em 0px 1em 40px;">I&#39;ve added two additional parameters/values</p>
<ul>
<li style="margin: 1em 0px 1em 40px;">size=&quot;thumb&quot; This will create a thumbnail, size based on your WordPress image settings. The thumb links to another image and support Lightbox et al (has attribute rel=&quot;lightbox[lorem]&quot;).</li>
<li style="margin: 1em 0px 1em 40px;">style=&quot;padding:5px;&quot; Default is empty</li>
</ul>
<p><strong>Changelog</strong>:</p>
<ul>
<li>1.1&nbsp;Added support for embedded shortcodes and added the [loremimage] short code. The [loremimage] can be used by itself. The image is created using <a href="http://dummyimage.com/">http://dummyimage.com/</a></li>
<li>1.0 Initial release</li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2010/11/17/lorem-shortcode/feed/</wfw:commentRss>
		<slash:comments>2</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 = plugin_dir_path(__FILE__) . 'languages/' . $this-&gt;localizationDomain . '-' . $locale . '.mo';
	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>14</slash:comments>
		</item>
		<item>
		<title>Fighting spam</title>
		<link>http://soderlind.no/archives/2010/02/10/fighting-spam/</link>
		<comments>http://soderlind.no/archives/2010/02/10/fighting-spam/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 17:48:42 +0000</pubDate>
		<dc:creator>PerS</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[wp-plugins]]></category>

		<guid isPermaLink="false">http://soderlind.no/?p=745</guid>
		<description><![CDATA[I have reduced the number of  splog attacks on my site I use the Akismet and WP-DenyHost anti-spam plugins for WordPress. Akismet is a must-have and has, since I installed it, caught 304,056 spams (!!).  When Akismet catch a spammer, it logs the spammers &#8230; <a href="http://soderlind.no/archives/2010/02/10/fighting-spam/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have reduced the number of  <a href="http://en.wikipedia.org/wiki/Spam_blog">splog</a> attacks on my site</p>
<p style="text-align: center;"><a href="http://soderlind.no/wp-content/uploads/2010/02/soderlind.no-spam-vs-visits.png"><img class="aligncenter size-medium wp-image-746" title="soderlind.no spam vs visits" src="http://soderlind.no/wp-content/uploads/2010/02/soderlind.no-spam-vs-visits-300x171.png" alt="" width="300" height="171" /></a></p>
<p>I use the <a href="http://wordpress.org/extend/plugins/akismet/">Akismet</a> and <a href="http://soderlind.no/archives/2008/04/18/wp-denyhost/">WP-DenyHost</a> anti-spam plugins for WordPress. Akismet is a must-have and has, since I installed it, caught 304,056 spams (!!).  When Akismet catch a spammer, it logs the spammers IP address. WP-DenyHost, written by me, prevents spammers from getting access to my site a second time by blocking access from this IP address.</p>
<p>I installed WP-DenyHost in the fall 2009 and, as you can see from <a href="http://soderlind.no/wp-content/uploads/2010/02/soderlind.no-spam-vs-visits.png">the graph</a> above, the number of spam has dropped dramatically.</p>
<p>.</p>
]]></content:encoded>
			<wfw:commentRss>http://soderlind.no/archives/2010/02/10/fighting-spam/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

