Last active
November 25, 2024 06:15
-
-
Save KittenCodes/e7a7207dc56155473cd2f572e27e09ad to your computer and use it in GitHub Desktop.
Language Conditions for Oxygen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( function_exists('oxygen_vsb_register_condition') && function_exists('pll_languages_list') ) { | |
$lang_list = pll_languages_list(); | |
oxygen_vsb_register_condition( | |
//Condition Name | |
'Locale', | |
//Values | |
array( | |
'options' => $lang_list, | |
'custom' => false | |
), | |
//Operators | |
array('==', '!='), | |
//Callback Function | |
'polylang_callback', | |
//Condition Category | |
'Polylang' | |
); | |
function polylang_callback($value, $operator) { | |
$my_lang = pll_current_language(); | |
global $OxygenConditions; | |
return $OxygenConditions->eval_string($my_lang, $value, $operator); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( function_exists('oxygen_vsb_register_condition') && function_exists('weglot_get_languages_available') ) { | |
$lang_list_full = weglot_get_languages_available(); | |
$lang_list = array(); | |
foreach ($lang_list_full as $code => $value) { | |
$lang_list[] = $code; | |
} | |
oxygen_vsb_register_condition( | |
//Condition Name | |
'Locale', | |
//Values | |
array( | |
'options' => $lang_list, | |
'custom' => false | |
), | |
//Operators | |
array('==', '!='), | |
//Callback Function | |
'weglot_callback', | |
//Condition Category | |
'Weglot' | |
); | |
function weglot_callback($value, $operator) { | |
$my_lang = weglot_get_current_language(); | |
global $OxygenConditions; | |
return $OxygenConditions->eval_string($my_lang, $value, $operator); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// WPML condition | |
if (function_exists('oxygen_vsb_register_condition')) { | |
$lang_list_full = icl_get_languages(); | |
$lang_list = array(); | |
foreach($lang_list_full as $code) { | |
$lang_list[] = $code['code']; | |
} | |
oxygen_vsb_register_condition( | |
//Condition Name | |
'Language', | |
//Values | |
array( | |
'options' => $lang_list, | |
'custom' => false | |
), | |
//Operators | |
array('==', '!='), | |
//Callback Function | |
'wpml_callback', | |
//Condition Category | |
'WPML' | |
); | |
function wpml_callback($value, $operator) { | |
$my_lang = ICL_LANGUAGE_CODE; | |
global $OxygenConditions; | |
return $OxygenConditions -> eval_string($my_lang, $value, $operator); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you need to wrap it around an init action