giovedì 7 maggio 2015

Polylang some additional settings

Polylang is a great plugin to make your site multilanguage.
That is great, but sometimes you need to manage it inside some more complex template.
In my case i had to show the flags just under my logo, cause using the widget i didn't get a great result.
Using the widget from the menu i got something like this:


As you can see using the widget with the Language Switcher, you can insert in the main menu, but the result is really ugly. So let's find something prettier.

I want to put my switcher just near the logo of my site.
To get this i modified some code.

Let's us see how to get this result:


What Did i do to make it possible ?

Let'us start to study how works Polylang.
Polylang offers you a nice function called pll_the_languages, that accepts some parameters to personalize it.

I used a particular template by Colorlib, the template travelify.
I modified the file \wp-content\themes\travelify\library\structure\header-extensions.php.

<ul><?php pll_the_languages(array("show_flags"=>1) );?></ul>
<h1 id="site-title">

Just before the h1 tag.
Here the documentation for this function: https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/
So your role now is to find the position where to show the flag, in relation with the template you are using and to put such code, this make you possible to position more accurate your switcher.



martedì 14 aprile 2015

Let's start with the conventions of the file plugin.php

Let's start this blog with the conventions used to create a simple plugin.
< ?php
/*
Plugin Name: My First Plugin
Plugin URI: http://example.com/wordpress-plugins/my-first-plugin
Description: A short description of my plugin
Version: 1.1
Author: Pierpaolo Romanelli
Author URI: http://pierpaoloromanelli.com
License: GPLv2
*/
? >

The first line is very important, it is useful to recognize the name of your plugin.
The second line is a page where is described what your plugin does.
The Description line is a short description shown in your Plugin Screen of WordPress.
The Version is useful to WordPress to search for new updates.
The author is the name of the author of the plugin.
The URI is the page of the plugin's Author.

Let's us see an example of our plugin: