<?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>gj |</title>
	<atom:link href="https://blog.gaiterjones.com/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.gaiterjones.com/category/wordpress/</link>
	<description>gaiterjones</description>
	<lastBuildDate>Thu, 13 Feb 2014 11:27:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.3</generator>
	<item>
		<title>Javascript only EU Law Cookie Notification Message for WordPress and Magento</title>
		<link>https://blog.gaiterjones.com/javascript-eu-law-cookie-notification-message-wordpress-magento/</link>
					<comments>https://blog.gaiterjones.com/javascript-eu-law-cookie-notification-message-wordpress-magento/#comments</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Wed, 12 Feb 2014 18:49:40 +0000</pubDate>
				<category><![CDATA[5 Minute Fix]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[EU Law]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=1120</guid>

					<description><![CDATA[You know sometimes you just want a quick solution to a problem and wherever you look there are just complex, overpriced scripts that make your simple problem sound like something...<a class="more-link" href="https://blog.gaiterjones.com/javascript-eu-law-cookie-notification-message-wordpress-magento/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="hang-2-column      alignnone" alt="" src="http://voices.suntimes.com/wp-content/uploads/2013/08/Cookiemonster2_FB.jpg" width="150" height="100" /></p>
<p>You know sometimes you just want a quick solution to a problem and wherever you look there are just complex, overpriced scripts that make your simple problem sound like something that needs a lot of code and money to get to work.</p>
<p>I needed to display a cookie notification message on a wordpress and magento site, to avoid compatibility problems I wanted to avoid using jQuery and just do it as simply as possible in javascript.</p>
<p>After looking around at a lot of $10 jQuery solutions I found a free javascript only solution, modified it for Magento and WordPress and implemented it.</p>
<p>Download the code from Github <a href="https://github.com/gaiterjones/javascript-eu-law-cookie-notification" target="_blank">here</a></p>
<p>Whatever your opinion of the <a href="http://ico.org.uk/for_organisations/privacy_and_electronic_communications/the_guide/cookies" target="_blank">EU Cookie Law</a> which came into effect in 2012, sooner or later if you are in Europe you may need to show that you are doing something about it. Err actually it&#8217;s 2014, so I guess we are already a teeny weeny bit late.</p>
<p>From what I understand the law may differ in various countries (certainly outside Europe), so depending on where your website is, and who visits your site the law may or may not apply to you.</p>
<p>This script will let  you quickly implement a cookie notification banner with a link to your privacy policy. The notification itself uses cookies and will not be show again when closed.</p>
<p>You can implement this solution on any website by copying the install files to your web server and adding the following code to the footer of your site.</p>
<p><span style="font-family: 'Courier New', Courier, monospace; font-size: 13px; line-height: 18px;">&lt;script type=&#8221;text/javascript&#8221;&gt;</span></p>
<pre class="brush:php">var cookieNotificationURL='/cookies/';
var cookieNotificationLifetime=180;
var cookieNotificationMessage='This website uses cookies. For more information please ';
var cookieNotificationClickMessage='click here';
var cookieNotificationMessageFade=true;
var cookieNotificationPath='/path-to-install-folder/
&lt;/script&gt;

&lt;script type="text/javascript" src="/js/cookienotification/cookie.notification.min.js"&gt;&lt;/script&gt;</pre>
<p>This sets up some variables used by the script, the URL of the privacy info page, the lifetime of the cookie used by the script in days, messages displayed, the option to fade the message automatically and the path to the install folder &#8211; used to display the close image.</p>
<p>For wordpress simply paste this into the footer php file of your theme.</p>
<p>For Magento paste this into the footer.phtml template file of your Magento theme. You can translate the messages, and perhaps a good idea, choose to display the message only on non SSL pages &#8211; we don&#8217;t want this javascript to somehow screw up a sale!</p>
<p><span style="font-family: 'Courier New', Courier, monospace; font-size: 13px; line-height: 18px;">&lt;?php if (empty($_SERVER[&#8216;HTTPS&#8217;]) &amp;&amp; $_SERVER[&#8216;HTTPS&#8217;] = &#8216;off&#8217;): ?&gt;</span></p>
<pre class="brush:php">&lt;!-- Cookie Notification --&gt;
&lt;script type="text/javascript"&gt;
var cookieNotificationURL='/datenschutzerklaerung/';
var cookieNotificationLifetime=180;

&lt;?php if (Mage::app()-&gt;getStore()-&gt;getId()==2): ?&gt;
var cookieNotificationMessage='This website uses cookies. For more information please ';
var cookieNotificationClickMessage='click here';
&lt;?php else: ?&gt;
var cookieNotificationMessage='Diese Website verwendet Cookies. ';
var cookieNotificationClickMessage='Klicken Sie hier für weitere Informationen.';
&lt;?php endif ?&gt;
&lt;/script&gt;

&lt;script type="text/javascript" src="/js/cookienotification/cookie.notification.js"&gt;&lt;/script&gt;
&lt;?php endif ?&gt;</pre>
<p>Here I am manually checking the store id and translating the text to German. Remember to refresh your Magento cache after editing and saving the footer template file.</p>
<p>You can see the code working on this WordPress blog below, and also with Magento on my <a href="http://dev.gaiterjones.com/magento/" target="_blank">Magento development site.</a></p>
<p>Tested with Magento 1.8.x, WordPress 3.blah, Chrome, Firefox, IE11. Detects mobile devices and modifies banner size accordingly.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/javascript-eu-law-cookie-notification-message-wordpress-magento/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>WordPress MultiLanguage Support the Simple Way</title>
		<link>https://blog.gaiterjones.com/wordpress-multi-language-support/</link>
					<comments>https://blog.gaiterjones.com/wordpress-multi-language-support/#respond</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Fri, 14 Sep 2012 12:43:24 +0000</pubDate>
				<category><![CDATA[5 Minute Fix]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Marketing]]></category>
		<category><![CDATA[Wordpress Multi Language]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=796</guid>

					<description><![CDATA[WordPress is a great multilanguage CMS, for a while I thought of it purely as a blogging tool but now I use it all the time when I need to...<a class="more-link" href="https://blog.gaiterjones.com/wordpress-multi-language-support/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="hang-2-column     alignnone" title="Wordpress Multilanguage Support" src="http://www.ideecon.com/wp-content/uploads/2011/12/wordpresslanguages.png" alt="" width="180" height="180" />WordPress is a great multilanguage CMS, for a while I thought of it purely as a blogging tool but now I use it all the time when I need to build a quick and effective marketing site. If you find a theme that you like and is adaptable you can put together a professional, great looking site that is easy for you or your clients to maintain in very little time.</p>
<p>Getting WordPress to work well with multi language content isn&#8217;t so straight forward, there are a lot of plugins available that offer multi language solutions but these seemed to be over complex for what I wanted.</p>
<p>My WordPress marketing sites are relatively simple with just a few pages used as marketing landing pages and stepping stones to e-commerce sites. I already created a simple method in PHP of detecting browser language and matching language to content in my pages however the WordPress frontend language remained in the default language of the installation. I did not want to modify core template files within WordPress as this makes upgrading difficult so after wasting time with Plugins I developed a very simple solution that sets the WordPress interface language for each visitor based on their browser language.</p>
<p>The WordPress WP-CONFIG.php file holds the main configuration settings for your WordPress installation, a global PHP constant WPLANG is defined here that sets the admin and frontend interface language using standard <a href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_16.html#Country-Codes" target="_blank">country</a> and <a href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_16.html#Language-Codes" target="_blank">language </a>codes, the default if WPLANG is not specified is American English en-US.</p>
<p>WordPress language packs come in .mo files that are located in the WordPress wp-content/languages folder, they are named after the language code, i.e. en_US.mo, de_DE.mo etc.</p>
<p>By detecting the browser language of the visitor and then checking if a corresponding .mo file exists in the languages folder we can automatically switch the WordPress interface language to match the visitors browser language &#8211; nice!</p>
<p>Decide which languages you want to support and download the corresponding .mo files, you can find all the language files available in the WordPress language file repository here <a href="http://svn.automattic.com/wordpress-i18n/">http://svn.automattic.com/wordpress-i18n/</a> e.g. here are the German language files <a href="http://svn.automattic.com/wordpress-i18n/de_DE/branches/2.8/messages/" target="_blank">http://svn.automattic.com/wordpress-i18n/de_DE/branches/2.8/messages/</a></p>
<p>If your WordPress site does not have a wp-content/languages folder, create a new one and copy your language files into it. Note you should copy your default language file too.</p>
<p>Now edit the WP-CONFIG.php file in the root folder of your WordPress installation and find the WP-LANG constant definition and comment it out:</p>
<p>#define (&#8216;WPLANG&#8217;, &#8221;);</p>
<p>and below it paste in the following code</p>
<pre class="brush:php">/**
 * Set language and load language files
 */
function detectlanguage() {
    $langcode = explode(";", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
    $langcode = explode(",", $langcode['0']);
    return $langcode['0'];
    }

function fileExists($fileName, $caseSensitive = true) {

    if(file_exists($fileName)) {
        return $fileName;
    }
    if($caseSensitive) return false;

    // Handle case insensitive requests            
    $directoryName = dirname($fileName);
    $fileArray = glob($directoryName . '/*', GLOB_NOSORT);
    $fileNameLowerCase = strtolower($fileName);
    foreach($fileArray as $file) {
        if(strtolower($file) == $fileNameLowerCase) {
            return $file;
        }
    }
    return false;
}	

$languageDefault='en_US';
$language = detectlanguage();

if (isset($_GET['set_lang'])) { $language = $_GET['set_lang']; }

$languageFile= 'wp-content/languages/'. str_replace('-','_',$language). '.mo';
$wpLanguageFile=fileExists($languageFile,false);

// check if WP language file exists for browser language
if ($wpLanguageFile) {
	$wpLanguageFile = basename($wpLanguageFile, '.mo');
	// language supported
	define ('WPLANG', $wpLanguageFile);
    //echo "Language - $language detected. Language file exists and is supported."; 
} else {
	// language not supported default to EN
    //echo "Language - $language detected. Language file does not exist - defaulting to $languageDefault."; 
	define ('WPLANG', $languageDefault);
}</pre>
<p>Save the file and test. You can force the language selection by specifying it in the URL, i.e. http://yourwordpresssite.com/?set_lang=de_DE which will force the interface language to German if you have the German language files installed. Uncomment the echo&#8217;s and you will see the language selection confirmed.</p>
<p>If all is working well the WordPress interface language will now switch to the browser language of your visitors.</p>
<p>Note that this will only change the language of the built in WordPress interface in the frontend or backend. Your content language will not change, you need to create a <a href="http://www.catswhocode.com/blog/how-to-make-a-translatable-wordpress-theme" target="_blank">translation system</a> for your content using portable object files, or alternatively use the Google translation tool.</p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/wordpress-multi-language-support/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
