| 1 |
<?php |
| 2 |
// displays the Languages admin panel |
| 3 |
?> |
| 4 |
<div class="wrap"> |
| 5 |
<?php screen_icon('options-general'); ?> |
| 6 |
<h2 class="nav-tab-wrapper"><?php |
| 7 |
// display tabs |
| 8 |
foreach ($tabs as $key => $name) |
| 9 |
printf( |
| 10 |
'<a href="options-general.php?page=mlang&tab=%s" class="nav-tab %s">%s</a>', |
| 11 |
$key, |
| 12 |
$key == $this->active_tab ? 'nav-tab-active' : '', |
| 13 |
$name |
| 14 |
);?> |
| 15 |
</h2><?php |
| 16 |
|
| 17 |
switch($this->active_tab) { |
| 18 |
|
| 19 |
// Languages tab |
| 20 |
case 'lang': ?> |
| 21 |
|
| 22 |
<div id="col-container"> |
| 23 |
<div id="col-right"> |
| 24 |
<div class="col-wrap"><?php |
| 25 |
// displays the language list in a table |
| 26 |
$list_table->display();?> |
| 27 |
<div class="metabox-holder"><?php |
| 28 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
| 29 |
do_meta_boxes('settings_page_mlang', 'normal', array());?> |
| 30 |
</div> |
| 31 |
</div><!-- col-wrap --> |
| 32 |
</div><!-- col-right --> |
| 33 |
|
| 34 |
<div id="col-left"> |
| 35 |
<div class="col-wrap"> |
| 36 |
|
| 37 |
<div class="form-wrap"> |
| 38 |
<h3><?php echo $action=='edit' ? __('Edit language', 'polylang') : __('Add new language', 'polylang'); ?></h3><?php |
| 39 |
|
| 40 |
// displays the add (or edit) language form |
| 41 |
// adds noheader=true in the action url to allow using wp_redirect when processing the form ?> |
| 42 |
<form id="add-lang" method="post" action="admin.php?page=mlang&noheader=true" class="validate"> |
| 43 |
<?php wp_nonce_field('add-lang', '_wpnonce_add-lang'); |
| 44 |
|
| 45 |
if ($action=='edit') {?> |
| 46 |
<input type="hidden" name="pll_action" value="update" /> |
| 47 |
<input type="hidden" name="lang_id" value="<?php echo esc_attr($edit_lang->term_id);?>" /><?php |
| 48 |
} |
| 49 |
else { ?> |
| 50 |
<input type="hidden" name="pll_action" value="add" /><?php |
| 51 |
}?> |
| 52 |
|
| 53 |
<div class="form-field"> |
| 54 |
<label for="lang_list"><?php _e('Choose a language', 'polylang');?></label> |
| 55 |
<select name="lang_list" id="lang_list"> |
| 56 |
<option value=""></option><?php |
| 57 |
include(PLL_ADMIN_INC.'/languages.php'); |
| 58 |
foreach ($languages as $lg) { |
| 59 |
printf( |
| 60 |
'<option value="%1$s-%2$s-%3$s">%4$s - %2$s</option>'."\n", |
| 61 |
esc_attr($lg[0]), |
| 62 |
esc_attr($lg[1]), |
| 63 |
isset($lg[3]) ? '1' : '0', |
| 64 |
esc_html($lg[2]) |
| 65 |
); |
| 66 |
} ?> |
| 67 |
</select> |
| 68 |
<p><?php _e('You can choose a language in the list or directly edit it below.', 'polylang');?></p> |
| 69 |
</div> |
| 70 |
|
| 71 |
<div class="form-field form-required"> |
| 72 |
<label for="lang_name"><?php _e('Full name', 'polylang');?></label> |
| 73 |
<input name="name" id="lang_name" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->name);?>" size="40" aria-required="true" /> |
| 74 |
<p><?php _e('The name is how it is displayed on your site (for example: English).', 'polylang');?></p> |
| 75 |
</div> |
| 76 |
|
| 77 |
<div class="form-field form-required"> |
| 78 |
<label for="lang_locale"><?php _e('Locale', 'polylang');?></label><?php |
| 79 |
printf( |
| 80 |
'<input name="locale" id="lang_locale" type="text" value="%s" size="40" aria-required="true" />', |
| 81 |
$action=='edit' ? esc_attr($edit_lang->locale) : '' |
| 82 |
);?> |
| 83 |
<p><?php _e('Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language.', 'polylang');?></p> |
| 84 |
</div> |
| 85 |
|
| 86 |
<div class="form-field"> |
| 87 |
<label for="lang_slug"><?php _e('Language code', 'polylang');?></label> |
| 88 |
<input name="slug" id="lang_slug" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->slug);?>" size="40"/> |
| 89 |
<p><?php _e('Language code - preferably 2-letters ISO 639-1 (for example: en)', 'polylang');?></p> |
| 90 |
</div> |
| 91 |
|
| 92 |
<div class="form-field"><fieldset> |
| 93 |
<legend><?php _e('Text direction', 'polylang');?></legend><?php |
| 94 |
printf( |
| 95 |
'<label><input name="rtl" type="radio" value="0" %s /> %s</label>', |
| 96 |
$action == 'edit' && $edit_lang->is_rtl ? '' : 'checked="checked"', |
| 97 |
__('left to right', 'polylang') |
| 98 |
); |
| 99 |
printf( |
| 100 |
'<label><input name="rtl" type="radio" value="1" %s /> %s</label>', |
| 101 |
$action == 'edit' && $edit_lang->is_rtl ? 'checked="checked"' : '', |
| 102 |
__('right to left', 'polylang') |
| 103 |
);?> |
| 104 |
<p><?php _e('Choose the text direction for the language', 'polylang');?></p> |
| 105 |
</fieldset></div> |
| 106 |
|
| 107 |
<div class="form-field"> |
| 108 |
<label for="lang_order"><?php _e('Order', 'polylang');?></label> |
| 109 |
<input name="term_group" id="lang_order" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->term_group);?>" /> |
| 110 |
<p><?php _e('Position of the language in the language switcher', 'polylang');?></p> |
| 111 |
</div> |
| 112 |
|
| 113 |
<?php submit_button( $action == 'edit' ? __('Update') : __('Add new language', 'polylang'), 'button'); // since WP 3.1 ?> |
| 114 |
|
| 115 |
</form> |
| 116 |
</div><!-- form-wrap --> |
| 117 |
</div><!-- col-wrap --> |
| 118 |
</div><!-- col-left --> |
| 119 |
</div><!-- col-container --> |
| 120 |
|
| 121 |
<script type="text/javascript"> |
| 122 |
//<![CDATA[ |
| 123 |
jQuery(document).ready( function($) { |
| 124 |
// close postboxes that should be closed |
| 125 |
$('.if-js-closed').removeClass('if-js-closed').addClass('closed'); |
| 126 |
// postboxes setup |
| 127 |
postboxes.add_postbox_toggles('settings_page_mlang'); |
| 128 |
}); |
| 129 |
//]]> |
| 130 |
</script><?php |
| 131 |
break; |
| 132 |
|
| 133 |
// string translations tab |
| 134 |
case 'strings': ?> |
| 135 |
|
| 136 |
<div class="form-wrap"> |
| 137 |
<form id="string-translation" method="post" action="admin.php?page=mlang&tab=strings&noheader=true"> |
| 138 |
<input type="hidden" name="pll_action" value="string-translation" /><?php |
| 139 |
$string_table->search_box(__('Search translations', 'polylang'), 'translations' ); |
| 140 |
wp_nonce_field('string-translation', '_wpnonce_string-translation'); |
| 141 |
$string_table->display(); |
| 142 |
printf('<br /><label><input name="clean" type="checkbox" value="1" /> %s</label>', __('Clean strings translation database', 'polylang')); ?> |
| 143 |
<p><?php _e('Use this to remove unused strings from database, for example after a plugin has been uninstalled.', 'polylang');?></p><?php |
| 144 |
submit_button(); // since WP 3.1 ?> |
| 145 |
</form> |
| 146 |
</div><?php |
| 147 |
break; |
| 148 |
|
| 149 |
// settings tab |
| 150 |
case 'settings': ?><?php |
| 151 |
$content_with_no_languages = $this->model->get_objects_with_no_lang() && $this->options['default_lang']; |
| 152 |
$page_on_front = 'page' == get_option('show_on_front') ? get_option('page_on_front') : 0; ?> |
| 153 |
|
| 154 |
<form id="options-lang" method="post" action="admin.php?page=mlang&tab=settings&noheader=true" class="validate"> |
| 155 |
<?php wp_nonce_field('options-lang', '_wpnonce_options-lang');?> |
| 156 |
<input type="hidden" name="pll_action" value="options" /> |
| 157 |
|
| 158 |
<table class="form-table"> |
| 159 |
<tr> |
| 160 |
<th <?php echo $content_with_no_languages ? 'rowspan=2' : ''; ?>> |
| 161 |
<label for='default_lang'><?php _e('Default language', 'polylang');?></label> |
| 162 |
</th> |
| 163 |
<td><?php |
| 164 |
$dropdown = new PLL_Walker_Dropdown; |
| 165 |
echo $dropdown->walk($listlanguages, array('name' => 'default_lang', 'selected' => $this->options['default_lang']));?> |
| 166 |
</td> |
| 167 |
</tr><?php |
| 168 |
|
| 169 |
// posts or terms without language set |
| 170 |
if ($content_with_no_languages) {?> |
| 171 |
<tr> |
| 172 |
<td> |
| 173 |
<label style="color: red"><?php |
| 174 |
printf( |
| 175 |
'<input name="fill_languages" type="checkbox" value="1" /> %s', |
| 176 |
__('There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?', 'polylang') |
| 177 |
);?> |
| 178 |
</label> |
| 179 |
</td> |
| 180 |
</tr><?php |
| 181 |
}?> |
| 182 |
|
| 183 |
<tr> |
| 184 |
<th rowspan = <?php echo ($page_on_front ? 3 : 2) + $using_permalinks; ?>><?php _e('URL modifications', 'polylang') ?></th> |
| 185 |
<td><fieldset id='pll-force-lang'> |
| 186 |
<label><?php |
| 187 |
printf( |
| 188 |
'<input name="force_lang" type="radio" value="0" %s /> %s', |
| 189 |
$this->options['force_lang'] ? '' : 'checked="checked"', |
| 190 |
__('The language is set from content', 'polylang') |
| 191 |
);?> |
| 192 |
</label> |
| 193 |
<p class="description"><?php _e('Posts, pages, categories and tags urls are not modified.', 'polylang');?></p> |
| 194 |
<label><?php |
| 195 |
printf( |
| 196 |
'<input name="force_lang" type="radio" value="1" %s %s/> %s', |
| 197 |
$using_permalinks ? '' : 'disabled="disabled"', |
| 198 |
1 == $this->options['force_lang'] ? 'checked="checked"' : '', |
| 199 |
__('The language is set from the directory name in pretty permalinks', 'polylang') |
| 200 |
);?> |
| 201 |
</label> |
| 202 |
<p class="description"><?php echo __('Example:', 'polylang') . ' <code>'.esc_html(home_url('en/my-post/')).'</code>';?></p> |
| 203 |
<label><?php |
| 204 |
printf( |
| 205 |
'<input name="force_lang" type="radio" value="2" %s %s/> %s', |
| 206 |
$using_permalinks ? '' : 'disabled="disabled"', |
| 207 |
2 == $this->options['force_lang'] ? 'checked="checked"' : '', |
| 208 |
__('The language is set from the subdomain name in pretty permalinks', 'polylang') |
| 209 |
);?> |
| 210 |
</label> |
| 211 |
<p class="description"><?php echo __('Example:', 'polylang') . ' <code>'.esc_html(str_replace(array('://', 'www.'), array('://en.', ''), home_url('my-post/'))).'</code>';?></p> |
| 212 |
<label><?php |
| 213 |
printf( |
| 214 |
'<input name="force_lang" type="radio" value="3" %s %s/> %s', |
| 215 |
$using_permalinks ? '' : 'disabled="disabled"', |
| 216 |
3 == $this->options['force_lang'] ? 'checked="checked"' : '', |
| 217 |
__('The language is set from different domains', 'polylang') |
| 218 |
);?> |
| 219 |
</label> |
| 220 |
<table id="pll-domains-table" <?php echo 3 == $this->options['force_lang'] ? '' : 'style="display: none;"'; ?>><?php |
| 221 |
foreach ($listlanguages as $lg) { |
| 222 |
printf( |
| 223 |
'<tr><td><label for="pll-domain[%1$s]">%2$s</label></td>' . |
| 224 |
'<td><input name="domains[%1$s]" id="pll-domain[%1$s]" type="text" value="%3$s" size="40" aria-required="true" %4$s /></td></tr>', |
| 225 |
esc_attr($lg->slug), |
| 226 |
esc_attr($lg->name), |
| 227 |
esc_url($lg->slug == $this->options['default_lang'] ? get_option('home') : (isset($this->options['domains'][$lg->slug]) ? $this->options['domains'][$lg->slug] : '')), |
| 228 |
!$using_permalinks || $lg->slug == $this->options['default_lang'] ? 'disabled="disabled"' : '' |
| 229 |
); |
| 230 |
}?> |
| 231 |
</table> |
| 232 |
</fieldset></td> |
| 233 |
</tr> |
| 234 |
|
| 235 |
<tr> |
| 236 |
<td id="pll-hide-default" <?php echo 3 > $this->options['force_lang'] ? '' : 'style="display: none;"'; ?>><fieldset> |
| 237 |
<label><?php |
| 238 |
printf( |
| 239 |
'<input name="hide_default" type="checkbox" value="1" %s /> %s', |
| 240 |
$this->options['hide_default'] ? 'checked="checked"' :'', |
| 241 |
__('Hide URL language information for default language', 'polylang') |
| 242 |
);?> |
| 243 |
</label> |
| 244 |
</fieldset></td> |
| 245 |
</tr><?php |
| 246 |
|
| 247 |
if ($using_permalinks) { ?> |
| 248 |
<tr> |
| 249 |
<td id="pll-rewrite" <?php echo 2 > $this->options['force_lang'] ? '' : 'style="display: none;"'; ?>><fieldset> |
| 250 |
<label><?php |
| 251 |
printf( |
| 252 |
'<input name="rewrite" type="radio" value="1" %s %s/> %s', |
| 253 |
$using_permalinks ? '' : 'disabled="disabled"', |
| 254 |
$this->options['rewrite'] ? 'checked="checked"' : '', |
| 255 |
__('Remove /language/ in pretty permalinks', 'polylang') |
| 256 |
);?> |
| 257 |
</label> |
| 258 |
<p class="description"><?php echo __('Example:', 'polylang') . ' <code>'.esc_html(home_url('en/')).'</code>';?></p> |
| 259 |
<label><?php |
| 260 |
printf( |
| 261 |
'<input name="rewrite" type="radio" value="0" %s %s/> %s', |
| 262 |
$using_permalinks ? '' : 'disabled="disabled"', |
| 263 |
$this->options['rewrite'] ? '' : 'checked="checked"', |
| 264 |
__('Keep /language/ in pretty permalinks', 'polylang') |
| 265 |
);?> |
| 266 |
</label> |
| 267 |
<p class="description"><?php echo __('Example:', 'polylang') . ' <code>'.esc_html(home_url('language/en/')).'</code>';?></p> |
| 268 |
</fieldset></td> |
| 269 |
</tr><?php |
| 270 |
} |
| 271 |
|
| 272 |
if ($page_on_front) { ?> |
| 273 |
<tr> |
| 274 |
<td><fieldset> |
| 275 |
<label><?php |
| 276 |
printf( |
| 277 |
'<input name="redirect_lang" type="checkbox" value="1" %s/> %s', |
| 278 |
$this->options['redirect_lang'] ? 'checked="checked"' :'', |
| 279 |
__('The front page url contains the language code instead of the page name or page id', 'polylang') |
| 280 |
);?> |
| 281 |
</label> |
| 282 |
<p class="description"><?php |
| 283 |
// that's nice to display the right home urls but don't forget that the page on front may have no language yet |
| 284 |
$lang = $this->model->get_post_language($page_on_front); |
| 285 |
$lang = $lang ? $lang : $this->model->get_language($this->options['default_lang']); |
| 286 |
printf( |
| 287 |
__('Example: %s instead of %s', 'polylang'), |
| 288 |
'<code>' . esc_html($this->links_model->home_url($lang)) . '</code>', |
| 289 |
'<code>' . esc_html(_get_page_link($page_on_front)) . '</code>' |
| 290 |
); ?> |
| 291 |
</p> |
| 292 |
</fieldset></td> |
| 293 |
</tr><?php |
| 294 |
} ?> |
| 295 |
|
| 296 |
<tr id="pll-detect-browser" <?php echo 3 > $this->options['force_lang'] ? '' : 'style="display: none;"'; ?>> |
| 297 |
<th><?php _e('Detect browser language', 'polylang');?></th> |
| 298 |
<td> |
| 299 |
<label><?php |
| 300 |
printf( |
| 301 |
'<input name="browser" type="checkbox" value="1" %s /> %s', |
| 302 |
$this->options['browser'] ? 'checked="checked"' :'', |
| 303 |
__('When the front page is visited, set the language according to the browser preference', 'polylang') |
| 304 |
);?> |
| 305 |
</label> |
| 306 |
</td> |
| 307 |
</tr> |
| 308 |
|
| 309 |
<tr> |
| 310 |
<th scope="row"><?php _e('Media', 'polylang') ?></th> |
| 311 |
<td> |
| 312 |
<label><?php |
| 313 |
printf( |
| 314 |
'<input name="media_support" type="checkbox" value="1" %s /> %s', |
| 315 |
$this->options['media_support'] ? 'checked="checked"' :'', |
| 316 |
__('Activate languages and translations for media', 'polylang') |
| 317 |
);?> |
| 318 |
</label> |
| 319 |
</td> |
| 320 |
</tr><?php |
| 321 |
|
| 322 |
if (!empty($post_types)) {?> |
| 323 |
<tr> |
| 324 |
<th scope="row"><?php _e('Custom post types', 'polylang') ?></th> |
| 325 |
<td> |
| 326 |
<ul class="pll_inline_block"><?php |
| 327 |
foreach ($post_types as $post_type) { |
| 328 |
$pt = get_post_type_object($post_type); |
| 329 |
printf( |
| 330 |
'<li><label><input name="post_types[%s]" type="checkbox" value="1" %s /> %s</label></li>', |
| 331 |
esc_attr($post_type), |
| 332 |
in_array($post_type, $this->options['post_types']) ? 'checked="checked"' :'', |
| 333 |
esc_html($pt->labels->name) |
| 334 |
); |
| 335 |
}?> |
| 336 |
</ul> |
| 337 |
<p class="description"><?php _e('Activate languages and translations for custom post types.', 'polylang');?></p> |
| 338 |
</td> |
| 339 |
</tr><?php |
| 340 |
} |
| 341 |
|
| 342 |
if (!empty($taxonomies)) {?> |
| 343 |
<tr> |
| 344 |
<th scope="row"><?php _e('Custom taxonomies', 'polylang') ?></th> |
| 345 |
<td> |
| 346 |
<ul class="pll_inline_block"><?php |
| 347 |
foreach ($taxonomies as $taxonomy) { |
| 348 |
$tax = get_taxonomy($taxonomy); |
| 349 |
printf( |
| 350 |
'<li><label><input name="taxonomies[%s]" type="checkbox" value="1" %s /> %s</label></li>', |
| 351 |
esc_attr($taxonomy), |
| 352 |
in_array($taxonomy, $this->options['taxonomies']) ? 'checked="checked"' :'', |
| 353 |
esc_html($tax->labels->name) |
| 354 |
); |
| 355 |
}?> |
| 356 |
</ul> |
| 357 |
<p class="description"><?php _e('Activate languages and translations for custom taxonomies.', 'polylang');?></p> |
| 358 |
</td> |
| 359 |
</tr><?php |
| 360 |
}?> |
| 361 |
|
| 362 |
<tr> |
| 363 |
<th scope="row"><?php _e('Synchronization', 'polylang') ?></th> |
| 364 |
<td> |
| 365 |
<ul class="pll_inline_block"><?php |
| 366 |
foreach (self::list_metas_to_sync() as $key => $str) |
| 367 |
printf( |
| 368 |
'<li><label><input name="sync[%s]" type="checkbox" value="1" %s /> %s</label></li>', |
| 369 |
esc_attr($key), |
| 370 |
in_array($key, $this->options['sync']) ? 'checked="checked"' :'', |
| 371 |
esc_html($str) |
| 372 |
);?> |
| 373 |
</ul> |
| 374 |
<p class="description"><?php _e('The synchronization options allow to maintain exact same values (or translations in the case of taxonomies and page parent) of meta content between the translations of a post or page.', 'polylang');?></p> |
| 375 |
</td> |
| 376 |
</tr> |
| 377 |
|
| 378 |
</table> |
| 379 |
|
| 380 |
<?php submit_button(); // since WP 3.1 ?> |
| 381 |
|
| 382 |
</form><?php |
| 383 |
break; |
| 384 |
|
| 385 |
default: |
| 386 |
break; |
| 387 |
}?> |
| 388 |
|
| 389 |
</div><!-- wrap --> |
| 390 |
|