WPML Translate Custom WordPress Plugin Text Fields

I will explain how to translate custom text fields of WordPress plugins using WPML (WordPress Multilingual Plugin) and XML formatted “Language Configuration Files“. Even thought not mandatory, phpMyAdmin and Firebug have been used in this example. I’ve tried to make this guide easier to understand and more useful than the official documentation which can be a headache for newbies.

To demonstrate the process I set up a “multilingual coming soon page” using the Ultimate Coming Soon Page plugin for WordPress. The plugin settings contain custom text boxes where you can write content in one language only. To translate this text in WPML, it requires the “WPML String Translation” plugin and a bit of extra effort which I will explain here.

I would like to note that (unlike WPML) in Qtranslate for WordPress, you can use “language tags” to enter content in different languages within the same text field. But this feature does not work within plugin settings. Comparing the “work arounds” for translating plugin content between the two, I think the one for Qtranslate isn’t any easier.

First make sure you have these two plugins installed and activated:

WPML Multilingual CMS
WPML String Translation

When you have the “String Translation” plugin installed, you can see an additional menu option for it in the admin dashboard. On this page you can translate content, however in the case of plugin text fields the strings are not shown automatically. So we need to create a “Language Configuration File” for each plugin in XML format.

To create the file, you need to find the attributes used by the plugin to fetch the strings of text from your MySQL database. There are a few ways around it, here is a few that I prefer.

Using for example, the Firebug page inspector or anything that will show you the source code of a page that has plugin content that you want translated.. Look for the text inside the source code, and what kind of DIV it’s wrapped inside of.

So in the case of the “Ultimate Coming Soon Page” plugin. The coming soon page has the following HTML:

<h1 id="teaser-headline">The title in English to be translated</h1>

Now locate the plugin file that uses the ID attribute. An easy way to do this in a linux console is:

grep -r -H “teaser-headline” /path/to/your/plugin/directory

The above query results in the following piece of code:

./ultimate-coming-soon-page/inc/template/template-coming-soon.php: <h1 id="teaser-headline"><?php echo $sc_jdt['comingsoo
n_headline'] ?></h1>

The MySQL attribute here is “comingsoon_headline“.

Next you could have a further look into the file, template-coming-soon.php and look for  the get_option line, on the top of the page.

$sc_jdt = get_option('seedprod_comingsoon_options');

The attribute you need here is “seedprod_comingsoon_options“.

The other way is to go to phpMyAdmin or another MySQL client and search for “comingsoon_headline” which is a table value inside the “wp_options” table. This will also discover the name of the table option, “seedprod_comingsoon_options” and inside it are all the rest of the attributes you might need.

Once all the attributes are collected, we create a file named: wpml-config.xml & place it inside the plugin directory. Ex: “~/public_html/wp-content/plugins/ultimate-coming-soon-page”. Examples of the file format below.

First comes the name of the table option and then the string values inside of it. This is the example for the “Ultimate Coming Soon Page” plugin:

<wpml-config>
<admin-texts>
<key name="seedprod_comingsoon_options">
<key name="comingsoon_description" />
<key name="comingsoon_headline" />
</key>
</admin-texts>
</wpml-config>

And this one is for the Easy Coming Soon plugin:

<wpml-config>
<admin-texts>
<key name="soon_page_settings">
<key name="title" />
<key name="descrip" />
</key>
</admin-texts>
</wpml-config>

The change should be instant and you can see the strings in the string translation menu of WPML, ready to be translated!

Fix Missing RSS Feed on New WordPress Site

Problem:

Got your WordPress site started up, looked up all the common RSS Feed URLs but none of them are validating on FEED Validator? Can’t get your FeedBurner account live?

Try this:

- create your first post

That’s about it. Basically if you don’t have any posts, there is no RSS Feed either. If this didn’t fix it for you however, you have a bigger problem in your hands.

Good luck :)

Add CSS Class Directly to WordPress Menu Item Link

In some cases you might want to add a CSS class directly to a WordPress menu item link. For example:

<a class=”piwik_link” href=”http://www.domain”>menu item</a>

In WordPress there is the “CSS Classes” setting in “advanced menu properties”. Which can be enabled in the “screen options”, when editing menus. This setting however puts the CSS class outside of the link code.

In this case I needed to add a class to track clicks on an outbound link in Piwik. Because by setting up the class “piwik_link“, directly inside the “a href” line of code, clicks can be recorded as as a “goal”.

