| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* links model abstract class |
| 5 |
* |
| 6 |
* @since 1.5 |
| 7 |
*/ |
| 8 |
abstract class PLL_Links_Model { |
| 9 |
public $model, $options; |
| 10 |
public $home; // used to store the home url before it is filtered |
| 11 |
public $using_permalinks; |
| 12 |
|
| 13 |
/* |
| 14 |
* constructor |
| 15 |
* |
| 16 |
* @since 1.5 |
| 17 |
* |
| 18 |
* @param object $model PLL_Model instance |
| 19 |
*/ |
| 20 |
public function __construct(&$model) { |
| 21 |
$this->model = &$model; |
| 22 |
$this->options = &$model->options; |
| 23 |
|
| 24 |
$this->home = home_url(); |
| 25 |
} |
| 26 |
|
| 27 |
/* |
| 28 |
* changes the language code in url |
| 29 |
* |
| 30 |
* @since 1.5 |
| 31 |
* |
| 32 |
* @param string $url url to modify |
| 33 |
* @param object $lang language |
| 34 |
* @return string modified url |
| 35 |
*/ |
| 36 |
public function switch_language_in_link($url, $lang) { |
| 37 |
$url = $this->remove_language_from_link($url); |
| 38 |
return $this->add_language_to_link($url, $lang); |
| 39 |
} |
| 40 |
|
| 41 |
/* |
| 42 |
* get hosts managed on the website |
| 43 |
* |
| 44 |
* @since 1.5 |
| 45 |
* |
| 46 |
* @return array list of hosts |
| 47 |
*/ |
| 48 |
public function get_hosts() { |
| 49 |
return array(parse_url($this->home, PHP_URL_HOST)); |
| 50 |
} |
| 51 |
} |
| 52 |
|