PluginProbe
Polylang / 0.7
Polylang v0.7
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
polylang / include / languages-form.php

languages-form.php in Polylang 0.7, at include/languages-form.php

262 lines 9.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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('<a href="options-general.php?page=mlang&tab=%s" class="nav-tab %s">%s</a>', $key, $key == $active_tab ? 'nav-tab-active' : '', $name);?>
10 </h2><?php
11
12 switch($active_tab) {
13
14 // Languages tab
15 case 'lang':
16
17 if (isset($_GET['error'])) {?>
18 <div id="message" class="error fade"><p><?php echo $errors[$_GET['error']]; ?></p></div><?php
19 }?>
20
21 <div id="col-container">
22 <div id="col-right">
23 <div class="col-wrap"><?php
24 // displays the language list in a table
25 $list_table->display(); ?>
26 </div><!-- col-wrap -->
27 </div><!-- col-right -->
28
29 <div id="col-left">
30 <div class="col-wrap">
31
32 <div class="form-wrap">
33 <h3><?php echo $action=='edit' ? _e('Edit language','polylang') : _e('Add new language','polylang'); ?></h3><?php
34
35 // displays the add (or edit) language form
36 // The term fields are used as follows :
37 // name -> language name (used only for display)
38 // slug -> language code (ideally 2-letters ISO 639-1 language code but I currently use it only as slug so it doesn't matter)
39 // description -> WordPress locale for the language. Here if something wrong is used, the .mo files will not be loaded...
40 // term_group -> order
41
42 // adds noheader=true in the action url to allow using wp_redirect when processing the form ?>
43 <form id="add-lang" method="post" action="admin.php?page=mlang&amp;noheader=true" class="validate">
44 <?php wp_nonce_field('add-lang', '_wpnonce_add-lang');
45
46 if ($action=='edit') {?>
47 <input type="hidden" name="action" value="update" />
48 <input type="hidden" name="lang_id" value="<?php echo esc_attr($edit_lang->term_id);?>" /><?php
49 }
50 else { ?>
51 <input type="hidden" name="action" value="add" /><?php
52 }?>
53
54 <div class="form-field">
55 <label for="lang_list"><?php _e('Choose a language', 'polylang');?></label>
56 <select name="lang_list" id="lang_list">
57 <option value=""></option>';<?php
58 include(PLL_INC.'/languages.php');
59 foreach ($languages as $key=>$lang) {
60 printf("<option value='%s-%s-%s'>%s</option>\n", esc_attr($key), esc_attr($lang[0]), $lang[2] ? '1' : '0' , esc_html($lang[1]));
61 } ?>
62 </select>
63 <p><?php _e('You can choose a language in the list or directly edit it below.', 'polylang');?></p>
64 </div>
65
66 <div class="form-field form-required">
67 <label for="name"><?php _e('Full name', 'polylang');?></label>
68 <input name="name" id="name" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->name);?>" size="40" aria-required="true" />
69 <p><?php _e('The name is how it is displayed on your site (for example: English).', 'polylang');?></p>
70 </div>
71
72 <div class="form-field form-required">
73 <label for="description"><?php _e('Locale', 'polylang');?></label><?php
74 printf('<input name="description" id="description" type="text" value="%s" size="5" maxlength="5" aria-required="true" />',
75 $action=='edit' ? esc_attr($edit_lang->description) : '');?>
76 <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>
77 </div>
78
79 <div class="form-field">
80 <label for="slug"><?php _e('Language code', 'polylang');?></label>
81 <input name="slug" id="slug" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->slug);?>" size="2" maxlength="2"/>
82 <p><?php _e('2-letters ISO 639-1 language code (for example: en)', 'polylang');?></p>
83 </div>
84
85 <div class="form-field">
86 <legend><?php _e('Text direction', 'polylang');?></legend><?php
87 printf('<label><input name="rtl" type="radio" class="tog" value="0" %s /> %s</label>',
88 $rtl ? '' : 'checked="checked"', __('left to right', 'polylang'));
89 printf('<label><input name="rtl" type="radio" class="tog" value="1" %s /> %s</label>',
90 $rtl ? 'checked="checked"' : '', __('right to left', 'polylang'));?>
91 <p><?php _e('Choose the text direction for the language', 'polylang');?></p>
92 </div>
93
94 <div class="form-field">
95 <label for="term_group"><?php _e('Order', 'polylang');?></label>
96 <input name="term_group" id="term_group" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->term_group);?>" />
97 <p><?php _e('Position of the language in the language switcher', 'polylang');?></p>
98 </div>
99
100 <?php submit_button( $action == 'edit' ? __('Update') : __('Add new language', 'polylang'), 'button'); // since WP 3.1 ?>
101
102 </form>
103 </div><!-- form-wrap -->
104 </div><!-- col-wrap -->
105 </div><!-- col-left -->
106 </div><!-- col-container --><?php
107 break;
108
109 // menu tab
110 case 'menus': ?>
111
112 <div class="form-wrap">
113 <form id="nav-menus-lang" method="post" action="admin.php?page=mlang&tab=menus" class="validate">
114 <?php wp_nonce_field('nav-menus-lang', '_wpnonce_nav-menus-lang');?>
115 <input type="hidden" name="action" value="nav-menus" /><?php
116
117 foreach ( $locations as $location => $description ) {?>
118 <h3><?php echo esc_html($description); ?></h3>
119 <table class="form-table"><?php
120 foreach ($listlanguages as $language) {?>
121 <tr><?php printf('<th><label for="menu-lang-%1$s-%2$s">%3$s</label></th>', esc_attr($location), esc_attr($language->slug), esc_html($language->name));?>
122 <td><?php printf('<select name="menu-lang[%1$s][%2$s]" id="menu-lang-%1$s-%2$s">', esc_attr($location), esc_attr($language->slug));?>
123 <option value="0"></option><?php
124 foreach ($menus as $menu) {
125 printf(
126 "<option value='%d'%s>%s</option>\n",
127 esc_attr($menu->term_id),
128 isset($menu_lang[$location][$language->slug]) && $menu_lang[$location][$language->slug] == $menu->term_id ? ' selected="selected"' : '',
129 esc_html($menu->name)
130 );
131 } ?>
132 </select></td>
133 </tr><?php
134 }?>
135 <tr>
136 <th><?php _e('Language switcher', 'polylang') ?></th>
137 <td><?php
138 foreach ($this->get_switcher_options('menu') as $key => $str)
139 printf('<label><input name="menu-lang[%1$s][%2$s]" type="checkbox" value="1" %3$s /> %4$s</label>',
140 esc_attr($location), esc_attr($key), isset($menu_lang[$location][$key]) && $menu_lang[$location][$key] ? 'checked="checked"' :'', esc_html($str));?>
141 </td>
142 </tr>
143 </table><?php
144 }
145
146 submit_button(); // since WP 3.1 ?>
147
148 </form>
149 </div><!-- form-wrap --><?php
150 break;
151
152 // string translations tab
153 case 'strings':
154
155 $paged = isset($_GET['paged']) ? '&paged='.$_GET['paged'] : '';?>
156 <form id="string-translation" method="post" action="<?php echo esc_url(admin_url('admin.php?page=mlang&tab=strings'.$paged.'&noheader=true'))?>" class="validate">
157 <?php wp_nonce_field('string-translation', '_wpnonce_string-translation');?>
158 <input type="hidden" name="action" value="string-translation" /><?php
159 $string_table->display();
160 submit_button(); // since WP 3.1 ?>
161 </form><?php
162 break;
163
164 // settings tab
165 case 'settings': ?>
166
167 <div class="form-wrap">
168 <form id="options-lang" method="post" action="admin.php?page=mlang&tab=settings" class="validate">
169 <?php wp_nonce_field('options-lang', '_wpnonce_options-lang');?>
170 <input type="hidden" name="action" value="options" />
171
172 <table class="form-table">
173
174 <tr>
175 <th><label for='default_lang'><?php _e('Default language', 'polylang');?></label></th>
176 <td><?php echo $this->dropdown_languages(array('name' => 'default_lang', 'selected' => $options['default_lang']));?></td>
177 </tr><?php
178
179 // posts or terms without language set
180 if (!empty($posts) || !empty($terms) && $options['default_lang']) {
181
182 if (!empty($posts))
183 echo '<input type="hidden" name="posts" value="'.esc_attr($posts).'" />';
184 if (!empty($terms))
185 echo '<input type="hidden" name="terms" value="'.esc_attr($terms).'" />';?>
186
187 <tr>
188 <th></th>
189 <td>
190 <label style="color: red"><?php
191 printf(
192 '<input name="fill_languages" type="checkbox" value="1" /> %s',
193 __('There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?', 'polylang')
194 );?>
195 </label>
196 </td>
197 </tr><?php
198 }?>
199
200 <tr>
201 <th><?php _e('Detect browser language', 'polylang');?></th>
202 <td>
203 <label><?php
204 printf(
205 '<input name="browser" type="checkbox" value="1" %s /> %s',
206 $options['browser'] ? 'checked="checked"' :'',
207 __('When the front page is visited, set the language according to the browser preference', 'polylang')
208 );?>
209 </label>
210 </td>
211 </tr>
212
213 <tr>
214 <th><?php _e('URL modifications', 'polylang') ?></th>
215 <td scope="row">
216 <label><?php
217 printf(
218 '<input name="rewrite" type="radio" value="0" %s /> %s %s',
219 $options['rewrite'] ? '' : 'checked="checked"',
220 __('Keep /language/ in pretty permalinks. Example:', 'polylang'),
221 '<code>'.esc_html(home_url('language/en/')).'</code>'
222 );?>
223 </label>
224 <label><?php
225 printf(
226 '<input name="rewrite" type="radio" value="1" %s /> %s %s',
227 $options['rewrite'] ? 'checked="checked"' : '',
228 __('Remove /language/ in pretty permalinks. Example:', 'polylang'),
229 '<code>'.esc_html(home_url('en/')).'</code>'
230 );?>
231 </label>
232 <label><?php
233 printf(
234 '<input name="hide_default" type="checkbox" value="1" %s /> %s',
235 $options['hide_default'] ? 'checked="checked"' :'',
236 __('Hide URL language information for default language', 'polylang')
237 );?>
238 </label>
239 <label><?php
240 printf(
241 '<input name="force_lang" type="checkbox" value="1" %s /> %s',
242 $options['force_lang'] ? 'checked="checked"' :'',
243 __('Add language information to all URL including posts, pages, categories and post tags (not recommended)', 'polylang')
244 );?>
245 </label>
246 </td>
247 </tr>
248
249 </table>
250
251 <?php submit_button(); // since WP 3.1 ?>
252
253 </form>
254 </div><!-- form-wrap --><?php
255 break;
256
257 default:
258 break;
259 }?>
260
261 </div><!-- wrap -->
262