dev.xiligroup is being renovated › Forums › xili-language plugin › Switch language if the one of visitor browser is not available
Tagged: class, filter, oop, php, rule, switch language, visitor browser's language, warning, wp eCommerce
This topic contains 0 replies, has 3 voices, and was last updated by xiligroup dev 12 years, 10 months ago.
-
AuthorPosts
-
October 18, 2011 at 6:51 #2994
Anonymousare you able to write in php and create a small function ?
October 18, 2011 at 13:58 #2996
AnonymousYes, 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
October 18, 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 !
October 20, 2011 at 13:15 #3000
Anonymousthanks for your help, hoping to hear from you soon
October 22, 2011 at 13:39 #3002
Anonymousthe 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' );October 30, 2011 at 16:44 #3006
Anonymousthanks 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?
October 31, 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 ».
-
AuthorPosts
You must be logged in to reply to this topic.