PluginProbe
Polylang / 3.1.4
Polylang v3.1.4
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | include/links-domain.php +18 -8 2.7.13.1.4 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +/**
3 + * @package Polylang
4 + */
2 5
3 6 /**
4 7 * Links model for use when using one domain per language
5 8 * for example mysite.com/sth and mysite.fr/qqch
@@ -9,8 +12,15 @@
9 12 */
10 13 class PLL_Links_Domain extends PLL_Links_Abstract_Domain {
11 14
12 15 /**
16 + * An array with language code as keys and the host as values.
17 + *
18 + * @var string[]
19 + */
20 + protected $hosts;
21 +
22 + /**
13 23 * Constructor
14 24 *
15 25 * @since 1.8
16 26 *
@@ -31,11 +41,11 @@
31 41 * links_model interface
32 42 *
33 43 * @since 1.2
34 44 *
35 - * @param string $url url to modify
36 - * @param object $lang language
37 - * @return string modified url
45 + * @param string $url The url to modify.
46 + * @param PLL_Language $lang The language object.
47 + * @return string Modified url.
38 48 */
39 49 public function add_language_to_link( $url, $lang ) {
40 50 if ( ! empty( $lang ) && ! empty( $this->hosts[ $lang->slug ] ) ) {
41 51 $url = preg_replace( '#://(' . wp_parse_url( $this->home, PHP_URL_HOST ) . ')($|/.*)#', '://' . $this->hosts[ $lang->slug ] . '$2', $url );
@@ -59,14 +69,14 @@
59 69 return $url;
60 70 }
61 71
62 72 /**
63 - * Returns the home url
64 - * links_model interface
73 + * Returns the home url in a given language.
74 + * links_model interface.
65 75 *
66 76 * @since 1.3.1
67 77 *
68 - * @param object $lang PLL_Language object
78 + * @param PLL_Language $lang PLL_Language object.
69 79 * @return string
70 80 */
71 81 public function home_url( $lang ) {
72 82 return trailingslashit( empty( $this->options['domains'][ $lang->slug ] ) ? $this->home : $this->options['domains'][ $lang->slug ] );
@@ -72,13 +82,13 @@
72 82 return trailingslashit( empty( $this->options['domains'][ $lang->slug ] ) ? $this->home : $this->options['domains'][ $lang->slug ] );
73 83 }
74 84
75 85 /**
76 - * Get hosts managed on the website
86 + * Get hosts managed on the website.
77 87 *
78 88 * @since 1.5
79 89 *
80 - * @return array list of hosts
90 + * @return string[] List of hosts.
81 91 */
82 92 public function get_hosts() {
83 93 $hosts = array();
84 94 foreach ( $this->options['domains'] as $lang => $domain ) {