Created
June 4, 2021 17:25
-
-
Save flyingwebie/2a09819f26809b73a83f51a6ed76b894 to your computer and use it in GitHub Desktop.
Polylang condition in Oxygen: how to use one template for different languages
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
/** | |
* | |
* Reference: https://oxywp.com/polylang-condition-in-oxygen/ | |
*/ | |
<?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); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment