Google Language Translator - Version 5.0.02

Version Description

Download this release

Release Info

Developer rm2773
Plugin Icon wp plugin Google Language Translator
Version 5.0.02
Comparing to
See all releases

Code changes from version 5.0.01 to 5.0.02

google-language-translator.php CHANGED
@@ -1,1138 +1,1138 @@
1
- <?php
2
- /*
3
- Plugin Name: Google Language Translator
4
- Plugin URI: http://www.studio88design.com/plugins/google-language-translator
5
- Version: 5.0.01
6
- Description: The MOST SIMPLE Google Translator plugin. This plugin adds Google Translator to your website by using a single shortcode, [google-translator]. Settings include: layout style, hide/show specific languages, hide/show Google toolbar, and hide/show Google branding. Add the shortcode to pages, posts, and widgets.
7
- Author: Rob Myrick
8
- Author URI: http://www.wp-studio.net/
9
- */
10
-
11
- include( plugin_dir_path( __FILE__ ) . 'widget.php');
12
-
13
- class google_language_translator {
14
-
15
- public $languages_array = array (
16
- 'af' => 'Afrikaans',
17
- 'sq' => 'Albanian',
18
- 'ar' => 'Arabic',
19
- 'hy' => 'Armenian',
20
- 'az' => 'Azerbaijani',
21
- 'eu' => 'Basque',
22
- 'be' => 'Belarusian',
23
- 'bn' => 'Bengali',
24
- 'bs' => 'Bosnian',
25
- 'bg' => 'Bulgarian',
26
- 'ca' => 'Catalan',
27
- 'ceb' => 'Cebuano',
28
- 'zh-CN' => 'Chinese',
29
- 'zh-TW' => 'Chinese(Traditional)',
30
- 'hr' => 'Croatian',
31
- 'cs' => 'Czech',
32
- 'da' => 'Danish',
33
- 'nl' => 'Dutch',
34
- 'en' => 'English',
35
- 'eo' => 'Esperanto',
36
- 'et' => 'Estonian',
37
- 'tl' => 'Filipino',
38
- 'fi' => 'Finnish',
39
- 'fr' => 'French',
40
- 'gl' => 'Galician',
41
- 'ka' => 'Georgian',
42
- 'de' => 'German',
43
- 'el' => 'Greek',
44
- 'gu' => 'Gujarati',
45
- 'ht' => 'Haitian',
46
- 'ha' => 'Hausa',
47
- 'iw' => 'Hebrew',
48
- 'hi' => 'Hindi',
49
- 'hmn' => 'Hmong',
50
- 'hu' => 'Hungarian',
51
- 'is' => 'Icelandic',
52
- 'ig' => 'Igbo',
53
- 'id' => 'Indonesian',
54
- 'ga' => 'Irish',
55
- 'it' => 'Italian',
56
- 'ja' => 'Japanese',
57
- 'jw' => 'Javanese',
58
- 'kn' => 'Kannada',
59
- 'km' => 'Khmer',
60
- 'ko' => 'Korean',
61
- 'lo' => 'Lao',
62
- 'la' => 'Latin',
63
- 'lv' => 'Latvian',
64
- 'lt' => 'Lithuanian',
65
- 'mk' => 'Macedonian',
66
- 'ms' => 'Malay',
67
- 'mt' => 'Maltese',
68
- 'mi' => 'Maori',
69
- 'mr' => 'Marathi',
70
- 'mn' => 'Mongolian',
71
- 'ne' => 'Nepali',
72
- 'no' => 'Norwegian',
73
- 'fa' => 'Persian',
74
- 'pl' => 'Polish',
75
- 'pt' => 'Portuguese',
76
- 'pa' => 'Punjabi',
77
- 'ro' => 'Romanian',
78
- 'ru' => 'Russian',
79
- 'sr' => 'Serbian',
80
- 'sk' => 'Slovak',
81
- 'sl' => 'Slovenian',
82
- 'so' => 'Somali',
83
- 'es' => 'Spanish',
84
- 'sw' => 'Swahili',
85
- 'sv' => 'Swedish',
86
- 'ta' => 'Tamil',
87
- 'te' => 'Telugu',
88
- 'th' => 'Thai',
89
- 'tr' => 'Turkish',
90
- 'uk' => 'Ukranian',
91
- 'ur' => 'Urdu',
92
- 'vi' => 'Vietnamese',
93
- 'cy' => 'Welsh',
94
- 'yi' => 'Yiddish',
95
- 'yo' => 'Yoruba',
96
- 'zu' => 'Zulu'
97
- );
98
-
99
- public function __construct() {
100
- register_activation_hook( __FILE__, array( &$this, 'glt_activate' ));
101
- register_uninstall_hook( __FILE__, 'glt_deactivate' );
102
- add_action( 'admin_menu', array( &$this, 'add_my_admin_menus'));
103
- add_action('admin_init',array(&$this, 'initialize_settings'));
104
- add_action('wp_head',array(&$this, 'load_css'));
105
- add_action('wp_footer',array(&$this, 'footer_script'));
106
- add_shortcode( 'google-translator',array(&$this, 'google_translator_shortcode'));
107
- add_shortcode( 'glt', array(&$this, 'google_translator_menu_language'));
108
- add_filter('widget_text','do_shortcode');
109
- add_filter('walker_nav_menu_start_el', array(&$this,'menu_shortcodes') , 10 , 2);
110
- add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'glt_settings_link') );
111
-
112
- if (!is_admin()) {
113
- add_action('init',array(&$this, 'flags'));
114
- }
115
- }
116
-
117
- public function glt_activate() {
118
- add_option('googlelanguagetranslator_active', 1);
119
- add_option('googlelanguagetranslator_language','en');
120
- add_option('googlelanguagetranslator_language_option','all');
121
- add_option('googlelanguagetranslator_flags','show_flags');
122
- add_option('language_display_settings',array ('en' => 1));
123
- add_option('flag_display_settings',array ('flag-en' => 1));
124
- add_option('googlelanguagetranslator_translatebox','yes');
125
- add_option('googlelanguagetranslator_display','Vertical');
126
- add_option('googlelanguagetranslator_toolbar','Yes');
127
- add_option('googlelanguagetranslator_showbranding','Yes');
128
- add_option('googlelanguagetranslator_flags_alignment','flags_left');
129
- add_option('googlelanguagetranslator_analytics', 0);
130
- add_option('googlelanguagetranslator_analytics_id','');
131
- add_option('googlelanguagetranslator_css','');
132
- add_option('googlelanguagetranslator_manage_translations',0);
133
- add_option('googlelanguagetranslator_multilanguage',0);
134
- add_option('googlelanguagetranslator_floating_widget','yes');
135
- add_option('googlelanguagetranslator_flag_size','18');
136
- add_option('googlelanguagetranslator_flags_order','');
137
- }
138
-
139
- public function glt_deactivate() {
140
- delete_option('googlelanguagetranslator_active', 1);
141
- delete_option('googlelanguagetranslator_language','en');
142
- delete_option('googlelanguagetranslator_language_option','all');
143
- delete_option('googlelanguagetranslator_flags','show_flags');
144
- delete_option('language_display_settings',array ('en' => 1));
145
- delete_option('flag_display_settings',array ('flag-en' => 1));
146
- delete_option('googlelanguagetranslator_translatebox','yes');
147
- delete_option('googlelanguagetranslator_display','Vertical');
148
- delete_option('googlelanguagetranslator_toolbar','Yes');
149
- delete_option('googlelanguagetranslator_showbranding','Yes');
150
- delete_option('googlelanguagetranslator_flags_alignment','flags_left');
151
- delete_option('googlelanguagetranslator_analytics',1);
152
- delete_option('googlelanguagetranslator_analytics_id','');
153
- delete_option('googlelanguagetranslator_css','');
154
- delete_option('googlelanguagetranslator_manage_translations',0);
155
- delete_option('googlelanguagetranslator_multilanguage',0);
156
- delete_option('googlelanguagetranslator_floating_widget','yes');
157
- delete_option('googlelanguagetranslator_flag_size','18');
158
- delete_option('googlelanguagetranslator_flags_order','');
159
- }
160
-
161
- public function glt_settings_link ( $links ) {
162
- $settings_link = array(
163
- '<a href="' . admin_url( 'options-general.php?page=google_language_translator' ) . '">Settings</a>',
164
- );
165
- return array_merge( $links, $settings_link );
166
- }
167
-
168
- public function add_my_admin_menus(){
169
- $p = add_options_page('Google Language Translator', 'Google Language Translator', 'manage_options', 'google_language_translator', array(&$this, 'page_layout_cb'));
170
-
171
- add_action( 'load-' . $p, array(&$this, 'load_admin_js' ));
172
- }
173
-
174
- public function load_admin_js(){
175
- add_action( 'admin_enqueue_scripts', array(&$this, 'enqueue_admin_js' ));
176
- add_action('admin_footer',array(&$this, 'footer_script'));
177
- }
178
-
179
- public function enqueue_admin_js(){
180
- wp_enqueue_script( 'my-admin-script', plugins_url('js/admin.js',__FILE__), array('jquery'));
181
- wp_enqueue_script( 'my-flag-script', plugins_url('js/flags.js',__FILE__), array('jquery'));
182
-
183
- if (get_option ('googlelanguagetranslator_floating_widget') == 'yes') {
184
- wp_enqueue_script( 'my-toolbar-script', plugins_url('js/toolbar.js',__FILE__), array('jquery'));
185
- wp_enqueue_script( 'my-load-toolbar-script', plugins_url('js/load-toolbar.js',__FILE__), array('jquery'));
186
- wp_register_style( 'toolbar.css', plugins_url('css/toolbar.css', __FILE__) );
187
- wp_enqueue_style( 'toolbar.css' );
188
- }
189
-
190
- wp_enqueue_script( 'jquery-ui-core');
191
- wp_enqueue_script( 'jquery-ui-sortable');
192
- wp_enqueue_script( 'load_sortable_flags', plugins_url('js/load-sortable-flags.js',__FILE__), array('jquery'));
193
- wp_register_style( 'jquery-ui.css', plugins_url('css/jquery-ui.css',__FILE__) );
194
- wp_register_style( 'style.css', plugins_url('css/style.css', __FILE__) );
195
- wp_enqueue_style( 'style.css' );
196
- //wp_enqueue_style( 'jquery-ui.css' );
197
- }
198
-
199
- public function flags() {
200
- wp_enqueue_script( 'flags', plugins_url('js/flags.js',__FILE__), array('jquery'));
201
-
202
- if (get_option ('googlelanguagetranslator_floating_widget') == 'yes') {
203
- wp_enqueue_script( 'my-toolbar-script', plugins_url('js/toolbar.js',__FILE__), array('jquery'));
204
- wp_enqueue_script( 'my-load-toolbar-script', plugins_url('js/load-toolbar.js',__FILE__), array('jquery'));
205
- wp_register_style( 'toolbar.css', plugins_url('css/toolbar.css', __FILE__) );
206
- wp_enqueue_style( 'toolbar.css' );
207
- }
208
-
209
- wp_register_style( 'style.css', plugins_url('css/style.css', __FILE__) );
210
- wp_enqueue_style( 'style.css' );
211
- }
212
-
213
- public function load_css() {
214
- include( plugin_dir_path( __FILE__ ) . '/css/style.php');
215
- }
216
-
217
- public function google_translator_shortcode() {
218
-
219
- if (get_option('googlelanguagetranslator_display')=='Vertical'){
220
- return $this->googlelanguagetranslator_vertical();
221
- }
222
- elseif(get_option('googlelanguagetranslator_display')=='Horizontal'){
223
- return $this->googlelanguagetranslator_horizontal();
224
- }
225
- }
226
-
227
- public function googlelanguagetranslator_included_languages() {
228
- if ( get_option('googlelanguagetranslator_language_option')=='specific') {
229
- $get_language_choices = get_option ('language_display_settings');
230
-
231
- foreach ($get_language_choices as $key=>$value) {
232
- if($value == 1) {
233
- $items[] = $key;
234
- }
235
- }
236
-
237
- $comma_separated = implode(",",array_values($items));
238
-
239
- if ( get_option('googlelanguagetranslator_display') == 'Vertical') {
240
- $lang = ", includedLanguages:'".$comma_separated."'";
241
- return $lang;
242
- } elseif ( get_option('googlelanguagetranslator_display') == 'Horizontal') {
243
- $lang = ", includedLanguages:'".$comma_separated."'";
244
- return $lang;
245
- }
246
- }
247
- }
248
-
249
- public function analytics() {
250
- if ( get_option('googlelanguagetranslator_analytics') == 1 ) {
251
- $analytics_id = get_option('googlelanguagetranslator_analytics_id');
252
- $analytics = "gaTrack: true, gaId: '".$analytics_id."'";
253
-
254
- if (!empty ($analytics_id) ):
255
- return ', '.$analytics;
256
- endif;
257
- }
258
- }
259
-
260
- public function menu_shortcodes( $item_output,$item ) {
261
- if ( !empty($item->description)) {
262
- $output = do_shortcode($item->description);
263
-
264
- if ( $output != $item->description )
265
- $item_output = $output;
266
- }
267
- return $item_output;
268
- }
269
-
270
- public function google_translator_menu_language($atts, $content = '') {
271
- extract(shortcode_atts(array(
272
- "language" => 'Spanish',
273
- "label" => 'Spanish'
274
- ), $atts));
275
-
276
- $default_language = get_option('googlelanguagetranslator_language');
277
- $language_code = array_search($language,$this->languages_array);
278
-
279
- return "<a class='nturl notranslate ".$language_code." single-language flag' title='".$language."'>".$label."</a>";
280
- }
281
-
282
- public function footer_script() {
283
- global $shortcode_started;
284
- $default_language = get_option('googlelanguagetranslator_language');
285
- $language_choices = $this->googlelanguagetranslator_included_languages();
286
- $get_language_option = get_option('googlelanguagetranslator_language_option');
287
- $get_flag_choices = get_option ('flag_display_settings');
288
- $floating_widget = get_option ('googlelanguagetranslator_floating_widget');
289
- $is_active = get_option ( 'googlelanguagetranslator_active' );
290
- $is_multilanguage = get_option('googlelanguagetranslator_multilanguage');
291
- $auto_display = ', autoDisplay: false';
292
- $str = ''; ?>
293
- <script>jQuery(document).ready(function(a){a("a.nturl").on("click",function(){function l(){doGoogleLanguageTranslator(default_lang+"|"+default_lang)}function n(){doGoogleLanguageTranslator(default_lang+"|"+lang_prefix)}default_lang="<?php echo get_option('googlelanguagetranslator_language'); ?>",lang_prefix=a(this).attr("class").split(" ")[2],lang_prefix==default_lang?l():n()}),a("a.flag").on("click",function(){function l(){doGoogleLanguageTranslator(default_lang+"|"+default_lang)}function n(){doGoogleLanguageTranslator(default_lang+"|"+lang_prefix)}default_lang="<?php echo get_option('googlelanguagetranslator_language'); ?>",lang_prefix=a(this).attr("class").split(" ")[2],a(".tool-container").hide(),lang_prefix==default_lang?l():n()}),0==a("body > #google_language_translator").length&&a("#glt-footer").html("<div id='google_language_translator'></div>")});</script>
294
-
295
- <?php
296
-
297
- if( $is_active == 1) {
298
-
299
- foreach ($get_flag_choices as $flag_choice_key) {}
300
-
301
- if ($floating_widget=='yes' && $get_language_option != 'specific') {
302
- $str.='<div id="glt-translate-trigger"><span class="notranslate">Translate &raquo;</span></div>';
303
- $str.='<div id="glt-toolbar"></div>';
304
- } //endif $floating_widget
305
-
306
- if ($shortcode_started != 'true') {
307
- $str.='<div id="flags" style="display:none">';
308
- $str.='<ul id="sortable" class="ui-sortable">';
309
-
310
- if ((empty($new_languages_array_string)) || ($new_languages_array_count != $get_flag_choices_count)) {
311
- foreach ($this->languages_array as $key=>$value) {
312
- $language_code = $key;
313
- $language_name = $value;
314
- $language_name_flag = $language_name;
315
- if ($flag_choice_key == '1') {
316
- if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
317
- $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
318
- }
319
- } //$key
320
- }//foreach
321
- } else {
322
- foreach ($new_languages_array_codes as $value) {
323
- $language_name = $value;
324
- $language_code = array_search ($language_name,$this->languages_array);
325
- $language_name_flag = $language_name;
326
- if ($flag_choice_key == '1') {
327
- if (in_array($language_name,$this->languages_array)) {
328
- if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
329
- $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
330
- } //isset
331
- } //in_array
332
- }//flag_choice_key
333
- }//foreach
334
- }//endif
335
- $str.='</ul>';
336
- $str.='</div>';
337
- }
338
- }
339
-
340
- $language_choices = $this->googlelanguagetranslator_included_languages();
341
- $layout = get_option('googlelanguagetranslator_display');
342
- $is_multilanguage = get_option('googlelanguagetranslator_multilanguage');
343
- $horizontal_layout = ', layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL';
344
- $auto_display = ', autoDisplay: false';
345
- $default_language = get_option('googlelanguagetranslator_language');
346
-
347
- if ($is_multilanguage == 1) {
348
- $multilanguagePage = ', multilanguagePage:true';
349
- $str.="<div id='glt-footer'></div><script type='text/javascript'>function GoogleLanguageTranslatorInit() { new google.translate.TranslateElement({pageLanguage: '".$default_language."'".$language_choices . ($layout=='Horizontal' ? $horizontal_layout : '') . $auto_display . $multilanguagePage . $this->analytics()."}, 'google_language_translator');}</script>";
350
- $str.="<script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=GoogleLanguageTranslatorInit'></script>";
351
- echo $str;
352
-
353
- } elseif ($is_multilanguage == 0) {
354
- $str.="<div id='glt-footer'></div><script type='text/javascript'>function GoogleLanguageTranslatorInit() { new google.translate.TranslateElement({pageLanguage: '".$default_language."'".$language_choices . ($layout=='Horizontal' ? $horizontal_layout : '') . $auto_display . $this->analytics()."}, 'google_language_translator');}</script>";
355
- $str.="<script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=GoogleLanguageTranslatorInit'></script>";
356
- echo $str;
357
- }
358
- }
359
-
360
- public function googlelanguagetranslator_vertical() {
361
-
362
- global $shortcode_started;
363
-
364
- $shortcode_started = 'true';
365
- $get_flag_choices = get_option ('flag_display_settings');
366
- $new_languages_array_string = get_option('googlelanguagetranslator_flags_order');
367
- $new_languages_array = explode(",",$new_languages_array_string);
368
- $new_languages_array_codes = array_values($new_languages_array);
369
- $new_languages_array_count = count($new_languages_array);
370
- $get_flag_choices_count = count($get_flag_choices);
371
- $get_language_choices = get_option ('language_display_settings');
372
- $flag_width = get_option('googlelanguagetranslator_flag_size');
373
- $default_language_code = get_option('googlelanguagetranslator_language');
374
- $is_active = get_option ( 'googlelanguagetranslator_active' );
375
- $get_language_option = get_option('googlelanguagetranslator_language_option');
376
- $language_choices = $this->googlelanguagetranslator_included_languages();
377
- $floating_widget = get_option ('googlelanguagetranslator_floating_widget');
378
- $str = '';
379
-
380
- if( $is_active == 1){
381
-
382
- foreach ($get_flag_choices as $flag_choice_key) {}
383
-
384
- $str.='<div id="flags" class="size'.$flag_width.'">';
385
- $str.='<ul id="sortable" class="ui-sortable" style="float:left">';
386
-
387
- if ((empty($new_languages_array_string)) || ($new_languages_array_count != $get_flag_choices_count)) {
388
- foreach ($this->languages_array as $key=>$value) {
389
- $language_code = $key;
390
- $language_name = $value;
391
- $language_name_flag = $language_name;
392
- if ($flag_choice_key == '1') {
393
- if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
394
- $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
395
- }
396
- } //$key
397
- }//foreach
398
- } else {
399
- foreach ($new_languages_array_codes as $value) {
400
- $language_name = $value;
401
- $language_code = array_search ($language_name,$this->languages_array);
402
- $language_name_flag = $language_name;
403
- if ($flag_choice_key == '1') {
404
- if (in_array($language_name,$this->languages_array)) {
405
- if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
406
- $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
407
- } //isset
408
- } //in_array
409
- }//flag_choice_key
410
- }//foreach
411
- }//endif
412
- $str.='</ul>';
413
- $str.='</div>';
414
- $str.='<div id="google_language_translator"></div>';
415
- return $str;
416
- } //End is_active
417
- } // End glt_vertical
418
-
419
- public function googlelanguagetranslator_horizontal(){
420
- $shortcode_started = true;
421
- $get_flag_choices = get_option ('flag_display_settings');
422
- $new_languages_array_string = get_option('googlelanguagetranslator_flags_order');
423
- $new_languages_array = explode(",",$new_languages_array_string);
424
- $new_languages_array_codes = array_values($new_languages_array);
425
- $new_languages_array_count = count($new_languages_array);
426
- $get_flag_choices_count = count($get_flag_choices);
427
- $get_language_choices = get_option ('language_display_settings');
428
- $flag_width = get_option('googlelanguagetranslator_flag_size');
429
- $default_language_code = get_option('googlelanguagetranslator_language');
430
- $is_active = get_option ( 'googlelanguagetranslator_active' );
431
- $get_language_option = get_option('googlelanguagetranslator_language_option');
432
- $language_choices = $this->googlelanguagetranslator_included_languages();
433
- $floating_widget = get_option ('googlelanguagetranslator_floating_widget');
434
- $str = '';
435
-
436
- if( $is_active == 1) {
437
- foreach ($get_flag_choices as $flag_choice_key) {}
438
-
439
- $str.='<div id="flags" class="size'.$flag_width.'">';
440
- $str.='<ul id="sortable" class="ui-sortable" style="float:left">';
441
-
442
- if ((empty($new_languages_array_string)) || ($new_languages_array_count != $get_flag_choices_count)) {
443
- foreach ($this->languages_array as $key=>$value) {
444
- $language_code = $key;
445
- $language_name = $value;
446
- $language_name_flag = $language_name;
447
-
448
- if ($flag_choice_key == '1') {
449
- if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
450
- $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
451
- }
452
- } //$key
453
- }//foreach
454
-
455
- } else {
456
-
457
- foreach ($new_languages_array_codes as $value) {
458
- $language_name = $value;
459
- $language_code = array_search ($language_name,$this->languages_array);
460
- $language_name_flag = $language_name;
461
- if ($flag_choice_key == '1') {
462
- if (in_array($language_name,$this->languages_array)) {
463
- if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
464
- $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
465
- } //isset
466
- } //in_array
467
- }//flag_choice_key
468
- }//foreach
469
- }//endif
470
- $str.='</ul>';
471
- $str.='</div>';
472
- $str.='<div id="google_language_translator"></div>';
473
- return $str;
474
- }
475
- } // End glt_horizontal
476
-
477
- public function initialize_settings() {
478
- add_settings_section('glt_settings','Settings','','google_language_translator');
479
-
480
- $settings_name_array = array (
481
- 'googlelanguagetranslator_active','googlelanguagetranslator_language','googlelanguagetranslator_language_option','language_display_settings','googlelanguagetranslator_flags','flag_display_settings','googlelanguagetranslator_translatebox','googlelanguagetranslator_display','googlelanguagetranslator_toolbar','googlelanguagetranslator_showbranding','googlelanguagetranslator_flags_alignment','googlelanguagetranslator_analytics','googlelanguagetranslator_analytics_id','googlelanguagetranslator_css','googlelanguagetranslator_manage_translations','googlelanguagetranslator_multilanguage','googlelanguagetranslator_floating_widget','googlelanguagetranslator_flag_size','googlelanguagetranslator_flags_order','googlelanguagetranslator_exclude_translation'
482
- );
483
-
484
- $settings_callback_array = array ( 'googlelanguagetranslator_active_cb','googlelanguagetranslator_language_cb','googlelanguagetranslator_language_option_cb','language_display_settings_cb','googlelanguagetranslator_flags_cb','flag_display_settings_cb','googlelanguagetranslator_translatebox_cb','googlelanguagetranslator_display_cb','googlelanguagetranslator_toolbar_cb','googlelanguagetranslator_showbranding_cb','googlelanguagetranslator_flags_alignment_cb','googlelanguagetranslator_analytics_cb','googlelanguagetranslator_analytics_id_cb','googlelanguagetranslator_css_cb','googlelanguagetranslator_manage_translations_cb','googlelanguagetranslator_multilanguage_cb','googlelanguagetranslator_floating_widget_cb','googlelanguagetranslator_flag_size_cb','googlelanguagetranslator_flags_order_cb','googlelanguagetranslator_exclude_translation_cb'
485
- );
486
-
487
- foreach ($settings_name_array as $setting) {
488
- add_settings_field( $setting,'',$setting.'_cb','google_language_translator','glt_settings');
489
- register_setting( 'google_language_translator',$setting);
490
- }
491
- }
492
-
493
- public function googlelanguagetranslator_active_cb() {
494
- $option_name = 'googlelanguagetranslator_active' ;
495
- $new_value = 1;
496
- if ( get_option( $option_name ) === false ) {
497
-
498
- // The option does not exist, so we update it.
499
- update_option( $option_name, $new_value );
500
- }
501
-
502
- $options = get_option (''.$option_name.'');
503
-
504
- $html = '<input type="checkbox" name="googlelanguagetranslator_active" id="googlelanguagetranslator_active" value="1" '.checked(1,$options,false).'/> &nbsp; Check this box to activate';
505
- echo $html;
506
- }
507
-
508
- public function googlelanguagetranslator_language_cb() {
509
-
510
- $option_name = 'googlelanguagetranslator_language';
511
- $new_value = 'en';
512
-
513
- if ( get_option( $option_name ) === false ) {
514
-
515
- // The option does not exist, so we update it.
516
- update_option( $option_name, $new_value );
517
- }
518
-
519
- $options = get_option (''.$option_name.''); ?>
520
-
521
- <select name="googlelanguagetranslator_language" id="googlelanguagetranslator_language">
522
-
523
- <?php
524
-
525
- foreach ($this->languages_array as $key => $value) {
526
- $language_code = $key;
527
- $language_name = $value; ?>
528
- <option value="<?php echo $language_code; ?>" <?php if($options==''.$language_code.''){echo "selected";}?>><?php echo $language_name; ?></option>
529
- <?php } ?>
530
- </select>
531
- <?php
532
- }
533
-
534
- public function googlelanguagetranslator_language_option_cb() {
535
-
536
- $option_name = 'googlelanguagetranslator_language_option' ;
537
- $new_value = 'all';
538
-
539
- if ( get_option( $option_name ) === false ) {
540
-
541
- // The option does not exist, so we update it.
542
- update_option( $option_name, $new_value );
543
- }
544
-
545
- $options = get_option (''.$option_name.''); ?>
546
-
547
- <input type="radio" name="googlelanguagetranslator_language_option" id="googlelanguagetranslator_language_option" value="all" <?php if($options=='all'){echo "checked";}?>/> All Languages<br/>
548
- <input type="radio" name="googlelanguagetranslator_language_option" id="googlelanguagetranslator_language_option" value="specific" <?php if($options=='specific'){echo "checked";}?>/> Specific Languages
549
- <?php
550
- }
551
-
552
- public function language_display_settings_cb() {
553
- $default_language_code = get_option('googlelanguagetranslator_language');
554
- $option_name = 'language_display_settings';
555
- $new_value = array(''.$default_language_code.'' => 1);
556
-
557
- if ( get_option( $option_name ) == false ) {
558
- // The option does not exist, so we update it.
559
- update_option( $option_name, $new_value );
560
- }
561
-
562
- $get_language_choices = get_option (''.$option_name.'');
563
-
564
- foreach ($this->languages_array as $key => $value) {
565
- $language_code = $key;
566
- $language_name = $value;
567
- $language_code_array[] = $key;
568
-
569
- if (!isset($get_language_choices[''.$language_code.''])) {
570
- $get_language_choices[''.$language_code.''] = 0;
571
- }
572
-
573
- $items[] = $get_language_choices[''.$language_code.''];
574
- $language_codes = $language_code_array;
575
- $item_count = count($items);
576
-
577
- if ($item_count == 1 || $item_count == 22 || $item_count == 43 || $item_count == 64) { ?>
578
- <div class="languages" style="width:25%; float:left">
579
- <?php } ?>
580
- <div><input type="checkbox" name="language_display_settings[<?php echo $language_code; ?>]" value="1"<?php checked( 1,$get_language_choices[''.$language_code.'']); ?>/><?php echo $language_name; ?></div>
581
- <?php
582
- if ($item_count == 21 || $item_count == 42 || $item_count == 63 || $item_count == 81) { ?>
583
- </div>
584
- <?php }
585
- } ?>
586
- <div class="clear"></div>
587
- <?php
588
- }
589
-
590
- public function googlelanguagetranslator_flags_cb() {
591
-
592
- $option_name = 'googlelanguagetranslator_flags' ;
593
- $new_value = 'show_flags';
594
-
595
- if ( get_option( $option_name ) === false ) {
596
-
597
- // The option does not exist, so we update it.
598
- update_option( $option_name, $new_value );
599
- }
600
-
601
- $options = get_option (''.$option_name.''); ?>
602
-
603
- <input type="radio" name="googlelanguagetranslator_flags" id="googlelanguagetranslator_flags" value="show_flags" <?php if($options=='show_flags'){echo "checked";}?>/> Yes, show flag images<br/>
604
- <input type="radio" name="googlelanguagetranslator_flags" id="googlelanguagetranslator_flags" value="hide_flags" <?php if($options=='hide_flags'){echo "checked";}?>/> No, hide flag images
605
- <?php
606
- }
607
-
608
- public function flag_display_settings_cb() {
609
- $default_language_code = get_option('googlelanguagetranslator_language');
610
- $option_name = 'flag_display_settings';
611
- $new_value = array('flag-'.$default_language_code.'' => 1);
612
-
613
- if ( get_option( $option_name ) == false ) {
614
- // The option does not exist, so we update it.
615
- update_option( $option_name, $new_value );
616
- }
617
-
618
- $get_flag_choices = get_option (''.$option_name.'');
619
-
620
- foreach ($this->languages_array as $key => $value) {
621
- $language_code = $key;
622
- $language_name = $value;
623
- $language_code_array[] = $key;
624
-
625
- if (!isset($get_flag_choices['flag-'.$language_code.''])) {
626
- $get_flag_choices['flag-'.$language_code.''] = 0;
627
- }
628
-
629
- $items[] = $get_flag_choices['flag-'.$language_code.''];
630
- $language_codes = $language_code_array;
631
- $item_count = count($items);
632
-
633
- if ($item_count == 1 || $item_count == 22 || $item_count == 43 || $item_count == 64) { ?>
634
- <div class="flagdisplay" style="width:25%; float:left">
635
- <?php } ?>
636
- <div><input type="checkbox" name="flag_display_settings[flag-<?php echo $language_code; ?>]" value="1"<?php checked( 1,$get_flag_choices['flag-'.$language_code.'']); ?>/><?php echo $language_name; ?></div>
637
- <?php
638
- if ($item_count == 21 || $item_count == 42 || $item_count == 63 || $item_count == 81) { ?>
639
- </div>
640
- <?php }
641
- } ?>
642
- <div class="clear"></div>
643
- <?php
644
- }
645
-
646
- public function googlelanguagetranslator_floating_widget_cb() {
647
-
648
- $option_name = 'googlelanguagetranslator_floating_widget' ;
649
- $new_value = 'yes';
650
-
651
- if ( get_option( $option_name ) === false ) {
652
-
653
- // The option does not exist, so we update it.
654
- update_option( $option_name, $new_value );
655
- }
656
-
657
- $options = get_option (''.$option_name.''); ?>
658
-
659
- <select name="googlelanguagetranslator_floating_widget" id="googlelanguagetranslator_floating_widget" style="width:170px">
660
- <option value="yes" <?php if($options=='yes'){echo "selected";}?>>Yes, show widget</option>
661
- <option value="no" <?php if($options=='no'){echo "selected";}?>>No, hide widget</option>
662
- </select>
663
- <?php }
664
-
665
- public function googlelanguagetranslator_translatebox_cb() {
666
-
667
- $option_name = 'googlelanguagetranslator_translatebox' ;
668
- $new_value = 'yes';
669
-
670
- if ( get_option( $option_name ) === false ) {
671
-
672
- // The option does not exist, so we update it.
673
- update_option( $option_name, $new_value );
674
- }
675
-
676
- $options = get_option (''.$option_name.''); ?>
677
-
678
- <select name="googlelanguagetranslator_translatebox" id="googlelanguagetranslator_translatebox" style="width:190px">
679
- <option value="yes" <?php if($options=='yes'){echo "selected";}?>>Yes, show language box</option>
680
- <option value="no" <?php if($options=='no'){echo "selected";}?>>No, hide language box</option>
681
- </select>
682
- <?php }
683
-
684
- public function googlelanguagetranslator_display_cb() {
685
-
686
- $option_name = 'googlelanguagetranslator_display' ;
687
- $new_value = 'Vertical';
688
-
689
- if ( get_option( $option_name ) === false ) {
690
-
691
- // The option does not exist, so we update it.
692
- update_option( $option_name, $new_value );
693
- }
694
-
695
- $options = get_option (''.$option_name.''); ?>
696
-
697
- <select name="googlelanguagetranslator_display" id="googlelanguagetranslator_display" style="width:170px;">
698
- <option value="Vertical" <?php if(get_option('googlelanguagetranslator_display')=='Vertical'){echo "selected";}?>>Vertical</option>
699
- <option value="Horizontal" <?php if(get_option('googlelanguagetranslator_display')=='Horizontal'){echo "selected";}?>>Horizontal</option>
700
- </select>
701
- <?php }
702
-
703
- public function googlelanguagetranslator_toolbar_cb() {
704
-
705
- $option_name = 'googlelanguagetranslator_toolbar' ;
706
- $new_value = 'Yes';
707
-
708
- if ( get_option( $option_name ) === false ) {
709
-
710
- // The option does not exist, so we update it.
711
- update_option( $option_name, $new_value );
712
- }
713
-
714
- $options = get_option (''.$option_name.''); ?>
715
-
716
- <select name="googlelanguagetranslator_toolbar" id="googlelanguagetranslator_toolbar" style="width:170px;">
717
- <option value="Yes" <?php if(get_option('googlelanguagetranslator_toolbar')=='Yes'){echo "selected";}?>>Yes</option>
718
- <option value="No" <?php if(get_option('googlelanguagetranslator_toolbar')=='No'){echo "selected";}?>>No</option>
719
- </select>
720
- <?php }
721
-
722
- public function googlelanguagetranslator_showbranding_cb() {
723
-
724
- $option_name = 'googlelanguagetranslator_showbranding' ;
725
- $new_value = 'Yes';
726
-
727
- if ( get_option( $option_name ) === false ) {
728
-
729
- // The option does not exist, so we update it.
730
- update_option( $option_name, $new_value );
731
- }
732
-
733
- $options = get_option (''.$option_name.''); ?>
734
-
735
- <select name="googlelanguagetranslator_showbranding" id="googlelanguagetranslator_showbranding" style="width:170px;">
736
- <option value="Yes" <?php if(get_option('googlelanguagetranslator_showbranding')=='Yes'){echo "selected";}?>>Yes</option>
737
- <option value="No" <?php if(get_option('googlelanguagetranslator_showbranding')=='No'){echo "selected";}?>>No</option>
738
- </select>
739
- <?php }
740
-
741
- public function googlelanguagetranslator_flags_alignment_cb() {
742
-
743
- $option_name = 'googlelanguagetranslator_flags_alignment' ;
744
- $new_value = 'flags_left';
745
-
746
- if ( get_option( $option_name ) === false ) {
747
-
748
- // The option does not exist, so we update it.
749
- update_option( $option_name, 'flags_left' );
750
- }
751
-
752
- $options = get_option (''.$option_name.''); ?>
753
-
754
- <input type="radio" name="googlelanguagetranslator_flags_alignment" id="flags_left" value="flags_left" <?php if($options=='flags_left'){echo "checked";}?>/> Align Left<br/>
755
- <input type="radio" name="googlelanguagetranslator_flags_alignment" id="flags_right" value="flags_right" <?php if($options=='flags_right'){echo "checked";}?>/> Align Right
756
- <?php }
757
-
758
- public function googlelanguagetranslator_analytics_cb() {
759
-
760
- $option_name = 'googlelanguagetranslator_analytics' ;
761
- $new_value = 0;
762
-
763
- if ( get_option( $option_name ) === false ) {
764
-
765
- // The option does not exist, so we update it.
766
- update_option( $option_name, $new_value );
767
- }
768
-
769
- $options = get_option (''.$option_name.'');
770
-
771
- $html = '<input type="checkbox" name="googlelanguagetranslator_analytics" id="googlelanguagetranslator_analytics" value="1" '.checked(1,$options,false).'/> &nbsp; Activate Google Analytics tracking?';
772
- echo $html;
773
- }
774
-
775
- public function googlelanguagetranslator_analytics_id_cb() {
776
-
777
- $option_name = 'googlelanguagetranslator_analytics_id' ;
778
- $new_value = '';
779
-
780
- if ( get_option( $option_name ) === false ) {
781
-
782
- // The option does not exist, so we update it.
783
- update_option( $option_name, $new_value );
784
- }
785
-
786
- $options = get_option (''.$option_name.'');
787
-
788
- $html = '<input type="text" name="googlelanguagetranslator_analytics_id" id="googlelanguagetranslator_analytics_id" value="'.$options.'" />';
789
- echo $html;
790
- }
791
-
792
- public function googlelanguagetranslator_flag_size_cb() {
793
-
794
- $option_name = 'googlelanguagetranslator_flag_size' ;
795
- $new_value = '18';
796
-
797
- if ( get_option( $option_name ) === false ) {
798
-
799
- // The option does not exist, so we update it.
800
- update_option( $option_name, $new_value );
801
- }
802
-
803
- $options = get_option (''.$option_name.''); ?>
804
-
805
- <select name="googlelanguagetranslator_flag_size" id="googlelanguagetranslator_flag_size" style="width:110px;">
806
- <option value="16" <?php if($options=='16'){echo "selected";}?>>16px</option>
807
- <option value="18" <?php if($options=='18'){echo "selected";}?>>18px</option>
808
- <option value="20" <?php if($options=='20'){echo "selected";}?>>20px</option>
809
- <option value="22" <?php if($options=='22'){echo "selected";}?>>22px</option>
810
- <option value="24" <?php if($options=='24'){echo "selected";}?>>24px</option>
811
- </select>
812
- <?php }
813
-
814
- public function googlelanguagetranslator_flags_order_cb() {
815
- $option_name = 'googlelanguagetranslator_flags_order';
816
- $new_value = '';
817
-
818
- if ( get_option ( $option_name ) === false ) {
819
-
820
- // The option does not exist, so we update it.
821
- update_option( $option_name, $new_value );
822
- }
823
-
824
- $options = get_option ( ''.$option_name.'' ); ?>
825
-
826
- <input type="hidden" id="order" name="googlelanguagetranslator_flags_order" value="<?php print_r(get_option('googlelanguagetranslator_flags_order')); ?>" />
827
- <?php
828
- }
829
-
830
- public function googlelanguagetranslator_css_cb() {
831
-
832
- $option_name = 'googlelanguagetranslator_css' ;
833
- $new_value = '';
834
-
835
- if ( get_option( $option_name ) === false ) {
836
-
837
- // The option does not exist, so we update it.
838
- update_option( $option_name, $new_value );
839
- }
840
-
841
- $options = get_option (''.$option_name.'');
842
-
843
- $html = '<textarea style="width:100%; height:200px" name="googlelanguagetranslator_css" id="googlelanguagetranslator_css">'.$options.'</textarea>';
844
- echo $html;
845
- }
846
-
847
- public function googlelanguagetranslator_manage_translations_cb() {
848
- $option_name = 'googlelanguagetranslator_manage_translations' ;
849
- $new_value = 0;
850
-
851
- if ( get_option( $option_name ) === false ) {
852
-
853
- // The option does not exist, so we update it.
854
- update_option( $option_name, $new_value );
855
- }
856
-
857
- $options = get_option (''.$option_name.'');
858
-
859
- $html = '<input type="checkbox" name="googlelanguagetranslator_manage_translations" id="googlelanguagetranslator_manage_translations" value="1" '.checked(1,$options,false).'/> &nbsp; Turn on translation management?';
860
- echo $html;
861
- }
862
-
863
- public function googlelanguagetranslator_multilanguage_cb() {
864
-
865
- $option_name = 'googlelanguagetranslator_multilanguage' ;
866
- $new_value = 0;
867
-
868
- if ( get_option( $option_name ) === false ) {
869
-
870
- // The option does not exist, so we update it.
871
- update_option( $option_name, $new_value );
872
- }
873
-
874
- $options = get_option (''.$option_name.'');
875
-
876
- $html = '<input type="checkbox" name="googlelanguagetranslator_multilanguage" id="googlelanguagetranslator_multilanguage" value="1" '.checked(1,$options,false).'/> &nbsp; Turn on multilanguage mode?';
877
- echo $html;
878
- }
879
-
880
- public function googlelanguagetranslator_exclude_translation_cb() {
881
-
882
- $option_name = 'googlelanguagetranslator_exclude_translation';
883
- $new_value = '';
884
-
885
- if (get_option($option_name) === false ) {
886
- // The option does not exist, so we update it.
887
- update_option( $option_name, $new_value );
888
- }
889
-
890
- $options = get_option (''.$option_name.'');
891
-
892
- $html = '<input type="text" name="'.$option_name.'" id="'.$option_name.'" value="'.$options.'" />';
893
-
894
- echo $html;
895
- }
896
-
897
- public function page_layout_cb() {
898
- include( plugin_dir_path( __FILE__ ) . '/css/style.php'); ?>
899
- <?php add_thickbox(); ?>
900
- <div class="wrap">
901
- <div id="icon-options-general" class="icon32"></div>
902
- <h2><span class="notranslate">Google Language Translator</span></h2>
903
- <form action="<?php echo admin_url( '/options.php'); ?>" method="post">
904
- <div class="metabox-holder has-right-sidebar" style="float:left; width:65%">
905
- <div class="postbox" style="width: 100%">
906
- <h3 class="notranslate">Settings</h3>
907
-
908
- <?php settings_fields('google_language_translator'); ?>
909
- <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
910
- <tr>
911
- <td style="width:60%" class="notranslate">Plugin Status:</td>
912
- <td class="notranslate"><?php $this->googlelanguagetranslator_active_cb(); ?></td>
913
- </tr>
914
-
915
- <tr class="notranslate">
916
- <td>Choose the original language of your website</td>
917
- <td><?php $this->googlelanguagetranslator_language_cb(); ?></td>
918
- </tr>
919
-
920
- <tr class="notranslate">
921
- <td>What translation languages will display in the language box?<br/>("All Languages" option <strong><u>must</u></strong> be chosen to show flags.)</td>
922
- <td><?php $this->googlelanguagetranslator_language_option_cb(); ?></td>
923
- </tr>
924
-
925
- <tr class="notranslate languages">
926
- <td colspan="2"><?php $this->language_display_settings_cb(); ?></td>
927
- </tr>
928
-
929
- <tr class="notranslate">
930
- <td class="choose_flags_intro">Show flag images?<br/>(Display up to 81 flags above the translator)</td>
931
- <td class="choose_flags_intro"><?php $this->googlelanguagetranslator_flags_cb(); ?></td>
932
- </tr>
933
-
934
- <tr class="notranslate choose_flags">
935
- <td class="choose_flags">Choose the flags you want to display:</td>
936
- <td></td>
937
- </tr>
938
-
939
- <tr class="notranslate">
940
- <td colspan="2" class="choose_flags"><?php $this->flag_display_settings_cb(); ?></td>
941
- </tr>
942
-
943
- <tr class="notranslate">
944
- <td>Show floating translation widget?<br/>
945
- <span>("All Languages" option <strong><u>must</u></strong> be chosen to show widget.)</span>
946
- </td>
947
- <td><?php $this->googlelanguagetranslator_floating_widget_cb(); ?></td>
948
- </tr>
949
-
950
- <tr class="notranslate">
951
- <td>Show translate box?</td>
952
- <td><?php $this->googlelanguagetranslator_translatebox_cb(); ?></td>
953
- </tr>
954
-
955
- <tr class="notranslate">
956
- <td>Layout option:</td>
957
- <td><?php $this->googlelanguagetranslator_display_cb(); ?></td>
958
- </tr>
959
-
960
- <tr class="notranslate">
961
- <td>Show Google Toolbar?</td>
962
- <td><?php $this->googlelanguagetranslator_toolbar_cb(); ?></td>
963
- </tr>
964
-
965
- <tr class="notranslate">
966
- <td>Show Google Branding? &nbsp;<a href="https://developers.google.com/translate/v2/attribution" target="_blank">Learn more</a></td>
967
- <td><?php $this->googlelanguagetranslator_showbranding_cb(); ?></td>
968
- </tr>
969
-
970
- <tr class="alignment notranslate">
971
- <td class="flagdisplay">Align the translator left or right?</td>
972
- <td class="flagdisplay"><?php $this->googlelanguagetranslator_flags_alignment_cb(); ?></td>
973
- </tr>
974
-
975
- <!--<tr class="manage_translations notranslate">
976
- <td>Turn on translation management? &nbsp;<a href="#TB_inline?width=200&height=300&inlineId=translation-management-description" title="What is Translation Management?" class="thickbox">Learn more</a><div id="translation-management-description" style="display:none"><p>Translation management is an interface that allows you to manage specific words and phrases on your website. The interface is linked directly to your Google Account, and no special subscriptions are necessary to setup this feature.</p><p>If translation management setting is checked, users who browse your website can hover their mouse over specific words and phrases, then send translation suggestions directly to your Google Translate account! You can then "approve" those suggestions, and Google will automatically display them when translations are requested by your users.</p><p>Translation management requires that you insert a custom meta tag into the <code>head</code> section of your website.</p><p><a href="http://translate.google.com/manager/website/settings" target="_blank">Click here to to get the required meta tag</a></p></div></td>
977
- <td><?php $this->googlelanguagetranslator_manage_translations_cb(); ?></td>
978
- </tr>-->
979
-
980
- <tr class="multilanguage notranslate">
981
- <td>Multilanguage Page option? &nbsp;<a href="#TB_inline?width=200&height=150&inlineId=multilanguage-page-description" title="What is the Multi-Language Page Option?" class="thickbox">Learn more</a><div id="multilanguage-page-description" style="display:none"><p>If checked, Google will automatically convert text written in multiple languages, into the single language requested by your user.</p><p>In most cases, this setting is not recommended, although for certain websites it might be necessary.</p></div></td>
982
- <td><?php $this->googlelanguagetranslator_multilanguage_cb(); ?></td>
983
- </tr>
984
-
985
- <tr class="notranslate">
986
- <td>Google Analytics:</td>
987
- <td><?php $this->googlelanguagetranslator_analytics_cb(); ?></td>
988
- </tr>
989
-
990
- <tr class="analytics notranslate">
991
- <td>Google Analytics ID (Ex. 'UA-11117410-2')</td>
992
- <td><?php $this->googlelanguagetranslator_analytics_id_cb(); ?></td>
993
- </tr>
994
-
995
- <tr class="notranslate">
996
- <td>Full widget usage in pages/posts/sidebar:</td>
997
- <td><code>[google-translator]</code></td>
998
- </tr>
999
- </table>
1000
-
1001
- <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
1002
- <tr class="notranslate">
1003
- <td style="width:40%">Full widget usage in header/footer or page template:</td>
1004
- <td style="width:60%"><code>&lt;?php echo do_shortcode('[google-translator]'); ?&gt;</code></td>
1005
- </tr>
1006
-
1007
- <tr class="notranslate">
1008
- <td>Single language usage in<br/>nav menu/pages/posts</td>
1009
- <td><code>[glt language="Spanish" label="Español"]</code></td>
1010
- </tr>
1011
-
1012
- <tr class="notranslate">
1013
- <td colspan="2">
1014
- <a href="#TB_inline?width=200&height=450&inlineId=single-language-shortcode-description" title="How to place a single language in your Wordpress menu" class="thickbox">How to place a single language in your Wordpress menu</a>
1015
- <div id="single-language-shortcode-description" style="display:none">
1016
- <p>For menu usage, you need to create a new menu, or use an existing menu, by navigating to "Appearance > Menus".</p>
1017
- <p>First you will need to enable "descriptions" for your menu items, which can be found in a tab labeled "Screen Options" in the upper-right area of the page.</p>
1018
- <p>Once descriptions are enabled, follow these steps:<br/>
1019
- <ol>
1020
- <li>Create a new menu item using "Link" as the menu item type.</li>
1021
- <li>Use <code style="border:none">#</code> for the URL</li>
1022
- <li>Enter a navigation label of your choice. This label does not appear on your website - it is meant only to help you identify the menu item.</li>
1023
- <li>Place the following shortcode into the "description" field, and modify it to display the language and navigation label of your choice:</li>
1024
- </ol>
1025
- <p><code>[glt language="Spanish" label="Español"]</code></p>
1026
- </div>
1027
- </td>
1028
- </tr>
1029
-
1030
- <tr class="notranslate">
1031
- <td>
1032
- <?php
1033
- if (isset($_POST['submit'])) {
1034
- if (empty($_POST['submit']) && !check_admin_referer( 'glt-save-settings', 'glt-save-settings-nonce' )) {
1035
- wp_die();
1036
- } else { echo 'hello'; }
1037
- }
1038
- wp_nonce_field('glt-save-settings, glt-save-settings-nonce', false);
1039
- submit_button();
1040
- ?>
1041
- </td>
1042
- <td></td>
1043
- </tr>
1044
- </table>
1045
- </div> <!-- .postbox -->
1046
- </div> <!-- .metbox-holder -->
1047
-
1048
- <div class="metabox-holder" style="float:right; clear:right; width:33%">
1049
- <div class="postbox">
1050
- <h3 class="notranslate">Preview</h3>
1051
- <table style="width:100%">
1052
- <tr>
1053
- <td style="box-sizing:border-box; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; padding:15px 15px; margin:0px"><span class="notranslate"> Drag &amp; drop flags to change their position.<br/><br/>(Note: flag order resets when flags are added/removed)</span><br/><br/><?php echo do_shortcode('[google-translator]'); ?><p class="hello"><span class="notranslate">Translated text:</span> &nbsp; <span>Hello</span></p></td>
1054
- </tr>
1055
-
1056
- <tr>
1057
- <td><?php if (isset ($_POST['googlelanguagetranslator_flags_order']) ) { echo $_POST['googlelanguagetranslator_flags_order']; } ?></td>
1058
- </tr>
1059
-
1060
-
1061
- </table>
1062
- </div> <!-- .postbox -->
1063
- </div> <!-- .metabox-holder -->
1064
-
1065
- <div id="glt_advanced_settings" class="metabox-holder notranslate" style="float: right; width: 33%;">
1066
- <div class="postbox">
1067
- <h3>Advanced Settings</h3>
1068
- <div class="inside">
1069
- <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
1070
- <tr class="notranslate">
1071
- <td class="advanced">Select flag size:</td>
1072
- <td class="advanced"><?php $this->googlelanguagetranslator_flag_size_cb(); ?></td>
1073
- </tr>
1074
- </table>
1075
- </div>
1076
- </div>
1077
- </div>
1078
-
1079
-
1080
- <div class="metabox-holder notranslate" style="float: right; width: 33%;">
1081
- <div class="postbox">
1082
- <h3>Add CSS Styles</h3>
1083
- <div class="inside">
1084
- <p>You can apply any necessary CSS styles below:</p>
1085
- <?php $this->googlelanguagetranslator_css_cb(); ?>
1086
- </div>
1087
- </div>
1088
- </div>
1089
- <?php $this->googlelanguagetranslator_flags_order_cb(); ?>
1090
- </form>
1091
-
1092
- <div class="metabox-holder notranslate" style="float: right; width: 33%;">
1093
- <div class="postbox">
1094
- <h3>GLT Premium 4.0.9 is Here! $30</h3>
1095
- <div class="inside"><a href="http://www.wp-studio.net/" target="_blank"><img style="background:#444; border-radius:3px; -webkit-border-radius:3px; -moz-border-radius:3px" src="<?php echo plugins_url('google-language-translator/images/logo.png'); ?>"></a><br />
1096
- <ul id="features" style="margin-left:15px">
1097
- <li style="list-style:square outside"><span style="color:red; font-weight:bold">New!</span> Manual Translation Module (Experimental)!</li>
1098
- <li style="list-style:square outside"><span style="color:red; font-weight:bold">New!</span> Exclude any specific area of your website from translation, directly from your settings panel</li>
1099
- <li style="list-style:square outside">81 Languages</li>
1100
- <li style="list-style:square outside">jQuery-powered language switcher<br/>(No Adobe Flash required)</li>
1101
- <li style="list-style:square outside">Add single languages to your menus/pages/posts</li>
1102
- <li style="list-style:square outside">Show/hide images or text for each language</li>
1103
- <li style="list-style:square outside">Language switcher loads inline with page content</li>
1104
- <li style="list-style:square outside">Custom flag choices for English, Spanish and Portuguese</li>
1105
- <li style="list-style:square outside">User-friendly URLs, hide or show <code>lang</code> attribute</li>
1106
- <li style="list-style:square outside">Drag/drop flags to re-arrange their order</li>
1107
- <li style="list-style:square outside">Full access to our support forum</li>
1108
- <li style="list-style:square outside">FREE access to all future updates</li>
1109
- </ul>
1110
- </div>
1111
- </div>
1112
- </div>
1113
-
1114
- <div class="metabox-holder notranslate" style="float: right; width: 33%;">
1115
- <div class="postbox">
1116
- <h3>Please Consider A Donation</h3>
1117
- <div class="inside">If you like this plugin and find it useful, help keep this plugin actively developed by clicking the donate button <br /><br />
1118
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
1119
- <input type="hidden" name="cmd" value="_donations">
1120
- <input type="hidden" name="business" value="robertmyrick@hotmail.com">
1121
- <input type="hidden" name="lc" value="US">
1122
- <input type="hidden" name="item_name" value="Support Studio 88 Design and help us bring you more Wordpress goodies! Any donation is kindly appreciated. Thank you!">
1123
- <input type="hidden" name="no_note" value="0">
1124
- <input type="hidden" name="currency_code" value="USD">
1125
- <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
1126
- <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
1127
- <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
1128
- </form>
1129
- <br />
1130
- <br />
1131
- </div>
1132
- </div>
1133
- </div>
1134
- </div> <!-- .wrap -->
1135
- <?php
1136
- }
1137
- }
1138
  $google_language_translator = new google_language_translator();
