# polylang/0.9.3/include/api.php

Polylang, version 0.9.3. 63 lines.

- Page: https://pluginprobe.com/plugins/polylang/0.9.3/code/include/api.php
- Raw: https://pluginprobe.com/plugins/polylang/0.9.3/raw/include/api.php
- Modified: 2012-10-08T19:24:28+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/polylang/0.9.3/code/include/api.php#L10-L20`.

```php
<?php

// template tag: displays the language switcher
function pll_the_languages($args = '') {
	global $polylang;
	return isset($polylang) ? $polylang->the_languages($args) : '';
}

// returns the current language
function pll_current_language($args = 'slug') {
	global $polylang;
	return isset($polylang) ? $polylang->current_language($args) : false;
}

// among the post and its translations, returns the id of the post which is in the language represented by $slug
function pll_get_post($post_id, $slug = false) {
	global $polylang;
	$slug = $slug ? $slug : pll_current_language();
	return isset($polylang) && $slug ? $polylang->get_post($post_id, $slug) : null;
}

// among the term and its translations, returns the id of the term which is in the language represented by $slug
function pll_get_term($term_id, $slug = false) {
	global $polylang;
	$slug = $slug ? $slug : pll_current_language();
	return isset($polylang) && $slug ? $polylang->get_term($term_id, $slug) : null;
}

// returns the home url in the right language
function pll_home_url() {
	global $polylang;
	return isset($polylang) ? $polylang->get_home_url() : home_url('/');
}

// register strings for translation in the "strings translation" panel
function pll_register_string($name, $string, $multiline = false) {
	global $polylang;
	if (isset($polylang) && is_admin())
		$polylang->register_string($name, $string, $multiline);
}

// translates string (previously registered with pll_register_string)
function pll__($string) {
	return __($string, 'pll_string');
}

// echoes translated string (previously registered with pll_register_string)
function pll_e($string) {
	_e($string, 'pll_string');
}

// compatibility with WPML string translation API
if (!function_exists('icl_register_string') && !function_exists('icl_t')) {
	function icl_register_string($context, $name, $string) {
		pll_register_string($name, $string);
	}

	function icl_t($context, $name, $string) {
		return pll__($string);
	}
}
?>

```
