| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * A class to manage URL modifications settings |
| 8 | 5 | * |
| @@ -8,23 +5,10 @@ | ||
| 8 | 5 | * |
| 9 | 6 | * @since 1.8 |
| 10 | 7 | */ |
| 11 | 8 | class PLL_Settings_Url extends PLL_Settings_Module { |
| 12 | - /** | |
| 13 | - * Stores the display order priority. | |
| 14 | - * | |
| 15 | - * @var int | |
| 16 | - */ | |
| 17 | - public $priority = 10; | |
| 18 | 9 | |
| 19 | 10 | /** |
| 20 | - * The page id of the static front page. | |
| 21 | - * | |
| 22 | - * @var int | |
| 23 | - */ | |
| 24 | - protected $page_on_front; | |
| 25 | - | |
| 26 | - /** | |
| 27 | 11 | * Constructor |
| 28 | 12 | * |
| 29 | 13 | * @since 1.8 |
| 30 | 14 | * |
| @@ -40,8 +24,9 @@ | ||
| 40 | 24 | 'configure' => true, |
| 41 | 25 | ) |
| 42 | 26 | ); |
| 43 | 27 | |
| 28 | + $this->links_model = &$polylang->links_model; | |
| 44 | 29 | $this->page_on_front = &$polylang->static_pages->page_on_front; |
| 45 | 30 | } |
| 46 | 31 | |
| 47 | 32 | /** |
| @@ -47,10 +32,8 @@ | ||
| 47 | 32 | /** |
| 48 | 33 | * Displays the fieldset to choose how the language is set |
| 49 | 34 | * |
| 50 | 35 | * @since 1.8 |
| 51 | - * | |
| 52 | - * @return void | |
| 53 | 36 | */ |
| 54 | 37 | protected function force_lang() { |
| 55 | 38 | ?> |
| 56 | 39 | <label> |
| @@ -56,20 +39,20 @@ | ||
| 56 | 39 | <label> |
| 57 | 40 | <?php |
| 58 | 41 | printf( |
| 59 | 42 | '<input name="force_lang" type="radio" value="0" %s /> %s', |
| 60 | - checked( $this->options['force_lang'], 0, false ), | |
| 43 | + $this->options['force_lang'] ? '' : 'checked="checked"', | |
| 61 | 44 | esc_html__( 'The language is set from content', 'polylang' ) |
| 62 | 45 | ); |
| 63 | 46 | ?> |
| 64 | 47 | </label> |
| 65 | - <p class="description"><?php esc_html_e( 'Posts, pages, categories and tags URLs will not be modified.', 'polylang' ); ?></p> | |
| 48 | + <p class="description"><?php esc_html_e( 'Posts, pages, categories and tags urls are not modified.', 'polylang' ); ?></p> | |
| 66 | 49 | <label> |
| 67 | 50 | <?php |
| 68 | 51 | printf( |
| 69 | 52 | '<input name="force_lang" type="radio" value="1" %s/> %s', |
| 70 | - checked( $this->options['force_lang'], 1, false ), | |
| 71 | - ( $this->links_model->using_permalinks ? esc_html__( 'The language is set from the directory name in pretty permalinks', 'polylang' ) : esc_html__( 'The language is set from the code in the URL', 'polylang' ) ) | |
| 53 | + 1 == $this->options['force_lang'] ? 'checked="checked"' : '', | |
| 54 | + $this->links_model->using_permalinks ? esc_html__( 'The language is set from the directory name in pretty permalinks', 'polylang' ) : esc_html__( 'The language is set from the code in the URL', 'polylang' ) | |
| 72 | 55 | ); |
| 73 | 56 | ?> |
| 74 | 57 | </label> |
| 75 | 58 | <p class="description"><?php echo esc_html__( 'Example:', 'polylang' ) . ' <code>' . esc_html( home_url( $this->links_model->using_permalinks ? 'en/my-post/' : '?lang=en&p=1' ) ) . '</code>'; ?></p> |
| @@ -76,10 +59,10 @@ | ||
| 76 | 59 | <label> |
| 77 | 60 | <?php |
| 78 | 61 | printf( |
| 79 | 62 | '<input name="force_lang" type="radio" value="2" %s %s/> %s', |
| 80 | - disabled( $this->links_model->using_permalinks, false, false ), | |
| 81 | - checked( $this->options['force_lang'], 2, false ), | |
| 63 | + $this->links_model->using_permalinks ? '' : 'disabled="disabled"', | |
| 64 | + 2 == $this->options['force_lang'] ? 'checked="checked"' : '', | |
| 82 | 65 | esc_html__( 'The language is set from the subdomain name in pretty permalinks', 'polylang' ) |
| 83 | 66 | ); |
| 84 | 67 | ?> |
| 85 | 68 | </label> |
| @@ -87,10 +70,10 @@ | ||
| 87 | 70 | <label> |
| 88 | 71 | <?php |
| 89 | 72 | printf( |
| 90 | 73 | '<input name="force_lang" type="radio" value="3" %s %s/> %s', |
| 91 | - disabled( $this->links_model->using_permalinks, false, false ), | |
| 92 | - checked( $this->options['force_lang'], 3, false ), | |
| 74 | + $this->links_model->using_permalinks ? '' : 'disabled="disabled"', | |
| 75 | + 3 == $this->options['force_lang'] ? 'checked="checked"' : '', | |
| 93 | 76 | esc_html__( 'The language is set from different domains', 'polylang' ) |
| 94 | 77 | ); |
| 95 | 78 | ?> |
| 96 | 79 | </label> |
| @@ -96,15 +79,14 @@ | ||
| 96 | 79 | </label> |
| 97 | 80 | <table id="pll-domains-table" class="form-table" <?php echo 3 == $this->options['force_lang'] ? '' : 'style="display: none;"'; ?>> |
| 98 | 81 | <?php |
| 99 | 82 | 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 : '' ); | |
| 101 | 83 | printf( |
| 102 | 84 | '<tr><td><label for="pll-domain[%1$s]">%2$s</label></td>' . |
| 103 | 85 | '<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 | 86 | esc_attr( $lg->slug ), |
| 105 | 87 | esc_attr( $lg->name ), |
| 106 | - esc_url( $url ) | |
| 88 | + esc_url( isset( $this->options['domains'][ $lg->slug ] ) ? $this->options['domains'][ $lg->slug ] : ( $lg->slug == $this->options['default_lang'] ? $this->links_model->home : '' ) ) | |
| 107 | 89 | ); |
| 108 | 90 | } |
| 109 | 91 | ?> |
| 110 | 92 | </table> |
| @@ -114,10 +96,8 @@ | ||
| 114 | 96 | /** |
| 115 | 97 | * Displays the fieldset to choose to hide the default language information in url |
| 116 | 98 | * |
| 117 | 99 | * @since 1.8 |
| 118 | - * | |
| 119 | - * @return void | |
| 120 | 100 | */ |
| 121 | 101 | protected function hide_default() { |
| 122 | 102 | ?> |
| 123 | 103 | <label> |
| @@ -123,9 +103,9 @@ | ||
| 123 | 103 | <label> |
| 124 | 104 | <?php |
| 125 | 105 | printf( |
| 126 | 106 | '<input name="hide_default" type="checkbox" value="1" %s /> %s', |
| 127 | - checked( $this->options['hide_default'], 1, false ), | |
| 107 | + $this->options['hide_default'] ? 'checked="checked"' : '', | |
| 128 | 108 | esc_html__( 'Hide URL language information for default language', 'polylang' ) |
| 129 | 109 | ); |
| 130 | 110 | ?> |
| 131 | 111 | </label> |
| @@ -135,10 +115,8 @@ | ||
| 135 | 115 | /** |
| 136 | 116 | * Displays the fieldset to choose to hide /language/ in url |
| 137 | 117 | * |
| 138 | 118 | * @since 1.8 |
| 139 | - * | |
| 140 | - * @return void | |
| 141 | 119 | */ |
| 142 | 120 | protected function rewrite() { |
| 143 | 121 | ?> |
| 144 | 122 | <label> |
| @@ -144,10 +122,10 @@ | ||
| 144 | 122 | <label> |
| 145 | 123 | <?php |
| 146 | 124 | printf( |
| 147 | 125 | '<input name="rewrite" type="radio" value="1" %s %s/> %s', |
| 148 | - disabled( $this->links_model->using_permalinks, false, false ), | |
| 149 | - checked( $this->options['rewrite'], 1, false ), | |
| 126 | + $this->links_model->using_permalinks ? '' : 'disabled="disabled"', | |
| 127 | + $this->options['rewrite'] ? 'checked="checked"' : '', | |
| 150 | 128 | esc_html__( 'Remove /language/ in pretty permalinks', 'polylang' ) |
| 151 | 129 | ); |
| 152 | 130 | ?> |
| 153 | 131 | </label> |
| @@ -155,10 +133,10 @@ | ||
| 155 | 133 | <label> |
| 156 | 134 | <?php |
| 157 | 135 | printf( |
| 158 | 136 | '<input name="rewrite" type="radio" value="0" %s %s/> %s', |
| 159 | - disabled( $this->links_model->using_permalinks, false, false ), | |
| 160 | - checked( $this->options['rewrite'], 0, false ), | |
| 137 | + $this->links_model->using_permalinks ? '' : 'disabled="disabled"', | |
| 138 | + $this->options['rewrite'] ? '' : 'checked="checked"', | |
| 161 | 139 | esc_html__( 'Keep /language/ in pretty permalinks', 'polylang' ) |
| 162 | 140 | ); |
| 163 | 141 | ?> |
| 164 | 142 | </label> |
| @@ -169,10 +147,8 @@ | ||
| 169 | 147 | /** |
| 170 | 148 | * Displays the fieldset to choose to redirect the home page to language page |
| 171 | 149 | * |
| 172 | 150 | * @since 1.8 |
| 173 | - * | |
| 174 | - * @return void | |
| 175 | 151 | */ |
| 176 | 152 | protected function redirect_lang() { |
| 177 | 153 | ?> |
| 178 | 154 | <label> |
| @@ -178,9 +154,9 @@ | ||
| 178 | 154 | <label> |
| 179 | 155 | <?php |
| 180 | 156 | printf( |
| 181 | 157 | '<input name="redirect_lang" type="checkbox" value="1" %s/> %s', |
| 182 | - checked( $this->options['redirect_lang'], 1, false ), | |
| 158 | + $this->options['redirect_lang'] ? 'checked="checked"' : '', | |
| 183 | 159 | esc_html__( 'The front page url contains the language code instead of the page name or page id', 'polylang' ) |
| 184 | 160 | ); |
| 185 | 161 | ?> |
| 186 | 162 | </label> |
| @@ -203,10 +179,8 @@ | ||
| 203 | 179 | /** |
| 204 | 180 | * Displays the settings |
| 205 | 181 | * |
| 206 | 182 | * @since 1.8 |
| 207 | - * | |
| 208 | - * @return void | |
| 209 | 183 | */ |
| 210 | 184 | public function form() { |
| 211 | 185 | ?> |
| 212 | 186 | <div class="pll-settings-url-col"> |
| @@ -245,13 +219,10 @@ | ||
| 245 | 219 | * |
| 246 | 220 | * @since 1.8 |
| 247 | 221 | * |
| 248 | 222 | * @param array $options |
| 249 | - * @return array | |
| 250 | 223 | */ |
| 251 | 224 | protected function update( $options ) { |
| 252 | - $newoptions = array(); | |
| 253 | - | |
| 254 | 225 | foreach ( array( 'force_lang', 'rewrite' ) as $key ) { |
| 255 | 226 | $newoptions[ $key ] = isset( $options[ $key ] ) ? (int) $options[ $key ] : 0; |
| 256 | 227 | } |
| 257 | 228 | |
| @@ -301,9 +272,8 @@ | ||
| 301 | 272 | * |
| 302 | 273 | * @since 1.8 |
| 303 | 274 | * |
| 304 | 275 | * @param array $options new set of options to test |
| 305 | - * @return void | |
| 306 | 276 | */ |
| 307 | 277 | protected function check_domains( $options ) { |
| 308 | 278 | $options = array_merge( $this->options, $options ); |
| 309 | 279 | $model = new PLL_Model( $options ); |
| @@ -320,9 +290,9 @@ | ||
| 320 | 290 | 'pll_invalid_domain', |
| 321 | 291 | esc_html( |
| 322 | 292 | sprintf( |
| 323 | 293 | /* translators: %s is an url */ |
| 324 | - __( 'Polylang was unable to access the %s URL. Please check that the URL is valid.', 'polylang' ), | |
| 294 | + __( 'Polylang was unable to access the URL %s. Please check that the URL is valid.', 'polylang' ), | |
| 325 | 295 | $url |
| 326 | 296 | ) |
| 327 | 297 | ) |
| 328 | 298 | ); |