In this table, all the main widgets, template tags, functions and hooks are grouped. (March 2015: under finishing and pending review step from previous version in 2010 đŸ˜‰ ).It is recommended to read the source of the most recent version. Functions are grouped at end of the source.
It is a summary of the “technical” features of xili-language plugin and is dedicaced to webmaster and theme’s designer.
Toolbox: xili-language plugin for a multilingual website in one table | ||||
Name | Definition | Comment | Example | Concern |
WIDGETS | to enrich widget enable themes | Theme | ||
Languages list | Display the list of available languages | Multiple widgets possible. If your theme contains functions that offer widget personalization, the item type must be filled. (see this post) | sidebar | |
Recent comments | Display the list of recent comments in current displayed language. |
This widget was created because the default one cannot be translatable or offer sub-selection in one language. multiple widgets possible |
sidebar | |
Recent posts | Display list of recent posts in a choosen language |
since v 1.4.0 for WP >2.8 This new widget solves conflicts or issues occuring when WP default widget is present (contains an obscur `wp_reset_query`). Also a choice of language of this list of recent posts is possible – not necessary the same of the current page. And you can install multiple widgets. Replace WP Recent Widget by this one named – List of recent posts – multiple widgets possible with different languages (fixed or dynamic) |
sidebar | |
TEMPLATE TAGS | usable by theme’s designer and webmaster | Theme | ||
xiliml_the_other_posts default parameters: ($post_ID,$before = “This post in”, $separator = “, “, $type = “display”) |
in loop display the link of other posts defined as in other languages |
can be used in theme template in single.php under the title * example: if(class_exists(‘xili_language’)) xiliml_the_other_posts($post->ID) (in the example, the default template tag was hooked to display flag – see hooks rows below) |
post – page – loop | |
xili_post_language default parameters: ($before = ‘<span class=”xili-lang”>(‘, $after =’)</span>’) |
in loop display the language of the post | Useful inside a multilingual category loop. |
|
loop, category, search |
xili_language_list default parameters: ($before = ‘<li>’, $after ='</li>’, $theoption=”) |
outside loop (sidebar) display the languages of the site (used also by widget) | When the theme don’t enable widget. Use this template tag to display the list in sidebar or (header and footer) |
|
sidebar |
xiliml_the_category default parameters: ($post_ID, $separator = ‘, ‘ ,$echo = true) |
replace the_category() tag of WP Core | The current template tag the_category is not hookable by plugin. So here the categories list of a post inside loop will be translated according the language of the current post. |
|
post – page – loop |
xiliml_langinsearchform default parameters: ($before=”,$after=”) |
Template Tag insertable in search form for sub-selection of a language | As in example, this function add a way to limit the search to a target language. |
/**
* define when search form is completed by radio buttons to sub-select language when searching
*
*/
function special_head() {
if ( class_exists('xili_language') ) { // if temporary disabled
// to change search form of widget
// if ( is_front_page() || is_category() || is_search() )
if ( is_search() || is_404() ) {
add_filter('get_search_form', 'my_langs_in_search_form_2015', 10, 1); // here below
}
}
}
add_action( 'wp_head', 'special_head', 11) ;
/**
* add search other languages in form - see functions.php when fired
*
*/
function my_langs_in_search_form_2015 ( $the_form ) {
$form = str_replace ( '', '', $the_form ) . '' . xiliml_langinsearchform ( $before='', $after='', false) . '';
$form .= '';
return $form ;
}
|
search – sidebar |
FUNCTIONS | usable by developer with knowledges in php (see php source) | CMS | ||
the_curlang() | deprecated | replaced by |
xili_curlang()
/*as used in child of twenty fifteen */ if ( isset ( $xili_theme_options['xl_header'] ) && $xili_theme_options['xl_header'] ) { global $xili_language, $xili_language_theme_options ; // check if image exists in current language // 2013-10-10 - Tiago suggestion $curlangslug = ( '' == xili_curlang() ) ? strtolower( $xili_language->default_lang ) : xili_curlang() ; |
theme |
the_cur_langs_group_id() | ||||
the_xili_local_time default parameters: ($format=’%B %d, %Y’,$time = null) |
time | |||
get_cur_language ($post_ID) | Return the language of current post in loop | see below | loop | |
get_cur_post_lang_dir ($post_ID) | Return the lang and dir of language of current post in loop. | The example on right uses this tag and the above one. |
while (have_posts()) : the_post();
$langdir = ((function_exists('get_cur_post_lang_dir')) ? get_cur_post_lang_dir($post->ID) : array()); ?>
|
loop |
xiliml_get_lang_object_of_post ($post_ID) | Return language object of a post. | loop | ||
choice_of_browsing_language() | Return the language of current browser. | visitor’s browser | ||
choice_of_browsing_lang_dir() | Return the lang and dir of current browser. | visitor’s browser lang and direction | ||
add_again_filter ($filtername,$filterfunction) | Activate hooks of plugin in class. | Reserved for high level developers – see code of function below | ||
xiliml_get_category_link ($catid = 0) | Replace get_category_link to bypass hook from xili_language | |||
xiliml_recent_comments | Recent comments – used by xili widget – usable if you need to create your own template tag | comments | ||
xiliml_get_language ($lang_nameorslug=””) | Return full object of a language | |||
ex_pages_by_lang ($pages, $r) | sub selection of pages for wp_list_pages() | example to use as hook | sidebar | |
function xiliml_force_loop_lang ($lang_query_tag) | functions to change loop’s query tag of language |
useful for sidebar widgets and latest posts widget – since 1.3.0 Even if the main loop is in one language, in the sidebar, it is possible to “force” the language in another one for the widgets. |
Another example :
|
sidebar, widget |
xiliml_add_lang_to_parsed_query () | function for filter ‘parse_query’ to authorize lang query tag in custom WP_Query() |
since 1.4.0 useful for function or plugin that put posts inside post… |
/* example: */
add_action('parse_query','xiliml_add_lang_to_parsed_query');
$r = new WP_Query($thequery);
remove_filter('parse_query','xiliml_add_lang_to_parsed_query');
|
loop, custom queries |
SHORTCODE | ||||
linked post | example of shortcode using plugin functions | this code can be inserted in dedicaced functions detectable inside this folder: wp-content/plugins/xilidev-libraries – see this post – |
(Cette page en français)
|
post content |
HOOKS |
Main functions and template tags of xili-language are modifiable by hooks to have better and adapted CMS behaviour. It is useful for developer with deep knowledges in php and wp (see end of php source) |
CMS | ||
xiliml_the_category add_action (‘xiliml_the_category’,’your_xiliml_the_category’,10,3) |
template tag | |||
xiliml_the_other_posts add_action(‘xiliml_the_other_posts’,’your_xiliml_the_other_posts’,10,3) |
template tag | |||
xili_post_language add_action(‘xili_post_language’,’your_xili_post_language’,10,2) |
template tag | |||
xili_language_list add_action(‘xili_language_list’,’your_xili_language_list’,10,3) |
In this example described formerly, the list of languages is enriched by flags:
function my_xili_language_list($before = ' |
template tag | ||
xiliml_langinsearchform add_action(‘xiliml_langinsearchform’,’your_xiliml_langinsearchform’,10,2) |
sidebar | |||
xiliml_cat_language add_filter(‘xiliml_cat_language’,’my_rules_for_cat_language’,2,3); |
Exemple to show translated and original item
function my_rules_for_cat_language ($content, $category = null, $curlang='') {
if (!is_admin()) : /*to detect admin UI*/
$new_cat_name = __($category->name,THEME_TEXTDOMAIN);
if ($new_cat_name != $content) :
$new_cat_name .= " (". $content .") ";
endif
else :
$new_cat_name = $content;
endif;
return $new_cat_name;
}
add_filter('xiliml_cat_language','my_rules_for_cat_language',2,3);
|
sidebar wp list categories content |
||
head_insert_language_metas add_filter(‘head_insert_language_metas’,’my_head_insert_language_metas’,1,2); |
header xhtml | |||
head_language_attributes add_filter(‘head_language_attributes’,’my_ head_language_attributes’,1,1); |
header xhtml | |||
xiliml_cur_lang_head add_filter(‘xiliml_cur_lang_head’,’my_xiliml_cur_lang_head’,1); |
default rules – set curlang in head according rules | multilingual behaviour (front, cat, search,…) | ||
More technical hooks and filters inside xili-language (Read the plugin php source for more infos) |
||||
choice_of_browsing_language | ||||
xiliml_link_translate_desc | ||||
xiliml_single_cat_title_translate | used by filter for wp_title() tags – since 1.4.1 | |||
xiliml_getarchives_where | ||||
xiliml_getarchives_join | ||||
xiliml_modify_querytag | ||||
xiliml_taglink_append_lang | ||||
xiliml_link_append_lang | ||||
xili_nav_lang_list |
usable to change the automatic insertion of languages list in navigation menu. Example:
/* tests */
function my_xili_nav_lang_list( $items, $args, $navmenu_check_option ) {
if ( $navmenu_check_option == $args->theme_location ) {
$end = xili_language_list( ' |
|||
xili_nav_page_list | usable to change the automatic insertion of sub-selection of pages : see source | |||
OTHER FILTERS | Some template tags inside WP core are not fully multilingual and need filters. |
| ||
the_time add_filter(‘the_time’,’my_date’,10,2); |
Date management and translation are very complicated. Here by using a xili-language function, it is possible to modify the basic behaviour of the current template tag the_time. |
function my_date($thetime,$theformat) {
/* param no used because php format */
return the_xili_local_time('%B %d, %Y - %H:%M',strtotime(get_the_time('m/d/Y H:i')));
}
add_filter('the_time','my_date',10,2);
|
Post, Page | |
the_modified_time add_filter(‘the_modified_time’,’my_modified_date’,10,2); |
Date management and translation are very complicated. Here by using a xili-language function, it is possible to modify the basic behaviour of the current template tag the_modified_time. |
function my_modified_date($thetime,$theformat) {
/* param no used because php format */
return the_xili_local_time('%B %d, %Y - %H:%M',strtotime(get_the_modified_time('m/d/Y H:i')));
}
add_filter('the_modified_time','my_modified_date',10,2);
|
Post, Page | |
get_comment_date add_filter(‘get_comment_date’,’my_comment_date’,10,2); |
This is the date of each comments in the comments loop. |
function my_comment_date($comment_time,$d = '') {
/* params no used because php format */
/* the first param is to be as msgid in .po example: %B %d, %Y - %H:%M or %B %d, %Y at %H:%M */
return the_xili_local_time('%B %d, %Y', strtotime(get_comment_time ('m/d/Y H:i')));
/* impossible to use get_comment_date as it is itself filtered*/
}
add_filter('get_comment_date','my_comment_date',10,2);
|
Comments | |
© dev.xiligroup.com | 2010 – 2015-03 |