To do this, simply navigate to the appearance editor in WordPress, and add a few lines of code to your “functions.php” file, in the bottom for example:

function add_menuclass($ulclass) {
return preg_replace('/<a rel="nofollow"/', '<a rel="nofollow" class="piwik_link"', $ulclass, 1);
}
add_filter('wp_nav_menu','add_menuclass');

In this example, all menu links that are set rel=”nofollow” will automatically append the class “piwik_link”. You may change the code to fit your needs.

Therefore automatically each:

<a rel=”nofollow” href=”http://www.domain”>menu item</a>

will be converted to:

<a class=”piwik_link” rel=”nofollow” href=”http://www.domain”>menu item</a>

To add rel attributes in wordpress, go to menu editor -> screen options -> enable “Link Relationship (XFN)” and each menu item will have a new Link Relationship (XFN) option. In this box you can enter the desired rel attributes.

Setting up subdomains for each WPML language w. cPanel

In my opinion, WPML documentation is not very user friendly. Reading the official documentation on setting up the Language URL format, didn’t help me much. I wasted a bit of time on it, so perhaps someone could find this guide useful on how to setup different subdomains for each language with the WordPress Multilingual Plugin, and cPanel. It’s actually a really simple thing to do.

First you need to add the actual subdomains. Just login to your sites cPanel and select “subdomains“, the settings are pretty self explanatory. Probably the easiest way is to just enter a wildcard (*) to the subdomain box and enter the html directory relative to $HOME below it, (usually “public_html”).

This way all the subdomains that you set up in WPML will work straight away. And those subdomains that are not set up, will forward to your main domain. Alternatively you could enter each necessary subdomain individually.

After the “WPML Multilingual CMS” plugin is installed, simply navigate to Dashboard -> WPML -> Languages. Choose the “Site Languages” for your website and head on to the “A different domain per language” setting below “Language URL format“.

Add the domains you want to set up for each language and hit “Apply”. If you get an error when saving the settings: “Error: data not saved”, you could try checking your file permissions. The two lines below will recursively setup 755 permission for directories and 644 for files.

find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

That’s about it!

Display Joomla Extra Vote Plugin in Module Position

The Extra Vote plugin for Joomla has a really nice feature where you can place Rich Snippet voting anywhere you want inside an article by adding {extravote 1}, {extravote 2}, etc. or {main vote} tags to your content. However this is limited to articles only. If you want to add those Snippets inside a module position, here’s how you can do it:

Download and install:

Extra Vote

Rich Snippets Vote

Disable plugin:

Content – Vote

Enable plugins:

Content – ExtraVote

Content – Rich Snippets Vote

Then all you have to do is create an article that contains the tag and put that article in it’s own category. Now you can publish a module type “Articles – Newsflash” and set it up to show only the category that contains your article with the rich snippets code.

Going to See Theatre in Beijing

If you are in Beijing you might as well go and see a few theatre performances. The quality is not always the best but most of the shows are perfectly entertaining enough to waste a few hours. Many visitors know about haggling and that one should ever accept the first price. However not so many people know that this also applies to most of the theatre productions in the city.

Some tour companies around the city offer discount tickets to these shows so you don’t even need to haggle! What you must understand is that this business is operated by tour guides and not by the official theatre ticket window. That’s why with companies like “May Tours” you must book the tickets in advance.

To actually purchase your discount tickets all you need to do is go to the theatre before the show starts and a tour guide will be there waiting for you while holding your name. I can assure you that it’s perfectly safe to purchase from them as the business is conducted inside the theatre premises.

I will briefly introduce some of the shows where you can get a significant reduction in price!

Liyuan Theatre

Here you can get a glimpse of the performing art of “Peking Opera”. This is the least popular which shows how little tourists are really interested in Chinese culture. One of the most important cultural events going on the city has to be Beijing Opera. This has hardly anything to do with western Opera but instead is a rather entertaining and even amusing art form you will most likely never see anywhere else.

No worries, this place has made sure to not bore you because all the visitors will be tourists. They also have english subtitles so you can catch the story. Great for first timers but if you are anything more than a little experienced in Peking Opera, it is advised to go somewhere else.

http://maytoursbeijing.info/beijing-opera-tickets

Chaoyang Theatre

