Created
April 7, 2021 10:30
-
-
Save yankiara/3059be583ab6bbfe89fbe062f28e642e to your computer and use it in GitHub Desktop.
Polylang helpers and translatable strings
This file contains hidden or 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 | |
function plang() { | |
if ( function_exists('pll_current_language') ) | |
return pll_current_language('slug'); | |
else | |
return 'fr'; | |
} | |
function phome() { | |
if ( plang() == 'fr' ) | |
return '/'; | |
else | |
return '/' . plang() . '/'; | |
} | |
function pl__($string) { | |
if ( function_exists('pll__') ) | |
return pll__($string); | |
else | |
return $string; | |
} | |
function pl_e($string) { | |
if ( function_exists('pll_e') ) | |
pll_e($string); | |
else | |
echo $string; | |
} | |
if ( function_exists('pll_register_string') ) { | |
pll_register_string( 'projectname', 'A really interesting string to translate', 'projectname' ); | |
pll_register_string( 'projectname', 'Another one', 'projectname' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment