PluginProbe
Polylang / 2.0.3
Polylang v2.0.3
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-model.php +9 -16 2.92.0.3 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Links model abstract class
8 5 *
@@ -54,9 +51,9 @@
54 51 *
55 52 * @return array list of hosts
56 53 */
57 54 public function get_hosts() {
58 - return array( wp_parse_url( $this->home, PHP_URL_HOST ) );
55 + return array( parse_url( $this->home, PHP_URL_HOST ) );
59 56 }
60 57
61 58 /**
62 59 * Returns the home url
@@ -67,9 +64,9 @@
67 64 * @return string
68 65 */
69 66 public function home_url( $lang ) {
70 67 $url = trailingslashit( $this->home );
71 - return $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ? $url : $this->add_language_to_link( $url, $lang );
68 + return $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ? $url: $this->add_language_to_link( $url, $lang );
72 69 }
73 70
74 71 /**
75 72 * Sets the home urls
@@ -78,18 +75,15 @@
78 75 *
79 76 * @param object $language
80 77 */
81 78 protected function set_home_url( $language ) {
82 - // We should always have a default language here, except, temporarily, in PHPUnit tests. The test here protects against PHP notices.
83 - if ( isset( $this->options['default_lang'] ) ) {
84 - $search_url = $this->home_url( $language );
85 - $home_url = empty( $language->page_on_front ) || $this->options['redirect_lang'] ? $search_url : $this->front_page_url( $language );
86 - $language->set_home_url( $search_url, $home_url );
87 - }
79 + $search_url = $this->home_url( $language );
80 + $home_url = empty( $language->page_on_front ) || $this->options['redirect_lang'] ? $search_url : $this->front_page_url( $language );
81 + $language->set_home_url( $search_url, $home_url );
88 82 }
89 83
90 84 /**
91 - * Sets the home urls and flags before the languages are persistently cached
85 + * Sets the home urls before it is persistently cached
92 86 *
93 87 * @since 1.8
94 88 *
95 89 * @param array $languages array of PLL_Language objects
@@ -97,9 +91,8 @@
97 91 */
98 92 public function pll_languages_list( $languages ) {
99 93 foreach ( $languages as $language ) {
100 94 $this->set_home_url( $language );
101 - $language->set_flag();
102 95 }
103 96 return $languages;
104 97 }
105 98
@@ -118,10 +111,10 @@
118 111 if ( ( defined( 'PLL_CACHE_LANGUAGES' ) && ! PLL_CACHE_LANGUAGES ) || ( defined( 'PLL_CACHE_HOME_URL' ) && ! PLL_CACHE_HOME_URL ) ) {
119 112 $this->set_home_url( $language );
120 113 }
121 114
122 - // Ensures that the ( possibly cached ) home and flag urls use the right scheme http or https.
123 - $language->set_url_scheme();
115 + // Ensures that the ( possibly cached ) home url uses the right scheme http or https
116 + $language->set_home_url_scheme();
124 117 }
125 118 return $languages;
126 119 }
127 120
@@ -133,7 +126,7 @@
133 126 * @param array $hosts allowed hosts
134 127 * @return array
135 128 */
136 129 public function allowed_redirect_hosts( $hosts ) {
137 - return array_unique( array_merge( $hosts, array_values( $this->get_hosts() ) ) );
130 + return array_unique( array_merge( $hosts, $this->get_hosts() ) );
138 131 }
139 132 }