If you want to see a Chinese acrobatic show, then without a doubt this is the best place in Beijing. As it’s probably the most popular performing arts venue amongst the regular tourist folk, you cannot go wrong. It’s something that everything likes and of course acrobatics is something very deeply routed to Chinese culture. Therefore you could call it an cultural experience as well :)

As for the acrobatics, it’s really top notch. The place is a bit old but has that originality in it’s attractive feel. Go there and enjoy with the whole family if your looking for an easy as well as an exiting time.

http://maytoursbeijing.info/beijing-acrobatic-show-tickets

Red Theatre

The Beijing Red Theatre is pretty much the coolest place you can go. Well almost, the Kung Fu show hosted here is really famous and extremely well done. The story however is not that profound. Anyone a fan of action or martial arts will definitely enjoy here, but children as well as those that like theatre productions will be equally satisfied.

To make one thing clear, these are not real Shaolin Monks. This is a purely commercial production meant to entertain you and in that aspect far from the original spirit of Kung Fu. Tricks will surely amaze most of the spectators so no need to worry about the lack of awesomeness! :)

http://maytoursbeijing.info/beijing-kung-fu-show-tickets

Have you been to a theatre in Beijing? Know how to get a discount? Just leave a comment below to share the goodness!

Jumping Great Firewall of China With Nokia N9

First and foremost this is a step-by-step guide on how to setup a Nokia N9 mobile phone (that uses the Harmattan or Meego operating system) to  jump the great firewall of China.

The method used in this howto is Shadowsocks proxy. This creates several advantages over the traditional VPN method. Plus I’ve made a neat little icon for easy use.

Shadowsocks is a socks5 proxy that is designed to pass firewalls. While the Chinese government has found ways to crack down on VPN use, such as port blocking, this socks method has reportedly so far remained untouched.

In my experience the use of a VPN on a mobile phone while you are on the go is less withstanding to network outages and reconnection times could be long or at worst, manual. The performance of a proxy however is hardly affected on mobile use, it can often be  easier to set up and even less power consuming according to my observations.

Furthermore this guide is well suited for anyone wanting to use such a proxy for any reason. As well as for other countries than China that block Facebook, YouTube, Twitter, etc. Also those with other types of cell phones such as Android phone or an iPod have the possibility of setting up a similar method.

Grab Shadowsocks

First grab the latest shadowsocks bundle from Github. Then unzip the package and edit ports, password and your server IP in “config.json“. If the server has a dynamic IP, use a DNS provider. Changing ports are an optional paranoia measure since China has a tendency to block default ports. But as far as I know these are not being blocked at the moment.

For the server side

Place these files on a machine preferably outside of China if your planning to do some wall hopping. Python needs to be installed for this to work, which shouldn’t be a problem for Linux users. For Mac OS X presumably you need to have Developer Tools installed, which you can grab from the App Store or somewhere else. Sorry I have no idea about windows, but surely it’s possible. Just make sure that the port you defined in “server_port” is open. On a machine that’s using iptables it would be as simple as adding this to your iptables.conf file:

-A INPUT -p tcp -m tcp --dport [PORT] -j ACCEPT

Then to fire it up from command line:

python server.py > local &

For the client side

You’ll be using the same set of files for the server and client. And to setup the quick launch icons you’ll be needing these four files:

startstop.sh

#!/bin/sh

if pkill -f "/usr/bin/python /opt/shadowsocks/local.py"; then
    echo "killed"
    cat /opt/shadowsocks/off.desktop >/usr/share/applications/breakwall.desktop
else
    echo "starting"
    cat /opt/shadowsocks/on.desktop >/usr/share/applications/breakwall.desktop
    /usr/bin/python /opt/shadowsocks/local.py > /dev/null 2>&1 &
fi

off.desktop

[Desktop Entry]
Type=Application
Name=BreakWall
Exec=/bin/sh /opt/shadowsocks/startstop.sh
Icon=/usr/share/icons/hicolor/80x80/apps/breakwall.png

on.desktop

[Desktop Entry]
Type=Application
Name=FixWall
Exec=/bin/sh /opt/shadowsocks/startstop.sh
Icon=/usr/share/icons/hicolor/80x80/apps/fixwall.png

breakwall.desktop

[Desktop Entry]
 Type=Application
 Name=BreakWall
 Exec=/bin/sh /opt/shadowsocks/startstop.sh
 Icon=/usr/share/icons/hicolor/80x80/apps/breakwall.png

After that all we need is to put those files into place. Plug-in the device and select “Use as mass storage“. Drag and drop these files into the Documents folder of your device (the root folder wont work!).

