| @@ -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)? |