dev.xiligroup est en travaux › Forums › xili-language plugin › Switch language if the one of visitor browser is not available
Taggé: class, filter, oop, php, rule, switch language, visitor browser's language, warning, wp eCommerce
Ce sujet contient 0 réponses et 3 voix, et a été mis à jour par xiligroup dev il y a Il y a 13 ans, 12 mois.
-
AuteurArticles
-
18 October 2011 at 6:51 #2994
Anonymeare you able to write in php and create a small function ?
18 October 2011 at 13:58 #2996
AnonymeYes, I’ve tried to hook the function that sets the language through a custom function in my functions.php file but I had errors telling that I was not in OOP anymore (because of the « this « tag of the original function that I’ve copied).
Basically I was looping through the available languages and if none was found then I returned « it_it » as the current one.
Thanks for the help
18 October 2011 at 15:25 #2997as readable in code of plugin itself or in multilingual-functions.php in theme named twentyten-xili, you must replace $this by the global $xili_language created when class is instantiated.
http://multilingual.wpmu.xilione.com/
function my_function() {
if ( class_exists('xili_language') ) {
global $xili_language;
if (for your specific case… give me a little time !
20 October 2011 at 13:15 #3000
Anonymethanks for your help, hoping to hear from you soon
22 October 2011 at 13:39 #3002
Anonymethe key filter named ‘choice_of_browsing_language’ for this purpose is called in a function (at around line #1700 in plugin)… and when an external filter is available don’t execute the core function.
function choice_of_browsing_language() {
if ( has_filter('choice_of_browsing_language') ) return apply_filters('choice_of_browsing_language');
....so in your functions.php create your own filter by studying before the current function inside plugin code…
function edo_choice_of_browsing_language() {
...
/// edo rules
return $lang_slug;
}
add_filter ( 'choice_of_browsing_language', 'edo_choice_of_browsing_language' );30 October 2011 at 16:44 #3006
Anonymethanks for your feedback. Just one thing: I have an error saying:
Warning: Missing argument 2 for apply_filters(), called in /Users/Edoardo/Sites/laletterag.it/wp-content/plugins/xili-language/xili-language.php on line 1721 and defined in /Users/Edoardo/Sites/laletterag.it/wp-includes/plugin.php on line 134
so I’ve checked around and it seems that apply_filters() has 2 variables and in xili_language.php there is only one. If I put a random variable $hello it works without showing the error.
from
if ( has_filter(‘choice_of_browsing_language’) ) return apply_filters(‘choice_of_browsing_language’);
to
if ( has_filter(‘choice_of_browsing_language’) ) return apply_filters(‘choice_of_browsing_language’, $hello);
Is it me or there is a minor bug?
31 October 2011 at 7:50 #3007Thanks,
this warning occur on some server (php ?) need one arg by default… next version 2.3.1 will fixe this message.. by including a ».
-
AuteurArticles
Vous devez être connecté pour répondre à ce sujet.
