xili-language – 1.4.1 – new libraries

This release xili-language 1.2.1 adds new features dedicated to multilingual theme’s creators and webmasters. Some new php functions, a folder to include functions shared by themes (not necessary to put functions in functions.php of the current theme); example with a shortcode to insert link inside content toward another post in a language. Since this release, xili-language is also compliant with wordpress 2.9.

Gold functions

Gold functions

Gold functions

In sidebox « Settings », a new check button appears if a folder named xilidev-libraries and containing a functions.php file was present inside your wp/content/plugins/ folder.
If this button is checked, all the functions inside this file was added when plugin is activated. Why it is interesting ? When adding here special filters or actions for hookable template tags of xili-language, you don’t need to copy and paste your functions of one theme to another theme.

New functions in core of xili-language

Two new functions was added for developers (since February – 3 new for time display) :
xiliml_get_lang_object_of_post($post_ID) Return an object containing properties of the language set to the post passed as param (false if the post don’t exist or undefined language) See code for more infos.
xiliml_get_language($lang_nameorslug="") Return an object containing properties of the language passed as slug (ex fr_fr) or name (ex fr_FR). False if the language doesn’t exist. $result->description gives the full name of the language set by you in xili-language settings.

To illustrate these new features, please find an example of functions.php here containing only two functions to create a shortcode named linkpost.

 * shortcode to insert link to post in other languages inside the content 
 * example : [linkpost lang="fr_FR"]link to french similar post[/linkpost] (if title="some text" : title of link is set by replacing title 'A similar post in...')
 *@since 1.2
function xiliml_build_linked_posts_shortcode($atts,$content=null) {
	global $post;
	$arr_result = shortcode_atts(array('lang'=>'','title'=>''), $atts);
	$language = xiliml_get_language($lang); /* test if lang is available */
	if ($language !== false) {
		$otherpost = get_post_meta($post->ID, 'lang-'.$language->slug, true);
	if ($otherpost) {
		if ('' == $title) {
			$obj_lang = xiliml_get_lang_object_of_post($otherpost);
			if (false !== $obj_lang) {
				$description = $obj_lang->description;
				$title = __('A similar post in',THEME_TEXTDOMAIN).' '.$description;
			} else {
				$title = __('Error with target post #',THEME_TEXTDOMAIN).$otherpost;
		$output = '<a href="'.get_permalink($otherpost).'" title="'.$title.'">'.$content.'</a>';
		/* this link above can be enriched by image or flag */
	} else {
		$output = '<a href="#" title="'.__('Error: other post not present !!!','xili-language').'">'.$content.'</a>';
	return $output;
add_shortcode('linkpost', 'xiliml_build_linked_posts_shortcode');

Please find here a .zip containing the folder « xilidev-libraries » to upload in wp-content/plugins/ directory and this example functions [enriched since Feb 28th, 2010].

This posts belong to the series: xili-language for experts
  1. xili-language plugin : release 2.1
  2. Q&A about xili-language plugin, release 1.1
  3. xili-language : hooks, filters, class and so on...
  4. From a theme with localization to a multilingual theme with xili-language : technical and general notes.
  5. xili-language - 1.4.1 - new libraries
  6. Xili-language toolbox in one table
  7. xili-language and the time
  8. xili-language : Affichage des dates et heures

Ce contenu a été publié dans Experts corner, xili-language, avec comme mot(s)-clé(s) , , , . Vous pouvez le mettre en favoris avec ce permalien.

2 réponses à xili-language – 1.4.1 – new libraries

  1. Ping : Posts about themes as of October 19, 2009 | All About WordPress

  2. Ping : xili-language review, discussions, does it work, and ratings on Loadwp.com | Loadwp.com

Laisser un commentaire