| 1 |
<?php // displays the Languages admin panel |
| 2 |
|
| 3 |
// I don't use the custom taxonomy form provide by Wordpress because I want to modify the labels below the fields... |
| 4 |
// It seems that there is currently (3.2.1) no filter to do this |
| 5 |
|
| 6 |
// The term fields are used as follows : |
| 7 |
// name -> language name (used only for display) |
| 8 |
// slug -> language code (ideally 2-letters ISO 639-1 language code but I currently use it only as slug so it doesn't matter) |
| 9 |
// description -> WordPress Locale for the language. Here if something wrong is used, the .mo files will not be loaded... |
| 10 |
|
| 11 |
?> |
| 12 |
<div class="wrap"> |
| 13 |
<?php screen_icon('options-general'); ?> |
| 14 |
<h2><?php _e('Languages','polylang') ?></h2> |
| 15 |
|
| 16 |
<div id="col-container"> |
| 17 |
<div id="col-right"> |
| 18 |
<div class="col-wrap"> |
| 19 |
|
| 20 |
<?php $list_table->display(); // displays the language list in a table ?> |
| 21 |
|
| 22 |
</div> <!-- col-wrap --> |
| 23 |
</div> <!-- col-right --> |
| 24 |
|
| 25 |
<div id="col-left"> |
| 26 |
<div class="col-wrap"> |
| 27 |
|
| 28 |
<div class="form-wrap"> |
| 29 |
<h3><?php echo $action=='edit' ? _e('Edit language','polylang') : _e('Add new language','polylang'); ?></h3> |
| 30 |
|
| 31 |
<?php // displays the add (or edit) language form |
| 32 |
|
| 33 |
// adds noheader=true in the action url to allow using wp_redirect when processing the form ?> |
| 34 |
<form id="add-lang" method="post" action="admin.php?page=mlang&noheader=true" class="validate"> |
| 35 |
<?php wp_nonce_field('add-lang', '_wpnonce_add-lang'); |
| 36 |
|
| 37 |
if ($action=='edit') {?> |
| 38 |
<input type="hidden" name="action" value="update" /> |
| 39 |
<input type="hidden" name="lang" value="<?php echo $edit_lang->term_id;?>" /><?php |
| 40 |
} |
| 41 |
else { ?> |
| 42 |
<input type="hidden" name="action" value="add" /><?php |
| 43 |
}?> |
| 44 |
|
| 45 |
<div class="form-field form-required"> |
| 46 |
<label for="name"><?php _e('Full name', 'polylang');?></label> |
| 47 |
<input name="name" id="name" type="text" value="<?php if ($action=='edit') echo $edit_lang->name;?>" size="40" aria-required="true" /> |
| 48 |
<p><?php _e('The name is how it is displayed on your site (for example: English).', 'polylang');?></p> |
| 49 |
</div> |
| 50 |
|
| 51 |
<div class="form-field form-required"> |
| 52 |
<label for="description"><?php _e('Locale', 'polylang');?></label> |
| 53 |
<input name="description" id="description" type="text" value="<?php if ($action=='edit') echo $edit_lang->description;?>" size="40" aria-required="true" /> |
| 54 |
<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> |
| 55 |
</div> |
| 56 |
|
| 57 |
<div class="form-field"> |
| 58 |
<label for="slug"><?php _e('Language code', 'polylang');?></label> |
| 59 |
<input name="slug" id="slug" type="text" value="<?php if ($action=='edit') echo $edit_lang->slug;?>" size="40" /> |
| 60 |
<p><?php _e('2-letters ISO 639-1 language code (for example: en)', 'polylang');?></p> |
| 61 |
</div> |
| 62 |
|
| 63 |
<?php if ($action=='edit') |
| 64 |
submit_button(__('Update'), 'button'); // since WP 3.1 |
| 65 |
else |
| 66 |
submit_button(__('Add new language', 'polylang'), 'button'); // since WP 3.1?> |
| 67 |
|
| 68 |
</form> |
| 69 |
</div> <!-- form-wrap --> |
| 70 |
</div> <!-- col-wrap --> |
| 71 |
</div> <!-- col-left --> |
| 72 |
</div> <!-- col-container --> <?php |
| 73 |
|
| 74 |
// displays the nav menus languages form |
| 75 |
if (current_theme_supports( 'menus' )) { ?> |
| 76 |
|
| 77 |
<div class="form-wrap"> |
| 78 |
<h3 id="menus"><?php _e('Menus','polylang');?></h3> |
| 79 |
|
| 80 |
<form id="nav-menus-lang" method="post" action="admin.php?page=mlang" class="validate"> |
| 81 |
<?php wp_nonce_field('nav-menus-lang', '_wpnonce_nav-menus-lang');?> |
| 82 |
<input type="hidden" name="action" value="nav-menus" /> |
| 83 |
|
| 84 |
<table class="wp-list-table widefat fixed tags" cellspacing="0" style="width: auto"> |
| 85 |
<thead><tr> |
| 86 |
<th><?php _e('Theme location','Polylang') ?></th><?php |
| 87 |
foreach ($listlanguages as $language) { |
| 88 |
echo '<th>' . $language->name . '</th>'; |
| 89 |
} ?> |
| 90 |
</tr></thead> |
| 91 |
|
| 92 |
<tbody> |
| 93 |
<?php foreach ( $locations as $location => $description ) { ?> |
| 94 |
<tr><td><?php echo $description; ?></td><?php |
| 95 |
foreach ($listlanguages as $language) { ?> |
| 96 |
<td><?php printf('<select name="menu-lang[%s][%s]" id="menu-lang-%s-%s">', $location, $language->slug, $location, $language->slug); ?> |
| 97 |
<option value="0"></option> |
| 98 |
<?php foreach ( $menus as $menu ) { |
| 99 |
printf("<option value='%s'%s>%s</option>\n", |
| 100 |
$menu->term_id, |
| 101 |
$menu_lang[$location][$language->slug] == $menu->term_id ? ' selected="selected"' : '', |
| 102 |
$menu->name); |
| 103 |
} ?> |
| 104 |
</select></td><?php |
| 105 |
}?> |
| 106 |
</tr><?php |
| 107 |
}?> |
| 108 |
</tbody> |
| 109 |
|
| 110 |
</table> |
| 111 |
|
| 112 |
<?php submit_button(); // since WP 3.1 ?> |
| 113 |
|
| 114 |
</form> |
| 115 |
</div> <!-- form-wrap --> <?php |
| 116 |
|
| 117 |
} // if (current_theme_supports( 'menus' )) |
| 118 |
|
| 119 |
// displays the Polylang options form |
| 120 |
//FIXME one inline CSS ?> |
| 121 |
<div class="form-wrap"> |
| 122 |
<h3><?php _e('Options','polylang');?></h3> |
| 123 |
|
| 124 |
<form id="options-lang" method="post" action="admin.php?page=mlang" class="validate"> |
| 125 |
<?php wp_nonce_field('options-lang', '_wpnonce_options-lang');?> |
| 126 |
<input type="hidden" name="action" value="options" /> |
| 127 |
|
| 128 |
<table class="form-table"> |
| 129 |
|
| 130 |
<tr> |
| 131 |
<th style="width: 300px;"><label><?php printf ('<input name="rewrite" type="radio" value="0" %s /> %s', |
| 132 |
$options['rewrite'] ? '' : 'checked="checked"', __('Keep /language/ in pretty permalinks', 'polylang')); ?></label></th> |
| 133 |
<td><code><?php echo home_url('language/en/'); ?></code></td> |
| 134 |
</tr> |
| 135 |
|
| 136 |
<tr> |
| 137 |
<th><label><?php printf ('<input name="rewrite" type="radio" value="1" %s /> %s', |
| 138 |
$options['rewrite'] ? 'checked="checked"' : '', __('Remove /language/ in pretty permalinks', 'polylang')); ?></label></th> |
| 139 |
<td><code><?php echo home_url('en/'); ?></code></td> |
| 140 |
</tr> |
| 141 |
|
| 142 |
<tr> |
| 143 |
<th><?php _e('The front page default language is : ', 'polylang');?></th> |
| 144 |
<td><label><?php printf('<input name="browser" type="checkbox" value="1" %s /> %s', |
| 145 |
$options['browser'] ? 'checked="checked"' :'', __('set by the browser preference', 'polylang')) ?></label> |
| 146 |
<label><?php _e('otherwise: ', 'polylang');?><select name="default_lang" id="default_lang"> |
| 147 |
<?php $listlanguages = $this->get_languages_list(); |
| 148 |
foreach ($listlanguages as $language) { |
| 149 |
printf("<option value='%s'%s>%s</option>\n", $language->slug, $options['default_lang'] == $language->slug ? ' selected="selected"' : '', $language->name); |
| 150 |
} ?> |
| 151 |
</select></label> |
| 152 |
</td> |
| 153 |
</tr> |
| 154 |
|
| 155 |
</table> |
| 156 |
|
| 157 |
<?php submit_button(); // since WP 3.1 ?> |
| 158 |
|
| 159 |
</form> |
| 160 |
</div> <!-- form-wrap --> |
| 161 |
|
| 162 |
</div> <!-- wrap --> |
| 163 |
|