<?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>Flying memes &#187; Wordpress</title>
	<atom:link href="http://sandropaganotti.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://sandropaganotti.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 23 Mar 2012 19:07:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Translating wp-members with WPML</title>
		<link>http://sandropaganotti.com/2012/03/23/translating-wp-members-with-wpml/</link>
		<comments>http://sandropaganotti.com/2012/03/23/translating-wp-members-with-wpml/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 18:56:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Librerie]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wp-members]]></category>
		<category><![CDATA[WPML]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=591</guid>
		<description><![CDATA[I was asked to create a website where some content can be viewed only by registered users. I decided to go for WordPress and I choose wp-members plugin to enable member-only content as well as custom login and register pages. Everything was going pretty well when I discovered that wp-members store in the wp_options table [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked to create a website where some content can be viewed only by registered users. I decided to go for WordPress and I choose <a href="http://butlerblog.com/wp-members/" target="_blank">wp-members</a> plugin to enable member-only content as well as custom login and register pages. </p>
<p><span id="more-591"></span>Everything was going pretty well when I discovered that wp-members store in the wp_options table some labels and sentences, such as fields labels and all the templates of the emails to be sent to the user. This behavior is not compatible with <a href="http://wpml.org/" target="_blank">WPML</a> and results in the same label or sentence rendered without caring of the current user language.<br />
Luckily there&#8217;s an easy workaround, we can create an hook that intercepts the request of such labels and substitue them when necessary.</p>
<p>To begin we have to create a filter call to be activated upon request of these properties, that&#8217;s easy because wp-member prefixes all of its properties with &#8216;wpmembers_&#8217;:</p>
<pre><code class="php">
if(is_plugin_active('wp-members/wp-members.php')){
	$db_options = get_alloptions();

	foreach($db_options as $name => $value){
		if(strpos($name, 'wpmembers_') === 0){
			add_filter('option_' . $name, 'i18n_wpmembers');
		}
	}
}
</code></pre>
<p>Now we can define a &#8216;i18n_wpmembers&#8217; function which determinate what property wp-members is looking for and acts by injecting translations taken from other properties, using name conventions:</p>
<pre><code class="php">
function i18n_wpmembers($value){
	global $db_options;
	$language_code = defined('ICL_LANGUAGE_CODE') ? constant('ICL_LANGUAGE_CODE') : substr(get_bloginfo("language"), 0,2);

        // load translations if available (ex: it_wpmembers_options)
	$translations = get_option($language_code . '_wpmembers_options');
	$current_option = str_replace('option_','',current_filter());

	switch($current_option){
		case 'wpmembers_fields':
			$elements_to_return = array();
			foreach($value as $i => $field){
				$new_field = $field;
				$label = $new_field[2];
				$translated_opt = $translations ? $translations[$current_option . '_' . $label] : false;
                                // inject the translation into the wp-members structured property
				$new_field[1] = ($translated_opt ? $translated_opt : $field[1]);
				$elements_to_return[] = $new_field;
			}
			return $elements_to_return;
			break;

                // continue with all the other wp-members properties

		default:
			return $value;
			break;
	}
}
</code></pre>
<p>Now all we have to do is create an extra admin page which let create the translated properties, we can achieve this following <a href="http://themeshaper.com/2010/06/03/sample-theme-options/" target="_blank">the theme options guidelines</a>.</p>
<p>Hope it might be useful! </p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2012/03/23/translating-wp-members-with-wpml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An iPad plugin theme for wordpress: working alpha</title>
		<link>http://sandropaganotti.com/2010/07/25/an-ipad-plugin-theme-for-wordpress-working-alpha/</link>
		<comments>http://sandropaganotti.com/2010/07/25/an-ipad-plugin-theme-for-wordpress-working-alpha/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 12:45:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Annunci]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[Sencha]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[WpTouch]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=425</guid>
		<description><![CDATA[Update 01/09/2010: WiPad is now published and available on the official WordPress plugin directory. I&#8217;ve started deploying an iPad wordpress theme/plugin based on wptouch and powered by Sencha. Today I&#8217;ve reached the first working alpha and so I&#8217;ve decided to use it against this blog. You can try out this theme by surfing here with [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update 01/09/2010: </strong>WiPad is now published and available on <a title="WiPad is a WordPress theme/plugin designed for iPad, based on WpTouch and powered by Sencha Touch" href="http://wordpress.org/extend/plugins/wipad/" target="_blank">the official WordPress plugin</a> directory.<strong> </strong></p>
<p>I&#8217;ve started deploying an iPad wordpress theme/plugin based on <a href="http://wordpress.org/extend/plugins/wptouch/">wptouch</a> and powered by <a href="http://www.sencha.com/">Sencha</a>. Today I&#8217;ve reached the first working alpha and so I&#8217;ve decided to use it against this blog. You can try out this theme by surfing here with an iPad or a simulator; two screenshots are also available after the jump.</p>
<p><span id="more-425"></span></p>
<p><a href="http://sandropaganotti.com/wp-content/uploads/2010/07/ishot-2241.png"><img class="alignnone size-full wp-image-430" title="ishot-224" src="http://sandropaganotti.com/wp-content/uploads/2010/07/ishot-2241.png" alt="" width="600" height="465" /></a></p>
<p><a href="http://sandropaganotti.com/wp-content/uploads/2010/07/Screen-shot-2010-07-25-at-14.27.471.png"><img class="alignnone size-full wp-image-429" title="Screen shot 2010-07-25 at 14.27.47" src="http://sandropaganotti.com/wp-content/uploads/2010/07/Screen-shot-2010-07-25-at-14.27.471.png" alt="" width="462" height="599" /></a></p>
<p>I&#8217;ve planned to release a first version of this plugin as soon as it include some basic features, such as permalink navigation and pages support.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2010/07/25/an-ipad-plugin-theme-for-wordpress-working-alpha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

