| 1 |
<?php |
| 2 |
|
| 3 |
// template tag: displays the language switcher |
| 4 |
function pll_the_languages($args = '') { |
| 5 |
global $polylang; |
| 6 |
return isset($polylang) ? $polylang->the_languages($args) : ''; |
| 7 |
} |
| 8 |
|
| 9 |
// among the post and its translations, returns the id of the post which is in the language represented by $slug |
| 10 |
function pll_get_post($post_id, $slug) { |
| 11 |
global $polylang; |
| 12 |
return isset($polylang) ? $polylang->get_post($post_id, $slug) : null; |
| 13 |
} |
| 14 |
|
| 15 |
// among the term and its translations, returns the id of the term which is in the language represented by $slug |
| 16 |
function pll_get_term($term_id, $slug) { |
| 17 |
global $polylang; |
| 18 |
return isset($polylang) ? $polylang->get_term($term_id, $slug) : null; |
| 19 |
} |
| 20 |
|
| 21 |
// acts as is_front_page but knows about translated front page |
| 22 |
function pll_is_front_page() { |
| 23 |
global $polylang; |
| 24 |
return isset($polylang) ? $polylang->is_front_page() : null; |
| 25 |
} |
| 26 |
|
| 27 |
// register strings for translation in the "strings translation" panel |
| 28 |
function pll_register_string($name, $string) { |
| 29 |
global $polylang; |
| 30 |
if ($polylang) |
| 31 |
$polylang->register_string($name, $string); |
| 32 |
} |
| 33 |
|
| 34 |
// translates string (previously registered with pll_register_string) |
| 35 |
function pll__($string) { |
| 36 |
return __($string, 'pll_string'); |
| 37 |
} |
| 38 |
|
| 39 |
// echoes translated string (previously registered with pll_register_string) |
| 40 |
function pll_e($string) { |
| 41 |
_e($string, 'pll_string'); |
| 42 |
} |
| 43 |
?> |
| 44 |
|