1) A directory named “shadowsocks” with all the files from Github and startstop.sh, off.desktop, on.desktop, on.desktop

2) breakwall.desktop on it’s own

3) These two images:

breakwall fixwall

Now that the files are in your phone, eject your device and plug it in again. Select “SDK mode” and open the “SDK Connect” app where you choose the “USB” option. On your computer, go to the terminal and connect with “ssh developer@[IP]“. Use the IP & password provided in the app.

Once your in your phone console, gain root access with the command “devel-su“. “default password is: rootme”

Now throw in these commands: “it’s safe to ignore some of the warnings”

mv /home/user/MyDocs/Documents/breakwall.png /usr/share/icons/hicolor/80×80/apps/
mv /home/user/MyDocs/Documents/fixwall.png /usr/share/icons/hicolor/80×80/apps/
mv /home/user/MyDocs/Documents/shadowsocks /opt
mv /home/user/MyDocs/Documents/breakwall.desktop /usr/share/applications/
chmod 666 /usr/share/applications/breakwall.desktop

Function

A shortcut icon with an American flag should appear on your desktop, named: “BreakWall“. Pressing it will start up the proxy in the background. Please note that it takes a little while for it to start working.

To use the proxy you will need to go to Settings -> Internet Connection -> Edit networks -> [select your network] -> Advanced settings. There you can fill in the SOCKS proxy and port number without a password. In the DNS section you may add for instance the Google DNS 8.8.8.8 & 8.8.4.4 (it wont work without a name server outside of the great firewall).

Once the proxy is in use, the icon should display a hammer and sickle “FixWall” which will shut down the proxy process if pressed. You will also need to turn off the socks proxy setting for your connection to have things in previous order.

Couple tips more. If you only need to use the proxy for YouTube, “cuteTube” has it’s own proxy setting. Also if you want to create your own icons get the template file from here and please share them in the comment box below!

List of Blogging Platforms Not Blocked in China

Here is a list of free online blogging platforms unblocked by the Great Firewall of China, compiled in April 2013. Furthermore I have verified if the blogs are being indexed in Baidu. Please use this as a reference only, obviously the situation may change at any time the Chinese government sees fit.

Thanks to the generous guys at Great Fire, I have provided a link to the historical data of the blogging platform which checks for blocks or other restrictions within the Great Firewall. This may help to evaluate the stability of the blog’s openness in China. Click on the “TEST NOW” link to see the status of the current day.

www.blog.com [check status] [pr6]

Blog.com is a WordPress based free blogging platform with some minor ads. Unfortunately in my experience it sometimes has annoying server overload outages.

- wordpress
- ads
- own subdomain
- links are dofollow
- indexed by Baidu

blogs.rediff.com [check status] [pr7]

Based on wordpress, but no subdomain so the blog URL is in the format http://blogs.rediff.com/yourblogname/. There are no actual ads but has a “rediff toolbar” on top of the page.

- wordpress
- no ads (toolbar)
- links are dofollow
- indexed by Baidu

www.tumblr.com [check status] [pr8]

There are no ads, you get your own subdomain and it’s great for microblogging. Tumblr toolbar sits on on top of the page.

- own subdomain
- no ads (toolbar)
- links are dofollow
- indexed by Baidu

tblog.com [check status] [pr4]

No ads, no toolbar neither. It’s their own blogging platform that’s really simple and easy to use.

- own subdomain
- no ads
- links are dofollow
- indexed by Baidu

jux.com [check status] [pr6]

Good for Microblogging. This site uses fancy javascript techniques but search engine robots are redirected to an escaped fragment standard to help indexing. Despite this, jux.com is not being indexed by Baidu.

- own subdomain
- no ads
- links are dofollow
- not indexed by Baidu

www.blogymate.com [check status] [pr3]

You get a page loaded with ads and all kinds of features which are included in the interface. More of a social place, but can be used for blogging. No subdomain, the URL you get is in the format: “blogymate.com/blog/yourname”.

- links are dofollow
- indexed by Baidu

You could also use these two, Baidu indexed website builders to run a blog:

www.weebly.com [check status] [pr8]

www.webs.com [check status] [pr7]

If you know of any more to add, please let me know in the comments!

A Good Place to Be

Nature and technology have no need to clash with each other. Nowadays a good place to be in society is where you enjoy the benefits of the technological movement while keeping in close contact with the nature.