1
+ <?php
2
+ /*
3
+ Plugin Name: Google Language Translator
4
+ Plugin URI: http://www.studio88design.com/plugins/google-language-translator
5
+ Version: 5.0.02
6
+ Description: The MOST SIMPLE Google Translator plugin. This plugin adds Google Translator to your website by using a single shortcode, [google-translator]. Settings include: layout style, hide/show specific languages, hide/show Google toolbar, and hide/show Google branding. Add the shortcode to pages, posts, and widgets.
7
+ Author: Rob Myrick
8
+ Author URI: http://www.wp-studio.net/
9
+ */
10
+
11
+ include( plugin_dir_path( __FILE__ ) . 'widget.php');
12
+
13
+ class google_language_translator {
14
+
15
+ public $languages_array = array (
16
+ 'af' => 'Afrikaans',
17
+ 'sq' => 'Albanian',
18
+ 'ar' => 'Arabic',
19
+ 'hy' => 'Armenian',
20
+ 'az' => 'Azerbaijani',
21
+ 'eu' => 'Basque',
22
+ 'be' => 'Belarusian',
23
+ 'bn' => 'Bengali',
24
+ 'bs' => 'Bosnian',
25
+ 'bg' => 'Bulgarian',
26
+ 'ca' => 'Catalan',
27
+ 'ceb' => 'Cebuano',
28
+ 'zh-CN' => 'Chinese',
29
+ 'zh-TW' => 'Chinese(Traditional)',
30
+ 'hr' => 'Croatian',
31
+ 'cs' => 'Czech',
32
+ 'da' => 'Danish',
33
+ 'nl' => 'Dutch',
34
+ 'en' => 'English',
35
+ 'eo' => 'Esperanto',
36
+ 'et' => 'Estonian',
37
+ 'tl' => 'Filipino',
38
+ 'fi' => 'Finnish',
39
+ 'fr' => 'French',
40
+ 'gl' => 'Galician',
41
+ 'ka' => 'Georgian',
42
+ 'de' => 'German',
43
+ 'el' => 'Greek',
44
+ 'gu' => 'Gujarati',
45
+ 'ht' => 'Haitian',
46
+ 'ha' => 'Hausa',
47
+ 'iw' => 'Hebrew',
48
+ 'hi' => 'Hindi',
49
+ 'hmn' => 'Hmong',
50
+ 'hu' => 'Hungarian',
51
+ 'is' => 'Icelandic',
52
+ 'ig' => 'Igbo',
53
+ 'id' => 'Indonesian',
54
+ 'ga' => 'Irish',
55
+ 'it' => 'Italian',
56
+ 'ja' => 'Japanese',
57
+ 'jw' => 'Javanese',
58
+ 'kn' => 'Kannada',
59
+ 'km' => 'Khmer',
60
+ 'ko' => 'Korean',
61
+ 'lo' => 'Lao',
62
+ 'la' => 'Latin',
63
+ 'lv' => 'Latvian',
64
+ 'lt' => 'Lithuanian',
65
+ 'mk' => 'Macedonian',
66
+ 'ms' => 'Malay',
67
+ 'mt' => 'Maltese',
68
+ 'mi' => 'Maori',
69
+ 'mr' => 'Marathi',
70
+ 'mn' => 'Mongolian',
71
+ 'ne' => 'Nepali',
72
+ 'no' => 'Norwegian',
73
+ 'fa' => 'Persian',
74
+ 'pl' => 'Polish',
75
+ 'pt' => 'Portuguese',
76
+ 'pa' => 'Punjabi',
77
+ 'ro' => 'Romanian',
78
+ 'ru' => 'Russian',
79
+ 'sr' => 'Serbian',
80
+ 'sk' => 'Slovak',
81
+ 'sl' => 'Slovenian',
82
+ 'so' => 'Somali',
83
+ 'es' => 'Spanish',
84
+ 'sw' => 'Swahili',
85
+ 'sv' => 'Swedish',
86
+ 'ta' => 'Tamil',
87
+ 'te' => 'Telugu',
88
+ 'th' => 'Thai',
89
+ 'tr' => 'Turkish',
90
+ 'uk' => 'Ukranian',
91
+ 'ur' => 'Urdu',
92
+ 'vi' => 'Vietnamese',
93
+ 'cy' => 'Welsh',
94
+ 'yi' => 'Yiddish',
95
+ 'yo' => 'Yoruba',
96
+ 'zu' => 'Zulu'
97
+ );
98
+
99
+ public function __construct() {
100
+ register_activation_hook( __FILE__, array( &$this, 'glt_activate' ));
101
+ register_uninstall_hook( __FILE__, 'glt_deactivate' );
102
+ add_action( 'admin_menu', array( &$this, 'add_my_admin_menus'));
103
+ add_action('admin_init',array(&$this, 'initialize_settings'));
104
+ add_action('wp_head',array(&$this, 'load_css'));
105
+ add_action('wp_footer',array(&$this, 'footer_script'));
106
+ add_shortcode( 'google-translator',array(&$this, 'google_translator_shortcode'));
107
+ add_shortcode( 'glt', array(&$this, 'google_translator_menu_language'));
108
+ add_filter('widget_text','do_shortcode');
109
+ add_filter('walker_nav_menu_start_el', array(&$this,'menu_shortcodes') , 10 , 2);
110
+ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'glt_settings_link') );
111
+
112
+ if (!is_admin()) {
113
+ add_action('init',array(&$this, 'flags'));
114
+ }
115
+ }
116
+
117
+ public function glt_activate() {
118
+ add_option('googlelanguagetranslator_active', 1);
119
+ add_option('googlelanguagetranslator_language','en');
120
+ add_option('googlelanguagetranslator_language_option','all');
121
+ add_option('googlelanguagetranslator_flags','show_flags');
122
+ add_option('language_display_settings',array ('en' => 1));
123
+ add_option('flag_display_settings',array ('flag-en' => 1));
124
+ add_option('googlelanguagetranslator_translatebox','yes');
125
+ add_option('googlelanguagetranslator_display','Vertical');
126
+ add_option('googlelanguagetranslator_toolbar','Yes');
127
+ add_option('googlelanguagetranslator_showbranding','Yes');
128
+ add_option('googlelanguagetranslator_flags_alignment','flags_left');
129
+ add_option('googlelanguagetranslator_analytics', 0);
130
+ add_option('googlelanguagetranslator_analytics_id','');
131
+ add_option('googlelanguagetranslator_css','');
132
+ add_option('googlelanguagetranslator_manage_translations',0);
133
+ add_option('googlelanguagetranslator_multilanguage',0);
134
+ add_option('googlelanguagetranslator_floating_widget','yes');
135
+ add_option('googlelanguagetranslator_flag_size','18');
136
+ add_option('googlelanguagetranslator_flags_order','');
137
+ }
138
+
139
+ public function glt_deactivate() {
140
+ delete_option('googlelanguagetranslator_active', 1);
141
+ delete_option('googlelanguagetranslator_language','en');
142
+ delete_option('googlelanguagetranslator_language_option','all');
143
+ delete_option('googlelanguagetranslator_flags','show_flags');
144
+ delete_option('language_display_settings',array ('en' => 1));
145
+ delete_option('flag_display_settings',array ('flag-en' => 1));
146
+ delete_option('googlelanguagetranslator_translatebox','yes');
147
+ delete_option('googlelanguagetranslator_display','Vertical');
148
+ delete_option('googlelanguagetranslator_toolbar','Yes');
149
+ delete_option('googlelanguagetranslator_showbranding','Yes');
150
+ delete_option('googlelanguagetranslator_flags_alignment','flags_left');
151
+ delete_option('googlelanguagetranslator_analytics',1);
152
+ delete_option('googlelanguagetranslator_analytics_id','');
153
+ delete_option('googlelanguagetranslator_css','');
154
+ delete_option('googlelanguagetranslator_manage_translations',0);
155
+ delete_option('googlelanguagetranslator_multilanguage',0);
156
+ delete_option('googlelanguagetranslator_floating_widget','yes');
157
+ delete_option('googlelanguagetranslator_flag_size','18');
158
+ delete_option('googlelanguagetranslator_flags_order','');
159
+ }
160
+
161
+ public function glt_settings_link ( $links ) {
162
+ $settings_link = array(
163
+ '<a href="' . admin_url( 'options-general.php?page=google_language_translator' ) . '">Settings</a>',
164
+ );
165
+ return array_merge( $links, $settings_link );
166
+ }
167
+
168
+ public function add_my_admin_menus(){
169
+ $p = add_options_page('Google Language Translator', 'Google Language Translator', 'manage_options', 'google_language_translator', array(&$this, 'page_layout_cb'));
170
+
171
+ add_action( 'load-' . $p, array(&$this, 'load_admin_js' ));
172
+ }
173
+
174
+ public function load_admin_js(){
175
+ add_action( 'admin_enqueue_scripts', array(&$this, 'enqueue_admin_js' ));
176
+ add_action('admin_footer',array(&$this, 'footer_script'));
177
+ }
178
+
179
+ public function enqueue_admin_js(){
180
+ wp_enqueue_script( 'my-admin-script', plugins_url('js/admin.js',__FILE__), array('jquery'));
181
+ wp_enqueue_script( 'my-flag-script', plugins_url('js/flags.js',__FILE__), array('jquery'));
182
+
183
+ if (get_option ('googlelanguagetranslator_floating_widget') == 'yes') {
184
+ wp_enqueue_script( 'my-toolbar-script', plugins_url('js/toolbar.js',__FILE__), array('jquery'));
185
+ wp_enqueue_script( 'my-load-toolbar-script', plugins_url('js/load-toolbar.js',__FILE__), array('jquery'));
186
+ wp_register_style( 'toolbar.css', plugins_url('css/toolbar.css', __FILE__) );
187
+ wp_enqueue_style( 'toolbar.css' );
188
+ }
189
+
190
+ wp_enqueue_script( 'jquery-ui-core');
191
+ wp_enqueue_script( 'jquery-ui-sortable');
192
+ wp_enqueue_script( 'load_sortable_flags', plugins_url('js/load-sortable-flags.js',__FILE__), array('jquery'));
193
+ wp_register_style( 'jquery-ui.css', plugins_url('css/jquery-ui.css',__FILE__) );
194
+ wp_register_style( 'style.css', plugins_url('css/style.css', __FILE__) );
195
+ wp_enqueue_style( 'style.css' );
196
+ //wp_enqueue_style( 'jquery-ui.css' );
197
+ }
198
+
199
+ public function flags() {
200
+ wp_enqueue_script( 'flags', plugins_url('js/flags.js',__FILE__), array('jquery'));
201
+
202
+ if (get_option ('googlelanguagetranslator_floating_widget') == 'yes') {
203
+ wp_enqueue_script( 'my-toolbar-script', plugins_url('js/toolbar.js',__FILE__), array('jquery'));
204
+ wp_enqueue_script( 'my-load-toolbar-script', plugins_url('js/load-toolbar.js',__FILE__), array('jquery'));
205
+ wp_register_style( 'toolbar.css', plugins_url('css/toolbar.css', __FILE__) );
206
+ wp_enqueue_style( 'toolbar.css' );
207
+ }
208
+
209
+ wp_register_style( 'style.css', plugins_url('css/style.css', __FILE__) );
210
+ wp_enqueue_style( 'style.css' );
211
+ }
212
+
213
+ public function load_css() {
214
+ include( plugin_dir_path( __FILE__ ) . '/css/style.php');
215
+ }
216
+
217
+ public function google_translator_shortcode() {
218
+
219
+ if (get_option('googlelanguagetranslator_display')=='Vertical'){
220
+ return $this->googlelanguagetranslator_vertical();
221
+ }
222
+ elseif(get_option('googlelanguagetranslator_display')=='Horizontal'){
223
+ return $this->googlelanguagetranslator_horizontal();
224
+ }
225
+ }
226
+
227
+ public function googlelanguagetranslator_included_languages() {
228
+ if ( get_option('googlelanguagetranslator_language_option')=='specific') {
229
+ $get_language_choices = get_option ('language_display_settings');
230
+
231
+ foreach ($get_language_choices as $key=>$value) {
232
+ if($value == 1) {
233
+ $items[] = $key;
234
+ }
235
+ }
236
+
237
+ $comma_separated = implode(",",array_values($items));
238
+
239
+ if ( get_option('googlelanguagetranslator_display') == 'Vertical') {
240
+ $lang = ", includedLanguages:'".$comma_separated."'";
241
+ return $lang;
242
+ } elseif ( get_option('googlelanguagetranslator_display') == 'Horizontal') {
243
+ $lang = ", includedLanguages:'".$comma_separated."'";
244
+ return $lang;
245
+ }
246
+ }
247
+ }
248
+
249
+ public function analytics() {
250
+ if ( get_option('googlelanguagetranslator_analytics') == 1 ) {
251
+ $analytics_id = get_option('googlelanguagetranslator_analytics_id');
252
+ $analytics = "gaTrack: true, gaId: '".$analytics_id."'";
253
+
254
+ if (!empty ($analytics_id) ):
255
+ return ', '.$analytics;
256
+ endif;
257
+ }
258
+ }
259
+
260
+ public function menu_shortcodes( $item_output,$item ) {
261
+ if ( !empty($item->description)) {
262
+ $output = do_shortcode($item->description);
263
+
264
+ if ( $output != $item->description )
265
+ $item_output = $output;
266
+ }
267
+ return $item_output;
268
+ }
269
+
270
+ public function google_translator_menu_language($atts, $content = '') {
271
+ extract(shortcode_atts(array(
272
+ "language" => 'Spanish',
273
+ "label" => 'Spanish'
274
+ ), $atts));
275
+
276
+ $default_language = get_option('googlelanguagetranslator_language');
277
+ $language_code = array_search($language,$this->languages_array);
278
+
279
+ return "<a class='nturl notranslate ".$language_code." single-language flag' title='".$language."'>".$label."</a>";
280
+ }
281
+
282
+ public function footer_script() {
283
+ global $shortcode_started;
284
+ $default_language = get_option('googlelanguagetranslator_language');
285
+ $language_choices = $this->googlelanguagetranslator_included_languages();
286
+ $get_language_option = get_option('googlelanguagetranslator_language_option');
287
+ $get_flag_choices = get_option ('flag_display_settings');
288
+ $floating_widget = get_option ('googlelanguagetranslator_floating_widget');
289
+ $is_active = get_option ( 'googlelanguagetranslator_active' );
290
+ $is_multilanguage = get_option('googlelanguagetranslator_multilanguage');
291
+ $auto_display = ', autoDisplay: false';
292
+ $str = ''; ?>
293
+ <script>jQuery(document).ready(function(a){a("a.nturl").on("click",function(){function l(){doGoogleLanguageTranslator(default_lang+"|"+default_lang)}function n(){doGoogleLanguageTranslator(default_lang+"|"+lang_prefix)}default_lang="<?php echo get_option('googlelanguagetranslator_language'); ?>",lang_prefix=a(this).attr("class").split(" ")[2],lang_prefix==default_lang?l():n()}),a("a.flag").on("click",function(){function l(){doGoogleLanguageTranslator(default_lang+"|"+default_lang)}function n(){doGoogleLanguageTranslator(default_lang+"|"+lang_prefix)}default_lang="<?php echo get_option('googlelanguagetranslator_language'); ?>",lang_prefix=a(this).attr("class").split(" ")[2],a(".tool-container").hide(),lang_prefix==default_lang?l():n()}),0==a("body > #google_language_translator").length&&a("#glt-footer").html("<div id='google_language_translator'></div>")});</script>
294
+
295
+ <?php
296
+
297
+ if( $is_active == 1) {
298
+
299
+ foreach ($get_flag_choices as $flag_choice_key) {}
300
+
301
+ if ($floating_widget=='yes' && $get_language_option != 'specific') {
302
+ $str.='<div id="glt-translate-trigger"><span class="notranslate">Translate &raquo;</span></div>';
303
+ $str.='<div id="glt-toolbar"></div>';
304
+ } //endif $floating_widget
305
+
306
+ if ($shortcode_started != 'true') {
307
+ $str.='<div id="flags" style="display:none">';
308
+ $str.='<ul id="sortable" class="ui-sortable">';
309
+
310
+ if ((empty($new_languages_array_string)) || ($new_languages_array_count != $get_flag_choices_count)) {
311
+ foreach ($this->languages_array as $key=>$value) {
312
+ $language_code = $key;
313
+ $language_name = $value;
314
+ $language_name_flag = $language_name;
315
+ if ($flag_choice_key == '1') {
316
+ if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
317
+ $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
318
+ }
319
+ } //$key
320
+ }//foreach
321
+ } else {
322
+ foreach ($new_languages_array_codes as $value) {
323
+ $language_name = $value;
324
+ $language_code = array_search ($language_name,$this->languages_array);
325
+ $language_name_flag = $language_name;
326
+ if ($flag_choice_key == '1') {
327
+ if (in_array($language_name,$this->languages_array)) {
328
+ if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
329
+ $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
330
+ } //isset
331
+ } //in_array
332
+ }//flag_choice_key
333
+ }//foreach
334
+ }//endif
335
+ $str.='</ul>';
336
+ $str.='</div>';
337
+ }
338
+ }
339
+
340
+ $language_choices = $this->googlelanguagetranslator_included_languages();
341
+ $layout = get_option('googlelanguagetranslator_display');
342
+ $is_multilanguage = get_option('googlelanguagetranslator_multilanguage');
343
+ $horizontal_layout = ', layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL';
344
+ $auto_display = ', autoDisplay: false';
345
+ $default_language = get_option('googlelanguagetranslator_language');
346
+
347
+ if ($is_multilanguage == 1) {
348
+ $multilanguagePage = ', multilanguagePage:true';
349
+ $str.="<div id='glt-footer'></div><script type='text/javascript'>function GoogleLanguageTranslatorInit() { new google.translate.TranslateElement({pageLanguage: '".$default_language."'".$language_choices . ($layout=='Horizontal' ? $horizontal_layout : '') . $auto_display . $multilanguagePage . $this->analytics()."}, 'google_language_translator');}</script>";
350
+ $str.="<script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=GoogleLanguageTranslatorInit'></script>";
351
+ echo $str;
352
+
353
+ } elseif ($is_multilanguage == 0) {
354
+ $str.="<div id='glt-footer'></div><script type='text/javascript'>function GoogleLanguageTranslatorInit() { new google.translate.TranslateElement({pageLanguage: '".$default_language."'".$language_choices . ($layout=='Horizontal' ? $horizontal_layout : '') . $auto_display . $this->analytics()."}, 'google_language_translator');}</script>";
355
+ $str.="<script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=GoogleLanguageTranslatorInit'></script>";
356
+ echo $str;
357
+ }
358
+ }
359
+
360
+ public function googlelanguagetranslator_vertical() {
361
+
362
+ global $shortcode_started;
363
+
364
+ $shortcode_started = 'true';
365
+ $get_flag_choices = get_option ('flag_display_settings');
366
+ $new_languages_array_string = get_option('googlelanguagetranslator_flags_order');
367
+ $new_languages_array = explode(",",$new_languages_array_string);
368
+ $new_languages_array_codes = array_values($new_languages_array);
369
+ $new_languages_array_count = count($new_languages_array);
370
+ $get_flag_choices_count = count($get_flag_choices);
371
+ $get_language_choices = get_option ('language_display_settings');
372
+ $flag_width = get_option('googlelanguagetranslator_flag_size');
373
+ $default_language_code = get_option('googlelanguagetranslator_language');
374
+ $is_active = get_option ( 'googlelanguagetranslator_active' );
375
+ $get_language_option = get_option('googlelanguagetranslator_language_option');
376
+ $language_choices = $this->googlelanguagetranslator_included_languages();
377
+ $floating_widget = get_option ('googlelanguagetranslator_floating_widget');
378
+ $str = '';
379
+
380
+ if( $is_active == 1){
381
+
382
+ foreach ($get_flag_choices as $flag_choice_key) {}
383
+
384
+ $str.='<div id="flags" class="size'.$flag_width.'">';
385
+ $str.='<ul id="sortable" class="ui-sortable" style="float:left">';
386
+
387
+ if ((empty($new_languages_array_string)) || ($new_languages_array_count != $get_flag_choices_count)) {
388
+ foreach ($this->languages_array as $key=>$value) {
389
+ $language_code = $key;
390
+ $language_name = $value;
391
+ $language_name_flag = $language_name;
392
+ if ($flag_choice_key == '1') {
393
+ if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
394
+ $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
395
+ }
396
+ } //$key
397
+ }//foreach
398
+ } else {
399
+ foreach ($new_languages_array_codes as $value) {
400
+ $language_name = $value;
401
+ $language_code = array_search ($language_name,$this->languages_array);
402
+ $language_name_flag = $language_name;
403
+ if ($flag_choice_key == '1') {
404
+ if (in_array($language_name,$this->languages_array)) {
405
+ if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
406
+ $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
407
+ } //isset
408
+ } //in_array
409
+ }//flag_choice_key
410
+ }//foreach
411
+ }//endif
412
+ $str.='</ul>';
413
+ $str.='</div>';
414
+ $str.='<div id="google_language_translator"></div>';
415
+ return $str;
416
+ } //End is_active
417
+ } // End glt_vertical
418
+
419
+ public function googlelanguagetranslator_horizontal(){
420
+ $shortcode_started = true;
421
+ $get_flag_choices = get_option ('flag_display_settings');
422
+ $new_languages_array_string = get_option('googlelanguagetranslator_flags_order');
423
+ $new_languages_array = explode(",",$new_languages_array_string);
424
+ $new_languages_array_codes = array_values($new_languages_array);
425
+ $new_languages_array_count = count($new_languages_array);
426
+ $get_flag_choices_count = count($get_flag_choices);
427
+ $get_language_choices = get_option ('language_display_settings');
428
+ $flag_width = get_option('googlelanguagetranslator_flag_size');
429
+ $default_language_code = get_option('googlelanguagetranslator_language');
430
+ $is_active = get_option ( 'googlelanguagetranslator_active' );
431
+ $get_language_option = get_option('googlelanguagetranslator_language_option');
432
+ $language_choices = $this->googlelanguagetranslator_included_languages();
433
+ $floating_widget = get_option ('googlelanguagetranslator_floating_widget');
434
+ $str = '';
435
+
436
+ if( $is_active == 1) {
437
+ foreach ($get_flag_choices as $flag_choice_key) {}
438
+
439
+ $str.='<div id="flags" class="size'.$flag_width.'">';
440
+ $str.='<ul id="sortable" class="ui-sortable" style="float:left">';
441
+
442
+ if ((empty($new_languages_array_string)) || ($new_languages_array_count != $get_flag_choices_count)) {
443
+ foreach ($this->languages_array as $key=>$value) {
444
+ $language_code = $key;
445
+ $language_name = $value;
446
+ $language_name_flag = $language_name;
447
+
448
+ if ($flag_choice_key == '1') {
449
+ if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
450
+ $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
451
+ }
452
+ } //$key
453
+ }//foreach
454
+
455
+ } else {
456
+
457
+ foreach ($new_languages_array_codes as $value) {
458
+ $language_name = $value;
459
+ $language_code = array_search ($language_name,$this->languages_array);
460
+ $language_name_flag = $language_name;
461
+ if ($flag_choice_key == '1') {
462
+ if (in_array($language_name,$this->languages_array)) {
463
+ if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) {
464
+ $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code."'></a></li>";
465
+ } //isset
466
+ } //in_array
467
+ }//flag_choice_key
468
+ }//foreach
469
+ }//endif
470
+ $str.='</ul>';
471
+ $str.='</div>';
472
+ $str.='<div id="google_language_translator"></div>';
473
+ return $str;
474
+ }
475
+ } // End glt_horizontal
476
+
477
+ public function initialize_settings() {
478
+ add_settings_section('glt_settings','Settings','','google_language_translator');
479
+
480
+ $settings_name_array = array (
481
+ 'googlelanguagetranslator_active','googlelanguagetranslator_language','googlelanguagetranslator_language_option','language_display_settings','googlelanguagetranslator_flags','flag_display_settings','googlelanguagetranslator_translatebox','googlelanguagetranslator_display','googlelanguagetranslator_toolbar','googlelanguagetranslator_showbranding','googlelanguagetranslator_flags_alignment','googlelanguagetranslator_analytics','googlelanguagetranslator_analytics_id','googlelanguagetranslator_css','googlelanguagetranslator_manage_translations','googlelanguagetranslator_multilanguage','googlelanguagetranslator_floating_widget','googlelanguagetranslator_flag_size','googlelanguagetranslator_flags_order','googlelanguagetranslator_exclude_translation'
482
+ );
483
+
484
+ $settings_callback_array = array ( 'googlelanguagetranslator_active_cb','googlelanguagetranslator_language_cb','googlelanguagetranslator_language_option_cb','language_display_settings_cb','googlelanguagetranslator_flags_cb','flag_display_settings_cb','googlelanguagetranslator_translatebox_cb','googlelanguagetranslator_display_cb','googlelanguagetranslator_toolbar_cb','googlelanguagetranslator_showbranding_cb','googlelanguagetranslator_flags_alignment_cb','googlelanguagetranslator_analytics_cb','googlelanguagetranslator_analytics_id_cb','googlelanguagetranslator_css_cb','googlelanguagetranslator_manage_translations_cb','googlelanguagetranslator_multilanguage_cb','googlelanguagetranslator_floating_widget_cb','googlelanguagetranslator_flag_size_cb','googlelanguagetranslator_flags_order_cb','googlelanguagetranslator_exclude_translation_cb'
485
+ );
486
+
487
+ foreach ($settings_name_array as $setting) {
488
+ add_settings_field( $setting,'',$setting.'_cb','google_language_translator','glt_settings');
489
+ register_setting( 'google_language_translator',$setting);
490
+ }
491
+ }
492
+
493
+ public function googlelanguagetranslator_active_cb() {
494
+ $option_name = 'googlelanguagetranslator_active' ;
495
+ $new_value = 1;
496
+ if ( get_option( $option_name ) === false ) {
497
+
498
+ // The option does not exist, so we update it.
499
+ update_option( $option_name, $new_value );
500
+ }
501
+
502
+ $options = get_option (''.$option_name.'');
503
+
504
+ $html = '<input type="checkbox" name="googlelanguagetranslator_active" id="googlelanguagetranslator_active" value="1" '.checked(1,$options,false).'/> &nbsp; Check this box to activate';
505
+ echo $html;
506
+ }
507
+
508
+ public function googlelanguagetranslator_language_cb() {
509
+
510
+ $option_name = 'googlelanguagetranslator_language';
511
+ $new_value = 'en';
512
+
513
+ if ( get_option( $option_name ) === false ) {
514
+
515
+ // The option does not exist, so we update it.
516
+ update_option( $option_name, $new_value );
517
+ }
518
+
519
+ $options = get_option (''.$option_name.''); ?>
520
+
521
+ <select name="googlelanguagetranslator_language" id="googlelanguagetranslator_language">
522
+
523
+ <?php
524
+
525
+ foreach ($this->languages_array as $key => $value) {
526
+ $language_code = $key;
527
+ $language_name = $value; ?>
528
+ <option value="<?php echo $language_code; ?>" <?php if($options==''.$language_code.''){echo "selected";}?>><?php echo $language_name; ?></option>
529
+ <?php } ?>
530
+ </select>
531
+ <?php
532
+ }
533
+
534
+ public function googlelanguagetranslator_language_option_cb() {
535
+
536
+ $option_name = 'googlelanguagetranslator_language_option' ;
537
+ $new_value = 'all';
538
+
539
+ if ( get_option( $option_name ) === false ) {
540
+
541
+ // The option does not exist, so we update it.
542
+ update_option( $option_name, $new_value );
543
+ }
544
+
545
+ $options = get_option (''.$option_name.''); ?>
546
+
547
+ <input type="radio" name="googlelanguagetranslator_language_option" id="googlelanguagetranslator_language_option" value="all" <?php if($options=='all'){echo "checked";}?>/> All Languages<br/>
548
+ <input type="radio" name="googlelanguagetranslator_language_option" id="googlelanguagetranslator_language_option" value="specific" <?php if($options=='specific'){echo "checked";}?>/> Specific Languages
549
+ <?php
550
+ }
551
+
552
+ public function language_display_settings_cb() {
553
+ $default_language_code = get_option('googlelanguagetranslator_language');
554
+ $option_name = 'language_display_settings';
555
+ $new_value = array(''.$default_language_code.'' => 1);
556
+
557
+ if ( get_option( $option_name ) == false ) {
558
+ // The option does not exist, so we update it.
559
+ update_option( $option_name, $new_value );
560
+ }
561
+
562
+ $get_language_choices = get_option (''.$option_name.'');
563
+
564
+ foreach ($this->languages_array as $key => $value) {
565
+ $language_code = $key;
566
+ $language_name = $value;
567
+ $language_code_array[] = $key;
568
+
569
+ if (!isset($get_language_choices[''.$language_code.''])) {
570
+ $get_language_choices[''.$language_code.''] = 0;
571
+ }
572
+
573
+ $items[] = $get_language_choices[''.$language_code.''];
574
+ $language_codes = $language_code_array;
575
+ $item_count = count($items);
576
+
577
+ if ($item_count == 1 || $item_count == 22 || $item_count == 43 || $item_count == 64) { ?>
578
+ <div class="languages" style="width:25%; float:left">
579
+ <?php } ?>
580
+ <div><input type="checkbox" name="language_display_settings[<?php echo $language_code; ?>]" value="1"<?php checked( 1,$get_language_choices[''.$language_code.'']); ?>/><?php echo $language_name; ?></div>
581
+ <?php
582
+ if ($item_count == 21 || $item_count == 42 || $item_count == 63 || $item_count == 81) { ?>
583
+ </div>
584
+ <?php }
585
+ } ?>
586
+ <div class="clear"></div>
587
+ <?php
588
+ }
589
+
590
+ public function googlelanguagetranslator_flags_cb() {
591
+
592
+ $option_name = 'googlelanguagetranslator_flags' ;
593
+ $new_value = 'show_flags';
594
+
595
+ if ( get_option( $option_name ) === false ) {
596
+
597
+ // The option does not exist, so we update it.
598
+ update_option( $option_name, $new_value );
599
+ }
600
+
601
+ $options = get_option (''.$option_name.''); ?>
602
+
603
+ <input type="radio" name="googlelanguagetranslator_flags" id="googlelanguagetranslator_flags" value="show_flags" <?php if($options=='show_flags'){echo "checked";}?>/> Yes, show flag images<br/>
604
+ <input type="radio" name="googlelanguagetranslator_flags" id="googlelanguagetranslator_flags" value="hide_flags" <?php if($options=='hide_flags'){echo "checked";}?>/> No, hide flag images
605
+ <?php
606
+ }
607
+
608
+ public function flag_display_settings_cb() {
609
+ $default_language_code = get_option('googlelanguagetranslator_language');
610
+ $option_name = 'flag_display_settings';
611
+ $new_value = array('flag-'.$default_language_code.'' => 1);
612
+
613
+ if ( get_option( $option_name ) == false ) {
614
+ // The option does not exist, so we update it.
615
+ update_option( $option_name, $new_value );
616
+ }
617
+
618
+ $get_flag_choices = get_option (''.$option_name.'');
619
+
620
+ foreach ($this->languages_array as $key => $value) {
621
+ $language_code = $key;
622
+ $language_name = $value;
623
+ $language_code_array[] = $key;
624
+
625
+ if (!isset($get_flag_choices['flag-'.$language_code.''])) {
626
+ $get_flag_choices['flag-'.$language_code.''] = 0;
627
+ }
628
+
629
+ $items[] = $get_flag_choices['flag-'.$language_code.''];
630
+ $language_codes = $language_code_array;
631
+ $item_count = count($items);
632
+
633
+ if ($item_count == 1 || $item_count == 22 || $item_count == 43 || $item_count == 64) { ?>
634
+ <div class="flagdisplay" style="width:25%; float:left">
635
+ <?php } ?>
636
+ <div><input type="checkbox" name="flag_display_settings[flag-<?php echo $language_code; ?>]" value="1"<?php checked( 1,$get_flag_choices['flag-'.$language_code.'']); ?>/><?php echo $language_name; ?></div>
637
+ <?php
638
+ if ($item_count == 21 || $item_count == 42 || $item_count == 63 || $item_count == 81) { ?>
639
+ </div>
640
+ <?php }
641
+ } ?>
642
+ <div class="clear"></div>
643
+ <?php
644
+ }
645
+
646
+ public function googlelanguagetranslator_floating_widget_cb() {
647
+
648
+ $option_name = 'googlelanguagetranslator_floating_widget' ;
649
+ $new_value = 'yes';
650
+
651
+ if ( get_option( $option_name ) === false ) {
652
+
653
+ // The option does not exist, so we update it.
654
+ update_option( $option_name, $new_value );
655
+ }
656
+
657
+ $options = get_option (''.$option_name.''); ?>
658
+
659
+ <select name="googlelanguagetranslator_floating_widget" id="googlelanguagetranslator_floating_widget" style="width:170px">
660
+ <option value="yes" <?php if($options=='yes'){echo "selected";}?>>Yes, show widget</option>
661
+ <option value="no" <?php if($options=='no'){echo "selected";}?>>No, hide widget</option>
662
+ </select>
663
+ <?php }
664
+
665
+ public function googlelanguagetranslator_translatebox_cb() {
666
+
667
+ $option_name = 'googlelanguagetranslator_translatebox' ;
668
+ $new_value = 'yes';
669
+
670
+ if ( get_option( $option_name ) === false ) {
671
+
672
+ // The option does not exist, so we update it.
673
+ update_option( $option_name, $new_value );
674
+ }
675
+
676
+ $options = get_option (''.$option_name.''); ?>
677
+
678
+ <select name="googlelanguagetranslator_translatebox" id="googlelanguagetranslator_translatebox" style="width:190px">
679
+ <option value="yes" <?php if($options=='yes'){echo "selected";}?>>Yes, show language box</option>
680
+ <option value="no" <?php if($options=='no'){echo "selected";}?>>No, hide language box</option>
681
+ </select>
682
+ <?php }
683
+
684
+ public function googlelanguagetranslator_display_cb() {
685
+
686
+ $option_name = 'googlelanguagetranslator_display' ;
687
+ $new_value = 'Vertical';
688
+
689
+ if ( get_option( $option_name ) === false ) {
690
+
691
+ // The option does not exist, so we update it.
692
+ update_option( $option_name, $new_value );
693
+ }
694
+
695
+ $options = get_option (''.$option_name.''); ?>
696
+
697
+ <select name="googlelanguagetranslator_display" id="googlelanguagetranslator_display" style="width:170px;">
698
+ <option value="Vertical" <?php if(get_option('googlelanguagetranslator_display')=='Vertical'){echo "selected";}?>>Vertical</option>
699
+ <option value="Horizontal" <?php if(get_option('googlelanguagetranslator_display')=='Horizontal'){echo "selected";}?>>Horizontal</option>
700
+ </select>
701
+ <?php }
702
+
703
+ public function googlelanguagetranslator_toolbar_cb() {
704
+
705
+ $option_name = 'googlelanguagetranslator_toolbar' ;
706
+ $new_value = 'Yes';
707
+
708
+ if ( get_option( $option_name ) === false ) {
709
+
710
+ // The option does not exist, so we update it.
711
+ update_option( $option_name, $new_value );
712
+ }
713
+
714
+ $options = get_option (''.$option_name.''); ?>
715
+
716
+ <select name="googlelanguagetranslator_toolbar" id="googlelanguagetranslator_toolbar" style="width:170px;">
717
+ <option value="Yes" <?php if(get_option('googlelanguagetranslator_toolbar')=='Yes'){echo "selected";}?>>Yes</option>
718
+ <option value="No" <?php if(get_option('googlelanguagetranslator_toolbar')=='No'){echo "selected";}?>>No</option>
719
+ </select>
720
+ <?php }
721
+
722
+ public function googlelanguagetranslator_showbranding_cb() {
723
+
724
+ $option_name = 'googlelanguagetranslator_showbranding' ;
725
+ $new_value = 'Yes';
726
+
727
+ if ( get_option( $option_name ) === false ) {
728
+
729
+ // The option does not exist, so we update it.
730
+ update_option( $option_name, $new_value );
731
+ }
732
+
733
+ $options = get_option (''.$option_name.''); ?>
734
+
735
+ <select name="googlelanguagetranslator_showbranding" id="googlelanguagetranslator_showbranding" style="width:170px;">
736
+ <option value="Yes" <?php if(get_option('googlelanguagetranslator_showbranding')=='Yes'){echo "selected";}?>>Yes</option>
737
+ <option value="No" <?php if(get_option('googlelanguagetranslator_showbranding')=='No'){echo "selected";}?>>No</option>
738
+ </select>
739
+ <?php }
740
+
741
+ public function googlelanguagetranslator_flags_alignment_cb() {
742
+
743
+ $option_name = 'googlelanguagetranslator_flags_alignment' ;
744
+ $new_value = 'flags_left';
745
+
746
+ if ( get_option( $option_name ) === false ) {
747
+
748
+ // The option does not exist, so we update it.
749
+ update_option( $option_name, 'flags_left' );
750
+ }
751
+
752
+ $options = get_option (''.$option_name.''); ?>
753
+
754
+ <input type="radio" name="googlelanguagetranslator_flags_alignment" id="flags_left" value="flags_left" <?php if($options=='flags_left'){echo "checked";}?>/> Align Left<br/>
755
+ <input type="radio" name="googlelanguagetranslator_flags_alignment" id="flags_right" value="flags_right" <?php if($options=='flags_right'){echo "checked";}?>/> Align Right
756
+ <?php }
757
+
758
+ public function googlelanguagetranslator_analytics_cb() {
759
+
760
+ $option_name = 'googlelanguagetranslator_analytics' ;
761
+ $new_value = 0;
762
+
763
+ if ( get_option( $option_name ) === false ) {
764
+
765
+ // The option does not exist, so we update it.
766
+ update_option( $option_name, $new_value );
767
+ }
768
+
769
+ $options = get_option (''.$option_name.'');
770
+
771
+ $html = '<input type="checkbox" name="googlelanguagetranslator_analytics" id="googlelanguagetranslator_analytics" value="1" '.checked(1,$options,false).'/> &nbsp; Activate Google Analytics tracking?';
772
+ echo $html;
773
+ }
774
+
775
+ public function googlelanguagetranslator_analytics_id_cb() {
776
+
777
+ $option_name = 'googlelanguagetranslator_analytics_id' ;
778
+ $new_value = '';
779
+
780
+ if ( get_option( $option_name ) === false ) {
781
+
782
+ // The option does not exist, so we update it.
783
+ update_option( $option_name, $new_value );
784
+ }
785
+
786
+ $options = get_option (''.$option_name.'');
787
+
788
+ $html = '<input type="text" name="googlelanguagetranslator_analytics_id" id="googlelanguagetranslator_analytics_id" value="'.$options.'" />';
789
+ echo $html;
790
+ }
791
+
792
+ public function googlelanguagetranslator_flag_size_cb() {
793
+
794
+ $option_name = 'googlelanguagetranslator_flag_size' ;
795
+ $new_value = '18';
796
+
797
+ if ( get_option( $option_name ) === false ) {
798
+
799
+ // The option does not exist, so we update it.
800
+ update_option( $option_name, $new_value );
801
+ }
802
+
803
+ $options = get_option (''.$option_name.''); ?>
804
+
805
+ <select name="googlelanguagetranslator_flag_size" id="googlelanguagetranslator_flag_size" style="width:110px;">
806
+ <option value="16" <?php if($options=='16'){echo "selected";}?>>16px</option>
807
+ <option value="18" <?php if($options=='18'){echo "selected";}?>>18px</option>
808
+ <option value="20" <?php if($options=='20'){echo "selected";}?>>20px</option>
809
+ <option value="22" <?php if($options=='22'){echo "selected";}?>>22px</option>
810
+ <option value="24" <?php if($options=='24'){echo "selected";}?>>24px</option>
811
+ </select>
812
+ <?php }
813
+
814
+ public function googlelanguagetranslator_flags_order_cb() {
815
+ $option_name = 'googlelanguagetranslator_flags_order';
816
+ $new_value = '';
817
+
818
+ if ( get_option ( $option_name ) === false ) {
819
+
820
+ // The option does not exist, so we update it.
821
+ update_option( $option_name, $new_value );
822
+ }
823
+
824
+ $options = get_option ( ''.$option_name.'' ); ?>
825
+
826
+ <input type="hidden" id="order" name="googlelanguagetranslator_flags_order" value="<?php print_r(get_option('googlelanguagetranslator_flags_order')); ?>" />
827
+ <?php
828
+ }
829
+
830
+ public function googlelanguagetranslator_css_cb() {
831
+
832
+ $option_name = 'googlelanguagetranslator_css' ;
833
+ $new_value = '';
834
+
835
+ if ( get_option( $option_name ) === false ) {
836
+
837
+ // The option does not exist, so we update it.
838
+ update_option( $option_name, $new_value );
839
+ }
840
+
841
+ $options = get_option (''.$option_name.'');
842
+
843
+ $html = '<textarea style="width:100%; height:200px" name="googlelanguagetranslator_css" id="googlelanguagetranslator_css">'.$options.'</textarea>';
844
+ echo $html;
845
+ }
846
+
847
+ public function googlelanguagetranslator_manage_translations_cb() {
848
+ $option_name = 'googlelanguagetranslator_manage_translations' ;
849
+ $new_value = 0;
850
+
851
+ if ( get_option( $option_name ) === false ) {
852
+
853
+ // The option does not exist, so we update it.
854
+ update_option( $option_name, $new_value );
855
+ }
856
+
857
+ $options = get_option (''.$option_name.'');
858
+
859
+ $html = '<input type="checkbox" name="googlelanguagetranslator_manage_translations" id="googlelanguagetranslator_manage_translations" value="1" '.checked(1,$options,false).'/> &nbsp; Turn on translation management?';
860
+ echo $html;
861
+ }
862
+
863
+ public function googlelanguagetranslator_multilanguage_cb() {
864
+
865
+ $option_name = 'googlelanguagetranslator_multilanguage' ;
866
+ $new_value = 0;
867
+
868
+ if ( get_option( $option_name ) === false ) {
869
+
870
+ // The option does not exist, so we update it.
871
+ update_option( $option_name, $new_value );
872
+ }
873
+
874
+ $options = get_option (''.$option_name.'');
875
+
876
+ $html = '<input type="checkbox" name="googlelanguagetranslator_multilanguage" id="googlelanguagetranslator_multilanguage" value="1" '.checked(1,$options,false).'/> &nbsp; Turn on multilanguage mode?';
877
+ echo $html;
878
+ }
879
+
880
+ public function googlelanguagetranslator_exclude_translation_cb() {
881
+
882
+ $option_name = 'googlelanguagetranslator_exclude_translation';
883
+ $new_value = '';
884
+
885
+ if (get_option($option_name) === false ) {
886
+ // The option does not exist, so we update it.
887
+ update_option( $option_name, $new_value );
888
+ }
889
+
890
+ $options = get_option (''.$option_name.'');
891
+
892
+ $html = '<input type="text" name="'.$option_name.'" id="'.$option_name.'" value="'.$options.'" />';
893
+
894
+ echo $html;
895
+ }
896
+
897
+ public function page_layout_cb() {
898
+ include( plugin_dir_path( __FILE__ ) . '/css/style.php'); ?>
899
+ <?php add_thickbox(); ?>
900
+ <div class="wrap">
901
+ <div id="icon-options-general" class="icon32"></div>
902
+ <h2><span class="notranslate">Google Language Translator</span></h2>
903
+ <form action="<?php echo admin_url( '/options.php'); ?>" method="post">
904
+ <div class="metabox-holder has-right-sidebar" style="float:left; width:65%">
905
+ <div class="postbox" style="width: 100%">
906
+ <h3 class="notranslate">Settings</h3>
907
+
908
+ <?php settings_fields('google_language_translator'); ?>
909
+ <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
910
+ <tr>
911
+ <td style="width:60%" class="notranslate">Plugin Status:</td>
912
+ <td class="notranslate"><?php $this->googlelanguagetranslator_active_cb(); ?></td>
913
+ </tr>
914
+
915
+ <tr class="notranslate">
916
+ <td>Choose the original language of your website</td>
917
+ <td><?php $this->googlelanguagetranslator_language_cb(); ?></td>
918
+ </tr>
919
+
920
+ <tr class="notranslate">
921
+ <td>What translation languages will display in the language box?<br/>("All Languages" option <strong><u>must</u></strong> be chosen to show flags.)</td>
922
+ <td><?php $this->googlelanguagetranslator_language_option_cb(); ?></td>
923
+ </tr>
924
+
925
+ <tr class="notranslate languages">
926
+ <td colspan="2"><?php $this->language_display_settings_cb(); ?></td>
927
+ </tr>
928
+
929
+ <tr class="notranslate">
930
+ <td class="choose_flags_intro">Show flag images?<br/>(Display up to 81 flags above the translator)</td>
931
+ <td class="choose_flags_intro"><?php $this->googlelanguagetranslator_flags_cb(); ?></td>
932
+ </tr>
933
+
934
+ <tr class="notranslate choose_flags">
935
+ <td class="choose_flags">Choose the flags you want to display:</td>
936
+ <td></td>
937
+ </tr>
938
+
939
+ <tr class="notranslate">
940
+ <td colspan="2" class="choose_flags"><?php $this->flag_display_settings_cb(); ?></td>
941
+ </tr>
942
+
943
+ <tr class="notranslate">
944
+ <td>Show floating translation widget?<br/>
945
+ <span>("All Languages" option <strong><u>must</u></strong> be chosen to show widget.)</span>
946
+ </td>
947
+ <td><?php $this->googlelanguagetranslator_floating_widget_cb(); ?></td>
948
+ </tr>
949
+
950
+ <tr class="notranslate">
951
+ <td>Show translate box?</td>
952
+ <td><?php $this->googlelanguagetranslator_translatebox_cb(); ?></td>
953
+ </tr>
954
+
955
+ <tr class="notranslate">
956
+ <td>Layout option:</td>
957
+ <td><?php $this->googlelanguagetranslator_display_cb(); ?></td>
958
+ </tr>
959
+
960
+ <tr class="notranslate">
961
+ <td>Show Google Toolbar?</td>
962
+ <td><?php $this->googlelanguagetranslator_toolbar_cb(); ?></td>
963
+ </tr>
964
+
965
+ <tr class="notranslate">
966
+ <td>Show Google Branding? &nbsp;<a href="https://developers.google.com/translate/v2/attribution" target="_blank">Learn more</a></td>
967
+ <td><?php $this->googlelanguagetranslator_showbranding_cb(); ?></td>
968
+ </tr>
969
+
970
+ <tr class="alignment notranslate">
971
+ <td class="flagdisplay">Align the translator left or right?</td>
972
+ <td class="flagdisplay"><?php $this->googlelanguagetranslator_flags_alignment_cb(); ?></td>
973
+ </tr>
974
+
975
+ <!--<tr class="manage_translations notranslate">
976
+ <td>Turn on translation management? &nbsp;<a href="#TB_inline?width=200&height=300&inlineId=translation-management-description" title="What is Translation Management?" class="thickbox">Learn more</a><div id="translation-management-description" style="display:none"><p>Translation management is an interface that allows you to manage specific words and phrases on your website. The interface is linked directly to your Google Account, and no special subscriptions are necessary to setup this feature.</p><p>If translation management setting is checked, users who browse your website can hover their mouse over specific words and phrases, then send translation suggestions directly to your Google Translate account! You can then "approve" those suggestions, and Google will automatically display them when translations are requested by your users.</p><p>Translation management requires that you insert a custom meta tag into the <code>head</code> section of your website.</p><p><a href="http://translate.google.com/manager/website/settings" target="_blank">Click here to to get the required meta tag</a></p></div></td>
977
+ <td><?php $this->googlelanguagetranslator_manage_translations_cb(); ?></td>
978
+ </tr>-->
979
+
980
+ <tr class="multilanguage notranslate">
981
+ <td>Multilanguage Page option? &nbsp;<a href="#TB_inline?width=200&height=150&inlineId=multilanguage-page-description" title="What is the Multi-Language Page Option?" class="thickbox">Learn more</a><div id="multilanguage-page-description" style="display:none"><p>If checked, Google will automatically convert text written in multiple languages, into the single language requested by your user.</p><p>In most cases, this setting is not recommended, although for certain websites it might be necessary.</p></div></td>
982
+ <td><?php $this->googlelanguagetranslator_multilanguage_cb(); ?></td>
983
+ </tr>
984
+
985
+ <tr class="notranslate">
986
+ <td>Google Analytics:</td>
987
+ <td><?php $this->googlelanguagetranslator_analytics_cb(); ?></td>
988
+ </tr>
989
+
990
+ <tr class="analytics notranslate">
991
+ <td>Google Analytics ID (Ex. 'UA-11117410-2')</td>
992
+ <td><?php $this->googlelanguagetranslator_analytics_id_cb(); ?></td>
993
+ </tr>
994
+
995
+ <tr class="notranslate">
996
+ <td>Full widget usage in pages/posts/sidebar:</td>
997
+ <td><code>[google-translator]</code></td>
998
+ </tr>
999
+ </table>
1000
+
1001
+ <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
1002
+ <tr class="notranslate">
1003
+ <td style="width:40%">Full widget usage in header/footer or page template:</td>
1004
+ <td style="width:60%"><code>&lt;?php echo do_shortcode('[google-translator]'); ?&gt;</code></td>
1005
+ </tr>
1006
+
1007
+ <tr class="notranslate">
1008
+ <td>Single language usage in<br/>nav menu/pages/posts</td>
1009
+ <td><code>[glt language="Spanish" label="Español"]</code></td>
1010
+ </tr>
1011
+
1012
+ <tr class="notranslate">
1013
+ <td colspan="2">
1014
+ <a href="#TB_inline?width=200&height=450&inlineId=single-language-shortcode-description" title="How to place a single language in your Wordpress menu" class="thickbox">How to place a single language in your Wordpress menu</a>
1015
+ <div id="single-language-shortcode-description" style="display:none">
1016
+ <p>For menu usage, you need to create a new menu, or use an existing menu, by navigating to "Appearance > Menus".</p>
1017
+ <p>First you will need to enable "descriptions" for your menu items, which can be found in a tab labeled "Screen Options" in the upper-right area of the page.</p>
1018
+ <p>Once descriptions are enabled, follow these steps:<br/>
1019
+ <ol>
1020
+ <li>Create a new menu item using "Link" as the menu item type.</li>
1021
+ <li>Use <code style="border:none">#</code> for the URL</li>
1022
+ <li>Enter a navigation label of your choice. This label does not appear on your website - it is meant only to help you identify the menu item.</li>
1023
+ <li>Place the following shortcode into the "description" field, and modify it to display the language and navigation label of your choice:</li>
1024
+ </ol>
1025
+ <p><code>[glt language="Spanish" label="Español"]</code></p>
1026
+ </div>
1027
+ </td>
1028
+ </tr>
1029
+
1030
+ <tr class="notranslate">
1031
+ <td>
1032
+ <?php
1033
+ if (isset($_POST['submit'])) {
1034
+ if (empty($_POST['submit']) && !check_admin_referer( 'glt-save-settings', 'glt-save-settings-nonce' )) {
1035
+ wp_die();
1036
+ } else { echo 'hello'; }
1037
+ }
1038
+ wp_nonce_field('glt-save-settings, glt-save-settings-nonce', false);
1039
+ submit_button();
1040
+ ?>
1041
+ </td>
1042
+ <td></td>
1043
+ </tr>
1044
+ </table>
1045
+ </div> <!-- .postbox -->
1046
+ </div> <!-- .metbox-holder -->
1047
+
1048
+ <div class="metabox-holder" style="float:right; clear:right; width:33%">
1049
+ <div class="postbox">
1050
+ <h3 class="notranslate">Preview</h3>
1051
+ <table style="width:100%">
1052
+ <tr>
1053
+ <td style="box-sizing:border-box; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; padding:15px 15px; margin:0px"><span class="notranslate"> Drag &amp; drop flags to change their position.<br/><br/>(Note: flag order resets when flags are added/removed)</span><br/><br/><?php echo do_shortcode('[google-translator]'); ?><p class="hello"><span class="notranslate">Translated text:</span> &nbsp; <span>Hello</span></p></td>
1054
+ </tr>
1055
+
1056
+ <tr>
1057
+ <td><?php if (isset ($_POST['googlelanguagetranslator_flags_order']) ) { echo $_POST['googlelanguagetranslator_flags_order']; } ?></td>
1058
+ </tr>
1059
+
1060
+
1061
+ </table>
1062
+ </div> <!-- .postbox -->
1063
+ </div> <!-- .metabox-holder -->
1064
+
1065
+ <div id="glt_advanced_settings" class="metabox-holder notranslate" style="float: right; width: 33%;">
1066
+ <div class="postbox">
1067
+ <h3>Advanced Settings</h3>
1068
+ <div class="inside">
1069
+ <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
1070
+ <tr class="notranslate">
1071
+ <td class="advanced">Select flag size:</td>
1072
+ <td class="advanced"><?php $this->googlelanguagetranslator_flag_size_cb(); ?></td>
1073
+ </tr>
1074
+ </table>
1075
+ </div>
1076
+ </div>
1077
+ </div>
1078
+
1079
+
1080
+ <div class="metabox-holder notranslate" style="float: right; width: 33%;">
1081
+ <div class="postbox">
1082
+ <h3>Add CSS Styles</h3>
1083
+ <div class="inside">
1084
+ <p>You can apply any necessary CSS styles below:</p>
1085
+ <?php $this->googlelanguagetranslator_css_cb(); ?>
1086
+ </div>
1087
+ </div>
1088
+ </div>
1089
+ <?php $this->googlelanguagetranslator_flags_order_cb(); ?>
1090
+ </form>
1091
+
1092
+ <div class="metabox-holder notranslate" style="float: right; width: 33%;">
1093
+ <div class="postbox">
1094
+ <h3>GLT Premium 4.0.9 is Here! $30</h3>
1095
+ <div class="inside"><a href="http://www.wp-studio.net/" target="_blank"><img style="background:#444; border-radius:3px; -webkit-border-radius:3px; -moz-border-radius:3px" src="<?php echo plugins_url('google-language-translator/images/logo.png'); ?>"></a><br />
1096
+ <ul id="features" style="margin-left:15px">
1097
+ <li style="list-style:square outside"><span style="color:red; font-weight:bold">New!</span> Manual Translation Module (Experimental)!</li>
1098
+ <li style="list-style:square outside"><span style="color:red; font-weight:bold">New!</span> Exclude any specific area of your website from translation, directly from your settings panel</li>
1099
+ <li style="list-style:square outside">81 Languages</li>
1100
+ <li style="list-style:square outside">jQuery-powered language switcher<br/>(No Adobe Flash required)</li>
1101
+ <li style="list-style:square outside">Add single languages to your menus/pages/posts</li>
1102
+ <li style="list-style:square outside">Show/hide images or text for each language</li>
1103
+ <li style="list-style:square outside">Language switcher loads inline with page content</li>
1104
+ <li style="list-style:square outside">Custom flag choices for English, Spanish and Portuguese</li>
1105
+ <li style="list-style:square outside">User-friendly URLs, hide or show <code>lang</code> attribute</li>
1106
+ <li style="list-style:square outside">Drag/drop flags to re-arrange their order</li>
1107
+ <li style="list-style:square outside">Full access to our support forum</li>
1108
+ <li style="list-style:square outside">FREE access to all future updates</li>
1109
+ </ul>
1110
+ </div>
1111
+ </div>
1112
+ </div>
1113
+
1114
+ <div class="metabox-holder notranslate" style="float: right; width: 33%;">
1115
+ <div class="postbox">
1116
+ <h3>Please Consider A Donation</h3>
1117
+ <div class="inside">If you like this plugin and find it useful, help keep this plugin actively developed by clicking the donate button <br /><br />
1118
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
1119
+ <input type="hidden" name="cmd" value="_donations">
1120
+ <input type="hidden" name="business" value="robertmyrick@hotmail.com">
1121
+ <input type="hidden" name="lc" value="US">
1122
+ <input type="hidden" name="item_name" value="Support Studio 88 Design and help us bring you more Wordpress goodies! Any donation is kindly appreciated. Thank you!">
1123
+ <input type="hidden" name="no_note" value="0">
1124
+ <input type="hidden" name="currency_code" value="USD">
1125
+ <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
1126
+ <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
1127
+ <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
1128
+ </form>
1129
+ <br />
1130
+ <br />
1131
+ </div>
1132
+ </div>
1133
+ </div>
1134
+ </div> <!-- .wrap -->
1135
+ <?php
1136
+ }
1137
+ }
1138
  $google_language_translator = new google_language_translator();
