Transposh WordPress Translation - Version 0.2.3

Version Description

Download this release

Release Info

Developer oferwald
Plugin Icon 128x128 Transposh WordPress Translation
Version 0.2.3
Comparing to
See all releases

Code changes from version 0.2.2 to 0.2.3

core/constants.php CHANGED
@@ -53,7 +53,7 @@ $languages = array("en" => "English,us,1",
53
  "id" => "Bahasa Indonesia,id,1",
54
  "it" => "Italiano,it,1",
55
  "is" => "íslenska,is,0",
56
- "ja" => "日本語 (にほんご/にっぽんご),jp,1",
57
  "ko" => "우리말,kr,1",
58
  "lv" => "latviešu valoda,lv,1",
59
  "lt" => "lietuvių kalba,lt,1",
@@ -95,6 +95,9 @@ define("ENABLE_AUTO_TRANSLATE", "transposh_enable_autotranslate");
95
  //Option to enable/disable rewrite of permalinks
96
  define("ENABLE_PERMALINKS_REWRITE", "transposh_enable_permalinks");
97
 
 
 
 
98
  //Option defining the default language
99
  define("DEFAULT_LANG", "transposh_default_language");
100
 
@@ -103,4 +106,8 @@ define("WIDGET_TRANSPOSH", "transposh_widget");
103
 
104
  //Define segment id prefix, will be included in span tag. also used as class identifier
105
  define("SPAN_PREFIX", "tr_");
 
 
 
 
106
  ?>
53
  "id" => "Bahasa Indonesia,id,1",
54
  "it" => "Italiano,it,1",
55
  "is" => "íslenska,is,0",
56
+ "ja" => "日本語,jp,1",
57
  "ko" => "우리말,kr,1",
58
  "lv" => "latviešu valoda,lv,1",
59
  "lt" => "lietuvių kalba,lt,1",
95
  //Option to enable/disable rewrite of permalinks
96
  define("ENABLE_PERMALINKS_REWRITE", "transposh_enable_permalinks");
97
 
98
+ //Option to enable/disable default language translation
99
+ define("ENABLE_DEFAULT_TRANSLATE", "transposh_enable_default_translate");
100
+
101
  //Option defining the default language
102
  define("DEFAULT_LANG", "transposh_default_language");
103
 
106
 
107
  //Define segment id prefix, will be included in span tag. also used as class identifier
108
  define("SPAN_PREFIX", "tr_");
109
+
110
+ //The name of our admin page
111
+ define('TRANSPOSH_ADMIN_PAGE_NAME', 'transposh');
112
+
113
  ?>
css/transposh_widget.css CHANGED
@@ -1 +1 @@
1
- .transposh_flags{direction:ltr;}.transposh_flags a{display:inline;}
1
+ .transposh_flags{direction:ltr;}.transposh_flags a{display:inline;background:transparent;}.transposh_flags img:hover{background:blue;}
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://transposh.org/
4
  Tags: translation, widget, filter, bilingual, multilingual, transposh, language, crowdsourcing, context, wiki, RTL, Hebrew, Spanish, French, Russian, English, Arabic, Portuguese
5
  Requires at least: 2.7
6
  Tested up to: 2.7.1
7
- Stable tag: 0.2.2
8
 
9
  Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
10
 
@@ -97,6 +97,13 @@ Just add the following line to your template:
97
  5. Widget style selection
98
 
99
  == Release notes ==
 
 
 
 
 
 
 
100
  * 2009/05/25 - 0.2.2
101
  * Fixed wrong handling of multy-byte chars as terminators (middle dots) which caused a regression bug
102
  * 2009/05/21 - 0.2.1
4
  Tags: translation, widget, filter, bilingual, multilingual, transposh, language, crowdsourcing, context, wiki, RTL, Hebrew, Spanish, French, Russian, English, Arabic, Portuguese
5
  Requires at least: 2.7
6
  Tested up to: 2.7.1
7
+ Stable tag: 0.2.3
8
 
9
  Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
10
 
97
  5. Widget style selection
98
 
99
  == Release notes ==
100
+ * 2009/06/03 - 0.2.3
101
+ * Revamped plugin setting page to a more useful one (code adapted from [code-styling.de](http://www.code-styling.de/))
102
+ * Widget settings may be changed from settings page (thanks [Db0](http://dbzer0.com/))
103
+ * Allow default language to be translated (for multilingual blogs) (thanks [Db0](http://dbzer0.com/))
104
+ * Setting page shows database statistics
105
+ * Fixed IE8 hover quirk in flags widget
106
+ * Avoid translating admin pages (even if we can)
107
  * 2009/05/25 - 0.2.2
108
  * Fixed wrong handling of multy-byte chars as terminators (middle dots) which caused a regression bug
109
  * 2009/05/21 - 0.2.1
screenshot-4.png CHANGED
Binary file
transposh.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin URI: http://transposh.org/
5
  Description: Translation filter for WordPress, After enabling please set languages at the <a href="options-general.php?page=Transposh">the options page</a> Want to help? visit our development site at <a href="http://trac.transposh.org/">trac.transposh.org</a>.
6
  Author: Team Transposh
7
- Version: 0.2.2
8
  Author URI: http://transposh.org/
9
  License: GPL (http://www.gnu.org/licenses/gpl.txt)
10
  */
@@ -42,19 +42,27 @@ function process_page(&$buffer) {
42
 
43
  global $wp_query, $lang, $is_edit_mode, $rtl_languages, $enable_auto_translate;
44
 
45
-
46
  $start_time = microtime(TRUE);
47
 
48
  // No language code - avoid further processing.
49
- if (!isset($wp_query->query_vars[LANG_PARAM]))
50
  {
 
 
 
 
 
 
 
51
  return $buffer;
52
  }
53
 
54
  $lang = $wp_query->query_vars[LANG_PARAM];
55
  $default_lang = get_default_lang();
56
- // Don't translate the default language
57
- if($lang == $default_lang)
 
 
58
  {
59
 
60
  return $buffer;
@@ -66,7 +74,6 @@ function process_page(&$buffer) {
66
  $is_edit_mode = TRUE;
67
  }
68
 
69
-
70
  //translate the entire page
71
  $parse = new parser();
72
  $parse->fetch_translate_func = 'fetch_translation';
@@ -213,13 +220,12 @@ function update_rewrite_rules($rules){
213
  }
214
 
215
  /*
216
- * Let WordPress which parameters are of interest to us.
217
  */
218
  function parameter_queryvars($qvars)
219
  {
220
  $qvars[] = LANG_PARAM;
221
  $qvars[] = EDIT_PARAM;
222
-
223
  return $qvars;
224
  }
225
 
@@ -357,7 +363,7 @@ function add_transposh_css() {
357
  return;
358
  }
359
  //include the transposh.css
360
- wp_enqueue_style("transposh","$tr_plugin_url/css/transposh.css",array(),'0.2.2');
361
  wp_enqueue_style("jquery","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/ui-lightness/jquery-ui.css",array(),'1.0');
362
 
363
  }
@@ -401,7 +407,7 @@ function add_transposh_js() {
401
  wp_deregister_script('jquery');
402
  wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",array(),'1.3.2');
403
  wp_enqueue_script("google","http://www.google.com/jsapi",array(),'1');
404
- wp_enqueue_script("transposh","$tr_plugin_url/js/transposh.js?post_url=$post_url{$edit_mode}&lang={$lang}&prefix=".SPAN_PREFIX,array("jquery"),'0.2.2');
405
  }
406
  }
407
 
@@ -414,19 +420,15 @@ function add_transposh_js() {
414
  */
415
  function is_editing_permitted()
416
  {
417
- global $wp_query;
418
 
419
- if(!is_translator())
420
- {
421
- return FALSE;
422
- }
423
 
424
- if (!isset($wp_query->query_vars[LANG_PARAM]))
425
- {
426
- return FALSE;
427
- }
428
 
429
- $lang = $wp_query->query_vars[LANG_PARAM];
430
  return is_editable_lang($lang);
431
  }
432
 
@@ -437,14 +439,7 @@ function is_editing_permitted()
437
  function is_editable_lang($lang)
438
  {
439
  $editable_langs = get_option(EDITABLE_LANGS);
440
-
441
- if(strpos($editable_langs, $lang) === FALSE)
442
- {
443
- //not an editable language
444
- return FALSE;
445
- }
446
-
447
- return TRUE;
448
  }
449
 
450
 
@@ -457,19 +452,16 @@ function is_editable_lang($lang)
457
  */
458
  function is_auto_translate_permitted()
459
  {
460
- global $wp_query;
 
461
 
462
- if(!get_option(ENABLE_AUTO_TRANSLATE, 1))
463
- {
464
- return FALSE;
465
- }
466
 
467
- if (!isset($wp_query->query_vars[LANG_PARAM]))
468
- {
469
- return FALSE;
470
- }
471
 
472
- $lang = $wp_query->query_vars[LANG_PARAM];
473
  return is_editable_lang($lang);
474
  }
475
  /**
4
  Plugin URI: http://transposh.org/
5
  Description: Translation filter for WordPress, After enabling please set languages at the <a href="options-general.php?page=Transposh">the options page</a> Want to help? visit our development site at <a href="http://trac.transposh.org/">trac.transposh.org</a>.
6
  Author: Team Transposh
7
+ Version: 0.2.3
8
  Author URI: http://transposh.org/
9
  License: GPL (http://www.gnu.org/licenses/gpl.txt)
10
  */
42
 
43
  global $wp_query, $lang, $is_edit_mode, $rtl_languages, $enable_auto_translate;
44
 
 
45
  $start_time = microtime(TRUE);
46
 
47
  // No language code - avoid further processing.
48
+ /*if (!isset($wp_query->query_vars[LANG_PARAM]) && !get_option(ENABLE_DEFAULT_TRANSLATE))
49
  {
50
+ return $buffer;
51
+ }*/
52
+
53
+ // Refrain from touching the administrative interface
54
+ if(stripos($_SERVER['REQUEST_URI'],'/wp-admin/') !== FALSE)
55
+ {
56
+
57
  return $buffer;
58
  }
59
 
60
  $lang = $wp_query->query_vars[LANG_PARAM];
61
  $default_lang = get_default_lang();
62
+ if (!$lang) $lang = $default_lang;
63
+
64
+ // Don't translate the default language unless specifically allowed to...
65
+ if($lang == $default_lang && !get_option(ENABLE_DEFAULT_TRANSLATE))
66
  {
67
 
68
  return $buffer;
74
  $is_edit_mode = TRUE;
75
  }
76
 
 
77
  //translate the entire page
78
  $parse = new parser();
79
  $parse->fetch_translate_func = 'fetch_translation';
220
  }
221
 
222
  /*
223
+ * Let WordPress know which parameters are of interest to us.
224
  */
225
  function parameter_queryvars($qvars)
226
  {
227
  $qvars[] = LANG_PARAM;
228
  $qvars[] = EDIT_PARAM;
 
229
  return $qvars;
230
  }
231
 
363
  return;
364
  }
365
  //include the transposh.css
366
+ wp_enqueue_style("transposh","$tr_plugin_url/css/transposh.css",array(),'0.2.3');
367
  wp_enqueue_style("jquery","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/ui-lightness/jquery-ui.css",array(),'1.0');
368
 
369
  }
407
  wp_deregister_script('jquery');
408
  wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",array(),'1.3.2');
409
  wp_enqueue_script("google","http://www.google.com/jsapi",array(),'1');
410
+ wp_enqueue_script("transposh","$tr_plugin_url/js/transposh.js?post_url=$post_url{$edit_mode}&lang={$lang}&prefix=".SPAN_PREFIX,array("jquery"),'0.2.3');
411
  }
412
  }
413
 
420
  */
421
  function is_editing_permitted()
422
  {
423
+ global $wp_query ,$lang;
424
 
425
+ if(!is_translator()) return FALSE;
 
 
 
426
 
427
+ $lang = $wp_query->query_vars[LANG_PARAM];
428
+ if (get_option(ENABLE_DEFAULT_TRANSLATE) && !$lang) $lang = get_default_lang();
429
+
430
+ if (!$lang) return FALSE;
431
 
 
432
  return is_editable_lang($lang);
433
  }
434
 
439
  function is_editable_lang($lang)
440
  {
441
  $editable_langs = get_option(EDITABLE_LANGS);
442
+ return (strpos($editable_langs, $lang) === FALSE) ? FALSE : TRUE;
 
 
 
 
 
 
 
443
  }
444
 
445
 
452
  */
453
  function is_auto_translate_permitted()
454
  {
455
+ global $wp_query ,$lang;
456
+
457
 
458
+ if(!get_option(ENABLE_AUTO_TRANSLATE, 1)) return FALSE;
 
 
 
459
 
460
+ $lang = $wp_query->query_vars[LANG_PARAM];
461
+ if (get_option(ENABLE_DEFAULT_TRANSLATE) && !$lang) $lang = get_default_lang();
462
+
463
+ if (!$lang) return FALSE;
464
 
 
465
  return is_editable_lang($lang);
466
  }
467
  /**
transposh_admin.php CHANGED
@@ -14,6 +14,8 @@
14
  * You should have received a copy of the GNU General Public License
15
  * along with this program; if not, write to the Free Software
16
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 
17
  */
18
 
19
  /*
@@ -21,58 +23,17 @@
21
  * who is allowed to translate ?
22
  */
23
 
 
24
 
25
- require_once("core/constants.php");
26
-
27
- /*
28
- * Add transposh to the admin menu.
29
- */
30
- function transposh_admin_menu()
31
- {
32
- add_options_page('Transposh','Transposh', 6,'Transposh', 'transposh_admin_page');
33
- }
34
-
35
- /*
36
- * Create the admin page.
37
- */
38
- function transposh_admin_page()
39
- {
40
-
41
-
42
- if($_POST['transposh_admin_posted'])
43
- {
44
- update_admin_options();
45
- }
46
-
47
- echo '<div class="wrap alternate">'.
48
- '<h2>Transposh</h2>'.
49
- '<form action="?page=Transposh" method="post">'.
50
- '<h3>Supported Languages</h3>';
51
-
52
- insert_supported_langs();
53
- echo '<br/><h3>Who can translate ?</h3>';
54
- insert_permissions();
55
-
56
- echo '<br/><h3>Rewrite URLs</h3>';
57
- insert_permalink_rewrite_option();
58
-
59
- echo '<br/><h3>Enable automatic translation</h3>';
60
- insert_auto_translate_option();
61
-
62
- echo '<input type="hidden" name="transposh_admin_posted" value="1" />'.
63
- '<p class="submit"><input type="submit" value="Save Changes" /></p>'.
64
- '</form>'.
65
- '</div>';
66
- }
67
 
68
  /*
69
  * Insert supported languages section in admin page
70
  */
71
  function insert_supported_langs()
72
  {
73
- global $languages, $tr_plugin_url;
74
 
75
- echo
76
  '<script type="text/javascript">'.
77
  'function chbx_change(lang)'.
78
  '{'.
@@ -88,73 +49,53 @@ function insert_supported_langs()
88
  '});'.
89
  '});'.
90
  '</script>';
91
- echo '<table><tr>';
92
 
93
  // we will hide the translatable column if anonymous can translate anyway
94
  if (can_translate('anonymous')) $extrastyle = ' style ="display:none"';
95
 
96
  $columns = 2;
97
-
98
- for($hdr=0; $hdr < $columns; $hdr++)
99
- {
100
- echo '<th>Language</th><th title="Is this language user selectable?">Viewable</th>'.
101
- '<th title="Is this language visible for translators?"'.$extrastyle.' class="tr_editable">Translatable</th>'.
102
- '<th>Default</th><th title="Can we auto-translate this language?">Auto?</th><th style="padding-right: 80px"></th>';
103
- }
104
-
105
- echo '</tr>';
106
-
107
- foreach($languages as $code => $lang)
108
- {
109
- list ($language,$flag,$autot) = explode (",",$lang);
110
- if($i % $columns == 0)
111
- {
112
- echo '<tr>';
113
- }
114
- $i++;
115
-
116
- echo "<td><img src=\"$tr_plugin_url/img/flags/$flag.png\" alt=\"\"/>&nbsp;$language</td>";
117
- echo '<td align="center"><input type="checkbox" id="' . $code .'_view" name="' .
118
- $code . '_view" onchange="chbx_change(\'' . $code . '\')" ' . is_viewable($code) . '/></td>';
119
- echo '<td class="tr_editable"'.$extrastyle.' align="center"><input type="checkbox" id="' . $code . '_edit" name="' .
120
- $code . '_edit" ' . is_editable($code). '/></td>';
121
- echo "<td align=\"center\"><input type=\"radio\" name=\"default_lang\" value=\"$code\" " .
122
- is_default_lang($code). "/></td>";
123
  // TODO: Add icons?
124
- if ($autot) {
125
- echo "<td>Y</td>";
126
- } else {
127
- echo "<td>N</td>";
128
- }
129
 
130
- if($i % $columns == 0)
131
- {
132
- echo '</tr>';
133
- }
134
- else
135
- {
136
- echo "<td style=\"padding-right: 60px\"></td>";
137
- }
138
- }
139
-
140
- echo '</table>';
141
  }
142
 
143
-
144
  /*
145
  * Determine if the given language code is currentlly editable
146
  * Return 'checked' if true otherwise ""
147
  */
148
  function is_editable($code)
149
  {
150
- $langs = get_option(EDITABLE_LANGS);
151
-
152
- if(strpos($langs, $code) !== FALSE)
153
- {
154
- return 'checked="checked"';
155
- }
156
-
157
- return "";
158
  }
159
 
160
  /*
@@ -163,13 +104,8 @@ function is_editable($code)
163
  */
164
  function is_viewable($code)
165
  {
166
- $langs = get_option(VIEWABLE_LANGS);
167
- if(strpos($langs, $code) !== FALSE)
168
- {
169
- return 'checked="checked"';
170
- }
171
-
172
- return "";
173
  }
174
 
175
  /*
@@ -178,58 +114,38 @@ function is_viewable($code)
178
  */
179
  function is_default_lang($code)
180
  {
181
- global $languages;
182
-
183
- $default = get_option(DEFAULT_LANG);
184
-
185
- if(!$languages[$default])
186
- {
187
- $default = "en";
188
- }
189
-
190
- if($default == $code)
191
- {
192
- return 'checked="checked"';
193
- }
194
-
195
- return "";
196
  }
197
 
198
  /*
199
- * Insert permissiions section in the admin page
200
  */
201
  function insert_permissions()
202
  {
203
- global $wp_roles;
204
-
205
- //display known roles and their permission to translate
206
- foreach($wp_roles->get_names() as $role_name => $something)
207
- {
208
- echo '<input type="checkbox" value="1" name="' . $role_name . '" ' . can_translate($role_name) .
209
- '/> ' . ucfirst($role_name) . '&nbsp;&nbsp;&nbsp;';
210
- }
211
-
212
- //Add our own custom role
213
- echo '<input id="tr_anon" type="checkbox" value="1" name="anonymous" '.
214
- can_translate('anonymous') . '/> Anonymous';
215
  }
216
 
217
  /*
218
  * Insert the option to enable/disable rewrite of perlmalinks.
219
  * When disabled only parameters will be used to identify the current language.
220
- *
221
  */
222
  function insert_permalink_rewrite_option()
223
  {
224
- $checked = "";
225
- if(get_option(ENABLE_PERMALINKS_REWRITE))
226
- {
227
- $checked = 'checked="checked"';
228
- }
229
-
230
- echo '<input type="checkbox" value="1" name="enable_permalinks" '. $checked . '/> '.
231
- 'Rewrite URLs to be search engine friendly, '.
232
- 'e.g. (http://wordpress.org/<strong>en</strong>). '.
233
  'Requires that permalinks will be enabled.';
234
  }
235
 
@@ -239,117 +155,276 @@ function insert_permalink_rewrite_option()
239
  */
240
  function insert_auto_translate_option()
241
  {
242
- $checked = "";
243
- if(get_option(ENABLE_AUTO_TRANSLATE,1))
244
- {
245
- $checked = 'checked="checked"';
246
- }
247
-
248
- echo '<input type="checkbox" value="1" name="enable_autotranslate" '.$checked.'/> '.
249
- 'Allow automatic translation of pages (currently using Google Translate)';
250
  }
251
 
 
 
 
 
 
 
 
 
 
 
 
252
  /*
253
  * Indicates whether the given role can translate.
254
  * Return either "checked" or ""
255
  */
256
  function can_translate($role_name)
257
  {
258
- global $wp_roles;
259
- if($role_name != 'anonymous')
260
- {
261
- $role = $wp_roles->get_role($role_name);
262
- if(isset($role) && $role->has_cap(TRANSLATOR))
263
- {
264
- return 'checked="checked"';
265
- }
266
- }
267
- else
268
- {
269
- $allow_anonymous = get_option(ANONYMOUS_TRANSLATION);
270
- if($allow_anonymous == "1")
271
- {
272
- return 'checked="checked"';
273
- }
274
- }
275
-
276
- return "";
277
  }
278
-
279
  /*
280
  * Handle newly posted admin options.
281
  */
282
  function update_admin_options()
283
  {
284
-
285
- global $wp_roles, $languages;
286
- $viewable_langs = array();
287
- $editable_langs = array();
288
-
289
- //update roles and capabilities
290
- foreach($wp_roles->get_names() as $role_name => $something)
291
- {
292
- $role = $wp_roles->get_role($role_name);
293
- if($_POST[$role_name] == "1")
294
- {
295
- $role->add_cap(TRANSLATOR);
296
- }
297
- else
298
- {
299
- $role->remove_cap(TRANSLATOR);
300
- }
301
- }
302
-
303
- //Anonymous needs to be handled differently as it does not have a role
304
- if($_POST['anonymous'] == "1")
305
- {
306
- update_option(ANONYMOUS_TRANSLATION, 1);
307
- }
308
- else
309
- {
310
- update_option(ANONYMOUS_TRANSLATION, 0);
311
- }
312
-
313
-
314
- //Update the list of supported/editable languages
315
- foreach($languages as $code => $lang)
316
- {
317
- if($_POST[$code . '_view'])
318
- {
319
- $viewable_langs[$code] = $code;
320
  // force that every viewable lang is editable
321
- $editable_langs[$code] = $code;
322
- }
323
-
324
- if($_POST[$code . '_edit'])
325
- {
326
- $editable_langs[$code] = $code;
327
- }
328
- }
329
-
330
- update_option(VIEWABLE_LANGS, implode(',', $viewable_langs));
331
- update_option(EDITABLE_LANGS, implode(',', $editable_langs));
332
- update_option(DEFAULT_LANG, $_POST['default_lang']);
333
-
334
- if(get_option(ENABLE_PERMALINKS_REWRITE) != $_POST['enable_permalinks'])
335
- {
336
- global $wp_rewrite;
337
- update_option(ENABLE_PERMALINKS_REWRITE, $_POST['enable_permalinks']);
338
-
339
- //rewrite rules
340
- add_filter('rewrite_rules_array', 'update_rewrite_rules');
341
- $wp_rewrite->flush_rules();
342
- }
343
-
344
- if(get_option(ENABLE_AUTO_TRANSLATE,1) != $_POST['enable_autotranslate'])
345
- {
346
- update_option(ENABLE_AUTO_TRANSLATE, $_POST['enable_autotranslate']);
347
- }
348
-
349
- echo '<div id="message" class="updated fade">';
350
- echo '<p>Changes saved</p>';
351
- echo '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  }
353
 
354
- add_action('admin_menu', 'transposh_admin_menu');
355
  ?>
14
  * You should have received a copy of the GNU General Public License
15
  * along with this program; if not, write to the Free Software
16
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+ *
18
+ * adapted metabox sample code from http://www.code-styling.de/
19
  */
20
 
21
  /*
23
  * who is allowed to translate ?
24
  */
25
 
26
+ define ("TR_NONCE","transposh_nonce");
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  /*
30
  * Insert supported languages section in admin page
31
  */
32
  function insert_supported_langs()
33
  {
34
+ global $languages, $tr_plugin_url;
35
 
36
+ echo
37
  '<script type="text/javascript">'.
38
  'function chbx_change(lang)'.
39
  '{'.
49
  '});'.
50
  '});'.
51
  '</script>';
52
+ echo '<table class="'.NO_TRANSLATE_CLASS.'" style="width: 100%"><tr>';
53
 
54
  // we will hide the translatable column if anonymous can translate anyway
55
  if (can_translate('anonymous')) $extrastyle = ' style ="display:none"';
56
 
57
  $columns = 2;
58
+ for($hdr=0; $hdr < $columns; $hdr++) {
59
+ $extrapad = ($hdr != $columns - 1) ? ";padding-right: 40px" : '';
60
+ echo '<th style="text-align:left; width:'.(100/$columns).'%">Language</th>'.
61
+ '<th title="Is this language user selectable?">Viewable</th>'.
62
+ '<th title="Is this language visible for translators?"'.$extrastyle.' class="tr_editable">Translatable</th>'.
63
+ '<th>Default</th>'.
64
+ '<th style="text-align:left;width: 80px'.$extrapad.'" title="Can we auto-translate this language?">Auto?</th>';
65
+ }
66
+ echo '</tr>';
67
+
68
+ foreach($languages as $code => $lang)
69
+ {
70
+ list ($language,$flag,$autot) = explode (",",$lang);
71
+ if(!($i % $columns)) echo '<tr>';
72
+ $i++;
73
+
74
+ echo "<td><img src=\"$tr_plugin_url/img/flags/$flag.png\" alt=\"\"/>&nbsp;$language</td>";
75
+ echo '<td align="center"><input type="checkbox" id="' . $code .'_view" name="' .
76
+ $code . '_view" onchange="chbx_change(\'' . $code . '\')" ' . is_viewable($code) . '/></td>';
77
+ echo '<td class="tr_editable"'.$extrastyle.' align="center"><input type="checkbox" id="' . $code . '_edit" name="' .
78
+ $code . '_edit" ' . is_editable($code). '/></td>';
79
+ echo "<td align=\"center\"><input type=\"radio\" name=\"default_lang\" value=\"$code\" " .
80
+ is_default_lang($code). "/></td>";
 
 
 
81
  // TODO: Add icons?
82
+ echo "<td>".($autot ? "Y" : "N")."</td>";
 
 
 
 
83
 
84
+ if(!($i % $columns)) echo '</tr>';
85
+ }
86
+ // add a missing </tr> if needed
87
+ if($i % $columns) echo '</tr>';
88
+ echo '</table>';
 
 
 
 
 
 
89
  }
90
 
 
91
  /*
92
  * Determine if the given language code is currentlly editable
93
  * Return 'checked' if true otherwise ""
94
  */
95
  function is_editable($code)
96
  {
97
+ $langs = get_option(EDITABLE_LANGS);
98
+ return (strpos($langs, $code) !== FALSE) ? 'checked="checked"' : '';
 
 
 
 
 
 
99
  }
100
 
101
  /*
104
  */
105
  function is_viewable($code)
106
  {
107
+ $langs = get_option(VIEWABLE_LANGS);
108
+ return (strpos($langs, $code) !== FALSE) ? 'checked="checked"' : '';
 
 
 
 
 
109
  }
110
 
111
  /*
114
  */
115
  function is_default_lang($code)
116
  {
117
+ global $languages;
118
+ $default = get_option(DEFAULT_LANG);
119
+ if(!$languages[$default]) $default = "en";
120
+ return ($default == $code) ? 'checked="checked"' : '';
 
 
 
 
 
 
 
 
 
 
 
121
  }
122
 
123
  /*
124
+ * Insert permissions section in the admin page
125
  */
126
  function insert_permissions()
127
  {
128
+ global $wp_roles;
129
+ //display known roles and their permission to translate
130
+ foreach($wp_roles->get_names() as $role_name => $something)
131
+ {
132
+ echo '<input type="checkbox" value="1" name="'.$role_name.'" '.can_translate($role_name).
133
+ '/> '.ucfirst($role_name).'&nbsp;&nbsp;&nbsp;';
134
+ }
135
+ //Add our own custom role
136
+ echo '<input id="tr_anon" type="checkbox" value="1" name="anonymous" '. can_translate('anonymous') . '/> Anonymous';
 
 
 
137
  }
138
 
139
  /*
140
  * Insert the option to enable/disable rewrite of perlmalinks.
141
  * When disabled only parameters will be used to identify the current language.
 
142
  */
143
  function insert_permalink_rewrite_option()
144
  {
145
+ $checked = (get_option(ENABLE_PERMALINKS_REWRITE)) ? 'checked="checked"' :'';
146
+ echo '<input type="checkbox" value="1" name="enable_permalinks" '. $checked . '/> '.
147
+ 'Rewrite URLs to be search engine friendly, '.
148
+ 'e.g. (http://wordpress.org/<strong>en</strong>). '.
 
 
 
 
 
149
  'Requires that permalinks will be enabled.';
150
  }
151
 
155
  */
156
  function insert_auto_translate_option()
157
  {
158
+ $checked = (get_option(ENABLE_AUTO_TRANSLATE,1)) ? 'checked="checked"' : '';
159
+ echo '<input type="checkbox" value="1" name="enable_autotranslate" '.$checked.'/> '.
160
+ 'Allow automatic translation of pages (currently using Google Translate)';
 
 
 
 
 
161
  }
162
 
163
+ /*
164
+ * Insert the option to enable/disable default language translation.
165
+ * Disabled by default.
166
+ */
167
+ function insert_default_translate_option()
168
+ {
169
+ $checked = (get_option(ENABLE_DEFAULT_TRANSLATE,0)) ? 'checked="checked"' : '';
170
+ echo '<input type="checkbox" value="1" name="enable_defaulttranslate" '.$checked.'/> '.
171
+ 'Allow translation of default language - useful for sites with more than one major language';
172
+ }
173
+ //
174
  /*
175
  * Indicates whether the given role can translate.
176
  * Return either "checked" or ""
177
  */
178
  function can_translate($role_name)
179
  {
180
+ global $wp_roles;
181
+ if($role_name != 'anonymous')
182
+ {
183
+ $role = $wp_roles->get_role($role_name);
184
+ if(isset($role) && $role->has_cap(TRANSLATOR))
185
+ return 'checked="checked"';
186
+
187
+ }
188
+ else
189
+ return (get_option(ANONYMOUS_TRANSLATION,1)) ? 'checked="checked"' : '';
 
 
 
 
 
 
 
 
 
190
  }
191
+ //
192
  /*
193
  * Handle newly posted admin options.
194
  */
195
  function update_admin_options()
196
  {
197
+
198
+ global $wp_roles, $languages;
199
+ $viewable_langs = array();
200
+ $editable_langs = array();
201
+
202
+ //update roles and capabilities
203
+ foreach($wp_roles->get_names() as $role_name => $something)
204
+ {
205
+ $role = $wp_roles->get_role($role_name);
206
+ if($_POST[$role_name] == "1")
207
+ $role->add_cap(TRANSLATOR);
208
+ else
209
+ $role->remove_cap(TRANSLATOR);
210
+ }
211
+
212
+ //Anonymous needs to be handled differently as it does not have a role
213
+ update_option(ANONYMOUS_TRANSLATION, ($_POST['anonymous']) ? 1 : 0);
214
+
215
+ //Update the list of supported/editable languages
216
+ foreach($languages as $code => $lang)
217
+ {
218
+ if($_POST[$code . '_view'])
219
+ {
220
+ $viewable_langs[$code] = $code;
 
 
 
 
 
 
 
 
 
 
 
 
221
  // force that every viewable lang is editable
222
+ $editable_langs[$code] = $code;
223
+ }
224
+
225
+ if($_POST[$code . '_edit'])
226
+ {
227
+ $editable_langs[$code] = $code;
228
+ }
229
+ }
230
+
231
+ update_option(VIEWABLE_LANGS, implode(',', $viewable_langs));
232
+ update_option(EDITABLE_LANGS, implode(',', $editable_langs));
233
+ update_option(DEFAULT_LANG, $_POST['default_lang']);
234
+
235
+ if(get_option(ENABLE_PERMALINKS_REWRITE) != $_POST['enable_permalinks'])
236
+ {
237
+ global $wp_rewrite;
238
+ update_option(ENABLE_PERMALINKS_REWRITE, $_POST['enable_permalinks']);
239
+
240
+ //rewrite rules
241
+ add_filter('rewrite_rules_array', 'update_rewrite_rules');
242
+ $wp_rewrite->flush_rules();
243
+ }
244
+
245
+ if(get_option(ENABLE_AUTO_TRANSLATE,1) != $_POST['enable_autotranslate'])
246
+ update_option(ENABLE_AUTO_TRANSLATE, $_POST['enable_autotranslate']);
247
+
248
+ if(get_option(ENABLE_DEFAULT_TRANSLATE) != $_POST['enable_defaulttranslate'])
249
+ update_option(ENABLE_DEFAULT_TRANSLATE, $_POST['enable_defaulttranslate']);
250
+
251
+ }
252
+
253
+ //class that reperesent the complete plugin
254
+ class transposh_plugin {
255
+
256
+ //constructor of class, PHP4 compatible construction for backward compatibility
257
+ function transposh_plugin() {
258
+ //add filter for WordPress 2.8 changed backend box system !
259
+ add_filter('screen_layout_columns', array(&$this, 'on_screen_layout_columns'), 10, 2);
260
+ //add some help
261
+ add_filter('contextual_help_list', array(&$this, 'on_contextual_help'),100,2);
262
+ //register callback for admin menu setup
263
+ add_action('admin_menu', array(&$this, 'on_admin_menu'));
264
+ //register the callback been used if options of page been submitted and needs to be processed
265
+ add_action('admin_post_save_transposh', array(&$this, 'on_save_changes'));
266
+ }
267
+
268
+ //for WordPress 2.8 we have to tell, that we support 2 columns !
269
+ function on_screen_layout_columns($columns, $screen) {
270
+ if ($screen == $this->pagehook) {
271
+ $columns[$this->pagehook] = 2;
272
+ }
273
+ return $columns;
274
+ }
275
+
276
+ //add some help
277
+ function on_contextual_help($filterVal,$screen) {
278
+ if($screen == "settings_page_transposh") {
279
+ $filterVal["settings_page_transposh"] = '<p>Transposh makes your blog translatable</p>'.
280
+ '<a href="http://transposh.org/">Plugin homepage</a><br/>'.
281
+ '<a href="http://transposh.org/faq/">Frequently asked questions</a>';
282
+ }
283
+ return $filterVal;
284
+ }
285
+
286
+ //extend the admin menu
287
+ function on_admin_menu() {
288
+ //add our own option page, you can also add it to different sections or use your own one
289
+ $this->pagehook = add_options_page('Transposh control center', "Transposh", 'manage_options', TRANSPOSH_ADMIN_PAGE_NAME, array(&$this, 'on_show_page'));
290
+ //register callback gets call prior your own page gets rendered
291
+ add_action('load-'.$this->pagehook, array(&$this, 'on_load_page'));
292
+ }
293
+
294
+ //will be executed if wordpress core detects this page has to be rendered
295
+ function on_load_page() {
296
+ //ensure, that the needed javascripts been loaded to allow drag/drop, expand/collapse and hide/show of boxes
297
+ wp_enqueue_script('common');
298
+ wp_enqueue_script('wp-lists');
299
+ wp_enqueue_script('postbox');
300
+
301
+ //add several metaboxes now, all metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
302
+ add_meta_box('transposh-sidebox-about', 'About this plugin', array(&$this, 'on_sidebox_about_content'), $this->pagehook, 'side', 'core');
303
+ add_meta_box('transposh-sidebox-widget', 'Widget settings', array(&$this, 'on_sidebox_widget_content'), $this->pagehook, 'side', 'core');
304
+ add_meta_box('transposh-sidebox-news', 'Plugin news', array(&$this, 'on_sidebox_news_content'), $this->pagehook, 'side', 'core');
305
+ add_meta_box('transposh-sidebox-stats', 'Plugin stats', array(&$this, 'on_sidebox_stats_content'), $this->pagehook, 'side', 'core');
306
+ add_meta_box('transposh-contentbox-languages', 'Supported languages', array(&$this, 'on_contentbox_languages_content'), $this->pagehook, 'normal', 'core');
307
+ add_meta_box('transposh-contentbox-translation', 'Translation settings', array(&$this, 'on_contentbox_translation_content'), $this->pagehook, 'normal', 'core');
308
+ add_meta_box('transposh-contentbox-general', 'Generic settings', array(&$this, 'on_contentbox_generic_content'), $this->pagehook, 'normal', 'core');
309
+ }
310
+
311
+ //executed to show the plugins complete admin page
312
+ function on_show_page() {
313
+ //we need the global screen column value to beable to have a sidebar in WordPress 2.8
314
+ global $screen_layout_columns;
315
+ //add a 3rd content box now for demonstration purpose, boxes added at start of page rendering can't be switched on/off,
316
+ //may be needed to ensure that a special box is always available
317
+ add_meta_box('transposh-contentbox-community', 'Transposh community features (upcoming)', array(&$this, 'on_contentbox_community_content'), $this->pagehook, 'normal', 'core');
318
+ //define some data can be given to each metabox during rendering - not used now
319
+ //$data = array('My Data 1', 'My Data 2', 'Available Data 1');
320
+ ?>
321
+ <div id="transposh-general" class="wrap">
322
+ <?php screen_icon('options-general'); ?>
323
+ <h2>Transposh</h2>
324
+ <form action="admin-post.php" method="post">
325
+ <?php wp_nonce_field(TR_NONCE); ?>
326
+ <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
327
+ <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
328
+ <input type="hidden" name="action" value="save_transposh" />
329
+
330
+ <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
331
+ <div id="side-info-column" class="inner-sidebar">
332
+ <?php do_meta_boxes($this->pagehook, 'side', $data); ?>
333
+ </div>
334
+ <div id="post-body" class="has-sidebar">
335
+ <div id="post-body-content" class="has-sidebar-content">
336
+ <?php do_meta_boxes($this->pagehook, 'normal', $data);
337
+ /* Maybe add static content here later */
338
+ //do_meta_boxes($this->pagehook, 'additional', $data); ?>
339
+ <p>
340
+ <input type="submit" value="Save Changes" class="button-primary" name="Submit"/>
341
+ </p>
342
+ </div>
343
+ </div>
344
+ <br class="clear"/>
345
+
346
+ </div>
347
+ </form>
348
+ </div>
349
+ <script type="text/javascript">
350
+ //<![CDATA[
351
+ jQuery(document).ready( function($) {
352
+ // close postboxes that should be closed
353
+ $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
354
+ // postboxes setup
355
+ postboxes.add_postbox_toggles('<?php echo $this->pagehook; ?>');
356
+ });
357
+ //]]>
358
+ </script>
359
+
360
+ <?php
361
+ }
362
+
363
+ //executed if the post arrives initiated by pressing the submit button of form
364
+ function on_save_changes() {
365
+ //user permission check
366
+ if ( !current_user_can('manage_options') )
367
+ wp_die( __('Problems?') );
368
+ //cross check the given referer
369
+ check_admin_referer(TR_NONCE);
370
+
371
+ //process here your on $_POST validation and / or option saving
372
+ update_admin_options();
373
+ transposh_widget_post();
374
+
375
+ //lets redirect the post request into get request (you may add additional params at the url, if you need to show save results
376
+ wp_redirect($_POST['_wp_http_referer']);
377
+ }
378
+
379
+ //below you will find for each registered metabox the callback method, that produces the content inside the boxes
380
+ //i did not describe each callback dedicated, what they do can be easily inspected and compare with the admin page displayed
381
+
382
+ function on_sidebox_about_content($data) {
383
+ echo '<ul style="list-style-type:disc;margin-left:20px;">';
384
+ echo '<li><a href="http://transposh.org/">Plugin Homepage</a></li>';
385
+ echo '<li><a href="http://transposh.org/redir/newfeature">Suggest a Feature</a></li>';
386
+ //Support Forum
387
+ echo '<li><a href="http://transposh.org/redir/newticket">Report a Bug</a></li>';
388
+ //Donate with PayPal
389
+ echo '</ul>';
390
+ }
391
+ function on_sidebox_widget_content($data) {
392
+ transposh_widget_control();
393
+ }
394
+
395
+ function on_sidebox_news_content($data) {
396
+ require_once(ABSPATH . WPINC . '/rss.php');
397
+ echo '<div style="margin:6px">';
398
+ wp_rss('http://feeds2.feedburner.com/transposh', 5);
399
+ echo '</div>';
400
+ }
401
+ function on_sidebox_stats_content($data) {
402
+ db_stats();
403
+ }
404
+
405
+ function on_contentbox_languages_content($data) {
406
+ insert_supported_langs();
407
+ }
408
+
409
+ function on_contentbox_translation_content($data) {
410
+ echo '<h4>Who can translate ?</h4>';
411
+ insert_permissions();
412
+
413
+ echo '<h4>Enable automatic translation</h4>';
414
+ insert_auto_translate_option();
415
+
416
+ echo '<h4>Enable default language translation</h4>';
417
+ insert_default_translate_option();
418
+
419
+ }
420
+ function on_contentbox_generic_content($data) {
421
+ echo '<h4>Rewrite URLs</h4>';
422
+ insert_permalink_rewrite_option();
423
+ }
424
+ function on_contentbox_community_content($data) {
425
+ echo "<p>This space is reserved for the coming community features of Transposh that will help you find translators to help with your site.</p>";
426
+ }
427
  }
428
 
429
+ $my_transposh_plugin = new transposh_plugin();
430
  ?>
transposh_db.php CHANGED
@@ -139,7 +139,7 @@ function update_translation()
139
  $original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
140
 
141
  //add our own custom header - so we will know that we got here
142
- header("Transposh: ver-0.2.2 db_version-". DB_VERSION);
143
 
144
  list($translated_text, $old_source) = fetch_translation($original, $lang);
145
  if ($translated_text) {
@@ -243,7 +243,7 @@ function get_translation_history($token, $lang)
243
  $original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
244
 
245
  //add our own custom header - so we will know that we got here
246
- header("Transposh: ver-0.2.2 db_version-". DB_VERSION);
247
 
248
  $query = "SELECT translated, translated_by, timestamp, source, user_login ".
249
  "FROM $table_name ".
@@ -262,10 +262,10 @@ function get_translation_history($token, $lang)
262
  '</tr>'.
263
  '</thead>'.
264
  '<tbody>';
265
- foreach ($rows as $row) :
266
  if (is_null($row->user_login)) $row->user_login = $row->translated_by;
267
  echo "<tr><td>{$row->translated}</td><td source=\"{$row->source}\"/><td user_id=\"{$row->translated_by}\">{$row->user_login}</td><td>{$row->timestamp}</td></tr>";
268
- endforeach;
269
  echo '</tbody></table>';
270
  }
271
 
@@ -314,4 +314,34 @@ function setup_db()
314
 
315
  }
316
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  ?>
139
  $original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
140
 
141
  //add our own custom header - so we will know that we got here
142
+ header("Transposh: ver-0.2.3 db_version-". DB_VERSION);
143
 
144
  list($translated_text, $old_source) = fetch_translation($original, $lang);
145
  if ($translated_text) {
243
  $original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
244
 
245
  //add our own custom header - so we will know that we got here
246
+ header("Transposh: ver-0.2.3 db_version-". DB_VERSION);
247
 
248
  $query = "SELECT translated, translated_by, timestamp, source, user_login ".
249
  "FROM $table_name ".
262
  '</tr>'.
263
  '</thead>'.
264
  '<tbody>';
265
+ foreach ($rows as $row) {
266
  if (is_null($row->user_login)) $row->user_login = $row->translated_by;
267
  echo "<tr><td>{$row->translated}</td><td source=\"{$row->source}\"/><td user_id=\"{$row->translated_by}\">{$row->user_login}</td><td>{$row->timestamp}</td></tr>";
268
+ }
269
  echo '</tbody></table>';
270
  }
271
 
314
 
315
  }
316
 
317
+ function db_stats () {
318
+ global $wpdb;
319
+ echo "<h4>Database stats</h4>";
320
+ $table_name = $wpdb->prefix . TRANSLATIONS_TABLE;
321
+ $log_table_name = $wpdb->prefix . TRANSLATIONS_LOG;
322
+ $query = "SELECT count(*) as count FROM `$table_name`";
323
+ $rows = $wpdb->get_results($query);
324
+ foreach ($rows as $row) {
325
+ if ($row->count)
326
+ echo "<p>Total of <strong style=\"color:red\">{$row->count}</strong> translated phrases.</p>";
327
+ }
328
+
329
+ $query = "SELECT count(*) as count,lang FROM `$table_name` WHERE source='0' GROUP BY `lang` ORDER BY `count` DESC LIMIT 3";
330
+ $rows = $wpdb->get_results($query);
331
+ foreach ($rows as $row) {
332
+ if ($row->count)
333
+ echo "<p><strong>{$row->lang}</strong> has <strong style=\"color:red\">{$row->count}</strong> human translated phrases.</p>";
334
+ }
335
+
336
+ echo "<h4>Recent activity</h4>";
337
+ $query = "SELECT * FROM `wp_translations_log` WHERE source='0' ORDER BY `timestamp` DESC LIMIT 3";
338
+ $rows = $wpdb->get_results($query);
339
+ foreach ($rows as $row) {
340
+ $td = mysql2date(get_option('date_format').' '.get_option('time_format'), $row->timestamp);
341
+ //the_date();
342
+ echo "<p>On <strong>{$td}</strong><br/>user <strong>{$row->translated_by}</strong> translated<br/>".
343
+ "\"<strong>{$row->original}</strong>\"<br/>to ".
344
+ "<strong style=\"color:red\">{$row->lang}</strong><br/>\"<strong>{$row->translated}</strong>\"</p>";
345
+ }
346
+ }
347
  ?>
transposh_widget.php CHANGED
@@ -85,7 +85,7 @@ function add_transposh_widget_css() {
85
  global $tr_plugin_url;
86
 
87
  //include the transposh_widget.css
88
- wp_enqueue_style("transposh_widget","$tr_plugin_url/css/transposh_widget.css",array(),'0.2.2');
89
 
90
  }
91
 
@@ -105,6 +105,7 @@ function transposh_widget($args)
105
 
106
  $is_edit = ($wp_query->query_vars[EDIT_PARAM] == "1" ? TRUE : FALSE);
107
  $lang = $wp_query->query_vars[LANG_PARAM];
 
108
 
109
  $options = get_option(WIDGET_TRANSPOSH);
110
  $viewable_langs = get_option(VIEWABLE_LANGS);
@@ -284,27 +285,23 @@ function no_translate($text)
284
  return "<span class=\"" . NO_TRANSLATE_CLASS . "\">$text</span>";
285
  }
286
 
 
 
 
 
 
 
 
 
 
 
287
  /*
288
  * This is the widget control, allowing the selection of presentation type.
289
  */
290
  function transposh_widget_control()
291
  {
292
- $options = $newoptions = get_option(WIDGET_TRANSPOSH);
293
-
294
- if ( isset($_POST['transposh-submit']) )
295
- {
296
- $newoptions['style'] = $_POST['transposh-style'];
297
- if ($_POST['transposh-progress'])
298
- $newoptions['progressbar'] = 1;
299
- else
300
- $newoptions['progressbar'] = 0;
301
- }
302
-
303
- if ( $options != $newoptions )
304
- {
305
- $options = $newoptions;
306
- update_option(WIDGET_TRANSPOSH, $options);
307
- }
308
 
309
  echo '<p><label for="transposh-style">Style:<br />'.
310
  '<select id="transposh-style" name="transposh-style">'.
85
  global $tr_plugin_url;
86
 
87
  //include the transposh_widget.css
88
+ wp_enqueue_style("transposh_widget","$tr_plugin_url/css/transposh_widget.css",array(),'0.2.3');
89
 
90
  }
91
 
105
 
106
  $is_edit = ($wp_query->query_vars[EDIT_PARAM] == "1" ? TRUE : FALSE);
107
  $lang = $wp_query->query_vars[LANG_PARAM];
108
+ if (get_option(ENABLE_DEFAULT_TRANSLATE) && !$lang) $lang = get_default_lang();
109
 
110
  $options = get_option(WIDGET_TRANSPOSH);
111
  $viewable_langs = get_option(VIEWABLE_LANGS);
285
  return "<span class=\"" . NO_TRANSLATE_CLASS . "\">$text</span>";
286
  }
287
 
288
+ function transposh_widget_post()
289
+ {
290
+ $options = $newoptions = get_option(WIDGET_TRANSPOSH);
291
+ $newoptions['style'] = $_POST['transposh-style'];
292
+ $newoptions['progressbar'] = ($_POST['transposh-progress']) ? 1 : 0;
293
+
294
+ if ($options != $newoptions) update_option(WIDGET_TRANSPOSH, $newoptions);
295
+
296
+ }
297
+
298
  /*
299
  * This is the widget control, allowing the selection of presentation type.
300
  */
301
  function transposh_widget_control()
302
  {
303
+ if (isset($_POST['transposh-submit'])) transposh_widget_post();
304
+ $options = get_option(WIDGET_TRANSPOSH);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
 
306
  echo '<p><label for="transposh-style">Style:<br />'.
307
  '<select id="transposh-style" name="transposh-style">'.