web/wp-content/plugins/xili-language/xili-language.php
author Anthony Ly <anthonyly.com@gmail.com>
Mon, 19 Nov 2012 18:26:13 +0100
changeset 194 32102edaa81b
parent 180 d8780eeb2607
permissions -rw-r--r--
MAJ wordpress et ajout de plugin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     1
<?php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     2
/*
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     3
Plugin Name: xili-language
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     4
Plugin URI: http://dev.xiligroup.com/xili-language/
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
     5
Description: This plugin modify on the fly the translation of the theme depending the language of the post or other blog elements - a way to create a real multilanguage site (cms or blog). Numerous template tags and three widgets are included. It introduce a new taxonomy - here language - to describe posts and pages. To complete with tags, use also xili-tidy-tags plugin. To include and set translation of .mo files use xili-dictionary plugin. Includes add-on for multilingual bbPress forums.
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     6
Author: dev.xiligroup.com - MS
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     7
Author URI: http://dev.xiligroup.com
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
     8
Version: 2.8.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
     9
License: GPLv2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    10
Text Domain: xili-language
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    11
Domain Path: /languages/
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    12
*/
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    13
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    14
# updated 120921 - 2.8.1 - fixes sticky perma - improvements for bbPress - new filters in admin - fixes feed links meta
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    15
# updated 120903 - 2.8.0 - fixes, new: admin side language selection - b : langstate
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    16
# updated 120819 - 120723 - 2.7.1 - fixes lang_perma detect for permalinks add-ons - new start via action
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    17
# updated 120721 - 2.7.0 - multilingual features in media library - centralize alert messages and ready for link to wiki
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    18
# updated 120708 - 2.6.3 - fixes notice when page-on-front - new icons - test propagate cats
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    19
# updated 120701 - 2.6.2 - add news pointer in class admin, tabs in help
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    20
# updated 120615 - 2.6.1 - fixes notice xlrp
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    21
# updated 120528 - 2.6.0 - class admin in separate file, able to detect and use local files (local-xx_XX.mo) containing translations
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    22
# updated 120420 - 2.5.1 - add style for post edit (flag in imput)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    23
# updated 120415 - 2.5.0 - new dashboard metabox for translations list of linked posts and actions (as in XD2), language postmetas now hidden, hreflang link added in head, WP3.4 pre-tests: fixes metaboxes columns
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    24
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    25
# updated 120329 - 2.4.4 - fixes posts list language column in 3.2.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    26
# updated 120225 - 2.4.3 - fixes before releasing
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    27
# updated 120212 - 2.4.2 - admin_bar replaced by toolbar and node (>= WP3.3) - cc: + Reply-To: - better merge loadthemedomain in multisite - ready for XD 2.0 - sub-sub-folder for language files
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    28
# updated 120128 - 2.4.1 - new readme - new tabs in settings - improved lang slug creation - test menu location get_registered_nav_menus - 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    29
# updated 111222 - 2.4.0 - if needed and present add rtl.css for rtl languages - new date based on wp_locale - time options
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    30
# less than 2.4….
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    31
# see readme text for these intermediate versions for WP 2.x. or visit other previous versions (2.5).
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    32
# updated 090228 - Class and OOP - see 0.9.7 in comments of functions below - only for WP 2.7.x
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    33
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    34
# This plugin is free software; you can redistribute it and/or
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    35
# modify it under the terms of the GNU Lesser General Public
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    36
# License as published by the Free Software Foundation; either
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    37
# version 2.1 of the License, or (at your option) any later version.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    38
#
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    39
# This plugin is distributed in the hope that it will be useful,
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    40
# but WITHOUT ANY WARRANTY; without even the implied warranty of
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    41
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    42
# Lesser General Public License for more details.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    43
#
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    44
# You should have received a copy of the GNU Lesser General Public
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    45
# License along with this plugin; if not, write to the Free Software
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    46
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    47
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    48
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    49
define('XILILANGUAGE_VER','2.8.1'); /* used in admin UI*/
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    50
define('XILILANGUAGE_WP_VER','3.3'); /* used in error - see at end */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    51
define('XILILANGUAGE_PHP_VER','5.0.0'); /* used in error - see at end */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    52
define('XILILANGUAGE_PREV_VER','2.4.3');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    53
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    54
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    55
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    56
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    57
/********************* the CLASS **********************/
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    58
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    59
class xili_language {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    60
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    61
	var $xili_settings; /* saved in options */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    62
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    63
	var $langs_group_id; /* group ID and Term Taxo ID */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    64
	var $langs_group_tt_id; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    65
	
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    66
	var $default_lang; /* language of config.php*/
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    67
	var $default_slug; /* slug of language of config.php since 1.5.3 wpmu*/
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    68
	var $curlang;
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    69
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    70
	var $thetextdomain = ""; /* since 1.5.2 - used if multiple */
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    71
	var $langstate; /* undefined or not */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    72
	
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    73
	var $browseroption = '';
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    74
	var $lang_neither_browser = ''; // when neither match with browser
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    75
	var $authorbrowseroption = '';
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    76
	
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    77
	var $default_dir = ''; /* undefined or not in WP config '' or rtl or ltr */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    78
	var $curlang_dir = ''; /* undefined or not according array */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    79
	var $rtllanglist = 'ar-he-fa-ur'; /* default-list - can be set after class instantiation */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    80
	
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    81
	var $get_archives_called = array(); /* if != '' - insert lang in link */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    82
	var $idx = array(); /* used to identify filter or action set from this class - since 0.9.9.6 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    83
	var $theme_locale = false; /* to control locale hook */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    84
	var $ossep = "/"; /* for recursive file search in xamp */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    85
	
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    86
	var $current_lang_query_tag = ""; /* since 1.3.0 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    87
	var $temp_lang_query_tag = "";
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    88
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    89
	var $domaindetectmsg = ""; // used if pb with load_theme_textdomain
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    90
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    91
	var $langs_list_options = array( array('','default'), array('typeone','Type #1'), array('typeonenew','Type for single'), array('navmenu', 'Nav Menu' ) , array('navmenu-1', 'Nav Menu Singular' ) ); // type of languages list see options in xili_language_list or navmenu
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    92
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    93
	var $comment_form_labels = array ( // since 1.6.0 for comment_form 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    94
		'name' => 'Name',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    95
		'email' => 'Email',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    96
		'website' => 'Website',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    97
		'comment' => 'Comment',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    98
		'youmustbe' => 'You must be <a href="%s">logged in</a> to post a comment.',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
    99
		'loggedinas' => 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   100
		'emailnotpublished' => 'Your email address will not be published.',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   101
		'requiredmarked' => ' Required fields are marked <span class="required">*</span>',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   102
		'youmayuse' => 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes:',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   103
		'leavereply' => 'Leave a Reply',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   104
		'replyto' => 'Leave a Reply to %s',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   105
		'cancelreply' => 'Cancel reply',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   106
		'postcomment' => 'Post Comment'
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   107
		);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   108
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   109
	var $sticky_keep_original = false ; // since 1.6.1 see translate_sticky_posts_ID function 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   110
	var $xl_recent_posts = false ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   111
	var $ltd = false ; // load_textdomain detected 1.8.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   112
	var $arraydomains = array();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   113
	var $show = false ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   114
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   115
	var $langs_ids_array ; // array slug => id
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   116
	var $langs_slug_name_array ; // array slug => name // 2.4.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   117
	var $langs_slug_fullname_array; // array slug => full name // 2.6.3
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   118
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   119
	var $show_page_on_front = false; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   120
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   121
	/* for permalink with lang at root */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   122
	var $lang_perma = false; // if true new permalink for root and categories /en_us/category/.... if special action available… 2.1.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   123
	var $lpr = ''; // 2.3.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   124
	var $show_page_on_front_array = array(); // array of lang=>page_id if show_on_front == page
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   125
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   126
	var $undefchar = "."; // 2.2.3 - used to detect undefined
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   127
	var $sublang = ""; // 2.2.3 - used to detect - or fr_fr- of like
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   128
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   129
	// 2.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   130
	// other in class admin
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   131
	var $translation_state = '_xl_translation_state' ; // set to initial when post created from dashboard metabox (to update post slug)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   132
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   133
	// 2.6 - class admin in separate file
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   134
	var $file_file = ''; // see in construct below
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   135
	var $file_basename = '';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   136
	var $plugin_basename = '';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   137
	var $plugin_url = '';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   138
	var $plugin_path = ''; // The path to this plugin - see construct
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   139
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   140
	var $xilidev_folder = '/xilidev-libraries'; //must be in plugins
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   141
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   142
	//since 2.7.1 - updated 2.8.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   143
	var $examples_list = array();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   144
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   145
	/**** Construct is future ****/
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   146
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   147
	public function __construct( $locale_method = false, $show = false, $class_admin = false ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   148
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   149
		// 2.6 - class admin in separate file
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   150
		$this->file_file = __FILE__ ; // see in construct below
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   151
		$this->file_basename = basename(__FILE__) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   152
		$this->plugin_basename = plugin_basename(__FILE__) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   153
		$this->plugin_url = plugins_url('', __FILE__) ; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   154
		$this->plugin_path = plugin_dir_path(__FILE__) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   155
		 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   156
		$this->locale_method = $locale_method; /* added for compatibility with cache plugin from johan */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   157
		$this->show = $show;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   158
		$this->class_admin = $class_admin;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   159
		/* activated when first activation of plug */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   160
		
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   161
		register_activation_hook(__FILE__,array(&$this,'xili_language_activate'));
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   162
		$this->ossep = strtoupper( substr(PHP_OS ,0 ,3 ) == 'WIN' ) ? '\\' : '/';	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   163
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   164
			 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   165
		/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   166
		 * get current settings
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   167
		 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   168
		$this->xili_settings = get_option('xili_language_settings'); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   169
		if( false === $this->xili_settings ) { //1.9.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   170
			$this->initial_settings ();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   171
			update_option('xili_language_settings', $this->xili_settings);				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   172
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   173
			if ($this->xili_settings['version'] == '1.9') { /* 2.4.0 */	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   174
				$this->xili_settings['wp_locale'] = 'wp_locale'; //wp_locale new mode
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   175
				$this->xili_settings['version'] = '2.0';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   176
				update_option('xili_language_settings', $this->xili_settings); //
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   177
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   178
			if ($this->xili_settings['version'] == '2.0') { /* 2.4.0 */	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   179
				$this->xili_settings['available_langs'] = array(); // default array 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   180
				$this->xili_settings['version'] = '2.1';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   181
				update_option('xili_language_settings', $this->xili_settings); //
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   182
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   183
			if ($this->xili_settings['version'] == '2.1') { /* 2.6.0 */	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   184
				$this->xili_settings['external_xl_style'] = "on";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   185
				$this->xili_settings['creation_redirect'] = 'redirect'; // default - after initial creation 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   186
				$this->xili_settings['version'] = '2.2';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   187
				update_option('xili_language_settings', $this->xili_settings);  //
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   188
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   189
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   190
			if ( ! isset ( $this->xili_settings['version'] ) || $this->xili_settings['version'] != '2.2') { // repair or restart from new
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   191
				$this->initial_settings ();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   192
				update_option('xili_language_settings', $this->xili_settings);  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   193
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   194
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   195
		if ( ! $class_admin ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   196
			if ( ! defined( 'TAXONAME' ) ) define('TAXONAME', $this->xili_settings['taxonomy']);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   197
			if ( ! defined( 'QUETAG' ) ) define('QUETAG', $this->xili_settings['reqtag']); // 'lang'
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   198
			if ( ! defined( 'TAXOLANGSGROUP' ) ) define('TAXOLANGSGROUP', $this->xili_settings['taxolangsgroup']);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   199
			if ( ! defined( 'LANG_UNDEF' ) ) define('LANG_UNDEF', $this->xili_settings['lang_undefined']); //2.2.3
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   200
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   201
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   202
		$this->browseroption = $this->xili_settings['browseroption']; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   203
		$this->lang_neither_browser = $this->xili_settings['lang_neither_browser']; // 2.3.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   204
		$this->authorbrowseroption = $this->xili_settings['authorbrowseroption'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   205
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   206
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   207
		//$this->thetextdomain = $this->xili_settings['theme_domain']; /* since 1.5.2 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   208
		$this->langsliststatus = $this->xili_settings['langs_list_status'];  /* 1.6.0 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   209
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   210
		/* detect research about permalinks */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   211
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   212
		//$this->lang_perma = ( has_filter ( 'term_link', 'insert_lang_4cat' ) ) ? true : false ;	// 1.4.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   213
		$this->show_page_on_front = ( 'page' == $this->get_option_wo_xili('show_on_front') ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   214
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   215
		if ( !$class_admin )  { // filtering only one time 2.6
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   216
			add_action( 'init', array(&$this,'init_textdomain'));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   217
			add_action( 'init', array(&$this,'init_and_register_language_post_taxonomy') );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   218
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   219
		add_action( 'init', array(&$this,'init_vars') ); // moved here 2.8.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   220
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   221
		if ( !$class_admin ) { // filtering only one time 2.6
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   222
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   223
			add_action( 'init', array(&$this,'add_link_taxonomy'), 12 ); // 1.8.5	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   224
			/* special to detect theme changing since 1.1.9 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   225
			add_action( 'switch_theme', array(&$this,'theme_switched') );	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   226
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   227
			/* query filters */	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   228
			add_filter( 'posts_join', array(&$this,'posts_join_with_lang'), 10, 2 );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   229
			add_filter( 'posts_where', array(&$this,'posts_where_lang'), 10, 2 );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   230
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   231
			add_filter( 'posts_search', array(&$this,'posts_search_filter'), 10, 2 ); //2.2.3
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   232
			add_action( 'pre_get_posts', array(&$this,'xiliml_modify_querytag') );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   233
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   234
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   235
			add_action( 'wp', array(&$this,'xiliml_language_wp') ); /// since 2.2.3 - wp_loaded - wp before
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   236
			/* 'wp' = where theme's language is defined just after query */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   237
			if ( $this->xili_settings['wp_locale'] == 'wp_locale' )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   238
				add_action( 'wp', array(&$this,'xili_locale_setup'), 15 ); // since 2.4
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   239
			if ( $this->locale_method )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   240
				add_filter('locale', array(&$this,'xiliml_setlocale'), 10);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   241
			/* to be compatible with l10n cache from Johan since 1.1.9 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   242
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   243
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   244
	 		add_filter( 'widget_title', array(&$this,'one_text')); /* added 0.9.8.1 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   245
		 	add_filter( 'widget_text', array(&$this,'one_text'));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   246
		 	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   247
			add_filter( 'list_cats', array(&$this,'xiliml_cat_language'), 10, 2 ); /* mode 2 : content = name */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   248
			add_filter( 'link_category', array(&$this,'one_text')); // 1.6.0 for wp_list_bookmarks (forgotten)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   249
			add_filter( 'category_link', array(&$this,'xiliml_link_append_lang'), 10, 2 );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   250
			$filter = 'category_link';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   251
			$function = 'xiliml_link_append_lang';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   252
			$this->idx['xiliml_link_append_lang'] = _wp_filter_build_unique_id($filter, array (&$this, $function == '' ? $filter : $function), 10, 2); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   253
			/* unique id of this filter from object fixed 1.0.1 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   254
			add_filter( 'category_description',array(&$this,'xiliml_link_translate_desc'));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   255
			add_filter( 'single_cat_title',array(&$this,'xiliml_single_cat_title_translate')); /* 1.4.1 wp_title() */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   256
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   257
			add_filter( 'tag_link', array(&$this,'xiliml_taglink_append_lang' ));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   258
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   259
			add_filter( 'bloginfo', array(&$this,'xiliml_bloginfo'), 10, 2); /* since 1.6.0 - description - date - time */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   260
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   261
			/* filters for archives since 0.9.9.4 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   262
			add_filter( 'getarchives_join', array(&$this, 'xiliml_getarchives_join'), 10, 2 );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   263
			add_filter( 'getarchives_where', array(&$this, 'xiliml_getarchives_where'), 10, 2 );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   264
			add_filter( 'get_archives_link', array(&$this, 'xiliml_get_archives_link') );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   265
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   266
			/* option modified */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   267
			add_filter( 'option_sticky_posts', array(&$this, 'translate_sticky_posts_ID') ); /* 1.6.1 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   268
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   269
			add_filter( 'option_page_on_front', array(&$this, 'translate_page_on_front_ID') ); /* 1.7.0 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   270
			$filter = 'option_page_on_front';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   271
			$function = 'translate_page_on_front_ID';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   272
			$this->idx['translate_page_on_front_ID'] = _wp_filter_build_unique_id($filter, array (&$this, $function == '' ? $filter : $function), 10, 2);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   273
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   274
			/* bookmarks and widget_links  1.8.5  #2500 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   275
			add_filter( 'widget_links_args', array( &$this, 'widget_links_args_and_lang' ), 10, 1 ); // in class WP_Widget_Links (default-widgets.php)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   276
			add_filter( 'get_bookmarks', array( &$this, 'the_get_bookmarks_lang' ), 10, 2); // only active if 'lang' in wp_list_bookmarks()
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   277
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   278
			add_action( 'wp_head', array(&$this,'head_insert_language_metas'), 11 ); // © and options present in functions.php
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   279
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   280
			if ( !is_admin() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   281
				add_filter( 'the_category', array(&$this,'xl_get_the_category_list'), 10, 2); /* 1.7.0 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   282
				add_filter( 'gettext', array(&$this,'change_plugin_domain'), 10, 3); /* 1.8.7 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   283
				add_filter( 'gettext_with_context', array(&$this,'change_plugin_domain_with_context'), 10, 4); /* 1.8.8 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   284
				add_filter( 'ngettext', array(&$this,'change_plugin_domain_plural'), 10, 5);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   285
				add_filter( 'ngettext_with_context', array(&$this,'change_plugin_domain_plural_with_context'), 10, 6);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   286
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   287
				// for wp nav menu
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   288
				add_filter('the_title', array(&$this,'wp_nav_title_text'),10,2);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   289
				if ('' != $this->xili_settings['in_nav_menu'])
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   290
						add_filter('wp_nav_menu_items', 'xili_nav_lang_list',10,2);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   291
				if ('' != $this->xili_settings['page_in_nav_menu'])
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   292
						add_filter('wp_nav_menu_items', 'xili_nav_page_list',9,2); // before lang's links - 1.7.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   293
				if ('' != $this->xili_settings['home_item_nav_menu'])
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   294
						add_filter('walker_nav_menu_start_el', 'xili_nav_page_home_item',10,4); // add lang if - 1.8.9.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   295
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   296
				add_filter( 'language_attributes',  array(&$this,'head_language_attributes'));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   297
				add_action( 'wp_head', array(&$this,'head_insert_hreflang_link' ), 10 ); // since 2.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   298
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   299
				add_filter( 'option_date_format', array(&$this, 'translate_date_format') ); /* 1.7.0 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   300
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   301
				add_filter( 'category_feed_link', array(&$this, 'category_feed_link') ); // 2.8.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   302
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   303
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   304
			// since 1.5.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   305
			add_filter( 'comment_form_default_fields', array(&$this,'xili_comment_form_default_fields'));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   306
			add_filter( 'comment_form_defaults', array(&$this,'xili_comment_form_defaults'));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   307
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   308
			// since 2.4.0 for rtl.css
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   309
			add_filter( 'locale_stylesheet_uri', array(&$this, 'change_locale_stylesheet_uri' ),10, 2 ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   310
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   311
			// since 1.8.8 - activate xl widget series
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   312
			if ( $this->xili_settings['widget'] == 'enable' )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   313
				add_action( 'widgets_init', array(&$this,'add_new_widgets') );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   314
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   315
			/* new actions for xili-language theme's templates tags */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   316
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   317
			$this->add_action( 'xili_language_list', 'xili_language_list', 10, 5); /* add third param 0.9.7.4 - 4th 1.6.0*/
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   318
			$this->add_action( 'xili_post_language', 'xili_post_language', 10, 2);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   319
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   320
			$this->add_action( 'xiliml_the_other_posts', 'the_other_posts', 10, 4); /* add a param 1.1 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   321
			$this->add_action( 'xiliml_the_category', 'the_category', 10, 3);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   322
			$this->add_filter( 'xiliml_langinsearchform', 'xiliml_langinsearchform', 10, 3); // 1.8.2 action to filter
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   323
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   324
		// verify theme and set ltd for both parent and admin child
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   325
			add_filter( 'override_load_textdomain', array(&$this,'xiliml_override_load'), 10, 3); // since 1.5.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   326
			add_filter( 'theme_locale', array(&$this,'xiliml_theme_locale'), 10, 2);	// two times if is_admin()
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   327
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   328
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   329
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   330
	/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   331
	 * first activation or empty settings 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   332
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   333
	function initial_settings () {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   334
		$this->xili_settings = array(
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   335
			    'taxonomy'		=> 'language',
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   336
			    'version' 		=> '2.2',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   337
			    'reqtag'		=> 'lang', // query_var
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   338
			    'browseroption' => '',
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   339
			    'authorbrowseroption' => '',
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   340
			    'taxolangsgroup' => 'languages_group',
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   341
			    'functions_enable' => '',
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   342
			    'langs_folder' => '',
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   343
			    'theme_domain' => '',
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   344
			    'homelang' => '',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   345
			    'langs_list_status' => '',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   346
			    'in_nav_menu' => '',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   347
			    'page_in_nav_menu' => '',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   348
				'args_page_in_nav_menu' => '',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   349
				'multilingual_custom_post' => array(),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   350
				'langs_in_root_theme' => '',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   351
				'domains' => array( 'all' => 'disable', 'default' => 'disable','bbpress' => 'disable' ),  // no default domain to theme domain 1.8.7
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   352
				'widget' => 'enable',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   353
				'delete_settings' => '', //1.8.8 for uninstall
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   354
				'allcategories_lang' => 'browser', // 1.8.9.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   355
				'lang_features' => array() ,
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   356
				'home_item_nav_menu' => '', // 1.8.9.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   357
				'lang_undefined' => $this->undefchar, //2.2.3
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   358
				'lang_neither_browser' => '', // 2.3.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   359
				'wp_locale' => 'wp_locale', // 2.7.1 new mode as default - 2.4.0 = old mode based on db strftime
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   360
				'available_langs' => array(),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   361
				'creation_redirect' => 'redirect', // 2.6 to redirect to new post after creation
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   362
				'external_xl_style' => "on" // activate external xl-style.css - on by default :2.6.3
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   363
		    );
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   364
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   365
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   366
	/* first activation of plugin */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   367
	function xili_language_activate() {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   368
		$this->xili_settings = get_option('xili_language_settings');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   369
		if( empty($this->xili_settings) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   370
			$this->initial_settings ();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   371
		    update_option('xili_language_settings', $this->xili_settings);  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   372
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   373
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   374
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   375
	function add_action ( $action, $function = '', $priority = 10, $accepted_args = 1 )
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   376
	{
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   377
		add_action ($action, array (&$this, $function == '' ? $action : $function), $priority, $accepted_args);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   378
		$this->idx[$action] = _wp_filter_build_unique_id($action, array (&$this, $function == '' ? $action : $function), $priority); /* unique id of this filter from object */		 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   379
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   380
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   381
	function add_filter ( $filter, $function = '', $priority = 10, $accepted_args = 1 )
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   382
	{
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   383
		add_filter ($filter, array (&$this, $function == '' ? $filter : $function), $priority, $accepted_args);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   384
		$this->idx[$filter] = _wp_filter_build_unique_id($filter, array (&$this, $function == '' ? $filter : $function), $priority); /* unique id of this filter from object fixed 1.0.1 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   385
	}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   386
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   387
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   388
	 * for wpmu 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   389
	 * register functions must be called by init
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   390
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   391
	 * @since 1.5.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   392
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   393
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   394
	function init_and_register_language_post_taxonomy () {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   395
		/** add new taxonomy in available taxonomies 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   396
		 * 1.0.2 - add label false as http://core.trac.wordpress.org/ticket/10437 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   397
		 * 			to avoid metabox as tag displayed  , 'query_var' => QUETAG 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   398
		 * @updated 1.4.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   399
		 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   400
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   401
		if ( !$this->class_admin ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   402
			if ( $this->xili_settings['wp_locale'] == 'wp_locale' )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   403
				xiliml_declare_xl_wp_locale ();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   404
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   405
			if ( $this->lang_perma ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   406
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   407
				register_taxonomy( TAXONAME, 'post', array('hierarchical' => false, 'label' => false, 'rewrite' => false , 'update_count_callback' => array(&$this, '_update_post_lang_count'), 'show_ui' => false, '_builtin' => false, 'query_var' => QUETAG ));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   408
				$this->lpr = "-"; // 2.3.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   409
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   410
				add_filter('query_vars', array(&$this,'keywords_addQueryVar')); // now in taxonomy decl. // 2.1.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   411
				register_taxonomy( TAXONAME, 'post', array('hierarchical' => false, 'label' => false, 'rewrite' => false , 'update_count_callback' => array(&$this, '_update_post_lang_count'), 'show_ui' => false, '_builtin' => false ));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   412
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   413
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   414
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   415
			register_taxonomy( TAXOLANGSGROUP, 'term', array('hierarchical' => false, 'update_count_callback' => '', 'show_ui' => false, 'label'=>false, 'rewrite' => false, '_builtin' => false ));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   416
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   417
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   418
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   419
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   420
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   421
	 * since 2.6
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   422
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   423
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   424
	function init_vars () {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   425
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   426
		$this->examples_list = array(
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   427
		'af' => __('afrikaans','xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   428
		'ar_AR' => __('arabic', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   429
		'be_BY' => __('belarusian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   430
		'bs_BA' => __('bosnian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   431
		'bg_BG' => __('bulgarian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   432
		'bn_BD' => __('bangla', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   433
		'ca' => __('catalan', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   434
		'cs_CZ' => __('czech', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   435
		'cy' => __('welsh', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   436
		'da_DK' => __('danish', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   437
		'de_DE' => __('german', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   438
		'el' => __('greek', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   439
		'en_GB' => __('british english', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   440
		'en_US' => __('english', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   441
		'eo' => __('esperanto', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   442
		'es_ES' => __('spanish', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   443
		'es_CL' => __('chilean', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   444
		'et' => __('estonian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   445
		'eu' => __('euskara', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   446
		'fa_IR' => __('persian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   447
		'fi_FI' => __('finnish', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   448
		'fo' => __('faroese', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   449
		'fr_FR' => __('french', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   450
		'ge_GE' => __('georgian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   451
		'gl_ES' => __('galician', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   452
		'he_IL' => __('hebrew', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   453
		'hr' => __('croatian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   454
		'hu_HU' => __('hungarian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   455
		'id_ID' => __('indonesian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   456
		'is_IS' => __('icelandic', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   457
		'it_IT' => __('italian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   458
		'ja' => __('japanese', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   459
		'km_KH' => __('khmer', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   460
		'ko_KR' => __('korean', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   461
		'lt_LT' => __('lithuanian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   462
		'lv' => __('latvian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   463
		'mg_MG' => __('malagasy', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   464
		'mk_MK' => __('macedonian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   465
		'mn_MN' => __('mongolian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   466
		'ms_MY' => __('malay', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   467
		'nb_NO' => __('norwegian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   468
		'ni_ID' => __('nias', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   469
		'nl_NL' => __('dutch', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   470
		'pl_PL' => __('polish', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   471
		'pt_BR' => __('brazilian portuguese', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   472
		'pt_PT' => __('portuguese', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   473
		'ro_RO' => __('romanian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   474
		'ru_RU' => __('russian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   475
		'si_LK' => __('sinhala', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   476
		'sk_SK' => __('slovak', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   477
		'sl_SI' => __('slovenian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   478
		'sq_AL' => __('albanian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   479
		'sr_CS' => __('serbian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   480
		'sv_SE' => __('swedish', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   481
		'su_ID' => __('sundanese', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   482
		'tg' => __('tajik', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   483
		'th' => __('thai', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   484
		'tr' => __('turkish', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   485
		'uk_UA' => __('ukrainian', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   486
		'uz_UZ' => __('uzbek', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   487
		'vi' => __('vietnamese', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   488
		'zh_CN' => __('chinese', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   489
		'zh_TW' => __('taiwan chinese', 'xili-language'),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   490
		'zh_HK' => __('hong kong chinese', 'xili-language')
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   491
		);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   492
		/* default values */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   493
		if ( ''!= WPLANG && ( strlen( WPLANG )==5 || strlen( WPLANG ) == 2 ) ) : // for japanese
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   494
			$this->default_lang = WPLANG;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   495
		else:
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   496
			$this->default_lang = 'en_US';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   497
		endif;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   498
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   499
		$thegroup = get_terms(TAXOLANGSGROUP, array('hide_empty' => false,'slug' => 'the-langs-group'));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   500
		if ( array() == $thegroup ) { /* update langs group 0.9.8 and if from start 2.3.1 */ 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   501
			$args = array( 'alias_of' => '', 'description' => 'the group of languages', 'parent' => 0, 'slug' =>'the-langs-group');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   502
			wp_insert_term( 'the-langs-group', TAXOLANGSGROUP, $args); /* create and link to existing langs */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   503
			$listlanguages = get_terms(TAXONAME, array('hide_empty' => false, 'get' => 'all'));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   504
			if ( array() == $listlanguages ) { /*create two default lines with the default language (as in config)*/ 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   505
		  		/* language of WP */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   506
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   507
				$term = 'en_US';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   508
				$args = array( 'alias_of' => '', 'description' => 'english', 'parent' => 0, 'slug' =>'en_us');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   509
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   510
				$theids = $this->safe_lang_term_creation ( $term, $args );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   511
				if ( ! is_wp_error($theids) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   512
					wp_set_object_terms($theids['term_id'], 'the-langs-group', TAXOLANGSGROUP);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   513
					$this->xili_settings['lang_features']['en_us'] = array('charset'=>"",'hidden'=>"");
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   514
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   515
				$term = $this->default_lang;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   516
		 		$desc = ( isset($this->examples_list[$term]) ) ? $this->examples_list[$term] : $this->default_lang;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   517
		 		$slug = strtolower( $this->default_lang ) ; // 2.3.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   518
		 		if (!defined('WPLANG') || $this->default_lang == 'en_US' || $this->default_lang == '' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   519
		 			$term = 'fr_FR'; $desc = 'french'; $slug = 'fr_fr' ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   520
		 		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   521
		 		$args = array( 'alias_of' => '', 'description' => $desc, 'parent' => 0, 'slug' => $slug);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   522
		 		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   523
		 		$theids = $this->safe_lang_term_creation ( $term, $args ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   524
				if ( ! is_wp_error($theids) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   525
					wp_set_object_terms($theids['term_id'], 'the-langs-group', TAXOLANGSGROUP);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   526
					$this->xili_settings['lang_features'][$slug] = array('charset'=>"",'hidden'=>"");
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   527
		 		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   528
				update_option('xili_language_settings', $this->xili_settings); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   529
				$listlanguages = get_terms(TAXONAME, array('hide_empty' => false, 'get' => 'all'));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   530
			}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   531
			foreach( $listlanguages as $language ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   532
				wp_set_object_terms( $language->term_id, 'the-langs-group', TAXOLANGSGROUP );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   533
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   534
			$thegroup = get_terms( TAXOLANGSGROUP, array('hide_empty' => false,'slug' => 'the-langs-group', 'get' => 'all') );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   535
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   536
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   537
		if (function_exists('is_child_theme') && is_child_theme() ) { // 1.8.1 - 1.8.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   538
			if ( $this->xili_settings['langs_in_root_theme'] == 'root' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   539
				$this->get_template_directory = get_template_directory();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   540
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   541
				$this->get_template_directory = get_stylesheet_directory();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   542
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   543
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   544
			$this->get_template_directory = get_template_directory();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   545
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   546
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   547
		$this->langs_group_id = $thegroup[0]->term_id;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   548
		$this->langs_group_tt_id = $thegroup[0]->term_taxonomy_id;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   549
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   550
		$this->get_lang_slug_ids(); // default array of languages slug=>id and slug=>name // 2.4.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   551
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   552
		if ( $this->show_page_on_front ) $this->get_show_page_on_front_array();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   553
		/* here because taxonomy is registered : since 1.5.3 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   554
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   555
		$this->default_slug = $this->get_default_slug(); /*no constant for wpmu */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   556
		if (!is_multisite() && !defined('DEFAULTSLUG')) define('DEFAULTSLUG',$this->default_slug); /* for backward compatibility */ 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   557
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   558
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   559
		if ( $dir = get_bloginfo('text_direction') ) /* if present in blog options @since 0.9.9 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   560
			$this->default_dir = $dir;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   561
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   562
			// 1.8.4
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   563
		if ( isset($this->xili_settings['available_langs'])  && array() != $this->xili_settings['available_langs'] ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   564
			$this->available_langs = $this->xili_settings['available_langs']; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   565
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   566
			$this->available_langs = $this->get_lang_ids() ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   567
			$this->xili_settings['available_langs'] = $this->available_langs;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   568
			update_option('xili_language_settings', $this->xili_settings); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   569
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   570
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   571
		// 2.2.0 - add_roles -
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   572
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   573
		if ( is_admin() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   574
			global $wp_roles;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   575
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   576
			if ( current_user_can ('activate_plugins') ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   577
				$wp_roles->add_cap ('administrator', 'xili_language_set');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   578
				$wp_roles->add_cap ('administrator', 'xili_language_menu');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   579
				$wp_roles->add_cap ('administrator', 'xili_language_clone_tax');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   580
			} elseif ( current_user_can ('editor') ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   581
				$wp_roles->add_cap ('editor', 'xili_language_menu');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   582
				$wp_roles->add_cap ('editor', 'xili_language_clone_tax'); // able to clone taxonomy ('categeory') during propagate or create post
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   583
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   584
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   585
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   586
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   587
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   588
	 * Safe language term creation 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   589
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   590
	 * @since 2.4.1 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   591
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   592
	 function safe_lang_term_creation ( $term, $args ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   593
	 	global $wpdb ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   594
		// test if exists with other slug or name 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   595
		if ( $term_id = term_exists( $term ) ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   596
			$existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name, slug FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   597
			if ( $existing_term['slug'] != $args['slug'] ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   598
				$res = wp_insert_term( $term.'xl', TAXONAME, $args); // temp insert with temp other name
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   599
				$args['name'] = $term ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   600
				$res = wp_update_term( $res['term_id'], TAXONAME, $args);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   601
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   602
				return new WP_Error('term_exists', __('A term with the name provided already exists.'), $term_id );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   603
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   604
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   605
			$res = wp_insert_term( $term, TAXONAME, $args);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   606
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   607
		if (is_wp_error($res)) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   608
			return $res ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   609
		} else { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   610
			$theids = $res;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   611
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   612
		return $theids ;		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   613
	 }
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   614
	 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   615
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   616
	 * Get list language Objects - designed and used to avoid query by using settings
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   617
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   618
	 * @since 1.6.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   619
	 * @param $force to avoid buffer
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   620
	 * @return array of objects
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   621
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   622
	function get_listlanguages( $force = false ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   623
		if ( $this->xili_settings['langs_list_status'] != "set" || $force === true ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   624
	 		$listlanguages = get_terms_of_groups_lite ( $this->langs_group_id, TAXOLANGSGROUP,TAXONAME, 'ASC' ); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   625
	 		if ( $listlanguages ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   626
	 			$this->xili_settings['languages_list'] = $listlanguages;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   627
	 			$this->xili_settings['langs_list_status'] = "set";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   628
	 			if ( ! $this->class_admin )  {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   629
	 				update_option('xili_language_settings', $this->xili_settings); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   630
	 			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   631
	 		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   632
	 		return $listlanguages;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   633
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   634
			return $this->xili_settings['languages_list'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   635
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   636
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   637
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   638
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   639
	 * Get list language IDs
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   640
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   641
	 * @since 1.8.4
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   642
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   643
	function get_lang_ids() {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   644
		 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   645
		$lang_ids = array() ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   646
		$listlanguages = get_terms_of_groups_lite ($this->langs_group_id,TAXOLANGSGROUP,TAXONAME,'ASC');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   647
		foreach ( $listlanguages as $lang) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   648
			$lang_ids[] = $lang->term_id;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   649
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   650
		return $lang_ids ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   651
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   652
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   653
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   654
	 * Get list languages slug_IDs
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   655
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   656
	 * @since 2.1.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   657
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   658
	function get_lang_slug_ids() {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   659
		 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   660
		$lang_slugs = array() ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   661
		$lang_names = array() ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   662
		$lang_full_names = array() ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   663
		$listlanguages = $this->get_listlanguages( true );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   664
		foreach ( $listlanguages as $lang) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   665
			$key = $lang->slug;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   666
			$lang_slugs[$key] = $lang->term_id;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   667
			$lang_names[$key] = $lang->name;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   668
			$lang_full_names[$key] = $lang->description;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   669
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   670
		$this->langs_ids_array = $lang_slugs;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   671
		$this->langs_slug_name_array = $lang_names;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   672
		$this->langs_slug_fullname_array = $lang_full_names;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   673
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   674
		$this->xili_settings['langs_ids_array'] = $lang_slugs;  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   675
		if ( is_admin () && !$this->class_admin ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   676
			update_option( 'xili_language_settings', $this->xili_settings );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   677
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   678
		}// if changing occurs...
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   679
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   680
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   681
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   682
	 * get show pages on front 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   683
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   684
	 * @since 2.1.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   685
	 * 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   686
	 *  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   687
	 * update $this->show_page_on_front_array array
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   688
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   689
	function get_show_page_on_front_array() {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   690
		$front_pages_array = array();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   691
		$languages = $this->get_listlanguages( true );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   692
		$front_page_id = $this->get_option_wo_xili ('page_on_front');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   693
		foreach ( $languages as $lang) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   694
			$key = $lang->slug;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   695
			$id = get_post_meta ( $front_page_id, QUETAG.'-'.$key, true );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   696
			$page_id = ( ''!= $id ) ? $id : $front_page_id ;  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   697
			$front_pages_array[$key] = $page_id; //
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   698
		} 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   699
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   700
		$this->show_page_on_front_array = $front_pages_array; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   701
		$this->xili_settings['show_page_on_front_array'] = $front_pages_array;  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   702
		if ( is_admin () ) update_option( 'xili_language_settings', $this->xili_settings ); // if changing occurs...
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   703
	}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   704
			
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   705
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   706
	 * More than one filter for the function. 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   707
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   708
	 * @since 0.9.7
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   709
	 * 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   710
	 * @param $the_function (string). 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   711
	 * @return true if more than one.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   712
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   713
	function this_has_filter( $the_function ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   714
		global $wp_filter;
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   715
		if ( !isset ( $wp_filter[$the_function]) ) return false; // avoid php warning 2.3.0
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   716
		$has = $wp_filter[$the_function];
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   717
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   718
		if ( ! is_array( $has ) ) return false; // avoid php warning 2.1.0
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   719
		$keys = array_keys($has);
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   720
		
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   721
		if (count($has[$keys[0]]) >= 2) { /*one from class others from functions.php or elsewhere*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   722
			return true;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   723
		} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   724
			return false;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   725
		} 	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   726
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   727
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   728
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   729
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   730
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   731
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   732
	function get_post_language ( $post_ID, $result = 'slug' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   733
		$ress = wp_get_object_terms($post_ID, TAXONAME);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   734
		if ( $ress ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   735
			$obj_term = $ress[0]; // today only one language per post
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   736
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   737
			switch ( $result ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   738
				case 'iso':
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   739
					$postlang = ('' != $obj_term->name) ? $obj_term->name : ""; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   740
					break;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   741
				case 'name':
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   742
					$postlang = ('' != $obj_term->description) ? $obj_term->description : ""; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   743
					break;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   744
				default: // slug 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   745
					$postlang = ('' != $obj_term->slug) ? $obj_term->slug : ""; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   746
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   747
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   748
			$postlang = "";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   749
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   750
		return $postlang;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   751
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   752
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   753
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   754
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   755
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   756
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   757
	 * Create a linked copy of current post in target language
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   758
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   759
	 * @since 2.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   760
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   761
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   762
	function create_initial_translation ( $target_lang, $from_post_title = "" , $frompostlang = "", $from_post_ID ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   763
		global $user_ID;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   764
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   765
		$post_title_prefix = sprintf ( __('Please translate in %s:', 'xili-language' ), $target_lang );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   766
		$target_post_title = ( $from_post_title == '' ) ? $post_title_prefix . ' ' . $from_post_ID : $post_title_prefix . ' ' . $from_post_title ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   767
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   768
		$post_type = get_post_type( $from_post_ID );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   769
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   770
		$params = array('post_status' => 'draft', 'post_type' => $post_type, 'post_author' => $user_ID,
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   771
			'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   772
			'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   773
			'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0,
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   774
			'post_content' => $target_post_title, 'post_title' => $target_post_title);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   775
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   776
		$post_ID = wp_insert_post( $params ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   777
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   778
		if ( $post_ID != 0 ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   779
			// taxonomy
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   780
			wp_set_object_terms( $post_ID, $target_lang, TAXONAME );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   781
			// metas
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   782
			// from
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   783
			update_post_meta( $from_post_ID, QUETAG.'-'.$target_lang, $post_ID );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   784
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   785
			// this with other target of from
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   786
			$listlanguages = $this->get_listlanguages () ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   787
			foreach ( $listlanguages as $language ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   788
				if ( $language->slug != $target_lang && $language->slug != $frompostlang ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   789
					$id = get_post_meta( $from_post_ID, QUETAG.'-'.$language->slug, true );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   790
					if ( $id != "" ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   791
						update_post_meta( $post_ID, QUETAG.'-'.$language->slug, $id );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   792
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   793
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   794
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   795
			// this
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   796
			update_post_meta( $post_ID, QUETAG.'-'.$frompostlang, $from_post_ID );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   797
			update_post_meta( $post_ID, $this->translation_state, "initial" ); // to update further slug - post_name
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   798
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   799
			// categories of from_post
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   800
			$this->propagate_categories ( $from_post_ID, $post_ID );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   801
			return $post_ID;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   802
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   803
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   804
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   805
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   806
	 * propagate categories from a reference post to another (loop is in class admin)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   807
	 * if cat is not in target, cat will be unassigned in target if mode is 'erase'
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   808
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   809
	 * @since 2.6 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   810
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   811
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   812
	function propagate_categories ( $from_post_ID, $post_ID, $mode = '' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   813
		// categories of from_post
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   814
		// get
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   815
		$categories = get_the_category( $from_post_ID );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   816
		if ( ! empty( $categories ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   817
			if ( is_object_in_taxonomy( get_post_type( $from_post_ID ), 'category' ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   818
				// set
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   819
				$the_cats = array();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   820
				foreach ( $categories as $category ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   821
					$the_cats[] = $category->slug; // wp_set_object_terms don't like loop
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   822
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   823
				// prepare target (erase all)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   824
				if ( $mode == 'erase' ) wp_delete_object_term_relationships ( $post_ID, 'category' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   825
				wp_set_object_terms( $post_ID, $the_cats, 'category' );	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   826
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   827
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   828
	} 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   829
	 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   830
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   831
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   832
	 * return post object
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   833
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   834
	 * @since 2.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   835
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   836
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   837
	function temp_get_post ( $post_id ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   838
		global $wpdb ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   839
		$res = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id)); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   840
		if ( $res && !is_wp_error($res) ) 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   841
			return $res;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   842
		else
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   843
			return false;		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   844
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   845
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   846
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   847
	 * return saved list of post_type and custom_post_type
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   848
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   849
	 * @since 2.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   850
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   851
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   852
	function authorized_custom_post_type () {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   853
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   854
		$custompoststype = $this->xili_settings['multilingual_custom_post'] ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   855
		$custom = get_post_type_object ('post');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   856
		$clabels = $custom->labels;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   857
		$custompoststype['post'] = array( 'name' => $custom->label , 'singular_name' => $clabels->singular_name , 'multilingual' => 'enable');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   858
		$custom = get_post_type_object ('page');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   859
		$clabels = $custom->labels;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   860
		$custompoststype['page'] = array( 'name' => $custom->label, 'singular_name' => $clabels->singular_name , 'multilingual' => 'enable');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   861
		return $custompoststype;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   862
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   863
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   864
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   865
	 * Will update term count based on posts AND pages.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   866
	 *  
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   867
	 * @access private from register taxonomy etc...
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   868
	 * @since 0.9.8.1
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   869
	 * @uses $wpdb
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   870
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   871
	 * @param array $terms List of Term taxonomy IDs
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   872
	 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   873
	function _update_post_lang_count( $terms ) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   874
		global $wpdb;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   875
		foreach ( (array) $terms as $term ) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   876
			$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND term_taxonomy_id = %d", $term ) );
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   877
			$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   878
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   879
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   880
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   881
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   882
	 * Return language dir
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   883
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   884
	 * @since 0.9.9
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   885
	 * @param slug of lang
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   886
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   887
	function get_dir_of_cur_language( $lang_slug ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   888
		$rtlarray = explode ('-',$this->rtllanglist);			
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   889
		$dir = ( in_array(substr(strtolower($lang_slug), 0, 2 ),$rtlarray) ) ? 'rtl' : 'ltr';
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   890
		return $dir;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   891
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   892
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   893
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   894
	 * Insert rtl.css if exists (default filter of wp_head) - see theme.php (Thanks Sam R.) 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   895
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   896
	 * @since 2.4.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   897
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   898
	function change_locale_stylesheet_uri ( $stylesheet_uri,  $stylesheet_dir_uri ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   899
		$rtlarray = explode ('-', $this->rtllanglist);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   900
		$dir = ( in_array( substr( strtolower( $this->curlang ), 0, 2 ), $rtlarray ) ) ? 'rtl' : 'ltr';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   901
		$dircss = get_stylesheet_directory();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   902
		// avoid with locale.css
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   903
		if ( $stylesheet_uri == '' || false !== strpos($stylesheet_uri, 'rtl.css'  ) || false !== strpos($stylesheet_uri, 'ltr.css'  ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   904
			if ( in_array ( substr( $this->curlang, 0, 2 ) , $rtlarray ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   905
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   906
				if ( file_exists("$dircss/{$dir}.css") ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   907
					return $stylesheet_dir_uri."/{$dir}.css";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   908
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   909
					return '';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   910
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   911
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   912
			}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   913
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   914
		return $stylesheet_uri ; // non filtered value
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   915
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   916
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   917
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   918
	/**
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   919
	 * Return language of post.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   920
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   921
	 * @since 0.9.0
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   922
	 * @updated 0.9.7.6, 0.9.9
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   923
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   924
	 * @param $post_ID.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   925
	 * @return slug of language of post or false if var langstate is false.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   926
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   927
	function get_cur_language( $post_ID ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   928
		$ress = wp_get_object_terms($post_ID, TAXONAME);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   929
		if ($ress) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   930
			if (is_a($ress, 'WP_Error')){
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   931
				echo "Language table not created ! see plug-in admin";
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   932
				$this->langstate = false;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   933
			} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   934
				$obj_term = $ress[0];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   935
				$this->langstate = true;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   936
				$postlang = $obj_term->slug;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   937
				$postlangdir = $this->get_dir_of_cur_language($postlang);
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   938
				return array( QUETAG => $postlang, 'direction' => $postlangdir);
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   939
			}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   940
	 	} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   941
	 		$this->langstate = false; /* can be used in language attributes for header */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   942
	  		return false;	/* undefined state */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   943
	 	}		
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   944
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   945
		
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   946
	/** enable the new query tag associated with new taxonomy */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   947
	function keywords_addQueryVar( $vars ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   948
		$vars[] = QUETAG;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   949
	return $vars ;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   950
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   951
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   952
	function get_default_slug() {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   953
		$listlanguages = get_terms(TAXONAME, array('hide_empty' => false)); 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   954
		$default_slug = 'en_us';
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   955
		foreach ($listlanguages as $language) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   956
			if ($language->name == $this->default_lang ) return $language->slug;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   957
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   958
		return $default_slug ;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   959
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   960
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   961
	/** 
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   962
	 * Query join filter used when querytag is used or home 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   963
	 *  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   964
	 * @updated 1.7.0 modify page on front and home query
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   965
	 * @updated 1.8.4 * to select posts with undefined lang
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   966
	 * @updated 2.2.3 LANG_UNDEF = . and no * 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   967
	 *
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   968
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   969
	function posts_join_with_lang( $join, $query_object = null ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   970
		global $wpdb, $wp_query;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   971
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   972
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   973
		$insert_join = false ;	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   974
		if ( isset ( $query_object->query_vars[QUETAG] ) && '' != $query_object->query_vars[QUETAG] ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   975
			if ( ( isset ( $query_object->query_vars['caller_get_posts'] ) && $query_object->query_vars['caller_get_posts']) || ( isset ( $query_object->query_vars['ignore_sticky_posts'] ) && $query_object->query_vars['ignore_sticky_posts']) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   976
				if ( isset ( $query_object->query_vars['xlrp'] ) && $query_object->query_vars['xlrp'] == 1 ) $insert_join = true ; // called by xili recent posts
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   977
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   978
				$a = $query_object->query_vars['page_id']; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   979
				$b = get_option('page_on_front'); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   980
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   981
				if ( !($query_object->is_home && $this->show_page_on_front ) ) { // join if no front-page and other page
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   982
					if ( $a == $b && $a !='' ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   983
						// 1.8.1 - two pages in results when language is selected at front !!
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   984
						// 1.8.4 - home as home + lang
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   985
						$insert_join = false ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   986
					} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   987
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   988
						$insert_join = true ; // as in cat or home+lang
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   989
					}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   990
				} elseif ( $query_object->is_home && !$this->show_page_on_front ) { // home and lang 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   991
					$insert_join = true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   992
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   993
					$insert_join = true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   994
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   995
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   996
				if ( $this->lang_perma ) {  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   997
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   998
					if ( $query_object->query_vars['category_name'] == ""  && isset( $query_object->query_vars[QUETAG])  && $this->show_page_on_front && !is_admin()) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
   999
						$join = '';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1000
						$insert_join = false ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1001
						unset($wp_query->queried_object); // to avoid notice in get_page_template and force get_queried_object -2.3.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1002
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1003
					if ( $query_object->is_tax &&  $query_object->query_vars['category_name'] != '' ) $insert_join = true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1004
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1005
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1006
			 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1007
		} else { // join if home and modify home according rule ignore_sticky_posts
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1008
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1009
			if ( ''== $this->sublang ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1010
				if ( ( isset ( $query_object->query_vars['caller_get_posts'] ) && $query_object->query_vars['caller_get_posts']) || ( isset ( $query_object->query_vars['ignore_sticky_posts'] ) && $query_object->query_vars['ignore_sticky_posts']) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1011
					if ( isset( $query_object->query_vars['xlrp'] ) && $query_object->query_vars['xlrp'] == 1 ) $insert_join = true ; // called by xili recent posts
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1012
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1013
				} else { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1014
					if ( ( $query_object->is_home && $this->xili_settings['homelang'] == 'modify') || $query_object->query_vars['ignore_sticky_posts']) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1015
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1016
							$insert_join = true ; //error_log ('************ join ************' . serialize ( $query_object->query_vars['post_type']));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1017
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1018
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1019
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1020
			}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1021
		}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1022
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1023
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1024
		if ( $insert_join ) {  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1025
			$join .= " LEFT JOIN $wpdb->term_relationships as xtr ON ($wpdb->posts.ID = xtr.object_id) LEFT JOIN $wpdb->term_taxonomy as xtt ON (xtr.term_taxonomy_id = xtt.term_taxonomy_id) ";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1026
		}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1027
		return $join;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1028
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1029
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1030
	 * to detect undefined query and unset language tax query
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1031
	 * @since 2.2.3 - LANG_UNDEF
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1032
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1033
	 */
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1034
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1035
	function posts_search_filter ( $search, $the_query) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1036
		$this->sublang = "";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1037
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1038
		if ( isset( $the_query->query_vars[QUETAG] ) && false !== strpos( $the_query->query_vars[QUETAG] , LANG_UNDEF ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1039
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1040
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1041
			if ( array() != $the_query->tax_query->queries ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1042
				$new_queries = array();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1043
				foreach ( $the_query->tax_query->queries as $query ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1044
					if ( $query['taxonomy'] != TAXONAME ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1045
						$new_queries[] = $query ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1046
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1047
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1048
				$the_query->tax_query->queries = $new_queries; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1049
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1050
			$this->sublang = $the_query->query_vars[QUETAG]; // to adapt in where filter below
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1051
			unset ( $the_query->query_vars[QUETAG] );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1052
			unset ( $the_query->tax_query->relation );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1053
			if ( array() == $the_query->tax_query->queries ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1054
				$the_query->is_tax = false ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1055
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1056
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1057
		return $search;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1058
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1059
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1060
	
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1061
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1062
	 * Modify the query including lang or home
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1063
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1064
	 * @since 0.9.0
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1065
	 * @updated 0.9.4 (OR added) lang=xx_xx,yy_yy,..
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1066
	 * @updated 1.7.0 modify page on front and home query 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1067
	 * @updated 2.2.3 LANG_UNDEF
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1068
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1069
	 * @param object $where.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1070
	 * @return $where.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1071
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1072
	function posts_where_lang( $where, $query_object = null ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1073
		global $wpdb, $wp_query;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1074
		$reqtags = array();
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1075
		$thereqtags = array();
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1076
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1077
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1078
		if ( "" != $this->sublang )  { // see above
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1079
		    
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1080
		    $lang =  str_replace ( LANG_UNDEF, '' , $this->sublang ); //$query_object->query_vars[QUETAG] ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1081
		    if ( "" == $lang ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1082
				$lang_string = implode( ", ", $this->available_langs );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1083
		    } else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1084
		    	$id = $this->langs_ids_array[ $lang ];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1085
		    	$remain = array_diff( $this->available_langs, array($id)); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1086
		    	$lang_string = implode( ", ", $remain  );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1087
		    }	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1088
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1089
			$where .= " AND $wpdb->posts.ID NOT IN ( SELECT xtr.object_id FROM $wpdb->term_relationships AS xtr INNER JOIN $wpdb->term_taxonomy AS xtt ON xtr.term_taxonomy_id = xtt.term_taxonomy_id WHERE xtt.taxonomy = '".TAXONAME."' AND xtt.term_id IN ($lang_string) )";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1090
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1091
		} elseif ( isset ($query_object->query_vars[QUETAG]) && '' != $query_object->query_vars[QUETAG] ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1092
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1093
			$do_it = false;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1094
			if ( (isset ( $query_object->query_vars['caller_get_posts'] ) && $query_object->query_vars['caller_get_posts']) || ( isset ( $query_object->query_vars['ignore_sticky_posts'] ) && $query_object->query_vars['ignore_sticky_posts']) ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1095
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1096
				if ( isset ( $query_object->query_vars['xlrp'] ) && $query_object->query_vars['xlrp'] == 1) $do_it = true;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1097
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1098
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1099
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1100
				if ( $this->lang_perma && !is_admin ()) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1101
					if ( $query_object->is_page && isset( $query_object->query_vars[QUETAG]) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1102
						$do_it == false;  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1103
					} elseif (!($query_object->is_home && $this->show_page_on_front )) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1104
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1105
						$do_it = true; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1106
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1107
					if ( $query_object->is_tax &&  $query_object->query_vars['taxonomy'] == 'category' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1108
						$do_it = true;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1109
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1110
					if ( $query_object->is_tax &&  $query_object->query_vars['taxonomy'] == TAXONAME && "" == $query_object->query_vars['category_name'] ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1111
						$do_it = false;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1112
						if ( !$query_object->is_page ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1113
							$where .= " AND $wpdb->posts.post_type = 'post'";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1114
						}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1115
					} 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1116
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1117
				    if ( !( $query_object->is_home && $this->show_page_on_front ) ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1118
						$do_it = true; // all but not home	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1119
					}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1120
				}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1121
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1122
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1123
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1124
			if ($do_it) { // insertion of selection
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1125
				
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1126
				if ( strpos($query_object->query_vars[QUETAG], ',') !== false ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1127
					$langs = preg_split('/[,\s]+/', $query_object->query_vars[QUETAG]);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1128
					foreach ( (array) $langs as $lang ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1129
						$lang = sanitize_term_field('slug', $lang, 0, 'post_tag', 'db');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1130
						$reqtags[]= $lang;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1131
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1132
					foreach ($reqtags as $reqtag){
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1133
						$thereqtagids[] = $this->langs_ids_array[$reqtag];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1134
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1135
					$wherereqtag = implode(", ", $thereqtagids); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1136
					$where .= " AND xtt.taxonomy = '".TAXONAME."' ";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1137
					$where .= " AND xtt.term_id IN ( $wherereqtag )";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1138
				 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1139
				} else {  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1140
				/* only one lang */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1141
					$query_object->query_vars[QUETAG] = sanitize_term_field('slug', $query_object->query_vars[QUETAG], 0, 'post_tag', 'db');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1142
					$reqtag = $query_object->query_vars[QUETAG];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1143
										
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1144
					$wherereqtag = $this->langs_ids_array[$reqtag];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1145
					$where .= " AND xtt.taxonomy = '".TAXONAME."' ";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1146
					$where .= " AND xtt.term_id = $wherereqtag ";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1147
				 }
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1148
				 	 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1149
			} else { // is_home and page
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1150
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1151
				if ( $query_object->is_home && $this->show_page_on_front ) {  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1152
					$query_object->is_home = false ; // renew the values because the query contains lang=
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1153
					$query_object->is_page = true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1154
					$query_object->is_singular = true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1155
					$query_object->query = array();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1156
					$query_object->query_vars['page_id'] = get_option('page_on_front'); // new filtered value 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1157
					//$query_object->query_vars['p'] = $query_object->query_vars['page_id'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1158
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1159
					$where = str_replace ("'post'","'page'",$where); // post_type = 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1160
					$where .= " AND 3=3 AND {$wpdb->posts}.ID = " . $query_object->query_vars['page_id'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1161
					
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1162
				}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1163
				
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1164
				if ( $this->lang_perma && $this->show_page_on_front) { // 2.1.1 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1165
					if ( $query_object->query_vars[QUETAG] != "" && $query_object->query_vars['taxonomy'] == TAXONAME  ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1166
						$query_object->is_page = true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1167
						$query_object->is_tax = false ; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1168
						$query_object->is_archive = false ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1169
						$query_object->is_singular = true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1170
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1171
						$query_object->query = array();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1172
						$pid = $this->get_option_wo_xili ('page_on_front') ; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1173
						$lang = ( isset ( $query_object->query_vars[QUETAG] ) ? $query_object->query_vars[QUETAG] : 'en_us' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1174
						$id = get_post_meta ( $pid, QUETAG.'-'.$lang, true );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1175
						$pagid = ( ''!= $id ) ? $id : $pid ; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1176
						$query_object->query_vars['page_id'] = $pagid ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1177
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1178
						unset ( $query_object->query_vars['taxonomy'] );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1179
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1180
						$where = str_replace ("'post'","'page'",$where); // post_type = 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1181
						$where = "AND {$pagid} = {$pagid} "." AND {$wpdb->posts}.ID = " . $query_object->query_vars['page_id'] . " AND {$wpdb->posts}.post_type = 'page'";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1182
						 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1183
						$query_object->query_vars['page_id'] = get_option ('page_on_front') ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1184
						//$query_object->query_vars['p'] = $query_object->query_vars['page_id'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1185
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1186
						unset($wp_query->queried_object);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1187
						$wp_query->queried_object_id = $query_object->query_vars['page_id'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1188
						$wp_query->queried_object->ID = $query_object->query_vars['page_id']; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1189
						//$this->first_change = $lang ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1190
						//update_option('xili_language_settings_test', $this->first_change);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1191
					}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1192
				}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1193
			}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1194
		
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1195
					
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1196
		} else { // no query tag 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1197
			//error_log ( "****** join ******" );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1198
			if ( ( isset ( $query_object->query_vars['caller_get_posts'] ) && $query_object->query_vars['caller_get_posts']) || ( isset ( $query_object->query_vars['ignore_sticky_posts'] ) && $query_object->query_vars['ignore_sticky_posts']) ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1199
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1200
				if ( isset($query_object->query_vars['xlrp']) && $query_object->query_vars['xlrp'] == 1) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1201
					$reqtag = $query_object->query_vars[QUETAG];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1202
										
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1203
					$wherereqtag = $this->langs_ids_array[$reqtag];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1204
					$where .= " AND xtt.taxonomy = '".TAXONAME."' ";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1205
					$where .= " AND xtt.term_id = $wherereqtag ";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1206
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1207
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1208
			} else {	 //error_log ( "****** ici ******" . serialize ( $query_object->query_vars['post_type']) );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1209
				if (  $query_object->is_home && !$this->show_page_on_front && $this->xili_settings['homelang'] == 'modify' )  {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1210
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1211
						// force change if loop
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1212
						$curlang = $this->choice_of_browsing_language();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1213
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1214
						$wherereqtag = $this->langs_ids_array[$curlang];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1215
						$where .= " AND xtt.taxonomy = '".TAXONAME."' ";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1216
						$where .= " AND xtt.term_id = $wherereqtag ";	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1217
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1218
				} 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1219
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1220
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1221
		//error_log ( "****** join ******".$where );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1222
		return $where; 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1223
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1224
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1225
	/******** template theme live modifications ********/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1226
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1227
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1228
	 * wp action for theme at end of query  
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1229
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1230
	 * @since 0.9.0
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1231
	 * @updated 1.1.9, 1.4.2a
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1232
	 * call by wp hook	   
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1233
	 *   
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1234
	 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1235
	function xiliml_language_wp() {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1236
		if ( !is_admin() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1237
			$this->curlang = $this->get_curlang_action_wp(); // see hooks in that function 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1238
			//$this->curlang = 'en_us';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1239
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1240
			$this->curlang_dir = $this->get_dir_of_cur_language( $this->curlang ); /* general dir of the theme */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1241
			if ( $this->locale_method ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1242
				$this->xiliml_load_theme_textdomain ( $this->thetextdomain ); /* new method for cache compatibility - tests */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1243
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1244
				$this->set_mofile( $this->curlang );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1245
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1246
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1247
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1248
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1249
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1250
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1251
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1252
	 * wp action to switch wp_locale only on front-end
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1253
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1254
	 * @since 2.4.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1255
	 * 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1256
	 * call by wp hook after theme cur_lang set	   
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1257
	 *   
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1258
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1259
	function xili_locale_setup ( ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1260
		if ( !is_admin() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1261
			unset($GLOBALS['wp_locale']);  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1262
			global $wp_locale;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1263
			$wp_locale = new xl_WP_Locale(); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1264
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1265
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1266
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1267
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1268
	 * only called in front-end
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1269
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1270
	 * @since 2.4.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1271
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1272
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1273
	function translate_date_format ( $format ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1274
		if ( $this->xili_settings['wp_locale'] == 'wp_locale' )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1275
	 	 	return __( $format , $this->thetextdomain );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1276
	 	else
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1277
	 		return $format;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1278
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1279
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1280
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1281
	 * fixes feed link if not permalinks because called after category filter
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1282
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1283
	 * @since 2.8.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1284
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1285
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1286
	function category_feed_link ( $link, $feed = '' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1287
		$permalink_structure = get_option( 'permalink_structure' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1288
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1289
		if ( '' != $permalink_structure ) {	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1290
			if ( $feed == get_default_feed() )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1291
				$feed_link = 'feed';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1292
			else
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1293
				$feed_link = "feed/$feed";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1294
		// clean current link
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1295
			$root_link = str_replace ( user_trailingslashit( $feed_link, 'feed' ), '', $link );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1296
		// get part after ?lang=
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1297
			$parts = explode ( '?'.QUETAG.'=', $root_link );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1298
			if ( isset( $parts[1] ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1299
				// recreate current link
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1300
				$link = trailingslashit( $parts[0] ) . user_trailingslashit( $feed_link, 'feed' ) . '?'.QUETAG.'='. str_replace ( '/','',$parts[1] );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1301
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1302
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1303
		return $link;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1304
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1305
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1306
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1307
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1308
	 * 'theme_locale' filter to detect theme and don't load theme_domain in functions.php
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1309
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1310
	 * @since 1.5.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1311
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1312
	 * call by 'theme_locale' filter
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1313
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1314
	function xiliml_theme_locale ( $locale, $domain ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1315
		$this->xili_settings['theme_domain'] = $domain; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1316
		$this->thetextdomain = $domain;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1317
		
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1318
		//if ( defined ( "WP_DEBUG" ) && WP_DEBUG == true ) error_log ( $this->class_admin . ' < domain = ' . $domain ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1319
		 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1320
		return 'wx_YZ'; // dummy local
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1321
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1322
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1323
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1324
	 * 'override_load_textdomain' filter to avoid dummy load
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1325
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1326
	 * @since 1.5.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1327
	 * @updated 1.8.1 - 1.8.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1328
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1329
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1330
	function xiliml_override_load ( $falseval, $domain, $mofile ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1331
		if ( $this->show ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1332
			if ( !in_array( $domain , $this->arraydomains ) )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1333
				$this->arraydomains[] = $domain;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1334
		}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1335
	   	if (false === strpos ($mofile ,'wx_YZ.mo')) {//
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1336
	   		return false;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1337
	   	} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1338
	   		if ( str_replace( get_stylesheet_directory(), '', $mofile ) == $mofile ) { // no effect
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1339
	   			$this->get_template_directory = get_template_directory();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1340
	   			$this->xili_settings['langs_in_root_theme'] = 'root';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1341
	   		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1342
	   			$this->get_template_directory = get_stylesheet_directory(); // a load is in child
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1343
	   			$this->xili_settings['langs_in_root_theme'] = '';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1344
	   			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1345
	   		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1346
	   		$this->ltd = true ; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1347
	   		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1348
	   		$langs_folder = str_replace('/wx_YZ.mo','',str_replace( $this->get_template_directory, '', $mofile ));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1349
	   		// in wp3 the detection is only done here (end user side by theme domain) so updated is mandatory for xili-dico
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1350
	   		if ( $this->xili_settings['langs_folder'] != $langs_folder ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1351
		 		$this->xili_settings['langs_folder'] = $langs_folder ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1352
		 		update_option( 'xili_language_settings', $this->xili_settings ); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1353
		 	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1354
		 	// to restore theme mo if theme datas and terms in admin ui….
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1355
		 	if ( is_admin() ) load_textdomain( $domain, str_replace('wx_YZ', get_locale(), $mofile )); // 2.3.1 - 18h18
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1356
	   		return true;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1357
	   		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1358
	   	}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1359
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1360
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1361
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1362
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1363
	 * Introduced only in visitors side (not in admin) to change domain of plugin or other
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1364
	 * gettext filter from function translate() in wp-includes/I10n.php
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1365
	 * 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1366
	 * @since 1.8.7 - 1.8.8
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1367
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1368
	function change_plugin_domain ($translation, $text, $domain ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1369
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1370
		$domain = $this->switching_domain ( $domain );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1371
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1372
		$translations = &get_translations_for_domain( $domain );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1373
		return $translations->translate( $text );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1374
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1375
	function change_plugin_domain_with_context ($translation, $text, $context, $domain ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1376
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1377
		$domain = $this->switching_domain ( $domain );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1378
		 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1379
		$translations = &get_translations_for_domain( $domain );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1380
		return $translations->translate( $text, $context );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1381
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1382
	function change_plugin_domain_plural ($translation, $single, $plural, $number, $domain ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1383
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1384
		$domain = $this->switching_domain ( $domain );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1385
		 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1386
		$translations = &get_translations_for_domain( $domain );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1387
		$translation = $translations->translate_plural( $single, $plural, $number );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1388
		return $translation ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1389
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1390
	function change_plugin_domain_plural_with_context ($translation, $single, $plural, $number, $context, $domain ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1391
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1392
		$domain = $this->switching_domain ( $domain );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1393
		 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1394
		$translations = &get_translations_for_domain( $domain );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1395
		$translation = $translations->translate_plural( $single, $plural, $number, $context );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1396
		return $translation ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1397
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1398
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1399
	/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1400
	 * domain switching 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1401
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1402
	function switching_domain ( $domain ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1403
		$ok = false ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1404
		if ( $domain != $this->thetextdomain ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1405
			if ( in_array ( $domain, array_keys( $this->xili_settings['domains'] ) ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1406
				if ( $this->xili_settings['domains'][$domain] == 'enable' ) $ok = true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1407
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1408
				if ( $this->xili_settings['domains']['all'] == 'enable' ) $ok = true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1409
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1410
			if ( $ok ) 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1411
				$domain = $this->thetextdomain ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1412
		} 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1413
		return $domain;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1414
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1415
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1416
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1417
	 * locale hook when load_theme_textdomain is present in functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1418
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1419
	 * @since 1.1.9
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1420
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1421
	 * call by locale hook
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1422
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1423
	function xiliml_setlocale ( $locale ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1424
		if ($this->theme_locale === true) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1425
			$listlanguages = get_terms(TAXONAME, array('hide_empty' => false,'slug' => $this->curlang));
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1426
			return $listlanguages[0]->name;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1427
		} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1428
			return $locale; 	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1429
		}		
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1430
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1431
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1432
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1433
	 * locale hook when load_theme_textdomain is present in functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1434
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1435
	 * @since 1.1.9
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1436
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1437
	 * call by locale hook
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1438
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1439
	function xiliml_load_theme_textdomain ( $domain ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1440
		$this->theme_locale = true;
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1441
		$langfolder = $this->xili_settings['langs_folder'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1442
		//$langfolder = '/'.str_replace("/","",$langfolder); /* please no lang folder in sub-subfolder */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1443
		$langfolder = ($langfolder == "/") ? "" : $langfolder; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1444
		load_theme_textdomain($domain, $this->get_template_directory . $langfolder);
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1445
		$this->theme_locale = false;		
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1446
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1447
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1448
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1449
	 * select .mo file 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1450
	 * @since 0.9.0
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1451
	 * @updated 0.9.7.1 - 1.1.9 - 1.5.2 wpmu - 1.8.9.1 (domain select)
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1452
	 * call by function xiliml_language_wp()
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1453
	 * @param $curlang .
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1454
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1455
	function set_mofile( $curlang ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1456
		// load_theme_textdomain(THEME_TEXTDOMAIN); - replaced to be flexible -
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1457
		if ( ""!=$this->thetextdomain ) { $themetextdomain = $this->thetextdomain; } else { $themetextdomain = 'ttd-not-defined'; }
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1458
		$langfolder = $this->xili_settings['langs_folder']; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1459
		
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1460
		$langfolder = ($langfolder == "/") ? "" : $langfolder;
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1461
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1462
		$filename = '';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1463
		if ( '' != $curlang ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1464
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1465
			$filename = $this->langs_slug_name_array[$curlang]; // 2.4.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1466
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1467
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1468
		if ( '' != $filename ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1469
			$filename .= '.mo'; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1470
			$mofile = $this->get_template_directory .$langfolder."/$filename";	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1471
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1472
			if ( is_multisite() ) { /* completes theme's language with db structure languages (cats, desc,…) */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1473
				if ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1474
					$wpmu_curdir = $uploads['basedir']."/languages";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1475
					load_textdomain( $themetextdomain, $wpmu_curdir."/local-" . $this->langs_slug_name_array[$curlang] . ".mo" ); // here to be the last value
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1476
					load_textdomain( $themetextdomain, $wpmu_curdir."/$filename" );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1477
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1478
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1479
			load_textdomain( $themetextdomain, $this->get_template_directory .$langfolder."/local-" . $this->langs_slug_name_array[$curlang] . ".mo" ); // here to be the last value
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1480
			load_textdomain( $themetextdomain, $mofile ); // moved here for merge (prior for site and not theme)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1481
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1482
			// 2.8.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1483
			do_action ( 'xiliml_add_frontend_mofiles' , $themetextdomain, $this->langs_slug_name_array[$curlang] ); // to add bbpress good mo
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1484
				
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1485
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1486
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1487
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1488
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1489
	 * default rules - set curlang for wp action 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1490
	 *
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1491
	 * @since 1.7.0 - new mechanism for front-page
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1492
	 * @updated 1.8.9.1 - better category case
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1493
	 * @updated 2.2.3 - fixes rare frontpage infinite loop
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1494
	 * replace xiliml_cur_lang_head (0.9.7 -> 1.6.1)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1495
	 * @return $curlang
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1496
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1497
	function get_curlang_action_wp () {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1498
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1499
		if ( has_filter( 'xiliml_curlang_action_wp' ) ) return apply_filters( 'xiliml_curlang_action_wp', '' ); /* '' warning on some server need one arg by default*/
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1500
		/* default */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1501
		global $post, $wp_query ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1502
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1503
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1504
		if ( have_posts() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1505
			$showpage = get_option('show_on_front');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1506
			$condition = false;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1507
			if ( 'page' == $showpage ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1508
				if (!in_array ( $wp_query->query_vars['page_id'], $this->xili_settings['show_page_on_front_array'] ) ) $condition = true;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1509
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1510
				if ( !is_home() ) 	$condition = true;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1511
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1512
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1513
			if ( $condition ) { /* every pages !is_front_page() */ 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1514
				$curlangdir = $this->get_cur_language($post->ID); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1515
				$curlang = $curlangdir[QUETAG]; /* the first post give the current lang*/ 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1516
				if ( $curlangdir == false ) $curlang = $this->choice_of_browsing_language(); //$this->default_slug; /* no more constant - wpmu - can be changed if use hook */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1517
				if ( is_page() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1518
					if ( isset( $_GET["loclang"] ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1519
		    			$curlang = $_GET["loclang"]; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1520
		    		/* get var to override the selected lang - ex. in bi-lingual contact*/ 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1521
					}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1522
					//
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1523
					if ( isset($wp_query->query_vars[QUETAG]) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1524
						$curlang = $wp_query->query_vars[QUETAG] ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1525
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1526
				} elseif ( is_search() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1527
					if ( isset( $wp_query->query_vars[QUETAG] ) ) $curlang = $wp_query->query_vars[QUETAG] ; //
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1528
				} elseif ( is_category() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1529
					if ( $this->lang_perma ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1530
						if ( isset( $wp_query->query_vars[QUETAG] ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1531
							$curlang = str_replace ( LANG_UNDEF, "", $wp_query->query_vars[QUETAG]) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1532
						} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1533
							$curlang = $this->choice_of_categories_all_languages( $curlang ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1534
						}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1535
					} else {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1536
						if ( isset( $_GET[QUETAG] ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1537
							$curlang = $_GET[QUETAG] ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1538
						} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1539
							$curlang = $this->choice_of_categories_all_languages( $curlang ) ;  //$this->choice_of_browsing_language(); // again as defined 1.8.9.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1540
						}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1541
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1542
				} 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1543
			} else { /* front page - switch between lang (and post/page) is done in query posts_where_lang filter see above */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1544
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1545
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1546
				if ( isset ( $wp_query->query_vars[QUETAG] ) && '' != $wp_query->query_vars[QUETAG] ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1547
					$this->langstate = true; // 2.8.0 b
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1548
					$curlang = $wp_query->query_vars[QUETAG];	// home series type 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1549
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1550
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1551
					if ( 'page' == $showpage ) { //$this->show_page_on_front ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1552
						$page_front = get_option('page_on_front');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1553
						$curlang = get_cur_language($page_front); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1554
					} else { // home.php - 1.3.2 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1555
						$curlang = $this->choice_of_browsing_language();
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1556
					}	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1557
				}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1558
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1559
		} else { /*no posts for instance in category + lang */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1560
		 	if ( $this->lang_perma ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1561
				if ( isset( $wp_query->query_vars[QUETAG] ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1562
					$curlang = $wp_query->query_vars[QUETAG] ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1563
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1564
					$curlang = $this->choice_of_browsing_language();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1565
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1566
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1567
				if ( isset( $_GET[QUETAG] ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1568
					$curlang = $_GET[QUETAG];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1569
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1570
					$curlang = $this->choice_of_browsing_language() ;  //$this->choice_of_browsing_language(); // again as defined 1.8.9.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1571
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1572
			} 	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1573
		} 	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1574
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1575
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1576
		return str_replace ( LANG_UNDEF  , '' , $curlang ) ; // 2.3 to return main part
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1577
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1578
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1579
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1580
	 * modify  language_attributes() output
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1581
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1582
	 * @since 0.9.7.6
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1583
	 *  
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1584
	 * The - language_attributes() -  template tag is use in header of theme file in html tag 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1585
	 *   
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1586
	 * @param $output
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1587
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1588
	function head_language_attributes( $output ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1589
		/* hook head_language_attributes */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1590
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1591
		if ( has_filter('head_language_attributes') ) return apply_filters('head_language_attributes',$output);
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1592
		$attributes = array();
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1593
		$output = '';
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1594
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1595
		if ( $dir = get_bloginfo('text_direction') ) /*use hook for future use */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1596
			$attributes[] = "dir=\"$dir\"";
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1597
		if ( $this->langstate = true ) {	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1598
			if (strlen($this->curlang) == 5) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1599
				$lang = str_replace('_','-',substr( $this->curlang, 0, 3).strtoupper( substr( $this->curlang, -2))); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1600
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1601
				$lang = $this->curlang; //1.5.2 for ja as commented in 200909
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1602
			}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1603
		} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1604
			//use hook if you decide to display limited list of languages for use by instance in frontpage 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1605
			$listlang = array();
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1606
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1607
			$listlanguages = $this->get_listlanguages();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1608
			if ( $listlanguages ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1609
				foreach ( $listlanguages as $language ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1610
					$listlang[] = str_replace( '_', '-', $language->name );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1611
				}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1612
				$lang = $listlang[0]; // implode(', ',$listlang); // not w3c compatible
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1613
			}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1614
		}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1615
		if ( get_option('html_type') == 'text/html' )
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1616
				$attributes[] = "lang=\"$lang\"";
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1617
	// to use both - use the hook - head_language_attributes
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1618
		if ( get_option('html_type') != 'text/html' )
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1619
			$attributes[] = "xml:lang=\"$lang\"";	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1620
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1621
		$output = implode(' ', $attributes);
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1622
		
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1623
		return $output;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1624
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1625
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1626
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1627
	 * modify  insert language metas in head (via wp_head)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1628
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1629
	 * @since 0.9.7.6
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1630
	 * @updated 1.1.8 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1631
	 * @must be defined in functions.php according general theme design (wp_head) 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1632
	 *   
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1633
	 * @param $curlang
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1634
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1635
	function head_insert_language_metas( ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1636
		$curlang = $this->curlang; 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1637
		$undefined = $this->langstate;
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1638
		echo "<!-- multilingual website powered with xili-language v. ".XILILANGUAGE_VER." ".$this->lpr." WP plugin of dev.xiligroup.com -->\n";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1639
		if ( has_filter('head_insert_language_metas') ) return apply_filters( 'head_insert_language_metas', $curlang, $undefined );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1640
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1641
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1642
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1643
	 * insert hreflang link in head (via wp_head)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1644
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1645
	 * @since 2.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1646
	 * as commented in Google rel="alternate" 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1647
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1648
	 * to change rules or be compatible with cpt and taxonomy use head_insert_hreflang_link filter
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1649
	 *   
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1650
	 * @param $curlang
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1651
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1652
	function head_insert_hreflang_link ( ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1653
		if ( has_filter('head_insert_hreflang_link') ) return apply_filters( 'head_insert_hreflang_link', $this->curlang );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1654
		global $post, $cat;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1655
		if ( is_front_page() || is_category () ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1656
			$listlanguages = $this->get_listlanguages();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1657
			$currenturl = $this->current_url ( $this->lang_perma );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1658
			foreach ( $listlanguages as $language ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1659
				if ( $language->slug != $this->curlang ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1660
					if ( is_category() ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1661
						$category = get_category ( $cat ); // test targets count
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1662
						if ( 0 < $this->count_posts_in_taxonomy_and_lang ( 'category', $category->slug , $language->slug ) ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1663
							$do_it = true; // 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1664
						} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1665
							$do_it = false;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1666
						}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1667
					} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1668
						$do_it = true;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1669
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1670
					if ( $do_it ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1671
						$lang = str_replace( '_', '-', $language->name );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1672
						$hreflang = ( $this->lang_perma ) ? str_replace ( '%lang%', $language->slug, $currenturl ) : $currenturl.QUETAG."=".$language->slug ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1673
						printf ( '<link rel="alternate" hreflang="%s" href="%s" />'."\n", $lang, $hreflang ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1674
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1675
				} 		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1676
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1677
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1678
		} elseif ( is_singular() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1679
			$listlanguages = $this->get_listlanguages();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1680
			foreach ( $listlanguages as $language ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1681
				$targetpost = $this->linked_post_in ( $post->ID, $language->slug ) ; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1682
				if ( $language->slug != $this->curlang  && !empty ( $targetpost ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1683
					$hreflang = $this->link_of_linked_post ( $post->ID, $language->slug ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1684
					$lang = str_replace( '_', '-', $language->name );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1685
					printf ( '<link rel="alternate" hreflang="%s" href="%s" />'."\n", $lang, $hreflang ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1686
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1687
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1688
		} 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1689
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1690
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1691
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1692
	 * used in head_insert_hreflang_link and in xili_language_list
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1693
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1694
	 * @since 2.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1695
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1696
	function current_url ( $lang_perma ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1697
		if ( $lang_perma ) {	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1698
			if (is_category()) {  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1699
				remove_filter('term_link', 'insert_lang_4cat') ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1700
				$catcur = xiliml_get_category_link();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1701
				add_filter( 'term_link', 'insert_lang_4cat', 10, 3 );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1702
				$currenturl = $catcur; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1703
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1704
				$currenturl = get_bloginfo('url').'/%lang%/';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1705
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1706
		} else {	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1707
			if (is_category()) {  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1708
				$catcur = xiliml_get_category_link();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1709
				$permalink = get_option('permalink_structure'); /* 1.6.0 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1710
				$sep = ('' == $permalink) ? "&amp;" : "?" ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1711
				$currenturl = $catcur.$sep;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1712
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1713
			 	$currenturl = get_bloginfo('url').'/?';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1714
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1715
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1716
		return $currenturl;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1717
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1718
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1719
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1720
	 * return count of posts in taxonomy and language
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1721
	 *
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1722
	 * called by head_insert_hreflang_link
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1723
	 * available for specific behaviour - why not in custom plugin for xili_language_list or...
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1724
	 * @params taxonomy (category), current slug, current lang
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1725
	 * @since 2.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1726
	 */ 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1727
	 function count_posts_in_taxonomy_and_lang ( $taxonomy, $slug = '' , $language = '', $post_type = 'post' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1728
	 	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1729
	 	$args = array(
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1730
	 		'post_type' => $post_type,
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1731
			'tax_query' => array(
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1732
				'relation' => 'AND',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1733
				array(
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1734
					'taxonomy' => $taxonomy,
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1735
					'field' => 'slug',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1736
					'terms' => array( $slug )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1737
				),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1738
				array( // language
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1739
					'taxonomy' => TAXONAME, 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1740
					'field' => 'slug',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1741
					'terms' => array( $language )	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1742
				)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1743
			)	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1744
		);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1745
		$query = new WP_Query( $args );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1746
	 	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1747
	 	return $query->found_posts;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1748
	 }
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1749
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1750
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1751
	 * Translate texts of widgets or other simple text... 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1752
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1753
	 * @updated 1.6.0 - Old name widget_texts
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1754
	 * @since 0.9.8.1 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1755
	 * @ return
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1756
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1757
	function one_text ( $value ){
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1758
		if ('' != $value)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1759
			return __($value, $this->thetextdomain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1760
		else
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1761
			return $value;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1762
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1763
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1764
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1765
	 * Translate title of wp nav menu  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1766
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1767
	 * @since 1.6.0
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1768
	 * @ return
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1769
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1770
	function wp_nav_title_text ( $value = "", $itemID = 0 ){
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1771
		if ('' != $value) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1772
			return __( $value, $this->thetextdomain );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1773
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1774
			return $value;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1775
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1776
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1777
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1778
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1779
	 * Add filters of texts of comment form  - because default text are linked with wp language (and not theme)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1780
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1781
	 * @since 1.5.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1782
	 * @ return arrays with themetextdomain
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1783
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1784
	function xili_comment_form_default_fields ( $fields ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1785
		$commenter = wp_get_current_commenter();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1786
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1787
		$req = get_option( 'require_name_email' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1788
		$aria_req = ( $req ? " aria-required='true'" : '' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1789
		$fields =  array(
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1790
			'author' => '<p class="comment-form-author">' . '<label for="author">' . __( $this->comment_form_labels['name'], $this->thetextdomain ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1791
			            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1792
			'email'  => '<p class="comment-form-email"><label for="email">' . __( $this->comment_form_labels['email'], $this->thetextdomain ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1793
			            '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1794
			'url'    => '<p class="comment-form-url"><label for="url">' . __( $this->comment_form_labels['website'], $this->thetextdomain ) . '</label>' .
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1795
			            '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1796
		);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1797
		return $fields;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1798
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1799
	/** 2.3.2 - noun context */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1800
	function xili_comment_form_defaults ( $defaults ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1801
		global $user_identity, $post;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1802
		$req = get_option( 'require_name_email' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1803
		$xilidefaults = array(
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1804
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1805
		'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( $this->comment_form_labels['comment'], 'noun', $this->thetextdomain ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1806
		'must_log_in'          => '<p class="must-log-in">' .  sprintf( __( $this->comment_form_labels['youmustbe'], $this->thetextdomain ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post->ID ) ) ) ) . '</p>',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1807
		'logged_in_as'         => '<p class="logged-in-as">' . sprintf( __( $this->comment_form_labels['loggedinas'], $this->thetextdomain ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post->ID ) ) ) ) . '</p>',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1808
		'comment_notes_before' => '<p class="comment-notes">' . __( $this->comment_form_labels['emailnotpublished'], $this->thetextdomain ) . ( $req ? __( $this->comment_form_labels['requiredmarked'], $this->thetextdomain ) : '' ) . '</p>',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1809
		'comment_notes_after'  => '<dl class="form-allowed-tags"><dt>' . __( $this->comment_form_labels['youmayuse'], $this->thetextdomain ) . '</dt> <dd><code>' . allowed_tags() . '</code></dd></dl>',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1810
		'id_form'              => 'commentform',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1811
		'id_submit'            => 'submit',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1812
		'title_reply'          => __( $this->comment_form_labels['leavereply'], $this->thetextdomain ),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1813
		'title_reply_to'       => __( $this->comment_form_labels['replyto'], $this->thetextdomain ),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1814
		'cancel_reply_link'    => __( $this->comment_form_labels['cancelreply'], $this->thetextdomain ),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1815
		'label_submit'         => __( $this->comment_form_labels['postcomment'], $this->thetextdomain ),
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1816
		);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1817
		$args = wp_parse_args( $xilidefaults, $defaults);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1818
		return $args;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1819
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1820
			
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1821
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1822
	 * insert other language of wp_list_categories 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1823
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1824
	 * @since 0.9.0
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1825
	 * @updated 0.9.8.4 - 1.4.1 = no original term in ()
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1826
	 * can be hooked by filter add_filter('xiliml_cat_language','yourfunction',2,3) in functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1827
	 * call by do_filter list_cats 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1828
	 * @param $content, $category
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1829
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1830
	function xiliml_cat_language ( $content, $category = null ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1831
		if (has_filter('xiliml_cat_language')) return apply_filters('xiliml_cat_language',$content, $category,$this->curlang);
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1832
	    $new_cat_name = (!is_admin()) ? __($category->name,$this->thetextdomain) : $content ;  /*to detect admin UI*/
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1833
	    return $new_cat_name;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1834
	 } 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1835
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1836
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1837
	 * add the language key in category links of current pages
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1838
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1839
	 * @since 0.9.0
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1840
	 * update 0.9.7 1.5.1
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1841
	 * can be hooked by filter add_filter('xiliml_link_append_lang','yourfunction',10,2) in functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1842
	 * call by do_filter 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1843
	 * @param $content,
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1844
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1845
	function xiliml_link_append_lang( $link, $category_id = 0 ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1846
		if ( has_filter( 'xiliml_link_append_lang' ) ) return apply_filters( 'xiliml_link_append_lang', $link, $category_id, $this->curlang );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1847
		/*default*/
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1848
			
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1849
	  		if ($this->curlang) :
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1850
	  		 	if ( !$this->lang_perma ){ // 2.1.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1851
	  				$permalink = get_option( 'permalink_structure' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1852
	  			 	$sep = ('' == $permalink) ? "&amp;".QUETAG."=" : "?".QUETAG."=";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1853
	  				$link .= $sep.$this->curlang ; // wpmu
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1854
				} 			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1855
	  			
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1856
	  		endif;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1857
	  	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1858
	  return $link;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1859
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1860
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1861
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1862
	 * Setup global post data.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1863
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1864
	 * @since 0.9.4
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1865
	 * update 0.9.7
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1866
	 * can be hooked by filter add_filter('xiliml_taglink_append_lang','yourfunction',2,3) in functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1867
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1868
	 * @param $taglink, $tag_id.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1869
	 * @return $taglink.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1870
	 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1871
	function xiliml_taglink_append_lang ( $taglink, $tag_id=null ) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1872
		if (has_filter('xiliml_taglink_append_lang')) return apply_filters('xiliml_taglink_append_lang',$taglink,$tag_id,$this->curlang);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1873
		/* no yet default */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1874
		/* global $curlang; 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1875
		
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1876
	  		if ($curlang) :
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1877
	  			$taglink .= '&amp;'.QUETAG.'='.$curlang ;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1878
	  		endif;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1879
	  	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1880
	  	*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1881
	 return $taglink;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1882
	} 
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1883
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1884
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1885
	 * Setup global post data.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1886
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1887
	 * @since 1.6.0 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1888
	 * can be hooked by filter add_filter('xiliml_bloginfo','yourfunction',10,3) in functions.php
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1889
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1890
	 * @param $output, $show.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1891
	 * @return translated $output.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1892
	 */ 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1893
	 function xiliml_bloginfo ( $output, $show ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1894
	 	if (has_filter('xiliml_bloginfo')) return apply_filters('xiliml_bloginfo',$output, $show, $this->curlang);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1895
	 	$info_enabled = array('name', 'blogname', 'description');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1896
	 	if (in_array($show, $info_enabled)) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1897
	 		return __($output, $this->thetextdomain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1898
	 	} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1899
	 		return $output;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1900
	 	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1901
	 }
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1902
	 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1903
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1904
	 * to cancel sub select by lang in cat 1 by default 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1905
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1906
	 * @since 0.9.2
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1907
	 * update 0.9.7 - 1.8.4
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1908
	 * can be hooked by filter add_filter('xiliml_modify_querytag','yourfunction') in functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1909
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1910
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1911
	 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1912
	function xiliml_modify_querytag() {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1913
		if ( has_filter('xiliml_modify_querytag') ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1914
			apply_filters('xiliml_modify_querytag','');
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1915
		} else {	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1916
			/*default*/
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1917
			global $wp_query;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1918
			if ( defined('XILI_CATS_ALL') && !empty($wp_query->query_vars['cat']) )  { /* change in functions.php or use hook in cat 1 by default*/
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1919
				$excludecats = explode(",", XILI_CATS_ALL);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1920
				if 	( $excludecats != array() && in_array($wp_query->query_vars['cat'],$excludecats) ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1921
					$wp_query->query_vars[QUETAG] = "";	/* to cancel sub select */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1922
				}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1923
			}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1924
		}	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1925
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1926
		
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1927
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1928
	 * filters for wp_get_archives 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1929
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1930
	 * @since 0.9.2
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1931
	 * @params $join or $where and template params
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1932
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1933
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1934
	function xiliml_getarchives_join( $join, $r ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1935
		global $wpdb;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1936
		if (has_filter('xiliml_getarchives_join')) return apply_filters('xiliml_getarchives_join',$join,$r,$this->curlang);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1937
		extract( $r, EXTR_SKIP );
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1938
		$this->get_archives_called = $r;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1939
		if (isset($lang)) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1940
			if ("" == $lang ) { /* used for link */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1941
				$this->get_archives_called[QUETAG] = $this->curlang;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1942
			} else {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1943
				$this->get_archives_called[QUETAG] = $lang;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1944
			}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1945
			$join = " INNER JOIN $wpdb->term_relationships as tr ON ($wpdb->posts.ID = tr.object_id) INNER JOIN $wpdb->term_taxonomy as tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) ";
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1946
		
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1947
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1948
		return $join;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1949
		
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1950
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1951
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1952
	function xiliml_getarchives_where( $where, $r ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1953
		global $wpdb;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1954
		if (has_filter('xiliml_getarchives_where')) return apply_filters('xiliml_getarchives_where',$where,$r,$this->curlang);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1955
		extract( $r, EXTR_SKIP );
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1956
		if (isset($lang)) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1957
			if ("" == $lang ) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1958
				$curlang = $this->curlang;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1959
			} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1960
				$curlang = $lang;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1961
			}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1962
			$reqtag = term_exists( $curlang, TAXONAME );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1963
				if (''!= $reqtag) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1964
					$wherereqtag = $reqtag['term_id'];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1965
				} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1966
					$wherereqtag = 0;	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1967
				}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1968
				$where .= " AND tt.taxonomy = '".TAXONAME."' ";
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1969
				$where .= " AND tt.term_id = $wherereqtag ";
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1970
		}		
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1971
		return $where;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1972
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1973
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1974
	/** *here basic translation - to improve depending theme features : use hook 'xiliml_get_archives_link' */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1975
	function xiliml_get_archives_link( $link_html ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1976
		if ( has_filter('xiliml_link_translate_desc')) return apply_filters('xiliml_get_archives_link', $link_html,$this->get_archives_called, $this->curlang );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1977
		extract( $this->get_archives_called, EXTR_SKIP );
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1978
		if ( isset( $lang ) && '' != $lang ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1979
			$permalink = get_option('permalink_structure');
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1980
			$sep = ('' == $permalink) ? "&amp;".QUETAG."=" : "?".QUETAG."=";
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1981
			if ($format != 'option' && $format != 'link' && $type != 'postbypost' && $type != 'alpha') {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1982
				/* text extract */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1983
				$i = preg_match_all("/'>(.*)<\/a>/Ui", $link_html, $matches,PREG_PATTERN_ORDER);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1984
				$line = $matches[1][0];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1985
				/* link extract */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1986
				$i = preg_match_all("/href='(.*)' title/Ui", $link_html, $matches,PREG_PATTERN_ORDER);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1987
				if ( '' == $type || 'monthly' == $type) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1988
					if ('' == $permalink) {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  1989
						$archivedate = str_replace(get_bloginfo('url').'/?' , "" , $matches[1][0]);
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1990
						$r = wp_parse_args( $archivedate, array());
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1991
						extract($r, EXTR_SKIP );
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1992
						$month = substr($m,-2);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1993
						$year = substr($m,0,4);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1994
					} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1995
						/* Due to prevents post ID and date permalinks from overlapping using /date/ v 1.1.9 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1996
						 * no / at end for "numeric" permalink giving /archives/date/2009/04
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1997
						 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1998
						$thelink = $matches[1][0];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  1999
						$i = preg_match_all("/\/([0-9]{4})\/([0-9]{2})/Ui", $thelink, $results,PREG_PATTERN_ORDER);
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2000
						if ($i) { 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2001
							$month = $results[2][0];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2002
							$year = $results[1][0];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2003
						}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2004
					}	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2005
					$time = strtotime($month.'/1/'.$year);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2006
					$line2print = the_xili_local_time('%B %Y',$time); /* use server local*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2007
					$link_html = str_replace($line , $line2print , $link_html);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2008
				}	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2009
				$link_html = str_replace("' titl" , $sep.$lang."' titl" , $link_html);	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2010
			} elseif ($format == 'option') {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2011
				/* need improve with regex */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2012
				$link_html = str_replace("'>" , $sep.$lang."'>" , $link_html);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2013
			}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2014
		}	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2015
		return $link_html;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2016
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2017
 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2018
	 /**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2019
	 * translate description of categories
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2020
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2021
	 * @since 0.9.0
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2022
	 * update 0.9.7 - 0.9.9.4
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2023
	 * can be hooked by filter add_filter('xiliml_link_translate_desc','yourfunction',2,4) in functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2024
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2025
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2026
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2027
	function xiliml_link_translate_desc( $description, $category=null, $context='' ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2028
		if (has_filter('xiliml_link_translate_desc')) return apply_filters('xiliml_link_translate_desc',$description,$category,$context,$this->curlang);
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2029
	  	$translated_desc = ($this->curlang && ''!= $description) ? __($description, $this->thetextdomain) : $description ;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2030
	 	return $translated_desc;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2031
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2032
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2033
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2034
	 * filters for wp_title() translation - single_cat_title - 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2035
	 * since 1.4.1
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2036
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2037
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2038
	function xiliml_single_cat_title_translate ( $cat_name ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2039
		if (has_filter('xiliml_single_cat_title_translate')) return apply_filters('xiliml_single_cat_title_translate',$cat_name);
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2040
		$translated = ($this->curlang && ''!= $cat_name) ? __($cat_name,$this->thetextdomain) : $cat_name;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2041
	 	return $translated;	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2042
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2043
		
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2044
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2045
	 * Return the list of preferred languages for displaying pages (see in firefox prefs)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2046
	 * thanks to php.net comments HTTP_ACCEPT_LANGUAGE
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2047
	 * @since 0.9.7.5
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2048
	 * @updated 2.7.1
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2049
	 * @return array (non sorted)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2050
	 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2051
	function the_preferred_languages() {	 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2052
		$preferred_languages = array();
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2053
			if( isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) && preg_match_all("#([^;,]+)(;[^,0-9]*([0-9\.]+)[^,]*)?#i",$_SERVER["HTTP_ACCEPT_LANGUAGE"], $matches, PREG_SET_ORDER)) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2054
				foreach($matches as $match) {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2055
					if(isset($match[3])) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2056
						$preferred_languages[$match[1]] = floatval($match[3]);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2057
					} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2058
						$preferred_languages[$match[1]] = 1.0; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2059
					}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2060
				}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2061
				return $preferred_languages;	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2062
			} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2063
				return false;	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2064
			}	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2065
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2066
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2067
	 * Return the lang defined by admin UI if no browser
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2068
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2069
	 * @since 1.0
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2070
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2071
	 */	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2072
	function choice_of_home_selected_lang() {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2073
		if ($this->browseroption == 'browser') {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2074
			return choice_of_browsing_language();
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2075
		} elseif ($this->browseroption != '') { /* slug of the lang*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2076
			return $this->browseroption;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2077
		} else {	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2078
	 		return strtolower($this->default_lang);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2079
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2080
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2081
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2082
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2083
	 * Return the list of preferred languages for displaying pages (see in firefox prefs)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2084
	 * thanks to php.net comments HTTP_ACCEPT_LANGUAGE
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2085
	 * @since 0.9.7.5
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2086
	 * @update 0.9.9.4
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2087
	 * @update 2.3.1 - lang_neither_browser
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2088
	 * @return default target language
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2089
	 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2090
	function choice_of_browsing_language() {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2091
		if ( has_filter('choice_of_browsing_language') ) return apply_filters('choice_of_browsing_language',''); // '' 2.3.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2092
		if ( $this->browseroption != 'browser' ) return $this->choice_of_home_selected_lang(); /* in settings UI - after filter to hook w/o UI */
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2093
		$listofprefs = $this->the_preferred_languages();
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2094
		$default_lang = ( "" != $this->lang_neither_browser ) ? $this->lang_neither_browser : $this->default_lang ; //2.3.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2095
		if ( is_array($listofprefs) ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2096
			arsort($listofprefs, SORT_NUMERIC);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2097
			$listlanguages = get_terms(TAXONAME, array('hide_empty' => false));
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2098
			$sitelanguage = $this->match_languages ( $listofprefs, $listlanguages );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2099
			if ( $sitelanguage ) return $sitelanguage->slug;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2100
			return strtolower( $default_lang );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2101
		} else {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2102
			return strtolower( $default_lang );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2103
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2104
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2105
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2106
	function match_languages ( $listofprefs, $listlanguages ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2107
		
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2108
			foreach($listofprefs as $browserlanguage => $priority) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2109
					/* match root languages to give similar in site  - first : five chars langs*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2110
					foreach($listlanguages as $sitelanguage) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2111
						if ($sitelanguage->slug == str_replace('-','_',$browserlanguage)) return $sitelanguage;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2112
					}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2113
			}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2114
			foreach($listofprefs as $browserlanguage => $priority) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2115
					/* match root languages to give similar in site  - second : two first chars langs*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2116
					foreach($listlanguages as $sitelanguage) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2117
						if (str_replace('-','_',$browserlanguage) == substr($sitelanguage->slug,0,2)) return $sitelanguage;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2118
					}	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2119
			}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2120
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2121
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2122
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2123
	 * Choice of language when is_category and all languages
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2124
	 *
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2125
	 * @since 1.8.9.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2126
	 * called by get_curlang_action_wp
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2127
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2128
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2129
	function choice_of_categories_all_languages( $curlang ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2130
		$choice = $this->xili_settings['allcategories_lang'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2131
		if ( $choice == "browser" ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2132
			return $this->choice_of_browsing_language();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2133
		} elseif ( $choice == "firstpost" ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2134
			return $curlang ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2135
		} elseif ( $choice == "" ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2136
			if ( function_exists('xl_choice_of_categories_all_languages') ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2137
				return xl_choice_of_categories_all_languages () ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2138
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2139
				return ''; // return without mo
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2140
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2141
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2142
		return $choice;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2143
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2144
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2145
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2146
	 * to encapsulate future method
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2147
	 *
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2148
	 * @since 1.8.9.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2149
	 * @param post_ID and lang slug
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2150
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2151
	function linked_post_in ( $fromID, $lang_slug ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2152
		return get_post_meta( $fromID, QUETAG.'-'.$lang_slug, true ); // will be soon changed
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2153
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2154
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2155
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2156
	 * if possible, translate the array of ID of sticky posts
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2157
	 *
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2158
	 * @since 1.6.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2159
	 * called by hook option_sticky_posts
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2160
	 * @updated 2.8.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2161
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2162
	function translate_sticky_posts_ID( $original_array ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2163
		global $wp_query ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2164
		if ( !is_admin() && is_home() ) { // because impossible to register the value in admin UI - 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2165
		// and because tracs http://core.trac.wordpress.org/ticket/14115
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2166
			if ($original_array != array()) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2167
				$translated_array = array(); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2168
				if ( isset( $wp_query->query_vars[QUETAG] )) { //if (isset($_GET[QUETAG])) {  // $_GET not usable by lang perma mode 2.8.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2169
					$curlang = $wp_query->query_vars[QUETAG]; // $_GET[QUETAG]; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2170
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2171
					$curlang = $this->choice_of_browsing_language(); // rule defined in admin UI
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2172
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2173
				foreach ($original_array as $id) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2174
					$langpost = $this->get_cur_language($id); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2175
					$post_lang = $langpost[QUETAG];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2176
					if ($post_lang != $curlang) { // only if necessary
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2177
						$trans_id = $this-> linked_post_in( $id, $curlang ) ; // get_post_meta($id, 'lang-'.$curlang, true);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2178
						if ( '' != $trans_id ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2179
							$translated_array[] = $trans_id;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2180
						} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2181
							if ( $this->sticky_keep_original === true ) $translated_array[] = $id; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2182
							// set by webmaster  in theme functions
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2183
							
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2184
						}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2185
					} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2186
						$translated_array[] = $id;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2187
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2188
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2189
				return $translated_array;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2190
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2191
				return $original_array;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2192
			} 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2193
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2194
			return $original_array;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2195
		}		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2196
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2197
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2198
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2199
	 * cancel default filtering when page on front
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2200
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2201
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2202
	 * @updated 2.6.3
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2203
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2204
	function get_option_wo_xili ( $option ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2205
		if ( $option == 'page_on_front' && isset( $this->idx['translate_page_on_front_ID'] ) ) { // 2.6.3
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2206
			remove_filter ( 'option_'.$option, $this->idx['translate_page_on_front_ID'] );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2207
			$value = get_option ( $option ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2208
			add_filter ( 'option_'.$option, array(&$this, 'translate_page_on_front_ID') );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2209
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2210
			$value = get_option (  $option ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2211
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2212
		return $value ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2213
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2214
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2215
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2216
	 * if possible, translate the ID of front_page post
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2217
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2218
	 * @since 1.7.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2219
	 * called by hook option_page_on_front
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2220
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2221
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2222
	function translate_page_on_front_ID ( $original_id ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2223
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2224
		if ( $this->lang_perma ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2225
			global $wp_query ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2226
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2227
			if ( !is_admin() && $this->show_page_on_front ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2228
			 	if ( isset( $wp_query->query_vars[QUETAG] ) && in_array ( $wp_query->query_vars[QUETAG], array_keys ( $this->show_page_on_front_array ) ) && '' != $wp_query->query_vars['page_id'] ) {	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2229
					$curlang = $wp_query->query_vars[QUETAG];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2230
				 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2231
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2232
				} elseif ( isset( $wp_query->query_vars[QUETAG] ) && in_array ( $wp_query->query_vars[QUETAG], array_keys ( $this->show_page_on_front_array ) ) ){
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2233
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2234
					$curlang = $wp_query->query_vars[QUETAG]; // to verify
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2235
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2236
					//$first_query = get_option('xili_language_settings_test') ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2237
					//if ( $first_query ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2238
						//$curlang = $first_query ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2239
					//} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2240
						$curlang = $this->choice_of_browsing_language(); // rule defined in admin UI
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2241
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2242
					//}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2243
				}				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2244
			 	$trans_id = $this->linked_post_in( $original_id, $curlang ) ; 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2245
				
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2246
				if ( '' != $trans_id ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2247
					return $trans_id;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2248
				} else {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2249
					return $original_id;	
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2250
				}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2251
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2252
				return $original_id;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2253
			}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2254
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2255
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2256
			//$showpage = get_option('show_on_front');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2257
			if ( !is_admin() && $this->show_page_on_front ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2258
				if ( isset( $_GET[QUETAG]) ) {  // $this_curlang is not yet set
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2259
					$curlang = $_GET[QUETAG]; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2260
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2261
					$curlang = $this->choice_of_browsing_language(); // rule defined in admin UI
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2262
				}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2263
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2264
				$trans_id = $this-> linked_post_in( $original_id, $curlang ) ; // get_post_meta($original_id, 'lang-'.$curlang, true);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2265
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2266
				if ( '' != $trans_id ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2267
					return $trans_id;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2268
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2269
					return $original_id;	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2270
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2271
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2272
				return $original_id;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2273
			}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2274
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2275
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2276
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2277
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2278
	 * List custom post types
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2279
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2280
	 * @since 1.8.0
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2281
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2282
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2283
	function get_custom_desc() {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2284
		$types = get_post_types(array('show_ui'=>1));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2285
		if ( count($types) > 2 ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2286
			$thecheck = array() ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2287
			$thecustoms = array();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2288
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2289
			foreach ( $types as $type) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2290
				$true = ( defined ('XDMSG') ) ? ( $type != XDMSG ) : true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2291
				if ( $type != 'page' && $type != 'post' && $true == true ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2292
					$custom = get_post_type_object ($type);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2293
					$clabels = $custom->labels;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2294
					$thecustoms[$type] = array ('name' => $custom->label, 'singular_name' => $clabels->singular_name, 'multilingual'=>''  ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2295
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2296
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2297
			return $thecustoms ;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2298
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2299
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2300
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2301
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2302
	 * unassign a language from a series of objects (post or link)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2303
	 * @since 1.8.8
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2304
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2305
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2306
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2307
	function multilingual_links_erase ( $lang_term_id ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2308
		$languages = $this -> get_listlanguages();
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2309
		
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2310
		foreach ($languages as $language ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2311
			if ( $language->term_id == $lang_term_id ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2312
				$lang_slug = $language->slug ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2313
				continue ;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2314
			}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2315
		}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2316
		foreach ($languages as $language ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2317
			// for other languages as this - delete postmeta linked to post of erased posts
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2318
			if ( $language->term_id != $lang_term_id) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2319
				$post_IDs = get_objects_in_term( array( $language->term_id ), array( TAXONAME ) );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2320
				foreach ( $post_IDs as $post_ID ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2321
						delete_post_meta( $post_ID, QUETAG.'-'.$lang_slug ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2322
				}			
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2323
			}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2324
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2325
		// posts
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2326
		$post_IDs = get_objects_in_term( array( $lang_term_id ), array( TAXONAME ) );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2327
		foreach ( $post_IDs as $post_ID ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2328
			// delete relationships posts
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2329
	 		wp_delete_object_term_relationships( $post_ID, TAXONAME );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2330
		}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2331
		// links of blogroll
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2332
		$links = get_objects_in_term( array( $lang_term_id ), array( 'link_'.TAXONAME ) );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2333
		foreach ( $links as $link ) {	   
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2334
			wp_delete_object_term_relationships( $link, 'link_'.TAXONAME );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2335
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2336
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2337
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2338
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2339
		
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2340
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2341
	 * Set language plugin 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2342
	 * 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2343
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2344
	 * @updated 1.1.9
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2345
	 * also include automatic search of domain and lang subfolder in current theme
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2346
	 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2347
	function init_textdomain() {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2348
	/*multilingual for admin pages and menu*/
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2349
		load_plugin_textdomain('xili-language', false, 'xili-language/languages' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2350
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2351
		/* in wp3 multisite - don't use constant - for backward compatibility keep it in mono*/			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2352
		if ( '' != $this->xili_settings['theme_domain'] ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2353
			if (!is_multisite() && !defined('THEME_TEXTDOMAIN') ) define('THEME_TEXTDOMAIN',$this->thetextdomain); // for backward compatibility;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2354
			if ( is_admin() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2355
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2356
				$this->thetextdomain = $this->xili_settings['theme_domain'] ; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2357
				update_option('xili_language_settings', $this->xili_settings); 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2358
				
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2359
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2360
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2361
			$this->domaindetectmsg = __('no load_theme_textdomain in functions.php','xili-language');
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2362
		}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2363
		
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2364
	}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2365
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2366
	function searchpath( $path, $filename ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2367
		$this->xili_settings['langs_folder'] = str_replace($this->get_template_directory,'',$path);
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2368
	}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2369
	
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2370
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2371
	 * Reset values when theme was changed... updated by previous function
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2372
	 * @since 1.1.9
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2373
	 */ 
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2374
	function theme_switched ( $theme ) { 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2375
		$this->xili_settings['langs_folder'] ="";
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2376
		$this->xili_settings['theme_domain'] ="";   /* to force future search in new theme */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2377
		update_option('xili_language_settings', $this->xili_settings); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2378
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2379
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2380
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2381
	 * to add links in current menu of twentyten
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2382
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2383
	 * 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2384
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2385
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2386
	function add_list_of_language_links_in_wp_menu ( $location ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2387
		$defaultarray = array(
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2388
			'menu-item-type' => 'custom',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2389
			'menu-item-title' => '',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2390
			'menu-item-url' => '',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2391
			'menu-item-description' => '',
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2392
			'menu-item-status' => 'publish');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2393
		$url = get_bloginfo('url') ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2394
		$listlanguages = get_terms_of_groups_lite ($this->langs_group_id,TAXOLANGSGROUP,TAXONAME,'ASC');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2395
		$langdesc_array = array();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2396
		foreach ($listlanguages as $language){
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2397
			$langdesc_array[] = $language->description;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2398
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2399
		/* detect menu inside location */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2400
		$menu_locations =  get_nav_menu_locations();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2401
		$menuid = $menu_locations[$location];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2402
		$menuitem = wp_get_nav_menu_object($menuid);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2403
		$items = get_objects_in_term( $menuitem->term_id, 'nav_menu' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2404
		$nothere = true;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2405
		if ( ! empty( $items ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2406
			$founditems = wp_get_nav_menu_items($menuid); //try to see if a previous insert was done
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2407
			foreach ($founditems as $item) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2408
		 		if ($item->title =='|' || in_array($item->title, $langdesc_array)) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2409
		 			$nothere = false;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2410
		 			break;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2411
		 		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2412
		 	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2413
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2414
		if ($nothere == true) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2415
			/* add separator */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2416
				$defaultarray['menu-item-title'] = '|';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2417
				$defaultarray['menu-item-url'] = $url.'/#';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2418
				wp_update_nav_menu_item($menuid,0,$defaultarray);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2419
			foreach ($listlanguages as $language){
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2420
				$defaultarray['menu-item-title'] = $language->description ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2421
				$defaultarray['menu-item-url'] = $url.'/?lang='.$language->slug ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2422
				wp_update_nav_menu_item($menuid,0,$defaultarray);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2423
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2424
			return __("language items added","xili-language");
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2425
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2426
			return __("seems to be set","xili-language");
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2427
		}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2428
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2429
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2430
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2431
	 * ***** Functions to improve bookmarks language filtering *****
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2432
	 * 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2433
	 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2434
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2435
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2436
	 * Filter to widget_links parameter
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2437
	 * @ since 1.8.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2438
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2439
	function widget_links_args_and_lang ($widget_args) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2440
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2441
		$cur_lang = $this->curlang;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2442
		// rules depending category and settings in xili-language
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2443
		$cat_settings = $this->xili_settings['link_categories_settings'] ; //array ( 'all'=> true, 'category' => array ( '2' => false , '811' => true ) );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2444
		$sub_select = false; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2445
		if ( $widget_args['category'] ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2446
			$sub_select = $cat_settings['category'][$widget_args['category']] ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2447
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2448
			$sub_select = $cat_settings['all'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2449
			// if ( $sub_select ) $widget_args['categorize'] = 0;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2450
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2451
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2452
		if ( $sub_select ) {	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2453
			$linklang = term_exists($cur_lang,'link_'.TAXONAME) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2454
			$linklang_ever = term_exists('ev_er','link_'.TAXONAME) ; // the dummy lang - shown ever with selected language
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2455
			if ( $cur_lang && $linklang ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2456
				if ( $widget_args['category'] ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2457
					$cat = get_term( $widget_args['category'], 'link_category' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2458
					$catname = apply_filters( "link_category", $cat->name );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2459
				}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2460
				$the_link_ids = array ();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2461
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2462
				$the_link_ids_cat = get_objects_in_term( array( $widget_args['category'] ), 'link_category' ) ; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2463
				$the_link_ids = get_objects_in_term( array( $linklang['term_id'], $linklang_ever['term_id'] ), 'link_'.TAXONAME ) ; // lang + ever
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2464
				$the_link_ids_all = array_intersect ($the_link_ids , $the_link_ids_cat ); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2465
				if ( $widget_args['category'] ) $widget_args['categorize'] = 0; // no sub list in one cat asked
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2466
				$widget_args['include'] = implode (',' , $the_link_ids_all );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2467
				$widget_args['category'] = ''; // because implode of intersect
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2468
				$widget_args['title_li'] = $catname ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2469
				
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2470
			}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2471
		}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2472
		return $widget_args ;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2473
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2474
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2475
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2476
	 * only active if 'lang' in template tag wp_list_bookmarks()
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2477
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2478
	 * as :  wp_list_bookmarks( array( 'lang'=>the_curlang() ) ) to display only in current language  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2479
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2480
	 * don't interfere with widget_links filter
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2481
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2482
	 * @ since 1.8.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2483
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2484
	function the_get_bookmarks_lang ($links_list, $args) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2485
		if ( isset( $args[QUETAG] ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2486
			// get links in selected lang
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2487
			$linklang = term_exists($args[QUETAG],'link_'.TAXONAME) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2488
			$linklang_ever = term_exists('ev_er','link_'.TAXONAME) ; // the dummy lang - shown ever with selected language
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2489
			//global $the_link_ids;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2490
			$this->the_link_ids = get_objects_in_term( array( $linklang['term_id'], $linklang_ever['term_id'] ), 'link_'.TAXONAME ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2491
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2492
			return array_filter ( $links_list , array(&$this,'_filtering_links') ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2493
			
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2494
		}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2495
		return $links_list;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2496
	}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2497
	function _filtering_links ($link) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2498
		//global $the_link_ids;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2499
		if ( in_array( $link->link_id , $this->the_link_ids ) ) return true ;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2500
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2501
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2502
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2503
	 * Register link language taxonomy
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2504
	 * @ since 1.8.5
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2505
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2506
	function add_link_taxonomy () {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2507
		register_taxonomy( 'link_'.TAXONAME, 'link', array('hierarchical' => false, 'label' => false, 'rewrite' => false, 'update_count_callback' =>  array(&$this,'_update_link_lang_count'), 'show_ui' => false, '_builtin' => false ));
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2508
		
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2509
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2510
	// count update
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2511
	function _update_link_lang_count( $terms ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2512
		//
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2513
		global $wpdb;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2514
			foreach ( (array) $terms as $term ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2515
				$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->term_relationships.object_id AND term_taxonomy_id = %d", $term ) );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2516
				$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2517
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2518
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2519
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2520
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2521
	/** end of language for bookmarks * @ since 1.8.5 **/
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2522
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2523
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2524
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2525
 	* now active in same file as class xili_language
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2526
 	* Widgets registration after classes rewritten
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2527
 	*
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2528
 	* @since 1.8.8
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2529
 	*/
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2530
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2531
	function add_new_widgets() {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2532
		load_plugin_textdomain('xili-language-widget',false, 'xili-language/languages'); // 1.8.8.1 fixes translation and red messages
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2533
 		register_widget('xili_Widget_Recent_Posts'); // since 1.3.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2534
 		register_widget('xili_WP_Widget_Recent_Comments'); // since 1.8.3 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2535
 		register_widget('xili_language_Widgets'); // since 1.8.3 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2536
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2537
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2538
	//********************************************//
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2539
	// Functions for themes (hookable by add_action() in functions.php - 0.9.7
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2540
	//********************************************//
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2541
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2542
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2543
	 * List of available languages.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2544
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2545
	 * @since 0.9.0
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2546
	 * @updated 0.9.7.4 - 0.9.8.3 - 0.9.9.6 - 1.5.5 (add class current-lang in <a>)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2547
	 * @updated 1.6.0 - new option for nav menu hook and echoing 4th param - better permalink
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2548
	 * @updated 1.8.1 - delete 'in' prefix in list - class if LI
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2549
	 * can be hooked by add_action in functions.php
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2550
	 * with : add_action('xili_language_list','my_infunc_language_list',10,4);
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2551
	 *
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2552
	 * for multiple widgets since 0.9.9.6, 1.6.0 : incorporate options
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2553
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2554
	 * @param $before = '<li>', $after ='</li>'.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2555
	 * @return list of languages of site for sidebar list.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2556
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2557
	function xili_language_list( $before = '<li>', $after ='</li>', $option='', $echo = true, $hidden = false ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2558
		global $post;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2559
		$lang_perma = $this->lang_perma; // since 2.1.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2560
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2561
		$before_class = false ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2562
		if ( substr($before,-2) == '.>' ) { // tips to add dynamic class in before
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2563
			$before_class = true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2564
			$before = str_replace('.>','>',$before);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2565
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2566
		$listlanguages = $this->get_listlanguages();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2567
		$a = ''; // 1.6.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2568
		
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2569
		if ($option == 'typeone') {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2570
			/* the rules : don't display the current lang if set and add link of category if is_category()*/
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2571
			$currenturl = $this->current_url ( $lang_perma ); // 2.5	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2572
			foreach ($listlanguages as $language) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2573
				$display = ( $hidden && ( $this->xili_settings['lang_features'][$language->slug]['hidden'] == 'hidden' ) ) ? false : true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2574
				if ($language->slug != the_curlang()   && $display ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2575
					$beforee = ( $before_class && $before == '<li>' ) ? '<li class="lang-'.$language->slug.'" >': $before;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2576
					$class = ' class="lang-'.$language->slug.'"';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2577
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2578
					$link = ( $lang_perma ) ? str_replace ( '%lang%', $language->slug, $currenturl ) : $currenturl.QUETAG."=".$language->slug ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2579
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2580
					$a .= $beforee .'<a '.$class.' href="'.$link.'" title="'.__('Posts selected', $this->thetextdomain ).' '.__('in '.$language->description, $this->thetextdomain ).'" >'. __( $language->description, $this->thetextdomain ) .'</a>'.$after;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2581
				}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2582
			}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2583
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2584
		} elseif ($option == 'typeonenew') {  // 2.1.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2585
				/* the rules : don't display the current lang if set and add link of category if is_category() but display linked singular */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2586
			$currenturl = $this->current_url ( $lang_perma ); // 2.5
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2587
			foreach ($listlanguages as $language) {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2588
				$display = ( $hidden && ( $this->xili_settings['lang_features'][$language->slug]['hidden'] == 'hidden' ) ) ? false : true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2589
				if ($language->slug != the_curlang()   && $display ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2590
					$beforee = ( $before_class && $before == '<li>' ) ? '<li class="lang-'.$language->slug.'" >': $before;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2591
					$class = ' class="lang-'.$language->slug.'"';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2592
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2593
					if ( ( is_single() || is_page() ) && !is_front_page() ) {	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2594
						$link = $this->link_of_linked_post ( $post->ID, $language->slug ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2595
						$title = sprintf (__('Current post in %s', $this->thetextdomain ), __($language->description, $this->thetextdomain ) ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2596
					} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2597
						$link = ( $lang_perma ) ? str_replace ( '%lang%', $language->slug, $currenturl ) : $currenturl.QUETAG."=".$language->slug ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2598
						$title = sprintf (__('Posts selected in %s', $this->thetextdomain ), __($language->description, $this->thetextdomain ) ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2599
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2600
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2601
					$a .= $beforee .'<a '.$class.' href="'.$link.'" title="'.$title.'" >'. __($language->description, $this->thetextdomain ) .'</a>' . $after;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2602
				}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2603
			}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2604
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2605
		} elseif ($option == 'navmenu')  {	 /* current list in nav menu 1.6.0 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2606
			if ( $lang_perma ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2607
				$currenturl = get_bloginfo('url').'/%lang%/';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2608
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2609
	 			$currenturl = get_bloginfo('url').'/?';
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2610
			}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2611
				foreach ($listlanguages as $language) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2612
					$display = ( $hidden && ( $this->xili_settings['lang_features'][$language->slug]['hidden'] == 'hidden' ) ) ? false : true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2613
					if ( $display ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2614
						if ($language->slug != the_curlang() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2615
							$class = " class='menu-item menu-item-type-custom lang-".$language->slug."'";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2616
						} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2617
							$class = " class='menu-item menu-item-type-custom lang-".$language->slug." current-lang current-menu-item'";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2618
						}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2619
						$beforee = (substr($before,-1) == '>') ? str_replace('>',' '.$class.' >' , $before ) : $before ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2620
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2621
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2622
						$link = ( $lang_perma ) ? str_replace ( '%lang%', $language->slug, $currenturl ) : $currenturl.QUETAG."=".$language->slug ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2623
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2624
						$a .= $beforee .'<a href="'.$link.'" title="'.__('Posts selected', $this->thetextdomain ).' '.__('in '.$language->description, $this->thetextdomain ).'" >'. __( $language->description, $this->thetextdomain ) . '</a>' . $after;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2625
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2626
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2627
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2628
		} elseif ($option == 'navmenu-1')  {	// 2.1.0  and single
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2629
				$currenturl = $this->current_url ( $lang_perma ); // 2.5
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2630
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2631
				foreach ($listlanguages as $language) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2632
					$display = ( $hidden && ( $this->xili_settings['lang_features'][$language->slug]['hidden'] == 'hidden' ) ) ? false : true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2633
					if ( $display ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2634
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2635
						if ($language->slug != the_curlang() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2636
							$class = " class='menu-item menu-item-type-custom lang-".$language->slug."'";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2637
						} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2638
							$class = " class='menu-item menu-item-type-custom lang-".$language->slug." current-lang current-menu-item'";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2639
						}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2640
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2641
						if ( ( is_single() || is_page() ) && !is_front_page() ) {	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2642
							$link = $this->link_of_linked_post ( $post->ID, $language->slug ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2643
							$title = sprintf (__('Current post in %s',the_theme_domain()), __($language->description, $this->thetextdomain) ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2644
						} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2645
							$link = ( $lang_perma ) ? str_replace ( '%lang%', $language->slug, $currenturl ) : $currenturl.QUETAG."=".$language->slug ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2646
							$title = sprintf ( __('Posts selected in %s',the_theme_domain()), __($language->description, $this->thetextdomain ) ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2647
						}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2648
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2649
						$beforee = (substr($before,-1) == '>') ? str_replace('>',' '.$class.' >' , $before ) : $before ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2650
						$a .= $beforee .'<a href="'.$link.'" title="'.$title.'" >'. __($language->description, $this->thetextdomain ) .'</a>'.$after;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2651
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2652
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2653
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2654
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2655
			} else {	/* current list only root */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2656
				if ( $lang_perma ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2657
					$currenturl = get_bloginfo('url').'/%lang%/';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2658
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2659
	 				$currenturl = get_bloginfo('url').'/?';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2660
				}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2661
				foreach ($listlanguages as $language) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2662
					$display = ( $hidden && ( $this->xili_settings['lang_features'][$language->slug]['hidden'] == 'hidden' ) ) ? false : true ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2663
					
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2664
					if ( $display ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2665
						if ( $language->slug != the_curlang() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2666
							$class = " class='lang-".$language->slug."'";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2667
						} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2668
							$class = " class='lang-".$language->slug." current-lang'";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2669
						}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2670
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2671
						$link = ( $lang_perma ) ? str_replace ( '%lang%', $language->slug, $currenturl ) : $currenturl.QUETAG."=".$language->slug ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2672
						
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2673
						$beforee = ( $before_class && $before == '<li>' ) ? '<li class="lang-'.$language->slug.'" >': $before;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2674
						$a .= $beforee .'<a '.$class.' href="'.$link.'" title="'.__('Posts selected', $this->thetextdomain ).' '.__('in '.$language->description, $this->thetextdomain).'" >'. __( $language->description, $this->thetextdomain ) .'</a>' . $after;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2675
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2676
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2677
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2678
			if ($echo) 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2679
				echo $a;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2680
			else
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2681
				return $a;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2682
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2683
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2684
	/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2685
	 * link of linked post
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2686
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2687
	 * @since 2.1.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2688
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2689
	 * @updated 2.1.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2690
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2691
	function link_of_linked_post ( $fromID, $lang_slug ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2692
	 	$targetpost = $this->linked_post_in ( $fromID, $lang_slug ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2693
	 	if ( $targetpost ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2694
	 		return get_permalink($targetpost);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2695
	 	} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2696
	 		if ( $this->lang_perma ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2697
	 			$currenturl = get_bloginfo('url').'/%lang%/';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2698
	 		} else	{
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2699
	 			$currenturl = get_bloginfo('url')."/?";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2700
	 		} 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2701
	 		$link = ( $this->lang_perma ) ? str_replace ( '%lang%', $lang_slug, $currenturl ) : $currenturl.QUETAG."=".$lang_slug ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2702
	 	    return $link ; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2703
	 	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2704
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2705
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2706
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2707
	 * For widget - the list of options above
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2708
	 * @since 1.6.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2709
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2710
	function xili_language_list_options () {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2711
		$this->langs_list_options = array( array('','default'), array('typeone','Type n°1'), array('typeonenew','Type for single') );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2712
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2713
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2714
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2715
	/**
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2716
	 * language of current post used in loop
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2717
	 * @since 0.9.0
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2718
	 * 
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2719
	 * @updated 2.5.1
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2720
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2721
	 * @param $before = '<span class"xili-lang">(', $after =')</span>'.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2722
	 * @return language of post.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2723
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2724
	function xili_post_language( $before = '<span class="xili-lang">(', $after =')</span>', $type = 'iso' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2725
		global $post ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2726
		$langpost = $this->get_post_language ( $post->ID, $type );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2727
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2728
		if ( '' != $langpost ) :
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2729
				$curlangname = $langpost;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2730
		else :
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2731
				$curlangname = __('undefined',$this->thetextdomain);
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2732
		endif;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2733
		$a = $before . $curlangname .$after.'';  
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2734
		echo $a;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2735
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2736
		
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2737
	/** 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2738
	 * for one post create a link list of the corresponding posts in other languages
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2739
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2740
	 * @since 0.9.0
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2741
	 * @updated 0.9.9.2 / 3 $separator replace $after, $before contains pre-text to echo a better list.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2742
	 * @updated 1.1 - see hookable same name function outside class
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2743
	 * can be hooked by add_action in functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2744
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2745
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2746
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2747
	function the_other_posts ( $post_ID, $before = "This post in", $separator = ", ", $type = "display" ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2748
		/* default here*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2749
			$outputarr = array();
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2750
			$listlanguages = get_terms(TAXONAME, array('hide_empty' => false));
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2751
			$langpost = $this->get_cur_language($post_ID); // to be used in multilingual loop since 1.1
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2752
			$post_lang = $langpost[QUETAG];
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2753
			foreach ($listlanguages as $language) {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2754
				$otherpost = $this->linked_post_in( $post_ID, $language->slug ) ; //get_post_meta($post_ID, 'lang-'.$language->slug, true);
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2755
				
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2756
				if ($type == "display") {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2757
					if ('' != $otherpost && $language->slug != $post_lang ) {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2758
						$outputarr[] = "<a href='".get_permalink($otherpost)."' >".__($language->description,$this->thetextdomain) ."</a>";
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2759
					}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2760
				} elseif ($type == "array") { // here don't exclude cur lang
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2761
					if ('' != $otherpost)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2762
						$outputarr[$language->slug] = $otherpost;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2763
				}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2764
			}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2765
			if ($type == "display") {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2766
				if (!empty($outputarr))
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2767
					$output =  (($before !="") ? __($before,$this->thetextdomain)." " : "" ).implode ($separator, $outputarr);
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2768
				if ('' != $output) { echo $output;}	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2769
			} elseif ($type == "array") {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2770
				if (!empty($outputarr)) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2771
					$outputarr[$post_ID] = $post_lang; 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2772
					// add a key with curid to give his lang (empty if undefined)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2773
					return $outputarr;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2774
				} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2775
					return false;	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2776
				}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2777
			}	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2778
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2779
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2780
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2781
	 * the_category() rewritten to keep new features of multilingual (and amp & pbs in link)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2782
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2783
	 * @since 0.9.0
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2784
	 * @updated 0.9.9.4 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2785
	 * can be hooked by add_action xiliml_the_category in functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2786
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2787
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2788
	function the_category( $post_ID, $separator = ', ' ,$echo = true ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2789
		/* default here*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2790
		$the_cats_list = wp_get_object_terms($post_ID, 'category');
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2791
		$i = 0;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2792
		foreach ($the_cats_list as $the_cat) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2793
			if ( 0 < $i )
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2794
				$thelist .= $separator . ' ';
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2795
			$desc4title = trim(attribute_escape(apply_filters( 'category_description', $the_cat->description, $the_cat->term_id )));
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2796
			
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2797
			$title = ('' == $desc4title) ? __($the_cat->name,$this->thetextdomain) : $desc4title;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2798
			$the_catlink = '<a href="' . get_category_link($the_cat->term_id) . '" title="' . $title . '" ' . $rel . '>';
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2799
			//if ($curlang != DEFAULTSLUG) :
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2800
	      	$the_catlink .=  __($the_cat->name,$this->thetextdomain).'</a>';;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2801
	      	//else :
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2802
	      		 //$the_catlink .=  $the_cat->name.'</a>';;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2803
	      	//endif;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2804
			$thelist .= $the_catlink;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2805
			++$i;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2806
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2807
		if ($echo) :
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2808
			echo $thelist;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2809
			return true;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2810
		else :
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2811
			return $thelist;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2812
		endif;	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2813
	}	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2814
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2815
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2816
	 * Add list of languages in radio input - for search form.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2817
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2818
	 * @since 0.9.7
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2819
	 * can be hooked by add_action in functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2820
	 *
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2821
	 * @updated 0.9.9.5, 1.8.2, 2.2.0 , 2.2.2
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2822
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2823
	 * $before, $after each line of radio input
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2824
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2825
	 * @param $before, $after. 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2826
	 * @return echo the form.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2827
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2828
	function xiliml_langinsearchform ( $before='', $after='', $echo = true ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2829
			/* default here*/
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2830
			global $wp_query;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2831
			$listlanguages = get_terms(TAXONAME, array('hide_empty' => false));
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2832
			$a = '';
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2833
			foreach ($listlanguages as $language) {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2834
				if ( is_search() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2835
					if ( isset( $wp_query->query_vars[QUETAG] ) ) { // to rebuilt form after search query
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2836
						$selected = ( ( $language->slug == $wp_query->query_vars[QUETAG] ) ) ? 'checked="checked"' : "" ; //2.2.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2837
					} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2838
						$selected = "";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2839
					}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2840
				} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2841
					$selected =  ( ( $language->slug == $this->curlang ) ) ? 'checked="checked"' : "" ; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2842
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2843
				$a .= $before.'<input type="radio" name="'.QUETAG.'" value="'.$language->slug.'" id="'.QUETAG.'" '.$selected.' />&nbsp;'.__( $language->description, $this->thetextdomain ).' '.$after;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2844
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2845
			// new javascript to uncheck radio buttons	on form named searchform
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2846
		    $a .= $before.'<input type="button" name="clear" onClick="var form = document.forms[\'searchform\'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2847
for (var i=0; i < form.'.QUETAG.'.length; i++) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2848
if(form.'.QUETAG.'[i].checked) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2849
form.'.QUETAG.'[i].checked = false; } }" value="'.__('All', $this->thetextdomain ).'" /> '.$after;	 // this to all lang query -
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2850
		    
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2851
		    
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2852
		    if ( $echo )  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2853
		    	echo $a;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2854
		    else
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2855
		    	return $a;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2856
		    		
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2857
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2858
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2859
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2860
	 * Select latest comments in current lang.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2861
	 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2862
	 * @since 0.9.9.4
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2863
	 * used by widget xili-recent-comments
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2864
	 *
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2865
	 * @param $number. 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2866
	 * @return $comments.
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2867
	 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2868
	function xiliml_recent_comments ( $number = 5 ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2869
		global $comments, $wpdb ;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2870
		if ( !$comments = wp_cache_get( 'xili_language_recent_comments', 'widget' ) ) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2871
				$join = "";
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2872
				$where = "";
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2873
				$reqtag = term_exists( $this->curlang, TAXONAME );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2874
					if (''!= $reqtag) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2875
						$wherereqtag = $reqtag['term_id'];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2876
						$join = " LEFT JOIN $wpdb->term_relationships as tr ON ($wpdb->comments.comment_post_ID = tr.object_id) LEFT JOIN $wpdb->term_taxonomy as tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) ";
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2877
					    $where = " AND tt.taxonomy = '".TAXONAME."' ";
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2878
					    $where .= " AND tt.term_id = $wherereqtag ";
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2879
					}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2880
				$query = "SELECT * FROM $wpdb->comments".$join." WHERE comment_approved = '1' ".$where." ORDER BY comment_date_gmt DESC LIMIT $number"; 
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2881
				
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2882
				$comments = $wpdb->get_results($query);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2883
				wp_cache_add( 'xili_language_recent_comments', $comments, 'widget' );
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2884
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2885
		return $comments;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2886
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2887
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2888
	/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2889
 	* Enable to add functions and filters that are not in theme's functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2890
 	* These filters are common even if you change default theme...
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2891
 	* Place your functions.php in folder plugins/xilidev-libraries/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2892
 	* if you have a filter in this file, avoid to have similar one in functions.php of the theme !!!
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2893
	*
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2894
 	*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2895
	function insert_gold_functions () {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2896
		$gold_path = WP_PLUGIN_DIR . $this->xilidev_folder ; /* since 1.0 to add xili-libraries */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2897
		if ( $this->xili_settings['functions_enable'] !='' && file_exists( $gold_path . '/functions.php') )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2898
			include_once ( $gold_path . '/functions.php');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2899
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2900
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2901
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2902
	 * Retrieve category list in either HTML list or custom format - as in category-template - rewritten for multilingual - filter the_category only frontend
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2903
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2904
	 * @since 1.7.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2905
	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2906
	 * @param string $separator Optional, default is empty string. Separator for between the categories.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2907
	 * @param string $parents Optional. How to display the parents.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2908
	 * no third param because call by end filter
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2909
	 * @return string
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2910
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2911
	function xl_get_the_category_list( $thelist, $separator = '', $parents='' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2912
		global $wp_rewrite, $post;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2913
		$categories = get_the_category( $post->ID );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2914
		//if ( !is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2915
			//return apply_filters( 'the_category', '', $separator, $parents );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2916
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2917
		if ( empty( $categories ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2918
			return  __( 'Uncategorized', $this->thetextdomain ) ; // fixed - avoid a previous recursive filter with custom @since 1.8.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2919
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2920
		$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2921
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2922
		$thelist = '';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2923
		if ( '' == $separator ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2924
			$thelist .= '<ul class="post-categories">';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2925
			foreach ( $categories as $category ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2926
				$thelist .= "\n\t<li>";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2927
				switch ( strtolower( $parents ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2928
					case 'multiple':
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2929
						if ( $category->parent )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2930
							$thelist .= get_category_parents( $category->parent, true, $separator );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2931
						$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", $this->thetextdomain ), __($category->name, $this->thetextdomain) ) ) . '" ' . $rel . '>' . __($category->name, $this->thetextdomain).'</a></li>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2932
						break;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2933
					case 'single':
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2934
						$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", $this->thetextdomain ), __($category->name, $this->thetextdomain) ) ) . '" ' . $rel . '>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2935
						if ( $category->parent )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2936
							$thelist .= get_category_parents( $category->parent, false, $separator );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2937
						$thelist .= __($category->name, $this->thetextdomain).'</a></li>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2938
						break;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2939
					case '':
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2940
					default:
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2941
						$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s", $this->thetextdomain ), __($category->name, $this->thetextdomain) ) ) . '" ' . $rel . '>' . __($category->cat_name, $this->thetextdomain).'</a></li>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2942
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2943
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2944
			$thelist .= '</ul>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2945
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2946
			$i = 0;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2947
			foreach ( $categories as $category ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2948
				if ( 0 < $i )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2949
					$thelist .= $separator;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2950
				switch ( strtolower( $parents ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2951
					case 'multiple':
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2952
						if ( $category->parent )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2953
							$thelist .= get_category_parents( $category->parent, true, $separator );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2954
						$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s",$this->thetextdomain ), __($category->name, $this->thetextdomain) ) ) . '" ' . $rel . '>' . __($category->name, $this->thetextdomain).'</a>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2955
						break;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2956
					case 'single':
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2957
						$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s",$this->thetextdomain ), __($category->name, $this->thetextdomain) ) ) . '" ' . $rel . '>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2958
						if ( $category->parent )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2959
							$thelist .= get_category_parents( $category->parent, false, $separator );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2960
						$thelist .= __($category->name, $this->thetextdomain)."</a>";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2961
						break;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2962
					case '':
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2963
					default:
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2964
						$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s",$this->thetextdomain ), __($category->name, $this->thetextdomain) ) ) . '" ' . $rel . '>' . __($category->name, $this->thetextdomain).'</a>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2965
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2966
				++$i;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2967
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2968
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2969
		return $thelist;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2970
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2971
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2972
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2973
			
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2974
} /* **************** end of xili-language class ******************* */
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  2975
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2976
/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2977
 * called when wp_locale is declared when plugin_loaded
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2978
 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2979
 * @since 2.4
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2980
 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2981
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2982
 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2983
function xiliml_declare_xl_wp_locale () { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2984
	/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2985
	 * special class extending wp_locale only for theme locale
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2986
	 * 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2987
	 * to work needs that locale datas and translation (a copy of those in core languages) will be in theme's po,mo files
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2988
	 * 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2989
	 * @since 2.4.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2990
	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2991
	if ( ! class_exists ( 'xl_WP_Locale'  ) ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2992
	class xl_WP_Locale extends WP_locale {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2993
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2994
			function __construct() {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2995
				parent::__construct();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2996
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2997
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2998
			function init() {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  2999
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3000
			$theme_domain = the_theme_domain();	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3001
				
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3002
			// The Weekdays
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3003
			$this->weekday[0] = /* translators: weekday */ __('Sunday', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3004
			$this->weekday[1] = /* translators: weekday */ __('Monday', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3005
			$this->weekday[2] = /* translators: weekday */ __('Tuesday', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3006
			$this->weekday[3] = /* translators: weekday */ __('Wednesday', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3007
			$this->weekday[4] = /* translators: weekday */ __('Thursday', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3008
			$this->weekday[5] = /* translators: weekday */ __('Friday', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3009
			$this->weekday[6] = /* translators: weekday */ __('Saturday', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3010
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3011
			// The first letter of each day.  The _%day%_initial suffix is a hack to make
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3012
			// sure the day initials are unique.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3013
			$this->weekday_initial[__('Sunday', $theme_domain)]    = /* translators: one-letter abbreviation of the weekday */ __('S_Sunday_initial', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3014
			$this->weekday_initial[__('Monday', $theme_domain)]    = /* translators: one-letter abbreviation of the weekday */ __('M_Monday_initial', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3015
			$this->weekday_initial[__('Tuesday', $theme_domain)]   = /* translators: one-letter abbreviation of the weekday */ __('T_Tuesday_initial', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3016
			$this->weekday_initial[__('Wednesday', $theme_domain)] = /* translators: one-letter abbreviation of the weekday */ __('W_Wednesday_initial', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3017
			$this->weekday_initial[__('Thursday', $theme_domain)]  = /* translators: one-letter abbreviation of the weekday */ __('T_Thursday_initial', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3018
			$this->weekday_initial[__('Friday', $theme_domain)]    = /* translators: one-letter abbreviation of the weekday */ __('F_Friday_initial', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3019
			$this->weekday_initial[__('Saturday', $theme_domain)]  = /* translators: one-letter abbreviation of the weekday */ __('S_Saturday_initial', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3020
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3021
			foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3022
				$this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3023
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3024
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3025
			// Abbreviations for each day.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3026
			$this->weekday_abbrev[__('Sunday', $theme_domain)]    = /* translators: three-letter abbreviation of the weekday */ __('Sun', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3027
			$this->weekday_abbrev[__('Monday', $theme_domain)]    = /* translators: three-letter abbreviation of the weekday */ __('Mon', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3028
			$this->weekday_abbrev[__('Tuesday', $theme_domain)]   = /* translators: three-letter abbreviation of the weekday */ __('Tue', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3029
			$this->weekday_abbrev[__('Wednesday', $theme_domain)] = /* translators: three-letter abbreviation of the weekday */ __('Wed', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3030
			$this->weekday_abbrev[__('Thursday', $theme_domain)]  = /* translators: three-letter abbreviation of the weekday */ __('Thu', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3031
			$this->weekday_abbrev[__('Friday', $theme_domain)]    = /* translators: three-letter abbreviation of the weekday */ __('Fri', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3032
			$this->weekday_abbrev[__('Saturday', $theme_domain)]  = /* translators: three-letter abbreviation of the weekday */ __('Sat', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3033
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3034
			// The Months
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3035
			$this->month['01'] = /* translators: month name */ __('January', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3036
			$this->month['02'] = /* translators: month name */ __('February', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3037
			$this->month['03'] = /* translators: month name */ __('March', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3038
			$this->month['04'] = /* translators: month name */ __('April', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3039
			$this->month['05'] = /* translators: month name */ __('May', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3040
			$this->month['06'] = /* translators: month name */ __('June', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3041
			$this->month['07'] = /* translators: month name */ __('July', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3042
			$this->month['08'] = /* translators: month name */ __('August', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3043
			$this->month['09'] = /* translators: month name */ __('September', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3044
			$this->month['10'] = /* translators: month name */ __('October', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3045
			$this->month['11'] = /* translators: month name */ __('November', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3046
			$this->month['12'] = /* translators: month name */ __('December', $theme_domain );  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3047
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3048
			// Abbreviations for each month. Uses the same hack as above to get around the
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3049
			// 'May' duplication.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3050
			$this->month_abbrev[__('January', $theme_domain)] = /* translators: three-letter abbreviation of the month */ __('Jan_January_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3051
			$this->month_abbrev[__('February', $theme_domain)] = /* translators: three-letter abbreviation of the month */ __('Feb_February_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3052
			$this->month_abbrev[__('March', $theme_domain)] = /* translators: three-letter abbreviation of the month */ __('Mar_March_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3053
			$this->month_abbrev[__('April', $theme_domain)] = /* translators: three-letter abbreviation of the month */ __('Apr_April_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3054
			$this->month_abbrev[__('May', $theme_domain)] = /* translators: three-letter abbreviation of the month */ __('May_May_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3055
			$this->month_abbrev[__('June', $theme_domain)] = /* translators: three-letter abbreviation of the month */ __('Jun_June_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3056
			$this->month_abbrev[__('July', $theme_domain)] = /* translators: three-letter abbreviation of the month */ __('Jul_July_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3057
			$this->month_abbrev[__('August', $theme_domain)] = /* translators: three-letter abbreviation of the month */ __('Aug_August_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3058
			$this->month_abbrev[__('September', $theme_domain)] = /* translators: three-letter abbreviation of the month */ __('Sep_September_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3059
			$this->month_abbrev[__('October', $theme_domain)] = /* translators: three-letter abbreviation of the month */ __('Oct_October_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3060
			$this->month_abbrev[__('November', $theme_domain)] = /* translators: three-letter abbreviation of the month */ __('Nov_November_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3061
			$this->month_abbrev[__('December',$theme_domain)] = /* translators: three-letter abbreviation of the month */ __('Dec_December_abbreviation', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3062
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3063
			foreach ($this->month_abbrev as $month_ => $month_abbrev_) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3064
				$this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3065
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3066
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3067
			// The Meridiems
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3068
			$this->meridiem['am'] = __('am', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3069
			$this->meridiem['pm'] = __('pm', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3070
			$this->meridiem['AM'] = __('AM', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3071
			$this->meridiem['PM'] = __('PM', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3072
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3073
			// Numbers formatting
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3074
			// See http://php.net/number_format
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3075
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3076
			/* translators: $thousands_sep argument for http://php.net/number_format, default is , */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3077
			$trans = __('number_format_thousands_sep', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3078
			$this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3079
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3080
			/* translators: $dec_point argument for http://php.net/number_format, default is . */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3081
			$trans = __('number_format_decimal_point', $theme_domain);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3082
			$this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3083
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3084
			// test version // 2.7.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3085
			global $wp_version;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3086
			if ( version_compare($wp_version, '3.4', '<') ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3087
				// Import global locale vars set during inclusion of $locale.php.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3088
				foreach ( (array) $this->locale_vars as $var ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3089
					if ( isset($GLOBALS[$var]) )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3090
						$this->$var = $GLOBALS[$var];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3091
				}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3092
			} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3093
			// Set text direction.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3094
				if ( isset( $GLOBALS['text_direction'] ) )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3095
					$this->text_direction = $GLOBALS['text_direction'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3096
				/* translators: 'rtl' or 'ltr'. This sets the text direction for WordPress. */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3097
				elseif ( 'rtl' == _x( 'ltr', 'text direction', $theme_domain ) )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3098
					$this->text_direction = 'rtl';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3099
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3100
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3101
		}	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3102
	} }
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3103
}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3104
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3105
/**** Functions that improve taxinomy.php ****/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3106
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3107
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3108
 * get terms and add order in term's series that are in a taxonomy 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3109
 * (not in class for general use)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3110
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3111
 * @since 0.9.8.2 - full version is in xili-tidy-tags
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3112
 * @uses $wpdb
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3113
 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3114
function get_terms_of_groups_lite ($group_ids, $taxonomy, $taxonomy_child, $order = '') {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3115
	global $wpdb;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3116
	if ( !is_array($group_ids) )
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3117
		$group_ids = array($group_ids);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3118
	$group_ids = array_map('intval', $group_ids);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3119
	$group_ids = implode(', ', $group_ids);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3120
	$theorderby = '';
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3121
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3122
	// lite release
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3123
	if ($order == 'ASC' || $order == 'DESC') $theorderby = ' ORDER BY tr.term_order '.$order ;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3124
		
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3125
	$query = "SELECT t.*, tt2.term_taxonomy_id, tt2.description,tt2.parent, tt2.count, tt2.taxonomy, tr.term_order FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id INNER JOIN $wpdb->terms AS t ON t.term_id = tr.object_id INNER JOIN $wpdb->term_taxonomy AS tt2 ON tt2.term_id = tr.object_id WHERE tt.taxonomy IN ('".$taxonomy."') AND tt2.taxonomy = '".$taxonomy_child."' AND tt.term_id IN (".$group_ids.") ".$theorderby;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3126
	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3127
	$listterms = $wpdb->get_results($query);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3128
	if ( ! $listterms )
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3129
		return array();
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3130
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3131
	return $listterms;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3132
}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3133
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3134
/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3135
 * for backward compatibility - soon obsolete - please modify your theme's function.php 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3136
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3137
function get_terms_with_order ( $group_ids, $taxonomy, $taxonomy_child, $order = 'ASC' ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3138
	return get_terms_of_groups_lite ($group_ids, $taxonomy, $taxonomy_child, $order);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3139
}	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3140
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3141
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3142
 * function that improve taxinomy.php 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3143
 * @since 0.9.8
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3144
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3145
 * update term order in relationships (for terms of langs group defined by his taxonomy_id)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3146
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3147
 * @param $object_id, $taxonomy_id, $term_order
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3148
 * 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3149
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3150
function update_term_order ( $object_id,$term_taxonomy_id,$term_order ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3151
	global $wpdb;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3152
	$wpdb->update( $wpdb->term_relationships, compact( 'term_order' ), array( 'term_taxonomy_id' => $term_taxonomy_id,'object_id' => $object_id ) );
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3153
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3154
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3155
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3156
 * function that improve taxinomy.php 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3157
 * @since 0.9.8
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3158
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3159
 * get one term and order of it in relationships
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3160
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3161
 * @param term_id and $group_ttid (taxonomy id of group)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3162
 * @return object with term_order
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3163
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3164
function get_term_and_order ( $term_id, $group_ttid, $taxonomy ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3165
	global $wpdb;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3166
	$term = get_term($term_id,$taxonomy,OBJECT,'edit');
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3167
	$term->term_order = $wpdb->get_var("SELECT term_order FROM $wpdb->term_relationships WHERE object_id =  $term_id AND term_taxonomy_id = $group_ttid ");
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3168
	return $term;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3169
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3170
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3171
/* *** Functions using the xili-language class *** */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3172
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3173
/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3174
 * function to progressively replace the previous constant THEME_TEXTDOMAIN only usable in mono site
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3175
 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3176
 * @since 1.5.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3177
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3178
function the_theme_domain() {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3179
	global $xili_language;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3180
	return $xili_language->thetextdomain;	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3181
} 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3182
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3183
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3184
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3185
 * Return the current language of theme.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3186
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3187
 * @since 0.9.7
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3188
 * use for other function elsewhere
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3189
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3190
 * @return the slug of language (used in query).
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3191
 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3192
function the_curlang() {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3193
	global $xili_language;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3194
	return $xili_language->curlang;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3195
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3196
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3197
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3198
 * Return the current language and dir of theme.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3199
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3200
 * @since 0.9.9
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3201
 * use for other function elsewhere
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3202
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3203
 * @return array with slug of language (used in query) and dir (ltr or rtl).
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3204
 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3205
function the_cur_lang_dir() {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3206
	global $xili_language;
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3207
	return array( QUETAG=>$xili_language->curlang, 'direction'=>$xili_language->curlang_dir );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3208
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3209
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3210
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3211
 * Return the current group of languages
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3212
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3213
 * @since 0.9.8.3
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3214
 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3215
function the_cur_langs_group_id() {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3216
	global $xili_language;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3217
	return $xili_language->langs_group_id;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3218
} 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3219
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3220
/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3221
 * Return the feature of language
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3222
 * Used by xili_language_list hook to hidden checked language
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3223
 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3224
 * @since 1.8.9.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3225
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3226
function xl_lang_features ( $slug, $param ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3227
	global $xili_language;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3228
	return $xili_language->xili_settings['lang_features'][$slug][$param];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3229
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3230
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3231
/**
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3232
 * Return the current date or a date formatted with strftime.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3233
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3234
 * @since 0.9.7.1
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3235
 * @updated 1.6.0 - timezone offset - http://core.trac.wordpress.org/ticket/11672
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3236
 * can be used in theme for multilingual date
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3237
 * @param format and time (if no time = current date-time)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3238
 * @return the formatted date.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3239
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3240
function the_xili_local_time( $format='%B %d, %Y',$time = null ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3241
	global $xili_language;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3242
	if ($time == null ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3243
		$time = current_time('timestamp'); //to get the Unix timestamp with a timezone offset - 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3244
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3245
	$curslug = $xili_language->curlang;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3246
	$curlang = ( strlen($curslug) == 5 ) ? substr($curslug,0,3).strtoupper(substr($curslug,-2)) : $curslug ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3247
	setlocale(LC_TIME, $curlang); /* work if server is ready */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3248
	$charset = ( $xili_language->xili_settings['lang_features'][$curslug]['charset'] != '' ) ? $xili_language->xili_settings['lang_features'][$curslug]['charset'] : "" ; // 1.8.9.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3249
	if ( "" != $charset  ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3250
	  return htmlentities( strftime(__( $format, the_theme_domain() ),$time), ENT_COMPAT, $charset ); /* ,'UTF-8' entities for some server */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3251
	} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3252
	 	return htmlentities( strftime(__( $format, the_theme_domain() ),$time), ENT_COMPAT );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3253
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3254
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3255
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3256
/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3257
 * Return the current date or a date formatted with strftime according get_option php date format.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3258
 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3259
 * @since 1.6.0, 1.8.9.1, 2.2.2
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3260
 * 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3261
 * can be used in theme for multilingual date 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3262
 * @param format and time (if no time = current date-time)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3263
 * @return the formatted date.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3264
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3265
function the_xili_wp_local_time( $wp_format='F j, Y', $time = null ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3266
	global $xili_language;
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3267
	if ($time == null ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3268
		$time = current_time('timestamp'); //to get the Unix timestamp with a timezone offset - 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3269
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3270
	$curslug = $xili_language->curlang; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3271
	if ( $xili_language->xili_settings['lang_features'][$curslug]['charset'] == 'no_locale' ) { // need to be inside charset input
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3272
		$date_formatted = date ( __($wp_format, the_theme_domain(), $time ) );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3273
		if ( function_exists ( 'xili_translate_date' ) ) 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3274
			return xili_translate_date ( $curslug, $date_formatted );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3275
		else
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3276
			return $date_formatted ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3277
	} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3278
		$curlang = ( strlen($curslug) == 5 ) ? substr($curslug,0,3).strtoupper(substr($curslug,-2)) : $curslug ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3279
		setlocale(LC_TIME, $curlang); /* work if server is ready */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3280
		$format = xiliml_php2loc_time_format_translator (__($wp_format, the_theme_domain())); /* translated by theme mo*/
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3281
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3282
		$charset = ( $xili_language->xili_settings['lang_features'][$curslug]['charset'] != '' ) ? $xili_language->xili_settings['lang_features'][$curslug]['charset'] : "" ; // 1.8.9.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3283
		if ( "" != $charset  ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3284
			return htmlentities(strftime($format, $time),ENT_COMPAT, $charset  ); /* ,'UTF-8' entities for some server - ja char */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3285
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3286
			return htmlentities(strftime($format, $time),ENT_COMPAT  );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3287
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3288
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3289
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3290
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3291
/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3292
 * Return translated format from php time to loc time used in strftime.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3293
 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3294
 * @since 1.6.0 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3295
 * @updated 1.8.1 - add T -> %z, e -> %Z - 1.8.7 T -> %Z (stephen)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3296
 * @ 1.8.9.1 - add n -> %m (japanese)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3297
 * (was formerly in xilidev-libraries)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3298
 * can be used in theme for multilingual date 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3299
 * @param phpformat
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3300
 * @return locale format.
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3301
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3302
function xiliml_php2loc_time_format_translator ( $phpformat = 'm/d/Y H:i' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3303
	/* order left to right to avoid over replacing DON'T MODIFY */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3304
	$phpformchar = array('A' ,'a' ,'D' ,'l' ,'g' ,'d' ,'e' ,'j' ,'z' ,'T' ,'N' ,'w ','W' ,'M' ,'F' ,'h' ,'M ','m' ,'y' ,'Y' ,'H' ,'G' ,'i' ,'S' ,'s' ,'O','n');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3305
	/* doc here: http://fr2.php.net/manual/en/function.date.php */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3306
	$locformchar = array('%p','%P','%a','%A','%l','%d','%Z','%e','%j','%Z','%U','%w','%W','%b','%B','%I', '%h', '%m','%y','%Y','%H','%l','%M', '','%S','%z','%m');
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3307
	/* doc here: http://fr.php.net/manual/en/function.strftime.php */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3308
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3309
   if ('' == $phpformat) $phpformat = 'm/d/Y H:i';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3310
   // use to detect escape char that illustrate date or hour... \h or \m
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3311
   	$ars = explode('\\', $phpformat ); $i=0;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3312
	if ($ars[0] == $phpformat) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3313
		$locform = str_replace($phpformchar, $locformchar,$phpformat);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3314
	} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3315
		$locform = "";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3316
		foreach ($ars as $a) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3317
			if (""!= $a) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3318
			$locform = $locform.((0 == $i) ? str_replace($phpformchar, $locformchar,$a) : substr($a,0,1).str_replace($phpformchar, $locformchar, substr($a,1)) );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3319
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3320
			$i++;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3321
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3322
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3323
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3324
   	return $locform ; 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3325
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3326
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3327
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3328
 * Return the language of current post in loop.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3329
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3330
 * @since 0.9.7.0
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3331
 * @updated 0.9.9, 2.6
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3332
 * useful for functions in functions.php or other plugins
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3333
 * 
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3334
 * @param ID of the post, $type 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3335
 * @return the slug (en_us) or iso (en_US) or name ( english )...
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3336
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3337
function get_cur_language( $post_ID, $type = 'slug' ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3338
	global $xili_language;
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3339
	return $xili_language->get_post_language( $post_ID, $type );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3340
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3341
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3342
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3343
 * Return the lang and dir of language of current post in loop.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3344
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3345
 * @since 0.9.9
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3346
 * useful for functions in functions.php or other plugins
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3347
 * 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3348
 * @param ID of the post
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3349
 * @return array two params : lang (as slug) and direction of lang (ltr or rtl).
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3350
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3351
function get_cur_post_lang_dir( $post_ID ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3352
	global $xili_language;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3353
	return $xili_language->get_cur_language($post_ID);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3354
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3355
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3356
/**
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3357
 * Return languages objects in taxinomy. Useful for hooks as in functions.php of theme
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3358
 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3359
 * @since 1.6.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3360
 * @param $force to avoid buffer
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3361
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3362
 function xili_get_listlanguages( $force = false ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3363
 	global $xili_language;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3364
 	return $xili_language->get_listlanguages( $force );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3365
 }
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3366
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3367
/**
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3368
 * Return language object of a post.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3369
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3370
 * @since 1.1.8
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3371
 * useful for functions in functions.php or other plugins
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3372
 * 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3373
 * @param ID of the post
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3374
 * @return false or object with params as in current term (->description = full name of lang, ->count = number of posts in this language,...
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3375
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3376
function xiliml_get_lang_object_of_post( $post_ID ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3377
	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3378
	$ress = wp_get_object_terms( $post_ID, TAXONAME ); /* lang of target post */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3379
	if ( $ress == array() ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3380
		return false;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3381
	} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3382
		return $ress[0];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3383
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3384
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3385
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3386
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3387
 * Return the language of current browser.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3388
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3389
 * @since 0.9.7.6
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3390
 * @updated 0.9.9
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3391
 * useful for functions in functions.php or other plugins
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3392
 * 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3393
 * @param no
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3394
 * @return the best choice.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3395
 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3396
function choice_of_browsing_language() {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3397
	global $xili_language;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3398
	return $xili_language->choice_of_browsing_language();
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3399
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3400
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3401
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3402
 * Return the lang and dir of current browser.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3403
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3404
 * @since 0.9.9
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3405
 * useful for functions in functions.php or other plugins
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3406
 * 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3407
 * @param no
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3408
 * @return array of the best choice lang and his dir.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3409
 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3410
function choice_of_browsing_lang_dir() {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3411
	global $xili_language;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3412
	$lang = $xili_language->choice_of_browsing_language();
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3413
	$dir = $xili_language->get_dir_of_cur_language($lang);
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3414
	return array( QUETAG => $lang,' direction' => $dir );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3415
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3416
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3417
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3418
 * Activate hooks of plugin in class.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3419
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3420
 * @since 0.9.7.4
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3421
 * can be used in functions.php for special action
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3422
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3423
 * @param filter name and function
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3424
 * 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3425
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3426
function add_again_filter( $filtername, $filterfunction ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3427
	global $xili_language;
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3428
	$xili_language->add_filter( $filtername, $filterfunction );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3429
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3430
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3431
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3432
 * Replace get_category_link to bypass hook from xili_language
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3433
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3434
 * @since 0.9.7.4
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3435
 * @updated 1.0.1
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3436
 * can be used in functions.php for special action needing permalink
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3437
 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3438
 * @param category ID 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3439
 * @return the permalink of passed cat_id.
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3440
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3441
function xiliml_get_category_link( $catid = 0 ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3442
			global $xili_language;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3443
			if ($catid == 0) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3444
				global $wp_query;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3445
				$catid = $wp_query->query_vars['cat'];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3446
			}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3447
			remove_filter('category_link', $xili_language->idx['xiliml_link_append_lang']);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3448
				$catcur = get_category_link($catid); 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3449
			add_again_filter('category_link', 'xiliml_link_append_lang');
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3450
	return $catcur;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3451
}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3452
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3453
/** used by xili widget - usable if you need to create your own template tag 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3454
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3455
 * @since 0.9.9.4
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3456
 * @param quantity of comments
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3457
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3458
 * @return comments objects...
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3459
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3460
function xiliml_recent_comments( $number = 5 ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3461
	global $xili_language;
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3462
	return $xili_language->xiliml_recent_comments( $number );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3463
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3464
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3465
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3466
 * Return full object of a language
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3467
 * @since 1.1.8
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3468
 * @param name (fr_FR) or slug (fr_fr)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3469
 * @return false or full language object (example ->description = full as set in admin UI)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3470
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3471
function xiliml_get_language( $lang_nameorslug="" ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3472
	$language = term_exists( $lang_nameorslug, TAXONAME );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3473
	if ($language) {
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3474
		return get_term( $language['term_id'], TAXONAME,OBJECT, 'edit' );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3475
	} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3476
		return false;	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3477
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3478
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3479
 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3480
 	/* 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3481
	 **
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3482
	 * Template Tags for themes (with current do_action tool some are hookable functions) 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3483
	 **
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3484
	 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3485
	 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3486
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3487
 * Template Tag insertable in search form for sub-selection of a language
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3488
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3489
 * @since 0.9.7
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3490
 * @updated 1.8.2
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3491
 * can be used in theme template
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3492
 * example: if(class_exists('xili_language')) xiliml_langinsearchform()
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3493
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3494
 * hook: add_action('xiliml_langinsearchform','your_xiliml_langinsearchform',10,2) to change its behaviour elsewhere
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3495
 * @param html tags 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3496
 * @return echo the list as radio-button
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3497
 */	 
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3498
function xiliml_langinsearchform ( $before='', $after='', $echo = true ) { /* list of radio buttons for search form*/
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3499
	global $xili_language;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3500
	if ($xili_language->this_has_filter('xiliml_langinsearchform')){ 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3501
		remove_filter('xiliml_langinsearchform',$xili_language->idx['xiliml_langinsearchform']); /*no default from class*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3502
	}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3503
	if ( $echo ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3504
		echo apply_filters( 'xiliml_langinsearchform', $before, $after, $echo);	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3505
	} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3506
		return apply_filters( 'xiliml_langinsearchform', $before, $after, $echo);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3507
	}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3508
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3509
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3510
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3511
 * Template Tag - replace the_category() tag of WP Core
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3512
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3513
 * @since 0.9.0
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3514
 * @updated 1.4.2 - default value to post_ID
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3515
 * can be used in theme template in each post in loop
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3516
 * example: if(class_exists('xili_language')) xiliml_the_category($post->ID)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3517
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3518
 * hook: add_action('xiliml_the_category','your_xiliml_the_category',10,3) to change its behaviour elsewhere
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3519
 * @param post_id separator echo (true by default) 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3520
 * @return echo (by default) the list of cats with comma separated...
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3521
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3522
function xiliml_the_category( $post_ID = 0, $separator = ', ' , $echo = true ) { /* replace the_category() */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3523
	global $xili_language, $post;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3524
	if ($post_ID == 0) $post_ID = $post->ID;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3525
	if ($xili_language->this_has_filter('xiliml_the_category')){ 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3526
		remove_filter('xiliml_the_category',$xili_language->idx['xiliml_the_category']); /*no default from class*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3527
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3528
	do_action('xiliml_the_category',$post_ID,$separator,$echo);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3529
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3530
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3531
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3532
 * Template Tag - in loop display the link of other posts defined as in other languages
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3533
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3534
 * @since 0.9.0
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3535
 * @updated 0.9.9.2, 1.1 (can return an array of lang + id)
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3536
 * @updated 1.4.2 - default value to post_ID
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3537
 * can be used in theme template in single.php under the title
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3538
 * example: if(class_exists('xili_language')) xiliml_the_other_posts($post->ID)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3539
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3540
 * hook: add_action('xiliml_the_other_posts','your_xiliml_the_other_posts',10,3) to change its behaviour elsewhere
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3541
 * @param post_id, before, separator, type (echo, array).
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3542
 * @return echo (by default) the list 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3543
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3544
function xiliml_the_other_posts ( $post_ID = 0, $before = "This post in", $separator = ", ", $type = "display" ) { /* display the other posts defined as in other lang */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3545
	global $xili_language, $post;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3546
	if ($post_ID == 0) $post_ID = $post->ID;
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3547
	if ($xili_language->this_has_filter('xiliml_the_other_posts')){ 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3548
		remove_filter('xiliml_the_other_posts',$xili_language->idx['xiliml_the_other_posts']); /*no default from class*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3549
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3550
	return apply_filters('xiliml_the_other_posts',$post_ID, $before, $separator,$type);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3551
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3552
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3553
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3554
 * Template Tag - in loop display the language of the post
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3555
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3556
 * @since 0.9.0
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3557
 * can be used in theme template in loop under the title
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3558
 * example: if(class_exists('xili_language')) xili_post_language()
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3559
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3560
 * hook: add_action('xili_post_language','your_xili_post_language',10,2) to change its behaviour elsewhere
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3561
 * @param before after 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3562
 * @return echo (by default) the language 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3563
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3564
function xili_post_language( $before = '<span class="xili-lang">(', $after =')</span>' ) { /* post language in loop*/
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3565
	do_action( 'xili_post_language',$before, $after );
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3566
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3567
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3568
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3569
 * Template Tag - outside loop (sidebar) display the languages of the site (used also by widget)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3570
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3571
 * @since 0.9.0
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3572
 * @updated 0.9.7.4
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3573
 * @udpated 1.8.9.1 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3574
 * can be used in theme template in sidebar menu or header menu
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3575
 * example: if(class_exists('xili_language')) xili_language_list()
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3576
 * theoption param is used to define type of display according places (sidebar / header) in theme (see dev.xiligroup.com)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3577
 *
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3578
 * hook: add_action('xili_language_list','your_xili_language_list',10,5) to change its behaviour elsewhere
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3579
 * @param before after theoption
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3580
 * @return echo the list of languages
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3581
 * @hidden don't list hidden languages
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3582
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3583
function xili_language_list( $before = '<li>', $after ='</li>', $theoption='', $echo = true, $hidden = false ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3584
	
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3585
	global $xili_language;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3586
	if ($xili_language->this_has_filter('xili_language_list')){ 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3587
		remove_filter('xili_language_list',$xili_language->idx['xili_language_list']); /*no default from class*/
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3588
	}	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3589
	return apply_filters('xili_language_list', $before, $after, $theoption, $echo, $hidden ); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3590
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3591
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3592
/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3593
 * function to get id, link or permalink of linked post in target lang
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3594
 * to replace get_post_meta($post->ID, 'lang-'.$language->slug, true) soon obsolete
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3595
 * @since 1.8.9.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3596
 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3597
 * @updated 2.1.0 - permalink as 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3598
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3599
function xl_get_linked_post_in ( $fromID, $lang, $info = 'id' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3600
	global $xili_language;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3601
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3602
	$language = xiliml_get_language( $lang ); /* test if lang is available */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3603
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3604
	if ( $language !== false ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3605
		$otherpost = get_post_meta( $fromID, QUETAG.'-'.$language->slug, true ); // will be soon changed
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3606
		if ( $info == 'permalinknav') return  $xili_language ->link_of_linked_post ( $fromID, $language->slug );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3607
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3608
		if ( $otherpost ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3609
			switch ( $info ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3610
				case 'id';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3611
					$output = $otherpost;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3612
					break;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3613
				case 'link';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3614
					$post = get_post($otherpost);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3615
			        if ( isset($post->post_type) ){
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3616
			         	if ( 'post' == $post->post_type ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3617
							$output = home_url('?p=' . $otherpost);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3618
			         	} elseif ( 'post' == $post->post_type ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3619
			         		$output = home_url('?page_id=' . $otherpost);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3620
			         	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3621
			        }
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3622
					break;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3623
				case 'permalink';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3624
					$output = get_permalink( $otherpost );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3625
					break;	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3626
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3627
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3628
			switch ( $info ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3629
				case 'id';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3630
					$output = 0; // false
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3631
					break;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3632
				case 'link';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3633
					$output = '#';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3634
					break;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3635
				case 'permalink';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3636
					$output = '#';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3637
					break;	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3638
			}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3639
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3640
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3641
		return $output;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3642
	}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3643
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3644
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3645
/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3646
 * Insert automatically some languages items at end in menu
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3647
 * @since 1.6.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3648
 * @updated 1.7.1 - add optionally wp_page_list result
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3649
 * @updated 1.8.1 - choose good menu location
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3650
 * @updated 1.8.9 - add filter (example: add_filter ('xili_nav_lang_list', 'my_xili_nav_lang_list', 10, 3);)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3651
 *					 and class for separator  ( example: li.menu-separator a {display:none;})
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3652
 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3653
 * updated 2.1.0 - for multiple navmenu locations - CAUTION new filter: xili_nav_lang_lists (with s at end)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3654
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3655
function xili_nav_lang_list( $items, $args ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3656
	global $xili_language;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3657
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3658
	if ( isset ( $xili_language->xili_settings['navmenu_check_options'] ) ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3659
		$navmenu_check_options = $xili_language->xili_settings['navmenu_check_options']; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3660
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3661
		if ( has_filter( 'xili_nav_lang_lists' ) ) return apply_filters ( 'xili_nav_lang_lists',  $items, $args, $navmenu_check_options );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3662
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3663
		if ( isset ( $navmenu_check_options[$args->theme_location] ) && $navmenu_check_options[$args->theme_location]['navenable'] == 'enable' ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3664
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3665
			$navmenu = ( '' != $navmenu_check_options[$args->theme_location]['navtype'] ) ? $navmenu_check_options[$args->theme_location]['navtype'] : "navmenu-1";
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3666
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3667
			$end = xili_language_list( '<li>', '</li>', $navmenu, false, true ) ; // don't display hidden languages
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3668
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3669
	   		return $items.'<li class="menu-item menu-separator" ><a>|</a></li>'.$end; // class for display none... 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3670
	   	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3671
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3672
			return $items;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3673
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3674
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3675
	} else { // if settings not updated since updated by admin user
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3676
		$navmenu_check_option = $xili_language->xili_settings['navmenu_check_option'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3677
		if ( has_filter( 'xili_nav_lang_list' ) ) return apply_filters ( 'xili_nav_lang_list',  $items, $args, $navmenu_check_option );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3678
		if ( $args->theme_location  ==  $navmenu_check_option ) { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3679
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3680
			$end = xili_language_list( '<li>', '</li>', 'navmenu', false, true ) ; // don't display hidden languages 1.8.9.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3681
			
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3682
   			return $items.'<li class="menu-item menu-separator" ><a>|</a></li>'.$end; // class for display none... 1.8.9 no ID for instantiations
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3683
   	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3684
		} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3685
			return $items;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3686
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3687
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3688
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3689
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3690
/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3691
 * Insert automatically some pages items at end in menu
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3692
 * @since 1.7.1 - add optionally wp_page_list result
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3693
 * @updated 1.8.1 - choose good menu location
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3694
 * @updated 1.8.9 - add filter (example: add_filter ('xili_nav_page_list', 'my_xili_nav_page_list', 10, 3);)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3695
 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3696
 */ 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3697
function xili_nav_page_list( $items, $args ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3698
	global $xili_language;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3699
	$navmenu_check_option = $xili_language->xili_settings['navmenu_check_optionp'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3700
	if ( has_filter( 'xili_nav_page_list' ) ) return apply_filters ( 'xili_nav_page_list',  $items, $args, $navmenu_check_option );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3701
	if ( $navmenu_check_option == $args->theme_location ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3702
		$pagelist = ''; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3703
		$pagelist_args = $xili_language->xili_settings['args_page_in_nav_menu'].'&';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3704
		// sub-selection
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3705
		$pagelist = wp_list_pages($pagelist_args."title_li=&echo=0&".QUETAG."=".$xili_language->curlang);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3706
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3707
   		return $items.$pagelist;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3708
   	} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3709
		return $items;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3710
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3711
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3712
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3713
/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3714
 * modify automatically home page item in nav menu - exemple for twentyten child menu
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3715
 * @since 1.8.9.2 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3716
 *  
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3717
 * filter (example: add_filter ('xili_nav_page_home_item', 'my_xili_nav_page_home_item', 10, 5);)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3718
 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3719
 */ 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3720
function xili_nav_page_home_item( $item_output, $item, $depth, $args ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3721
	global $xili_language;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3722
	$homemenu_check_option = $xili_language->xili_settings['home_item_nav_menu'];
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3723
	if ( has_filter( 'xili_nav_page_home_item' ) ) return apply_filters ( 'xili_nav_page_home_item',  $item_output, $item, $depth, $args, $homemenu_check_option ); // fixed 2.8
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3724
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3725
	if ( $item->url == get_option('siteurl').'/'  ) { // page or list
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3726
		$curlang = $xili_language->curlang ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3727
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3728
		$attributes  = ! empty( $item->attr_title ) ? ' title="'  . __( esc_attr( $item->attr_title ), $xili_language->thetextdomain ) .'"' : ''; //
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3729
		$attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3730
		$attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3731
		$attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'?'.QUETAG.'='.$curlang.'"' : ''; //
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3732
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3733
		$item_output = $args->before;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3734
		$item_output .= '<a'. $attributes .'>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3735
		$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3736
		$item_output .= '</a>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3737
		$item_output .= $args->after;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3738
		return $item_output;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3739
   	} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3740
		return $item_output;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3741
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3742
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3743
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3744
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3745
/*
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3746
 * sub selection of pages for wp_list_pages()
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3747
 * @ since 090504 - exemple of new function add here or addable in functions.php
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3748
 * © xiligroup.dev
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3749
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3750
 * only called if xili-language plugin is active and query tag 'lang' is in wp_list_pages template tag
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3751
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3752
 * example 1 : wp_list_pages('title_li=&lang='.the_curlang() ); will display only pages of current lang
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3753
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3754
 * example 2 : wp_list_pages('title_li=&setlang=0&lang='.the_curlang() ); will display pages of current lang AND pages with lang undefined (polyglot pages).
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3755
 * example 3 : wp_list_pages('title_li=&echo=0&include=2,10&lang='); will display pages of current lang (new since 2.2.2) useful with xili-widget plugin
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3756
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3757
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3758
function ex_pages_by_lang ( $pages, $r ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3759
	if (isset($r[QUETAG]) && !empty($pages) && function_exists('get_cur_post_lang_dir')) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3760
		$keepundefined = null;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3761
		if (isset($r['setlang'])) { 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3762
			if ($r['setlang'] == 0 || $r['setlang'] == 'false') $keepundefined = false;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3763
			if ($r['setlang'] == 1 || $r['setlang'] == 'true') $keepundefined = true;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3764
		}	
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3765
		$resultingpages = array(); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3766
		if ( $r[QUETAG] == "" ) $r[QUETAG] = the_curlang(); // when param is here but empty = cur lang of page - 2.2.2 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3767
		foreach ($pages as $page) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3768
			$post_lang_dir = get_cur_post_lang_dir($page->ID);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3769
			if ($post_lang_dir === $keepundefined) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3770
					$resultingpages[] = $page;
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3771
			} elseif ($post_lang_dir[QUETAG] == $r[QUETAG] ) {
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3772
					$resultingpages[] = $page;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3773
			}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3774
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3775
		return $resultingpages;	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3776
	} else {	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3777
	 	return $pages;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3778
	}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3779
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3780
add_filter('get_pages','ex_pages_by_lang',10,2);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3781
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3782
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3783
 * functions to change and restore loop's query tag
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3784
 * (useful for sidebar widget - see functions table)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3785
 * @since 1.3.0
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3786
 * @param  lang to modify query_tag - 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3787
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3788
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3789
function xiliml_force_loop_lang ( $lang_query_tag ){
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3790
	global $xili_language, $wp_query;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3791
	$xili_language->temp_lang_query_tag = $wp_query->query_vars[QUETAG];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3792
	$wp_query->query_vars[QUETAG] = $lang_query_tag;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3793
	$xili_language->current_lang_query_tag = $wp_query->query_vars[QUETAG];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3794
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3795
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3796
function xiliml_restore_loop_lang (){
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3797
	global $xili_language, $wp_query;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3798
	$wp_query->query_vars[QUETAG] = $xili_language->temp_lang_query_tag;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3799
	$xili_language->current_lang_query_tag = $wp_query->query_vars[QUETAG];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3800
}
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3801
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3802
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3803
 * functions to permit lang query tag
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3804
 * (useful for WP_Query)
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3805
 * @since 1.3.2
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3806
 * example: add_action('parse_query','xiliml_add_lang_to_parsed_query');
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3807
 *		$r = new WP_Query($thequery);
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3808
 *		remove_filter('parse_query','xiliml_add_lang_to_parsed_query'); 
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3809
 * used by class xili_Widget_Recent_Posts
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3810
 */
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3811
function xiliml_add_lang_to_parsed_query ($theclass = array()) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3812
		global $wp_query;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3813
		$query = $theclass->query;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3814
		if (is_array($query)) {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3815
			$r = $query;
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3816
		} else {
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3817
			parse_str($query, $r); 	
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3818
		}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3819
		if (array_key_exists(QUETAG,$r)) $wp_query->query_vars[QUETAG] = $r[QUETAG];
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3820
}
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3821
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3822
/* ****** functions and filter added for new default theme named twentyten and twenty-eleven (since WP 3.0) ******* */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3823
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3824
/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3825
 * in twentyten theme: display the time of current post when mouse is on date 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3826
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3827
function xiliml_get_the_translated_time( $thetime, $format = '' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3828
	global $xili_language;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3829
	if ( $xili_language->xili_settings['wp_locale'] == 'db_locale' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3830
		$theformat = (''== $format) ? get_option('time_format') : $format ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3831
		return the_xili_wp_local_time( $theformat, strtotime(xiliml_get_the_time('m/d/Y H:i'))); // old method locale
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3832
	} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3833
		return $thetime; // new mode wp_locale ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3834
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3835
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3836
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3837
/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3838
 * Clone w/o filter 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3839
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3840
function xiliml_get_the_time( $d = '', $post = null ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3841
	$post = get_post($post);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3842
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3843
	if ( '' == $d )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3844
		$the_time = get_post_time(get_option('time_format'), false, $post, true);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3845
	else
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3846
		$the_time = get_post_time($d, false, $post, true);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3847
	return $the_time; /* without filter */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3848
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3849
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3850
/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3851
 * in twentyten theme: display the date of current post 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3852
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3853
function xiliml_get_translated_date( $thedate, $format = '' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3854
	global $xili_language;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3855
	$theformat = (''== $format) ? get_option('date_format') : $format ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3856
	if ( $xili_language->xili_settings['wp_locale'] == 'db_locale' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3857
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3858
		return the_xili_wp_local_time( $theformat, strtotime(xiliml_get_the_date('m/d/Y H:i')));
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3859
	} else { 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3860
		//echo $theformat ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3861
		return $thedate ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3862
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3863
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3864
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3865
if ( !is_admin() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3866
	add_filter( 'get_the_time', 'xiliml_get_the_translated_time', 10, 3);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3867
	add_filter( 'get_the_date', 'xiliml_get_translated_date', 10, 2);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3868
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3869
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3870
/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3871
 * Clone w/o filter 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3872
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3873
function xiliml_get_the_date( $d = '' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3874
	global $post;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3875
	$the_date = '';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3876
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3877
	if ( '' == $d )
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3878
		$the_date .= mysql2date(get_option('date_format'), $post->post_date);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3879
	else
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3880
		$the_date .= mysql2date($d, $post->post_date);
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3881
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3882
	return $the_date; /* without filter */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3883
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3884
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3885
/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3886
 * filter for template tag: get_comment_date() 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3887
 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3888
function xiliml3_comment_date( $comment_time, $format = '' ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3889
  $theformat = ( ''== $format ) ? get_option( 'date_format' ) : $format ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3890
  return the_xili_wp_local_time( $theformat, strtotime(get_comment_time ( 'm/d/Y H:i' ) ) ); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3891
  /* impossible to use get_comment_date as it is itself filtered*/
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3892
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3893
if ( !is_admin() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3894
	add_filter( 'get_comment_date', 'xiliml3_comment_date',10 ,2 );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3895
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3896
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3897
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3898
/****************** instantiation Class *****************/
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3899
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3900
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3901
/**
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3902
 * instantiation of xili_language class
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3903
 *
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3904
 * @since 1.8.8 to verify that WP 3.0 is installed
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3905
 * @updated for 1.8.9, 2.3.1, 2.7.1 (function)
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3906
 *
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3907
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3908
function xili_language_start () {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3909
	global $wp_version, $xili_language;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3910
	if ( version_compare(PHP_VERSION, XILILANGUAGE_PHP_VER, '<') ){
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3911
		add_action( 'admin_notices', 'xili_language_need_php5' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3912
		return;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3913
	} elseif ( version_compare($wp_version, XILILANGUAGE_WP_VER, '<') && XILILANGUAGE_VER > XILILANGUAGE_PREV_VER ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3914
		add_action( 'admin_notices', 'xili_language_need_31' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3915
		return;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3916
	} else {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3917
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3918
		// new sub-folder since 2.6
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3919
	    require_once ( plugin_dir_path( __FILE__ ) . 'xili-includes/xili-language-widgets.php' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3920
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3921
	
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3922
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3923
		/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3924
	 	 * instantiation of xili_language class
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3925
	 	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3926
	 	 * @since 0.9.7 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3927
	 	 * @updated 2.6 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3928
	 	 *
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3929
	 	 * 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3930
	 	 * @param locale_method (true for cache compatibility... in current tests with johan.eenfeldt@kostdoktorn.se)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3931
	 	 * @param future version
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3932
	 	 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3933
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3934
		$xili_language = new xili_language( false , false ); 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3935
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3936
		if ( is_admin() ) {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3937
			$plugin_path = dirname(__FILE__) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3938
			require( $plugin_path . '/xili-includes/xl-class-admin.php' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3939
			$xili_language_admin = new xili_language_admin( $xili_language );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3940
		}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3941
		
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3942
		/**
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3943
		 * Enable to add functions and filters that are not in theme's functions.php
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3944
		 * These filters are common even if you change default theme...
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3945
		 * Place your functions.php in folder plugins/xilidev-libraries/
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3946
		 * if you have a filter in this file, avoid to have similar one in functions.php of the theme !!!
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3947
		 * 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3948
		 * (for tests, check / uncheck 'enable gold functions' in settings UI)
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3949
		 * @since 1.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3950
		 * @updated 1.4.0
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3951
		 */
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3952
		$xili_language->insert_gold_functions ();
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3953
	}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3954
}
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3955
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3956
add_action( 'plugins_loaded', 'xili_language_start', 13 ); // before xili-dictionary (20) and xili_tidy_tags (15) - 2.7.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3957
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3958
// to fixe event in WP 3.4 - 2.7.1
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3959
function xili_test_lang_perma () {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3960
	global $xili_language ; 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3961
	$xili_language->lang_perma = ( has_filter ( 'term_link', 'insert_lang_4cat' ) ) ? true : false ;	// 1.4.1 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3962
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3963
add_action( 'wp', 'xili_test_lang_perma', 1 );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3964
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3965
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3966
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3967
/** 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3968
 * errors messages 
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3969
 */
194
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3970
 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3971
function xili_language_need_php5() {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3972
		global $wp_version;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3973
		load_plugin_textdomain( 'xili_language_errors', false, 'xili-language/languages' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3974
		echo '<div id="message" class="error fade"><p>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3975
		echo '<strong>'.__( 'Installation of xili-language is not completed.', 'xili_language_errors' ) . '</strong>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3976
		echo '<br />';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3977
		printf( __( 'This xili-language version (%s) need PHP Version more than %s; installed release is %s.', 'xili_language_errors' ), XILILANGUAGE_VER , XILILANGUAGE_PHP_VER, PHP_VERSION ) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3978
		echo '<br />';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3979
		printf( __( 'Find a server with PHP Version to more %s or use xili-language version less or equal to %s', 'xili_language_errors' ), XILILANGUAGE_PHP_VER, XILILANGUAGE_PREV_VER );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3980
		echo '</p></div>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3981
} 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3982
 
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3983
function xili_language_need_31() {
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3984
		global $wp_version;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3985
		load_plugin_textdomain( 'xili_language_errors', false, 'xili-language/languages' );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3986
		echo '<div id="message" class="error fade"><p>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3987
		echo '<strong>'.__( 'Installation of xili-language is not completed.', 'xili_language_errors' ) . '</strong>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3988
		echo '<br />';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3989
		printf( __( 'This xili-language version (%s) need WordPress Version more than %s; installed release is %s.', 'xili_language_errors' ), XILILANGUAGE_VER , XILILANGUAGE_WP_VER, $wp_version) ;
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3990
		echo '<br />';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3991
		printf( __( 'Upgrade WordPress Version to more %s or use xili-language version less than %s', 'xili_language_errors' ), XILILANGUAGE_WP_VER, XILILANGUAGE_PREV_VER );
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3992
		echo '</p></div>';
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3993
}
32102edaa81b MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents: 180
diff changeset
  3994
170
8e3a5a6fc63e English version just for user loged view
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
  3995
?>