| @@ -18,18 +18,18 @@ | ||
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * The page id of the static front page. |
| 21 | 21 | * |
| 22 | - * @var int | |
| 22 | + * @var int|null | |
| 23 | 23 | */ |
| 24 | 24 | protected $page_on_front; |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * Constructor | |
| 27 | + * Constructor. | |
| 28 | 28 | * |
| 29 | 29 | * @since 1.8 |
| 30 | 30 | * |
| 31 | - * @param object $polylang | |
| 31 | + * @param object $polylang The Polylang object. | |
| 32 | 32 | */ |
| 33 | 33 | public function __construct( &$polylang ) { |
| 34 | 34 | parent::__construct( |
| 35 | 35 | $polylang, |
| @@ -36,9 +36,8 @@ | ||
| 36 | 36 | array( |
| 37 | 37 | 'module' => 'url', |
| 38 | 38 | 'title' => __( 'URL modifications', 'polylang' ), |
| 39 | 39 | 'description' => __( 'Decide how your URLs will look like.', 'polylang' ), |
| 40 | - 'configure' => true, | |
| 41 | 40 | ) |
| 42 | 41 | ); |
| 43 | 42 | |
| 44 | 43 | $this->page_on_front = &$polylang->static_pages->page_on_front; |
| @@ -52,8 +51,9 @@ | ||
| 52 | 51 | * @return void |
| 53 | 52 | */ |
| 54 | 53 | protected function force_lang() { |
| 55 | 54 | ?> |
| 55 | + <p class="description"><?php esc_html_e( 'Some themes or plugins may not be fully compatible with the language defined by the content or by domains.', 'polylang' ); ?></p> | |
| 56 | 56 | <label> |
| 57 | 57 | <?php |
| 58 | 58 | printf( |
| 59 | 59 | '<input name="force_lang" type="radio" value="0" %s /> %s', |
| @@ -96,9 +96,9 @@ | ||
| 96 | 96 | </label> |
| 97 | 97 | <table id="pll-domains-table" class="form-table" <?php echo 3 == $this->options['force_lang'] ? '' : 'style="display: none;"'; ?>> |
| 98 | 98 | <?php |
| 99 | 99 | foreach ( $this->model->get_languages_list() as $lg ) { |
| 100 | - $url = isset( $this->options['domains'][ $lg->slug ] ) ? $this->options['domains'][ $lg->slug ] : ( $lg->slug == $this->options['default_lang'] ? $this->links_model->home : '' ); | |
| 100 | + $url = isset( $this->options['domains'][ $lg->slug ] ) ? $this->options['domains'][ $lg->slug ] : ( $lg->is_default ? $this->links_model->home : '' ); | |
| 101 | 101 | printf( |
| 102 | 102 | '<tr><td><label for="pll-domain[%1$s]">%2$s</label></td>' . |
| 103 | 103 | '<td><input name="domains[%1$s]" id="pll-domain[%1$s]" type="text" value="%3$s" class="regular-text code" aria-required="true" /></td></tr>', |
| 104 | 104 | esc_attr( $lg->slug ), |
| @@ -179,9 +179,9 @@ | ||
| 179 | 179 | <?php |
| 180 | 180 | printf( |
| 181 | 181 | '<input name="redirect_lang" type="checkbox" value="1" %s/> %s', |
| 182 | 182 | checked( $this->options['redirect_lang'], 1, false ), |
| 183 | - esc_html__( 'The front page url contains the language code instead of the page name or page id', 'polylang' ) | |
| 183 | + esc_html__( 'The front page URL contains the language code instead of the page name or page id', 'polylang' ) | |
| 184 | 184 | ); |
| 185 | 185 | ?> |
| 186 | 186 | </label> |
| 187 | 187 | <p class="description"> |
| @@ -187,9 +187,10 @@ | ||
| 187 | 187 | <p class="description"> |
| 188 | 188 | <?php |
| 189 | 189 | // That's nice to display the right home urls but don't forget that the page on front may have no language yet |
| 190 | 190 | $lang = $this->model->post->get_language( $this->page_on_front ); |
| 191 | - $lang = $lang ? $lang : $this->model->get_language( $this->options['default_lang'] ); | |
| 191 | + /** @var PLL_Language $lang */ | |
| 192 | + $lang = $lang ? $lang : $this->model->get_default_language(); | |
| 192 | 193 | printf( |
| 193 | 194 | /* translators: %1$s example url when the option is active. %2$s example url when the option is not active */ |
| 194 | 195 | esc_html__( 'Example: %1$s instead of %2$s', 'polylang' ), |
| 195 | 196 | '<code>' . esc_html( $this->links_model->home_url( $lang ) ) . '</code>', |
| @@ -240,13 +241,13 @@ | ||
| 240 | 241 | <?php |
| 241 | 242 | } |
| 242 | 243 | |
| 243 | 244 | /** |
| 244 | - * Sanitizes the settings before saving | |
| 245 | + * Sanitizes the settings before saving. | |
| 245 | 246 | * |
| 246 | 247 | * @since 1.8 |
| 247 | 248 | * |
| 248 | - * @param array $options | |
| 249 | + * @param array $options Unsanitized options to save. | |
| 249 | 250 | * @return array |
| 250 | 251 | */ |
| 251 | 252 | protected function update( $options ) { |
| 252 | 253 | $newoptions = array(); |
| @@ -255,15 +256,15 @@ | ||
| 255 | 256 | $newoptions[ $key ] = isset( $options[ $key ] ) ? (int) $options[ $key ] : 0; |
| 256 | 257 | } |
| 257 | 258 | |
| 258 | 259 | if ( 3 == $options['force_lang'] && isset( $options['domains'] ) && is_array( $options['domains'] ) ) { |
| 260 | + $newoptions['domains'] = array(); | |
| 259 | 261 | foreach ( $options['domains'] as $key => $domain ) { |
| 260 | 262 | if ( empty( $domain ) ) { |
| 261 | 263 | $lang = $this->model->get_language( $key ); |
| 262 | - add_settings_error( | |
| 263 | - 'general', | |
| 264 | - 'pll_invalid_domain', | |
| 265 | - esc_html( | |
| 264 | + pll_add_notice( | |
| 265 | + new WP_Error( | |
| 266 | + sprintf( 'pll_invalid_domain_%s', $key ), | |
| 266 | 267 | sprintf( |
| 267 | 268 | /* translators: %s is a native language name */ |
| 268 | 269 | __( 'Please enter a valid URL for %s.', 'polylang' ), |
| 269 | 270 | $lang->name |
| @@ -314,12 +315,11 @@ | ||
| 314 | 315 | $response = function_exists( 'vip_safe_wp_remote_get' ) ? vip_safe_wp_remote_get( esc_url_raw( $url ) ) : wp_remote_get( esc_url_raw( $url ) ); |
| 315 | 316 | $response_code = wp_remote_retrieve_response_code( $response ); |
| 316 | 317 | |
| 317 | 318 | if ( 200 != $response_code ) { |
| 318 | - add_settings_error( | |
| 319 | - 'general', | |
| 320 | - 'pll_invalid_domain', | |
| 321 | - esc_html( | |
| 319 | + pll_add_notice( | |
| 320 | + new WP_Error( | |
| 321 | + sprintf( 'pll_invalid_domain_%s', $lang->slug ), | |
| 322 | 322 | sprintf( |
| 323 | 323 | /* translators: %s is an url */ |
| 324 | 324 | __( 'Polylang was unable to access the %s URL. Please check that the URL is valid.', 'polylang' ), |
| 325 | 325 | $url |