images/flags.png CHANGED
Binary file
images/flags16.png CHANGED
Binary file
images/flags18.png CHANGED
Binary file
images/flags20.png CHANGED
Binary file
images/flags22.png CHANGED
Binary file
readme.txt CHANGED
@@ -1,273 +1,276 @@
1
- === Google Language Translator ===
2
- Contributors: Rob Myrick
3
- Donate link: http://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=47LFA33AC89S6
4
- Plugin link: http://www.wp-studio.net/how-it-works
5
- Tags: language translator, google translator, language translate, google, google language translator, translation, translate, multi language
6
- Requires at least: 2.9
7
- Tested up to: 4.3
8
- stable tag: 5.0.01
9
-
10
- Welcome to Google Language Translator! This plugin allows you to insert the Google Language Translator tool anywhere on your website using shortcode.
11
-
12
- == Description ==
13
-
14
- Settings include: inline or vertical layout, show/hide specific languages, hide/show Google toolbar, and hide/show Google branding. Add the shortcode to pages, posts, and widgets.
15
-
16
- == Installation ==
17
-
18
- 1. Download the zip folder named google-language-translator.zip
19
- 2. Unzip the folder and put it in the plugins directory of your wordpress installation. (wp-content/plugins).
20
- 3. Activate the plugin through the plugin window in the admin panel.
21
- 4. Go to Settings > Google Language Translator, enable the plugin, and then choose your settings.
22
- 5. Copy the shortcode and paste it into a page, post or widget.
23
- 6. Do not use the shortcode twice on a single page - it will not work.
24
-
25
- == Frequently Asked Questions ==
26
-
27
- Q: What should I do if the translate widget does not show on my website?
28
-
29
- 1. Make sure that the plugin is installed and activated.
30
- 2. Verify that a check mark is placed in the activation setting located at "Settings > Google Language Translator".
31
- 3. Verify that the native Wordpress function, wp_footer(), is included in your theme's footer file.
32
- 4. Verify that "Show Language Box?" setting is enabled at "Settings > Google Language Translator".
33
- 5. Use your browser's web tools to ensure that CSS styles are not hiding the translation widget.
34
- 6. Contact support at http://www.wp-studio.net/submit-ticket.
35
-
36
- Q: What should I do if there are no languages being displayed in the language box?
37
-
38
- 1. Make sure that the plugin is installed and activated.
39
- 2. Verify that a check mark is placed in the activation setting located at "Settings > Google Language Translator".
40
- 3. Verify that Adobe Flash is installed in your web browser. Google uses Flash in order to display their language box.
41
- 4. Contact support at http://www.wp-studio.net/submit-ticket.
42
-
43
- Q: Can I exclude certain areas of my website from being translated?
44
-
45
- A: Yes! Add the "notranslate" class to the HTML element containing your text. For example, the following text will be excluded from translation: <span class="notranslate">Hello World!</span>
46
-
47
- == Changelog ==
48
-
49
- 5.0.01
50
- - Updated style.css to reflect the syntax error connecting to the Chinese flag.
51
-
52
- 5.0.0
53
- - Wordpress security updates added to the settings page [wp_nonce_field()].
54
- - Removed 3 outside Javascript files - these files are now called upon directly from Wordpress CMS.
55
- - Unpacked flags.js p,a,c,k,e,r code. Unknowingly, this method of coding violated Wordpress plugin policy.
56
- - Updated pricing display for GLT Premium. It was displaying $15 previously, but the price had increased since the last update.
57
-
58
- 4.0.9
59
- - Replaced: incorrect Catalonian flag image, with the correct image. I apologize for any inconvenience.
60
- - Fixed: Floating Widget issue - previously it loaded 2 times when shortcode was added, which caused it not to work.
61
-
62
- 4.0.8
63
- - Fixed the small syntax issue related to the Google Analytics tracking number - it was another cause of the language box not displaying.
64
-
65
- 4.0.7
66
- - Fixed a CSS error in the settings panel display.
67
- - Fixed the coding issue when "Specific Languages" option is chosen - the shortcode was not displaying the language dropdown.
68
-
69
- 4.0.6
70
-
71
- - Removed: "onclick" events from diplaying directly inside HTML. Converted those events to jQuery.
72
- - Fixed the shortcode that allows adding single languages to Wordpress menus. (New example is shown on settings page.)
73
- - Consolidated all flag images into image sprites!
74
- - Re-designed 10 flag images to match the quality of the other flags.
75
- - Fixed the incorrect "alt" tags associated with flag images. The "alt" tag now displays the language name.
76
- - Modified text on the settings page - also added some lightbox pop-ups to help explain settings.
77
- - New updates have also been provided for our Premium version (currently version 4.0.1) located at http://www.wp-studio.net/
78
-
79
- 4.0.5
80
-
81
- - Fixed: Display bug when using single language shortcode.
82
- - Added: New link on the Plugins menu page, which links directly to Google Language Translator settings.
83
-
84
-
85
- 4.0.4
86
-
87
- - Added NEW shortcode! Allows placement of single languages into the navigation menu, pages, and posts. See settings panel for usage details.
88
- - Re-factored code in googlelanguagetranslator.php which reduced code to around 950 lines.
89
- - Removed the "de-activation" hook, which previously deleted options when plugin de-activated. Added "uninstall" hook instead, so that settings will be preserved only when user deletes the plugin completely.
90
- - Updated CSS styles for the flags area to prevent themes from overriding layouts.
91
-
92
- 4.0.3
93
-
94
- - Adjusted CSS styles for the flag display.
95
-
96
- 4.0.2
97
-
98
- - Eliminated all (or most) HTML validation errors. Big improvement!
99
- - Re-factored more code to increase efficiency.
100
- - Added de-activation hook to reset all plugin settings when plugin is de-activated. (CSS Overrides and Google Analytics ID setting will remain in place and won't be deleted.)
101
- - Fixed the issue with flag language checkboxes. Users can remove English flag if so desired. Previously, English flag was alway required to stay checked, which was not most user-friendly.
102
-
103
- 4.0.1
104
-
105
- - Fixed PHP errors that were neglected in upgrade to 4.0.
106
- - Added conditionals to prevent scripts from loading when the floating widget is turned off.
107
-
108
- 4.0
109
-
110
- - Added 2 new features: 1) Drag/drop flags to re-arrange their order, and 2) Custom flag sizes (16px to 24px).
111
- - Re-factored code in google-language-translator.php. Languages are now loaded dynamically and are not hard-coded.
112
- - GLT Premium is now released: Updates include multiple flags for English, Spanish, and Portuguese languages; customized URLs with 'lang' attribute; drag/drop flags to re-arrnage their order
113
-
114
- 3.0.9
115
-
116
- - Added a title field to the Google Language Translator widget.
117
- - Removed "unexpected text characters" error upon activation (due to error in activation hook).
118
-
119
- 3.0.8
120
-
121
- - Added 9 new languages into the plugin (Hausa, Igbo, Maori, Mongolian, Nepali, Punjabi, Somali, Yoruba, Zulu).
122
- - Corrected an "undefined variable" error that was being generated in Vertical and Horizontal layouts.
123
- - Re-structured coding once again into an Object-Oriented approach.
124
- - Moved all functions of the base class into 'googlelanguagetranslator.php' and the widget into 'widget.php'.
125
- - Moved all javascript files into it's own JS folder.
126
- - Fixed an display issue with "Edit Translations" - they were being hidden when "No branding" option was chosen.
127
- - Corrected various "comma" errors in the string that outputs the script for loading the translator.
128
- - Changed Changelog in readme.txt to show most recent changes first, instead of last.
129
-
130
- 3.0.7
131
-
132
- - Removed an unnecessary CSS file, left over from development. Sorry for any inconvenience if you received display errors.
133
-
134
- 3.0.6
135
-
136
- - Corrected a small display error in displaying the floating widget correctly.
137
-
138
- 3.0.5
139
-
140
- - Added new Floating Widget (see settings page). The Floating Widget is simply another way for allowing website visitors to translate languages. The functionality is built-in with the existing flag preferences, and can be turned on or off at the administrator's preference. The floating widget can also function in full with both the language box and/or flags showing OR hiding, so the administrator has full control of how it displays. The floating widget is placed at bottom right of the website in the free version, but can be placed in other locations by changing CSS styles associated with the box. The premium version will allow more options as to changing the Floating Widget location.
141
- - Fixed the issue with Dashboard styles loading on the wrong pages. This was causing some annoying display issues on the Wordpress Dashboard.
142
-
143
- 3.0.4
144
-
145
- - Re-factored/re-arranged more code in google languagetransltor.php by placing them into separate files.
146
- - Fixed the issue of Custom CSS box not displaying it's styles to the website. This was only missed in this last update, due to re-arrangement of the files. Sorry for any inconvenience.
147
- - Removed style2.php file, which is unnecessary and was being used in testing.
148
-
149
- 3.0.3
150
-
151
- - Re-factored/re-arranged some of the code in googlelanguagetranslator.php by placing them into separate files.
152
- - Fixed a minor coding issue in glt_widget.php - this was generating an error in Wordpress when debugging.
153
- - Moved all CSS code into a single file. The result is nice, clean inline CSS code that is now called only once.
154
- - Fixed some additional CSS display issues.
155
-
156
- 3.0.2
157
-
158
- - Adjusted additional minor invalid HTML issues on the settings page, and also in the front-end plugin display.
159
-
160
- 3.0.1
161
-
162
- - Changed the url request to Google to allow both unsecured and secured page translations. Previously, some users experienced errors when trying to use the translator on "https://" (secured) pages.
163
- - Adjusted some minor spacing issues in the settings page HTML (caused some annoying red HTML errors when using "View Source" in right-click menu).
164
- - Removed old CSS styles that were added in the previous 3.0 update - the styles were added when Google servers were being updated, and were producing major translation dislay issues until their update was complete. Now the styles I added are no longer needed.
165
-
166
- 3.0
167
-
168
- - Correct a small CSS error that affected the showing/hiding of the Google toolbar.
169
-
170
- 2.9
171
-
172
- ***IMPORTANT: Google's most recent server update is producing display issues for website translation tool. There are major display issues with the translation toolbar and also the translations editing interface. Version 2.9 temporarily hides the edit translation functionality until Google decides to fix this issue, although you can still edit translations directly through your Google account at translate.google.com. Please direct any support requests through Wordpress.org and we will be happy to assist you.
173
-
174
- - Fixed Google Translation toolbar display issue
175
- - Fixed the Edit Translation interface by hiding it temporarily until Google fixes this
176
- - Removed some unneeded styles from the style sheet.
177
- - Fixed some CSS issues for the Google Branding display, which was affected by Google's most recent update
178
-
179
- 2.8
180
-
181
- - Added an option to allow users to manage their own translations directly through their Google Translate account (free). When activated, users can hover over the text of their website, and edit the translations from the webpage directly. Google will remember these translations, and then serve them to users once the edits are made. Users must install the Google Translate Customization meta tag provided through Google Translate here: translate.google.com/manager/website/settings. To obtain this meta tag, users need to configure the Google Translate tool directly from this website (although they will not use this because the plugin provides it), then the user can obtain the meta tag on the "Get Code" screen, which is displayed after configuring the Google Translate tool on this webpage.
182
- - Added an option to allow users to turn on/off Google's multilanguagePage option, that when activated, the original website content will be a forced translation, instead of original content (but only after a translation is made.)
183
- - Added more flexible styles to the settings page, so that left and right panels display nicely to the user.
184
-
185
- 2.7
186
-
187
- - Added Google Analytics tracking capability to the plugin.
188
-
189
- - Added a "CSS Styles" box in the settings panel.
190
-
191
- - Changed the Catalonian flag to its correct flag image.
192
-
193
- - Fixed coding issues that previously updated options incorrectly, which is why many users experienced display issues. All options are now initialized upon plugin activation, which should fix this issue permanently.
194
-
195
- - Fixed a glitch in our usage of the translate API. Previously, when the user clicked the default language, it would toggle back and forth between the default language and "Afrikaans" language. Now, users will see the correct language displayed at all times, no matter how many times it is clicked.
196
-
197
- 2.6
198
-
199
- - Added defaults to all options to ensure there are no more issues with the translator displaying upon installation. Again, sorry for any inconvenience.
200
-
201
- 2.5
202
-
203
- - Eliminated an internal Wordpress error being generated from a coding mistake.
204
-
205
- - Added a default option for the Translator alingment. Previously, this was causing the plugin to disapppear.
206
-
207
- 2.4
208
-
209
- - Found a couple of small display errors in the settings page after uploading version 2.3. Sorry for any inconvenience!
210
-
211
- 2.3
212
-
213
- - Added a "Preview" area on the settings page that allows you to see your settings in action.
214
-
215
- - Added custom flag support for all languages (custom flags available ONLY when selecting the "ALL Languages" setting.
216
-
217
- - Added an option that allows left/right alignment of the translation tool.
218
-
219
- - Added the "Google Language Translator" widget.
220
-
221
- - Updated googlelanguagetranslator.php to properly register setting in the admin settings panel.
222
-
223
- 2.2
224
-
225
- - Added language "Portuguese" and "German" to the Original Language drop-down option on the settings page.
226
-
227
- - Changed flag image for the English language (changed United States flag to the United Kingdom flag).
228
-
229
- - Added link in the settings panel that points to Google's Attribution Policy.
230
-
231
- 2.1
232
-
233
- - Added language "Dutch" to the Original Language drop-down option on the settings page.
234
-
235
- - Added a new CSS class that more accurately hides the "Powered by" text when hiding Google's branding. In previous version, the "Powered by" text was actually disguised by setting it's color to "transparent", but now we have set it's font-size to 0px instead.
236
-
237
- 2.0 Corrected some immediate errors in the 1.9 update.
238
-
239
- 1.9
240
-
241
- - Added 7 flag image choices that, when clicked by website visitors, will change the language displayed, both on the website, AND in the drop-down box (flag language choices are limited to those provided in this plugin).
242
-
243
- - Added 6 additional languages to the translator, as provided in Google's most recent updates ( new languages include Bosnian, Cebuano, Khmer, Marathi, Hmong, Javanese ).
244
-
245
- - Corrected a minor technical issue where the Czech option (on the backend) was incorrectly displaying the Croatian language on the front end.
246
-
247
- - Added jQuery functionality to the settings panel to improve the user experience.
248
-
249
- - Added an option for users to display/hide the flag images.
250
-
251
- - Added an option for users to display/hide the translate box when flags are displayed.
252
-
253
- - Removed the settings.css file - I found a better way of displaying the options without CSS.
254
-
255
- 1.8 Modified google-language-translator.php to display the correct output to the browser when horizontal layout is selected. Previously, it was not displaying at all.
256
-
257
- 1.7 Modified google-language-translator.php so that jQuery and CSS styles were enqueued properly onto the settings page only. Previously, jQuery functionality and CSS styles were being added to all pages of the Wordpresss Dashboard, which was causing functionality and display issues for some users.
258
-
259
- 1.6 Added "Specific Language" support to the plugin settings, which allows the user to choose specific languages that are displayed to website visitors.
260
-
261
- 1.5 Added "Original Language" support to the plugin settings, which allows the user to choose the original language of their website, which ultimately removes the original language as a choice in the language drop-down presented to website visitors.
262
-
263
- 1.4 Corrected display problems associated with CSS styles not being placed correctly in wp_head.
264
-
265
- 1.3 HTML display problem in the sidebar area now fixed. Previously, inserting the [google-translator] plugin into a text widget caused it to display above the widget, instead of inside of it.
266
-
267
- 1.2 Shortcode support is now available for adding [google-translator] to text widgets. I apologize for any inconvenience this may have caused.
268
-
269
- 1.1 The shortcode supplied on the settings page was updated to display '[google-translator]'.
270
-
271
- == Screenshots ==
272
-
273
- 1. Settings include: inline or vertical layout, hide/show Google toolbar, display specific languages, and show/hide Google branding. Add the shortcode to pages, posts, and widgets.
 
 
 
1
+ === Google Language Translator ===
2
+ Contributors: Rob Myrick
3
+ Donate link: http://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=47LFA33AC89S6
4
+ Plugin link: http://www.wp-studio.net/how-it-works
5
+ Tags: language translator, google translator, language translate, google, google language translator, translation, translate, multi language
6
+ Requires at least: 2.9
7
+ Tested up to: 4.3
8
+ stable tag: 5.0.02
9
+
10
+ Welcome to Google Language Translator! This plugin allows you to insert the Google Language Translator tool anywhere on your website using shortcode.
11
+
12
+ == Description ==
13
+
14
+ Settings include: inline or vertical layout, show/hide specific languages, hide/show Google toolbar, and hide/show Google branding. Add the shortcode to pages, posts, and widgets.
15
+
16
+ == Installation ==
17
+
18
+ 1. Download the zip folder named google-language-translator.zip
19
+ 2. Unzip the folder and put it in the plugins directory of your wordpress installation. (wp-content/plugins).
20
+ 3. Activate the plugin through the plugin window in the admin panel.
21
+ 4. Go to Settings > Google Language Translator, enable the plugin, and then choose your settings.
22
+ 5. Copy the shortcode and paste it into a page, post or widget.
23
+ 6. Do not use the shortcode twice on a single page - it will not work.
24
+
25
+ == Frequently Asked Questions ==
26
+
27
+ Q: What should I do if the translate widget does not show on my website?
28
+
29
+ 1. Make sure that the plugin is installed and activated.
30
+ 2. Verify that a check mark is placed in the activation setting located at "Settings > Google Language Translator".
31
+ 3. Verify that the native Wordpress function, wp_footer(), is included in your theme's footer file.
32
+ 4. Verify that "Show Language Box?" setting is enabled at "Settings > Google Language Translator".
33
+ 5. Use your browser's web tools to ensure that CSS styles are not hiding the translation widget.
34
+ 6. Contact support at http://www.wp-studio.net/submit-ticket.
35
+
36
+ Q: What should I do if there are no languages being displayed in the language box?
37
+
38
+ 1. Make sure that the plugin is installed and activated.
39
+ 2. Verify that a check mark is placed in the activation setting located at "Settings > Google Language Translator".
40
+ 3. Verify that Adobe Flash is installed in your web browser. Google uses Flash in order to display their language box.
41
+ 4. Contact support at http://www.wp-studio.net/submit-ticket.
42
+
43
+ Q: Can I exclude certain areas of my website from being translated?
44
+
45
+ A: Yes! Add the "notranslate" class to the HTML element containing your text. For example, the following text will be excluded from translation: <span class="notranslate">Hello World!</span>
46
+
47
+ == Changelog ==
48
+
49
+ 5.0.02
50
+ - Updated the Tamil flag to use the Indian flag, instead of Tamil Tigers flag.
51
+
52
+ 5.0.01
53
+ - Updated style.css to reflect the syntax error connecting to the Chinese flag.
54
+
55
+ 5.0.0
56
+ - Wordpress security updates added to the settings page [wp_nonce_field()].
57
+ - Removed 3 outside Javascript files - these files are now called upon directly from Wordpress CMS.
58
+ - Unpacked flags.js p,a,c,k,e,r code. Unknowingly, this method of coding violated Wordpress plugin policy.
59
+ - Updated pricing display for GLT Premium. It was displaying $15 previously, but the price had increased since the last update.
60
+
61
+ 4.0.9
62
+ - Replaced: incorrect Catalonian flag image, with the correct image. I apologize for any inconvenience.
63
+ - Fixed: Floating Widget issue - previously it loaded 2 times when shortcode was added, which caused it not to work.
64
+
65
+ 4.0.8
66
+ - Fixed the small syntax issue related to the Google Analytics tracking number - it was another cause of the language box not displaying.
67
+
68
+ 4.0.7
69
+ - Fixed a CSS error in the settings panel display.
70
+ - Fixed the coding issue when "Specific Languages" option is chosen - the shortcode was not displaying the language dropdown.
71
+
72
+ 4.0.6
73
+
74
+ - Removed: "onclick" events from diplaying directly inside HTML. Converted those events to jQuery.
75
+ - Fixed the shortcode that allows adding single languages to Wordpress menus. (New example is shown on settings page.)
76
+ - Consolidated all flag images into image sprites!
77
+ - Re-designed 10 flag images to match the quality of the other flags.
78
+ - Fixed the incorrect "alt" tags associated with flag images. The "alt" tag now displays the language name.
79
+ - Modified text on the settings page - also added some lightbox pop-ups to help explain settings.
80
+ - New updates have also been provided for our Premium version (currently version 4.0.1) located at http://www.wp-studio.net/
81
+
82
+ 4.0.5
83
+
84
+ - Fixed: Display bug when using single language shortcode.
85
+ - Added: New link on the Plugins menu page, which links directly to Google Language Translator settings.
86
+
87
+
88
+ 4.0.4
89
+
90
+ - Added NEW shortcode! Allows placement of single languages into the navigation menu, pages, and posts. See settings panel for usage details.
91
+ - Re-factored code in googlelanguagetranslator.php which reduced code to around 950 lines.
92
+ - Removed the "de-activation" hook, which previously deleted options when plugin de-activated. Added "uninstall" hook instead, so that settings will be preserved only when user deletes the plugin completely.
93
+ - Updated CSS styles for the flags area to prevent themes from overriding layouts.
94
+
95
+ 4.0.3
96
+
97
+ - Adjusted CSS styles for the flag display.
98
+
99
+ 4.0.2
100
+
101
+ - Eliminated all (or most) HTML validation errors. Big improvement!
102
+ - Re-factored more code to increase efficiency.
103
+ - Added de-activation hook to reset all plugin settings when plugin is de-activated. (CSS Overrides and Google Analytics ID setting will remain in place and won't be deleted.)
104
+ - Fixed the issue with flag language checkboxes. Users can remove English flag if so desired. Previously, English flag was alway required to stay checked, which was not most user-friendly.
105
+
106
+ 4.0.1
107
+
108
+ - Fixed PHP errors that were neglected in upgrade to 4.0.
109
+ - Added conditionals to prevent scripts from loading when the floating widget is turned off.
110
+
111
+ 4.0
112
+
113
+ - Added 2 new features: 1) Drag/drop flags to re-arrange their order, and 2) Custom flag sizes (16px to 24px).
114
+ - Re-factored code in google-language-translator.php. Languages are now loaded dynamically and are not hard-coded.
115
+ - GLT Premium is now released: Updates include multiple flags for English, Spanish, and Portuguese languages; customized URLs with 'lang' attribute; drag/drop flags to re-arrnage their order
116
+
117
+ 3.0.9
118
+
119
+ - Added a title field to the Google Language Translator widget.
120
+ - Removed "unexpected text characters" error upon activation (due to error in activation hook).
121
+
122
+ 3.0.8
123
+
124
+ - Added 9 new languages into the plugin (Hausa, Igbo, Maori, Mongolian, Nepali, Punjabi, Somali, Yoruba, Zulu).
125
+ - Corrected an "undefined variable" error that was being generated in Vertical and Horizontal layouts.
126
+ - Re-structured coding once again into an Object-Oriented approach.
127
+ - Moved all functions of the base class into 'googlelanguagetranslator.php' and the widget into 'widget.php'.
128
+ - Moved all javascript files into it's own JS folder.
129
+ - Fixed an display issue with "Edit Translations" - they were being hidden when "No branding" option was chosen.
130
+ - Corrected various "comma" errors in the string that outputs the script for loading the translator.
131
+ - Changed Changelog in readme.txt to show most recent changes first, instead of last.
132
+
133
+ 3.0.7
134
+
135
+ - Removed an unnecessary CSS file, left over from development. Sorry for any inconvenience if you received display errors.
136
+
137
+ 3.0.6
138
+
139
+ - Corrected a small display error in displaying the floating widget correctly.
140
+
141
+ 3.0.5
142
+
143
+ - Added new Floating Widget (see settings page). The Floating Widget is simply another way for allowing website visitors to translate languages. The functionality is built-in with the existing flag preferences, and can be turned on or off at the administrator's preference. The floating widget can also function in full with both the language box and/or flags showing OR hiding, so the administrator has full control of how it displays. The floating widget is placed at bottom right of the website in the free version, but can be placed in other locations by changing CSS styles associated with the box. The premium version will allow more options as to changing the Floating Widget location.
144
+ - Fixed the issue with Dashboard styles loading on the wrong pages. This was causing some annoying display issues on the Wordpress Dashboard.
145
+
146
+ 3.0.4
147
+
148
+ - Re-factored/re-arranged more code in google languagetransltor.php by placing them into separate files.
149
+ - Fixed the issue of Custom CSS box not displaying it's styles to the website. This was only missed in this last update, due to re-arrangement of the files. Sorry for any inconvenience.
150
+ - Removed style2.php file, which is unnecessary and was being used in testing.
151
+
152
+ 3.0.3
153
+
154
+ - Re-factored/re-arranged some of the code in googlelanguagetranslator.php by placing them into separate files.
155
+ - Fixed a minor coding issue in glt_widget.php - this was generating an error in Wordpress when debugging.
156
+ - Moved all CSS code into a single file. The result is nice, clean inline CSS code that is now called only once.
157
+ - Fixed some additional CSS display issues.
158
+
159
+ 3.0.2
160
+
161
+ - Adjusted additional minor invalid HTML issues on the settings page, and also in the front-end plugin display.
162
+
163
+ 3.0.1
164
+
165
+ - Changed the url request to Google to allow both unsecured and secured page translations. Previously, some users experienced errors when trying to use the translator on "https://" (secured) pages.
166
+ - Adjusted some minor spacing issues in the settings page HTML (caused some annoying red HTML errors when using "View Source" in right-click menu).
167
+ - Removed old CSS styles that were added in the previous 3.0 update - the styles were added when Google servers were being updated, and were producing major translation dislay issues until their update was complete. Now the styles I added are no longer needed.
168
+
169
+ 3.0
170
+
171
+ - Correct a small CSS error that affected the showing/hiding of the Google toolbar.
172
+
173
+ 2.9
174
+
175
+ ***IMPORTANT: Google's most recent server update is producing display issues for website translation tool. There are major display issues with the translation toolbar and also the translations editing interface. Version 2.9 temporarily hides the edit translation functionality until Google decides to fix this issue, although you can still edit translations directly through your Google account at translate.google.com. Please direct any support requests through Wordpress.org and we will be happy to assist you.
176
+
177
+ - Fixed Google Translation toolbar display issue
178
+ - Fixed the Edit Translation interface by hiding it temporarily until Google fixes this
179
+ - Removed some unneeded styles from the style sheet.
180
+ - Fixed some CSS issues for the Google Branding display, which was affected by Google's most recent update
181
+
182
+ 2.8
183
+
184
+ - Added an option to allow users to manage their own translations directly through their Google Translate account (free). When activated, users can hover over the text of their website, and edit the translations from the webpage directly. Google will remember these translations, and then serve them to users once the edits are made. Users must install the Google Translate Customization meta tag provided through Google Translate here: translate.google.com/manager/website/settings. To obtain this meta tag, users need to configure the Google Translate tool directly from this website (although they will not use this because the plugin provides it), then the user can obtain the meta tag on the "Get Code" screen, which is displayed after configuring the Google Translate tool on this webpage.
185
+ - Added an option to allow users to turn on/off Google's multilanguagePage option, that when activated, the original website content will be a forced translation, instead of original content (but only after a translation is made.)
186
+ - Added more flexible styles to the settings page, so that left and right panels display nicely to the user.
187
+
188
+ 2.7
189
+
190
+ - Added Google Analytics tracking capability to the plugin.
191
+
192
+ - Added a "CSS Styles" box in the settings panel.
193
+
194
+ - Changed the Catalonian flag to its correct flag image.
195
+
196
+ - Fixed coding issues that previously updated options incorrectly, which is why many users experienced display issues. All options are now initialized upon plugin activation, which should fix this issue permanently.
197
+
198
+ - Fixed a glitch in our usage of the translate API. Previously, when the user clicked the default language, it would toggle back and forth between the default language and "Afrikaans" language. Now, users will see the correct language displayed at all times, no matter how many times it is clicked.
199
+
200
+ 2.6
201
+
202
+ - Added defaults to all options to ensure there are no more issues with the translator displaying upon installation. Again, sorry for any inconvenience.
203
+
204
+ 2.5
205
+
206
+ - Eliminated an internal Wordpress error being generated from a coding mistake.
207
+
208
+ - Added a default option for the Translator alingment. Previously, this was causing the plugin to disapppear.
209
+
210
+ 2.4
211
+
212
+ - Found a couple of small display errors in the settings page after uploading version 2.3. Sorry for any inconvenience!
213
+
214
+ 2.3
215
+
216
+ - Added a "Preview" area on the settings page that allows you to see your settings in action.
217
+
218
+ - Added custom flag support for all languages (custom flags available ONLY when selecting the "ALL Languages" setting.
219
+
220
+ - Added an option that allows left/right alignment of the translation tool.
221
+
222
+ - Added the "Google Language Translator" widget.
223
+
224
+ - Updated googlelanguagetranslator.php to properly register setting in the admin settings panel.
225
+
226
+ 2.2
227
+
228
+ - Added language "Portuguese" and "German" to the Original Language drop-down option on the settings page.
229
+
230
+ - Changed flag image for the English language (changed United States flag to the United Kingdom flag).
231
+
232
+ - Added link in the settings panel that points to Google's Attribution Policy.
233
+
234
+ 2.1
235
+
236
+ - Added language "Dutch" to the Original Language drop-down option on the settings page.
237
+
238
+ - Added a new CSS class that more accurately hides the "Powered by" text when hiding Google's branding. In previous version, the "Powered by" text was actually disguised by setting it's color to "transparent", but now we have set it's font-size to 0px instead.
239
+
240
+ 2.0 Corrected some immediate errors in the 1.9 update.
241
+
242
+ 1.9
243
+
244
+ - Added 7 flag image choices that, when clicked by website visitors, will change the language displayed, both on the website, AND in the drop-down box (flag language choices are limited to those provided in this plugin).
245
+
246
+ - Added 6 additional languages to the translator, as provided in Google's most recent updates ( new languages include Bosnian, Cebuano, Khmer, Marathi, Hmong, Javanese ).
247
+
248
+ - Corrected a minor technical issue where the Czech option (on the backend) was incorrectly displaying the Croatian language on the front end.
249
+
250
+ - Added jQuery functionality to the settings panel to improve the user experience.
251
+
252
+ - Added an option for users to display/hide the flag images.
253
+
254
+ - Added an option for users to display/hide the translate box when flags are displayed.
255
+
256
+ - Removed the settings.css file - I found a better way of displaying the options without CSS.
257
+
258
+ 1.8 Modified google-language-translator.php to display the correct output to the browser when horizontal layout is selected. Previously, it was not displaying at all.
259
+
260
+ 1.7 Modified google-language-translator.php so that jQuery and CSS styles were enqueued properly onto the settings page only. Previously, jQuery functionality and CSS styles were being added to all pages of the Wordpresss Dashboard, which was causing functionality and display issues for some users.
261
+
262
+ 1.6 Added "Specific Language" support to the plugin settings, which allows the user to choose specific languages that are displayed to website visitors.
263
+
264
+ 1.5 Added "Original Language" support to the plugin settings, which allows the user to choose the original language of their website, which ultimately removes the original language as a choice in the language drop-down presented to website visitors.
265
+
266
+ 1.4 Corrected display problems associated with CSS styles not being placed correctly in wp_head.
267
+
268
+ 1.3 HTML display problem in the sidebar area now fixed. Previously, inserting the [google-translator] plugin into a text widget caused it to display above the widget, instead of inside of it.
269
+
270
+ 1.2 Shortcode support is now available for adding [google-translator] to text widgets. I apologize for any inconvenience this may have caused.
271
+
272
+ 1.1 The shortcode supplied on the settings page was updated to display '[google-translator]'.
273
+
274
+ == Screenshots ==
275
+
276
+ 1. Settings include: inline or vertical layout, hide/show Google toolbar, display specific languages, and show/hide Google branding. Add the shortcode to pages, posts, and widgets.