Skip to content

Instantly share code, notes, and snippets.

@flyingwebie
Created June 4, 2021 17:25
Show Gist options
  • Save flyingwebie/2a09819f26809b73a83f51a6ed76b894 to your computer and use it in GitHub Desktop.
Save flyingwebie/2a09819f26809b73a83f51a6ed76b894 to your computer and use it in GitHub Desktop.
Polylang condition in Oxygen: how to use one template for different languages
/**
*
* 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