PluginProbe
Polylang / trunk
Polylang vtrunk
3.8.10 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 All 234 releases
← All changes | src/frontend/frontend-static-pages.php +5 -26 3.8.8 → trunk View file →
@@ -130,38 +130,17 @@
130 130 return $url;
131 131 }
132 132
133 133 /**
134 - * Manages redirections for the static front pages.
134 + * Prevents the canonical redirect if we are on a static front page.
135 135 *
136 136 * @since 1.8
137 137 *
138 - * @param string|false $redirect_url The redirect URL.
138 + * @param string $redirect_url The redirect url.
139 139 * @return string|false
140 140 */
141 141 public function pll_check_canonical_url( $redirect_url ) {
142 - global $wp_query;
143 -
144 - if ( empty( $this->curlang->page_on_front ) ) {
145 - return $redirect_url;
146 - }
147 -
148 - if ( $this->options['redirect_lang'] ) {
149 - // Prevent the canonical redirect if we are on a static front page.
150 - if ( empty( $redirect_url ) ) {
151 - // Already prevented.
152 - return $redirect_url;
153 - }
154 - return ! $this->options['force_lang'] && $wp_query->is_page( $this->curlang->page_on_front ) ? false : $redirect_url;
155 - }
156 -
157 - if ( 1 === $this->options['force_lang'] && ! $this->options['hide_default'] && $wp_query->is_home && ! $wp_query->is_posts_page ) {
158 - // Redirect example.com/fr/ to example.com/fr/front-page/ if we're not hiding the page name, and not hiding
159 - // the language slug for the default language.
160 - return $this->curlang->get_home_url();
161 - }
162 -
163 - return $redirect_url;
142 + return $this->options['redirect_lang'] && ! $this->options['force_lang'] && ! empty( $this->curlang->page_on_front ) && is_page( $this->curlang->page_on_front ) ? false : $redirect_url;
164 143 }
165 144
166 145 /**
167 146 * Is the query for a the static front page (redirected from the language page)?
@@ -171,9 +150,9 @@
171 150 * @param WP_Query $query The WP_Query object.
172 151 * @return bool
173 152 */
174 153 protected function is_front_page( $query ) {
175 - $query = array_diff( array_keys( $query->query ), array( 'preview', 'page', 'paged', 'cpage', 'orderby' ) );
154 + $query = array_diff( array_keys( (array) $query->query ), array( 'preview', 'page', 'paged', 'cpage', 'orderby' ) );
176 155 return 1 === count( $query ) && in_array( 'lang', $query );
177 156 }
178 157
179 158 /**
@@ -205,9 +184,9 @@
205 184 }
206 185 }
207 186
208 187 // Fix paged static front page in plain permalinks when Settings > Reading doesn't match the default language
209 - elseif ( ! $this->links_model->using_permalinks && count( $query->query ) === 1 && ! empty( $query->query['page'] ) ) {
188 + elseif ( ! $this->links_model->using_permalinks && count( (array) $query->query ) === 1 && ! empty( $query->query['page'] ) ) {
210 189 $lang = $this->model->get_default_language();
211 190 if ( empty( $lang ) ) {
212 191 return $lang;
213 192 }