| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Manages links related functions |
| 5 |
* |
| 6 |
* @since 1.2 |
| 7 |
*/ |
| 8 |
class PLL_Links { |
| 9 |
public $links_model, $model, $options; |
| 10 |
|
| 11 |
/** |
| 12 |
* Constructor |
| 13 |
* |
| 14 |
* @since 1.2 |
| 15 |
* |
| 16 |
* @param object $polylang |
| 17 |
*/ |
| 18 |
public function __construct( &$polylang ) { |
| 19 |
$this->links_model = &$polylang->links_model; |
| 20 |
$this->model = &$polylang->model; |
| 21 |
$this->options = &$polylang->options; |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Returns the home url in the requested language |
| 26 |
* |
| 27 |
* @since 1.3 |
| 28 |
* |
| 29 |
* @param object|string $language |
| 30 |
* @param bool $is_search optional whether we need the home url for a search form, defaults to false |
| 31 |
*/ |
| 32 |
public function get_home_url( $language, $is_search = false ) { |
| 33 |
$language = is_object( $language ) ? $language : $this->model->get_language( $language ); |
| 34 |
return $is_search ? $language->search_url : $language->home_url; |
| 35 |
} |
| 36 |
} |
| 37 |
|