Google Language Translator - Version 6.0.0

Version Description

  • Added SEO features (paid only): search engines can index translated pages, URL/slug translation, define hreflang tags
  • Added Live Chat support by GTranslate support team directly in the plugin settings page
  • Google Analytics feature is now on by default
  • Settings page updated for better user experience
Download this release

Release Info

Developer edo888
Plugin Icon wp plugin Google Language Translator
Version 6.0.0
Comparing to
See all releases

Code changes from version 5.0.49 to 6.0.0

banner-1544x500.png DELETED
Binary file
banner-772x250.png DELETED
Binary file
css/glt-notices.css ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .glt-admin-notice {
2
+ background: #fff;
3
+ border-color: #ED494D;
4
+ border-top: 4px;
5
+ display: block;
6
+ min-height: 68px;
7
+ padding: 10px 40px 10px 145px;
8
+ position: relative;
9
+ }
10
+ .glt-admin-notice a {
11
+ color: #ED494D;
12
+ text-decoration:none;
13
+ }
14
+ .glt-notice-logo {
15
+ clear: both;
16
+ content: "";
17
+ display: block;
18
+ background-image: url(../images/gt_logo.svg);
19
+ background-size: 125px auto;
20
+ background-repeat: no-repeat;
21
+ background-position: 0 45%;
22
+ width: 125px;
23
+ position: absolute;
24
+ top: 0;
25
+ bottom: 0;
26
+ left: 5px;
27
+ }
28
+ .glt-admin-notice > .dashicons {
29
+ color: #424242;
30
+ position: absolute;
31
+ right: 20px;
32
+ top: 40%;
33
+ }
34
+ .glt-notice-title {
35
+ font-size: 24px;
36
+ margin: 0;
37
+ }
38
+ .glt-notice-body {
39
+ font-weight: normal;
40
+ margin: 5px 0;
41
+ }
42
+ .glt-notice-body:after {
43
+ clear: both;
44
+ content: "";
45
+ display: block;
46
+ }
47
+ .glt-notice-body li {
48
+ float: left;
49
+ margin-right: 20px;
50
+ }
51
+ .glt-notice-body .dashicons {
52
+ font-size: 17px;
53
+ }
54
+ .glt-red {
55
+ color: #ED494D;
56
+ }
css/style.css CHANGED
@@ -42,21 +42,33 @@
42
  content:'\f115';
43
  }
44
 
45
- #glt-settings .glt-advanced-settings h3:before {
46
- content:'\f314';
 
 
 
 
 
 
 
 
47
  }
48
 
49
  #glt-settings .glt-css-settings h3:before {
50
  content:'\f119';
51
  }
52
 
 
 
53
  #glt-settings .glt-main-settings h3:before,
54
  #glt-settings .glt-layout-settings h3:before,
55
  #glt-settings .glt-behavior-settings h3:before,
56
  #glt-settings .glt-floating-widget-settings h3:before,
57
  #glt-settings .glt-usage-settings h3:before,
58
  #glt-settings .glt-preview-settings h3:before,
59
- #glt-settings .glt-advanced-settings h3:before,
 
 
60
  #glt-settings .glt-css-settings h3:before {
61
  margin-right: 5px;
62
  display: inline-block;
@@ -75,7 +87,7 @@
75
  -webkit-font-smoothing: antialiased;
76
  }
77
 
78
- #glt-settings .button,
79
  #glt-settings .button-primary {
80
  text-shadow: none;
81
  border-radius: 0;
@@ -89,31 +101,31 @@
89
  -moz-transition: .25s opacity ease-in-out;
90
  }
91
 
92
- #glt-settings .button {
93
- background: #95a5a6;
94
- border:1px solid #95a5a6;
95
- color:#fff;
96
- }
97
 
98
- #glt-settings .button-primary {
99
- background:#ea4335;
100
- border:1px solid #ea4335;
101
- }
102
 
103
- #glt-settings .button:hover {
104
- opacity:0.8;
105
- }
106
 
107
- #glt-settings .button-primary:hover {
108
- opacity:0.8;
109
- background:#ea4335;
110
- border:1px solid #ea4335;
111
  }
112
 
113
  .tool-container {
114
  bottom:50px !important;
115
  top:auto !important;
116
- z-index:9999 !important;
117
  }
118
 
119
  .tool-container .tool-items a {
@@ -135,17 +147,17 @@ a.wp-helpdesk-logo:focus {
135
  margin:4px 0;
136
  }
137
 
138
- #google_language_translator select.goog-te-combo {
139
  width:143px;
140
  background:#fff;
141
- box-shadow:none !important;
142
- -moz-box-shadow:none !important;
143
- -webkit-box-shadow:none !important;
144
- padding:3px !important;
145
- height:auto !important;
146
- border:1px solid lightgray !important;
147
- border-radius:0px !important;
148
- -webkit-border-radius:0px;
149
  -moz-border-radius:0px !important;
150
  -o-border-radius:0px !important;
151
  }
@@ -160,6 +172,7 @@ a.wp-helpdesk-logo:focus {
160
 
161
  #flags ul {
162
  margin:0;
 
163
  }
164
 
165
  #flags li {
@@ -249,7 +262,7 @@ a.single-language span.size16 {
249
  -o-box-sizing:content-box;
250
  -ms-box-sizing:content-box;
251
  }
252
-
253
  .tool-container .tool-items a {
254
  display:inline-block;
255
  margin:3px 5px 3px;
@@ -267,10 +280,10 @@ a.single-language span.size16 {
267
  vertical-align:middle;
268
  }
269
 
270
- select.goog-te-combo:focus {
271
- box-shadow:none !important;
272
- -moz-box-shadow:none !important;
273
- -webkit-box-shadow:none !important;
274
  }
275
 
276
  .metabox-holder {
@@ -279,25 +292,25 @@ select.goog-te-combo:focus {
279
  }
280
 
281
  .metabox-holder h2 {
282
- margin-bottom:18px;
283
  }
284
 
285
- .submit {
286
  padding:0px;
287
  }
288
 
289
  .form-table th {
290
- width:50%;
291
  }
292
 
293
- td.advanced {
294
  padding-top:0px;
295
  padding-bottom:0px;
296
  }
297
 
298
- p.hello {
299
- font-size:12px;
300
- color:darkgray;
301
  }
302
 
303
  .flag{
@@ -316,7 +329,7 @@ a.nturl {
316
  }
317
 
318
  .attribution {
319
- width:152px;
320
  line-height:1em;
321
  margin-top:4px;
322
  }
@@ -335,10 +348,10 @@ span.goog-branding {
335
  float: right;
336
  }
337
 
338
- .goog-logo-link,
339
- .goog-logo-link:link,
340
- .goog-logo-link:visited,
341
- .goog-logo-link:hover,
342
  .goog-logo-link:active {
343
  font-size: 12px;
344
  font-weight: bold;
@@ -351,12 +364,12 @@ span.goog-branding img {
351
  float: left;
352
  margin:0px;
353
  width: 37px;
354
-
355
  }
356
 
357
  span.vertical-translator {
358
- position:auto;
359
- float:none !important;
360
  font-size: 11px;
361
  font-family: arial;
362
  color: rgb(102, 102, 102);
@@ -380,7 +393,7 @@ span.vertical-translator {
380
  padding:0px !important;
381
  }
382
 
383
- .tool-container {
384
  line-height:1;
385
  }
386
 
42
  content:'\f115';
43
  }
44
 
45
+ #glt-settings .glt-flag-settings h3:before {
46
+ content:'\f227';
47
+ }
48
+
49
+ #glt-settings .glt-seo-settings h3:before {
50
+ content:'\f11e';
51
+ }
52
+
53
+ #glt-settings .glt-gtranslate-ad h3:before {
54
+ content:'\f326';
55
  }
56
 
57
  #glt-settings .glt-css-settings h3:before {
58
  content:'\f119';
59
  }
60
 
61
+ #glt-settings .glt-seo-settings {background-color: #FFC293;}
62
+
63
  #glt-settings .glt-main-settings h3:before,
64
  #glt-settings .glt-layout-settings h3:before,
65
  #glt-settings .glt-behavior-settings h3:before,
66
  #glt-settings .glt-floating-widget-settings h3:before,
67
  #glt-settings .glt-usage-settings h3:before,
68
  #glt-settings .glt-preview-settings h3:before,
69
+ #glt-settings .glt-flag-settings h3:before,
70
+ #glt-settings .glt-seo-settings h3:before,
71
+ #glt-settings .glt-gtranslate-ad h3:before,
72
  #glt-settings .glt-css-settings h3:before {
73
  margin-right: 5px;
74
  display: inline-block;
87
  -webkit-font-smoothing: antialiased;
88
  }
89
 
90
+ #glt-settings .button,
91
  #glt-settings .button-primary {
92
  text-shadow: none;
93
  border-radius: 0;
101
  -moz-transition: .25s opacity ease-in-out;
102
  }
103
 
104
+ #glt-settings .button {
105
+ background: #95a5a6;
106
+ border:1px solid #95a5a6;
107
+ color:#fff;
108
+ }
109
 
110
+ #glt-settings .button-primary {
111
+ background:#ea4335;
112
+ border:1px solid #ea4335;
113
+ }
114
 
115
+ #glt-settings .button:hover {
116
+ opacity:0.8;
117
+ }
118
 
119
+ #glt-settings .button-primary:hover {
120
+ opacity:0.8;
121
+ background:#ea4335;
122
+ border:1px solid #ea4335;
123
  }
124
 
125
  .tool-container {
126
  bottom:50px !important;
127
  top:auto !important;
128
+ z-index:99999999 !important;
129
  }
130
 
131
  .tool-container .tool-items a {
147
  margin:4px 0;
148
  }
149
 
150
+ #google_language_translator select.goog-te-combo {
151
  width:143px;
152
  background:#fff;
153
+ box-shadow:none !important;
154
+ -moz-box-shadow:none !important;
155
+ -webkit-box-shadow:none !important;
156
+ padding:3px !important;
157
+ height:auto !important;
158
+ border:1px solid lightgray !important;
159
+ border-radius:0px !important;
160
+ -webkit-border-radius:0px;
161
  -moz-border-radius:0px !important;
162
  -o-border-radius:0px !important;
163
  }
172
 
173
  #flags ul {
174
  margin:0;
175
+ padding:0;
176
  }
177
 
178
  #flags li {
262
  -o-box-sizing:content-box;
263
  -ms-box-sizing:content-box;
264
  }
265
+
266
  .tool-container .tool-items a {
267
  display:inline-block;
268
  margin:3px 5px 3px;
280
  vertical-align:middle;
281
  }
282
 
283
+ select.goog-te-combo:focus {
284
+ box-shadow:none !important;
285
+ -moz-box-shadow:none !important;
286
+ -webkit-box-shadow:none !important;
287
  }
288
 
289
  .metabox-holder {
292
  }
293
 
294
  .metabox-holder h2 {
295
+ margin-bottom:18px;
296
  }
297
 
298
+ .submit {
299
  padding:0px;
300
  }
301
 
302
  .form-table th {
303
+ width:50%;
304
  }
305
 
306
+ td.advanced {
307
  padding-top:0px;
308
  padding-bottom:0px;
309
  }
310
 
311
+ p.hello {
312
+ font-size:12px;
313
+ color:darkgray;
314
  }
315
 
316
  .flag{
329
  }
330
 
331
  .attribution {
332
+ width:152px;
333
  line-height:1em;
334
  margin-top:4px;
335
  }
348
  float: right;
349
  }
350
 
351
+ .goog-logo-link,
352
+ .goog-logo-link:link,
353
+ .goog-logo-link:visited,
354
+ .goog-logo-link:hover,
355
  .goog-logo-link:active {
356
  font-size: 12px;
357
  font-weight: bold;
364
  float: left;
365
  margin:0px;
366
  width: 37px;
367
+
368
  }
369
 
370
  span.vertical-translator {
371
+ position:auto;
372
+ float:none !important;
373
  font-size: 11px;
374
  font-family: arial;
375
  color: rgb(102, 102, 102);
393
  padding:0px !important;
394
  }
395
 
396
+ .tool-container {
397
  line-height:1;
398
  }
399
 
google-language-translator.php CHANGED
@@ -1,11 +1,12 @@
1
  <?php
2
  /*
3
  Plugin Name: Google Language Translator
4
- Plugin URI: https://gtranslate.io/?xyz=998
5
- Version: 5.0.49
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: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
 
9
  */
10
 
11
  //ini_set('display_errors', 1);
@@ -146,6 +147,22 @@ class google_language_translator {
146
  if (!is_admin()) {
147
  add_action('wp_enqueue_scripts',array(&$this, 'flags'));
148
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  }
150
 
151
  public function glt_activate() {
@@ -281,6 +298,8 @@ class google_language_translator {
281
  "label" => 'Espa&ntilde;ol'
282
  ), $atts));
283
 
 
 
284
  $default_language = get_option('googlelanguagetranslator_language');
285
  $english_flag_choice = get_option('googlelanguagetranslator_english_flag_choice');
286
  $spanish_flag_choice = get_option('googlelanguagetranslator_spanish_flag_choice');
@@ -302,7 +321,23 @@ class google_language_translator {
302
  $language_name_flag = 'brazil';
303
  }
304
 
305
- return "<a class='nturl notranslate ".$language_code." ".$language_name_flag." single-language flag' title='".$language."'>".($image=='yes' ? "<span class='flag size".$image_size."'></span>" : '') .($text=='yes' ? $label : '')."</a>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  }
307
 
308
  public function footer_script() {
@@ -327,6 +362,8 @@ class google_language_translator {
327
  $floating_widget_text_translation_allowed = get_option ('googlelanguagetranslator_floating_widget_text_allow_translation');
328
  $is_active = get_option ( 'googlelanguagetranslator_active' );
329
  $is_multilanguage = get_option('googlelanguagetranslator_multilanguage');
 
 
330
  $str = '';
331
 
332
  if( $is_active == 1) {
@@ -357,8 +394,25 @@ class google_language_translator {
357
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
358
  $language_name_flag = 'brazil';
359
  }
360
- $str.='<li id="'.$language_name.'"><a title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a>';
361
- } //empty
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  }//foreach
363
  } else {
364
  if ($new_languages_array_count != count($get_language_choices)):
@@ -379,7 +433,24 @@ class google_language_translator {
379
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
380
  $language_name_flag = 'brazil';
381
  }
382
- $str.='<li id="'.$language_name.'"><a title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  } //foreach
384
  else:
385
  foreach ($new_languages_array_codes as $value) {
@@ -399,7 +470,24 @@ class google_language_translator {
399
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
400
  $language_name_flag = 'brazil';
401
  }
402
- $str.='<li id="'.$language_name.'"><a title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
403
  }//foreach
404
  endif;
405
  }//endif
@@ -419,10 +507,12 @@ class google_language_translator {
419
 
420
  if ($is_multilanguage == 1):
421
  $multilanguagePage = ', multilanguagePage:true';
422
- $str.="<div id='glt-footer'>".(!isset($vertical) && !isset($horizontal) ? '<div id="google_language_translator" class="default-language-'.$default_language.'"></div>' : '')."</div><script>function GoogleLanguageTranslatorInit() { new google.translate.TranslateElement({pageLanguage: '".$default_language."'".$language_choices . ($layout=='Horizontal' ? $horizontal_layout : ($layout=='SIMPLE' ? $simple_layout : '')) . $auto_display . $multilanguagePage . $this->analytics()."}, 'google_language_translator');}</script>";
 
423
  echo $str;
424
  elseif ($is_multilanguage == 0):
425
- $str.="<div id='glt-footer'>".(!isset($vertical) && !isset($horizontal) ? '<div id="google_language_translator" class="default-language-'.$default_language.'"></div>' : '')."</div><script>function GoogleLanguageTranslatorInit() { new google.translate.TranslateElement({pageLanguage: '".$default_language."'".$language_choices . ($layout=='Horizontal' ? $horizontal_layout : ($layout=='SIMPLE' ? $simple_layout : '')) . $auto_display . $this->analytics()."}, 'google_language_translator');}</script>";
 
426
  echo $str;
427
  endif; //is_multilanguage
428
  }
@@ -446,6 +536,10 @@ class google_language_translator {
446
  $is_active = get_option ( 'googlelanguagetranslator_active' );
447
  $language_choices = $this->googlelanguagetranslator_included_languages();
448
  $floating_widget = get_option ('googlelanguagetranslator_floating_widget');
 
 
 
 
449
  $str = '';
450
 
451
  if ($is_active==1):
@@ -472,7 +566,24 @@ class google_language_translator {
472
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
473
  $language_name_flag = 'brazil';
474
  }
475
- $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code." ".$language_name_flag."'></a></li>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
476
  } //endif
477
  }//foreach
478
  else:
@@ -495,7 +606,23 @@ class google_language_translator {
495
  $language_name_flag = 'brazil';
496
  }
497
 
498
- $str.='<li id="'.$language_name.'"><a title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  } //foreach
500
  else:
501
  foreach ($new_languages_array_codes as $value) {
@@ -515,7 +642,24 @@ class google_language_translator {
515
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
516
  $language_name_flag = 'brazil';
517
  }
518
- $str.='<li id="'.$language_name.'"><a title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  }//foreach
520
  endif;
521
  endif;
@@ -525,7 +669,29 @@ class google_language_translator {
525
 
526
  endif; //show_flags
527
 
528
- $str.='<div id="google_language_translator" class="default-language-'.$default_language_code.'"></div>'; return $str;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
 
530
  endif;
531
  } // End glt_vertical
@@ -549,6 +715,10 @@ class google_language_translator {
549
  $is_active = get_option ( 'googlelanguagetranslator_active' );
550
  $language_choices = $this->googlelanguagetranslator_included_languages();
551
  $floating_widget = get_option ('googlelanguagetranslator_floating_widget');
 
 
 
 
552
  $str = '';
553
 
554
  if ($is_active==1):
@@ -575,7 +745,24 @@ class google_language_translator {
575
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
576
  $language_name_flag = 'brazil';
577
  }
578
- $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code." ".$language_name_flag."'></a></li>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
579
  } //endif
580
  }//foreach
581
  else:
@@ -597,7 +784,24 @@ class google_language_translator {
597
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
598
  $language_name_flag = 'brazil';
599
  }
600
- $str.='<li id="'.$language_name.'"><a title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601
  } //foreach
602
  else:
603
  foreach ($new_languages_array_codes as $value) {
@@ -617,7 +821,24 @@ class google_language_translator {
617
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
618
  $language_name_flag = 'brazil';
619
  }
620
- $str.='<li id="'.$language_name.'"><a title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
621
  }//foreach
622
  endif;
623
  endif;
@@ -626,7 +847,28 @@ class google_language_translator {
626
 
627
  endif; //show_flags
628
 
629
- $str.='<div id="google_language_translator" class="default-language-'.$default_language_code.'"></div>'; return $str;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
630
 
631
  endif;
632
  } // End glt_horizontal
@@ -634,7 +876,39 @@ class google_language_translator {
634
  public function initialize_settings() {
635
  add_settings_section('glt_settings','Settings','','google_language_translator');
636
 
637
- $settings_name_array = array ('googlelanguagetranslator_active','googlelanguagetranslator_language','language_display_settings','googlelanguagetranslator_flags','googlelanguagetranslator_translatebox','googlelanguagetranslator_display','glt_language_switcher_width','glt_language_switcher_text_color','glt_language_switcher_bg_color','googlelanguagetranslator_toolbar','googlelanguagetranslator_showbranding','googlelanguagetranslator_flags_alignment','googlelanguagetranslator_analytics','googlelanguagetranslator_analytics_id','googlelanguagetranslator_css','googlelanguagetranslator_multilanguage','googlelanguagetranslator_floating_widget','googlelanguagetranslator_flag_size','googlelanguagetranslator_flags_order','googlelanguagetranslator_english_flag_choice','googlelanguagetranslator_spanish_flag_choice','googlelanguagetranslator_portuguese_flag_choice','googlelanguagetranslator_floating_widget_text','glt_floating_widget_text_color','googlelanguagetranslator_floating_widget_text_allow_translation','glt_floating_widget_position','glt_floating_widget_bg_color');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
638
 
639
  foreach ($settings_name_array as $setting) {
640
  add_settings_field( $setting,'',$setting.'_cb','google_language_translator','glt_settings');
@@ -1006,8 +1280,8 @@ $('.languages').find('input:checkbox').prop('checked', false); }); }); </script>
1006
 
1007
  $options = get_option (''.$option_name.''); ?>
1008
 
1009
- <input type="radio" name="googlelanguagetranslator_flags_alignment" id="flags_left" value="flags_left" <?php if($options=='flags_left'){echo "checked";}?>/> Align Left<br/>
1010
- <input type="radio" name="googlelanguagetranslator_flags_alignment" id="flags_right" value="flags_right" <?php if($options=='flags_right'){echo "checked";}?>/> Align Right
1011
  <?php }
1012
 
1013
  public function googlelanguagetranslator_analytics_cb() {
@@ -1140,6 +1414,65 @@ $('.languages').find('input:checkbox').prop('checked', false); }); }); </script>
1140
  <?php
1141
  }
1142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1143
  public function googlelanguagetranslator_css_cb() {
1144
 
1145
  $option_name = 'googlelanguagetranslator_css' ;
@@ -1153,7 +1486,7 @@ $('.languages').find('input:checkbox').prop('checked', false); }); }); </script>
1153
 
1154
  $options = get_option (''.$option_name.'');
1155
 
1156
- $html = '<textarea style="width:100%; height:200px" name="googlelanguagetranslator_css" id="googlelanguagetranslator_css">'.$options.'</textarea>';
1157
  echo $html;
1158
  }
1159
 
@@ -1222,22 +1555,49 @@ $('.languages').find('input:checkbox').prop('checked', false); }); }); </script>
1222
  </table>
1223
  </div> <!-- .postbox -->
1224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1225
  <div class="postbox glt-layout-settings" style="width: 100%">
1226
  <h3 class="notranslate">Language Switcher Settings</h3>
1227
  <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
1228
 
1229
  <tr class="notranslate">
1230
- <td class="choose_flags_intro">Language switcher width: <strong style="color:red">NEW!</strong></td>
1231
  <td class="choose_flags_intro"><?php $this->glt_language_switcher_width_cb(); ?></td>
1232
  </tr>
1233
 
1234
  <tr class="notranslate">
1235
- <td class="choose_flags_intro">Language switcher text color: <strong style="color:red">NEW!</strong></td>
1236
  <td class="choose_flags_intro"><?php $this->glt_language_switcher_text_color_cb(); ?></td>
1237
  </tr>
1238
 
1239
  <tr class="notranslate">
1240
- <td class="choose_flags_intro">Language switcher background color: <strong style="color:red">NEW!</strong></td>
1241
  <td class="choose_flags_intro"><?php $this->glt_language_switcher_bg_color_cb(); ?></td>
1242
  </tr>
1243
 
@@ -1292,23 +1652,23 @@ $('.languages').find('input:checkbox').prop('checked', false); }); }); </script>
1292
  </tr>
1293
 
1294
  <tr class="floating-widget floating-widget-position notranslate hidden">
1295
- <td>Floating Widget Position: <strong style="color:red">NEW!</strong></td>
1296
  <td><?php $this->glt_floating_widget_position_cb(); ?></td>
1297
  </tr>
1298
 
1299
  <tr class="floating-widget floating-widget-text-color notranslate hidden">
1300
- <td>Floating Widget Text Color: <strong style="color:red">NEW!</strong></td>
1301
  <td><?php $this->glt_floating_widget_text_color_cb(); ?></td>
1302
  </tr>
1303
 
1304
  <tr class="floating-widget floating-widget-color notranslate hidden">
1305
- <td>Floating Widget Background Color <strong style="color:red">NEW!</strong></td>
1306
  <td><?php $this->glt_floating_widget_bg_color_cb(); ?></td>
1307
  </tr>
1308
  </table>
1309
  </div> <!-- .postbox -->
1310
 
1311
- <div class="postbox glt-behavior-settings" style="width: 100%">
1312
  <h3 class="notranslate">Behavior Settings</h3>
1313
  <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
1314
  <tr class="multilanguage notranslate">
@@ -1366,21 +1726,21 @@ $('.languages').find('input:checkbox').prop('checked', false); }); }); </script>
1366
  </div> <!-- .single-language-shortcode-description -->
1367
  </td>
1368
  </tr>
1369
-
1370
- <tr class="notranslate">
1371
- <td colspan="2">
1372
- <?php
1373
- if (isset($_POST['submit'])) {
1374
- if (empty($_POST['submit']) && !check_admin_referer( 'glt-save-settings', 'glt-save-settings-nonce' )) {
1375
- wp_die();
1376
- }
1377
- }
1378
- wp_nonce_field('glt-save-settings, glt-save-settings-nonce', false);
1379
- submit_button(); ?>
1380
- </td>
1381
- </tr>
1382
  </table>
1383
  </div> <!-- .postbox -->
 
 
 
 
 
 
 
 
 
 
 
 
 
1384
  </div> <!-- .metbox-holder -->
1385
 
1386
  <div class="metabox-holder" style="float:right; clear:right; width:33%">
@@ -1396,8 +1756,8 @@ $('.languages').find('input:checkbox').prop('checked', false); }); }); </script>
1396
  </div> <!-- .metabox-holder -->
1397
 
1398
  <div class="metabox-holder box-right notranslate" style="float: right; width: 33%; clear:right">
1399
- <div class="postbox glt-advanced-settings">
1400
- <h3>Advanced Settings</h3>
1401
  <div class="inside">
1402
  <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
1403
  <tr class="notranslate">
@@ -1424,6 +1784,32 @@ $('.languages').find('input:checkbox').prop('checked', false); }); }); </script>
1424
  </div> <!-- .postbox -->
1425
  </div> <!-- .metabox-holder -->
1426
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1427
 
1428
  <div class="metabox-holder box-right notranslate" style="float: right; width: 33%;">
1429
  <div class="postbox glt-css-settings">
@@ -1436,34 +1822,719 @@ $('.languages').find('input:checkbox').prop('checked', false); }); }); </script>
1436
  </div> <!-- .metabox-holder -->
1437
  <?php $this->googlelanguagetranslator_flags_order_cb(); ?>
1438
  </form>
1439
-
1440
- <div class="metabox-holder box-right notranslate" style="float: right; width: 33%;">
1441
- <div class="postbox">
1442
- <h3>Enable SEO features with GTranslate</h3>
1443
- <div class="inside">
1444
- <a class="wp-studio-logo" href="https://gtranslate.io/?xyz=3167#pricing" target="_blank"><img style="width:177px;" src="<?php echo plugins_url( 'images/gt_logo.svg' , __FILE__ ); ?>"></a><br />
1445
- <ul id="features" style="margin-left:15px">
1446
- <li style="list-style:square outside"><?php _e('Search engine indexing', 'gtranslate'); ?></li>
1447
- <li style="list-style:square outside"><?php _e('Search engine friendly (SEF) URLs', 'gtranslate'); ?></li>
1448
- <li style="list-style:square outside"><?php _e('Human level neural translations', 'gtranslate'); ?></li>
1449
- <li style="list-style:square outside"><?php _e('Edit translations manually', 'gtranslate'); ?></li>
1450
- <li style="list-style:square outside"><?php _e('Meta data translation (keywords, page description, etc...)', 'gtranslate'); ?></li>
1451
- <li style="list-style:square outside"><?php _e('URL/slug translation', 'gtranslate'); ?></li>
1452
- <li style="list-style:square outside"><?php _e('Language hosting (custom domain like example.fr, example.es)', 'gtranslate'); ?></li>
1453
- <li style="list-style:square outside"><?php _e('Seamless updates', 'gtranslate'); ?></li>
1454
- <li style="list-style:square outside"><?php _e('Increased international traffic and AdSense revenue', 'gtranslate'); ?></li>
1455
- <li style="list-style:square outside"><?php _e('Works in China', 'gtranslate'); ?></li>
1456
- <li style="list-style:square outside"><?php _e('Priority Live Chat support', 'gtranslate'); ?></li>
1457
- </ul>
1458
-
1459
- <p><?php _e('Prices starting from <b>$5.99/month</b>!', 'gtranslate'); ?></p>
1460
-
1461
- <a href="https://gtranslate.io/?xyz=3167#pricing" target="_blank" class="button-primary"><?php _e('Try Now (15 days free)', 'gtranslate'); ?></a> <a href="https://gtranslate.io/?xyz=3167#faq" target="_blank" class="button-primary"><?php _e('FAQ', 'gtranslate'); ?></a> <a href="https://gtranslate.io/?xyz=3167#contact" target="_blank" class="button-primary"><?php _e('Live Chat', 'gtranslate'); ?></a>
1462
- </div> <!-- .inside -->
1463
- </div> <!-- .postbox -->
1464
- </div> <!-- .metabox-holder -->
1465
  </div> <!-- .wrap -->
 
 
 
 
 
 
 
 
 
 
 
 
 
1466
  <?php
1467
  }
1468
  }
1469
- $google_language_translator = new google_language_translator();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /*
3
  Plugin Name: Google Language Translator
4
+ Plugin URI: https://gtranslate.io/?xyz=3167
5
+ Version: 6.0.0
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: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
9
+ Text Domain: glt
10
  */
11
 
12
  //ini_set('display_errors', 1);
147
  if (!is_admin()) {
148
  add_action('wp_enqueue_scripts',array(&$this, 'flags'));
149
  }
150
+
151
+ // make sure main_lang is set correctly in config.php file
152
+ global $glt_url_structure, $glt_seo_active;
153
+ if($glt_seo_active == '1' and $glt_url_structure == 'sub_directory') {
154
+ include dirname(__FILE__) . '/url_addon/config.php';
155
+
156
+ $default_language = get_option('googlelanguagetranslator_language');
157
+ if($main_lang != $default_language) { // update main_lang in config.php
158
+ $config_file = dirname(__FILE__) . '/url_addon/config.php';
159
+ if(is_writable($config_file)) {
160
+ $config = file_get_contents($config_file);
161
+ $config = preg_replace('/\$main_lang = \'[a-z-]{2,5}\'/i', '$main_lang = \''.$default_language.'\'', $config);
162
+ file_put_contents($config_file, $config);
163
+ }
164
+ }
165
+ }
166
  }
167
 
168
  public function glt_activate() {
298
  "label" => 'Espa&ntilde;ol'
299
  ), $atts));
300
 
301
+ $glt_url_structure = get_option('googlelanguagetranslator_url_structure');
302
+ $glt_seo_active = get_option('googlelanguagetranslator_seo_active');
303
  $default_language = get_option('googlelanguagetranslator_language');
304
  $english_flag_choice = get_option('googlelanguagetranslator_english_flag_choice');
305
  $spanish_flag_choice = get_option('googlelanguagetranslator_spanish_flag_choice');
321
  $language_name_flag = 'brazil';
322
  }
323
 
324
+ $href = '#';
325
+ if($glt_seo_active == '1') {
326
+ $current_url = network_home_url(add_query_arg(null, null));
327
+ switch($glt_url_structure) {
328
+ case 'sub_directory':
329
+ $href = ($language_code == $default_language) ? $current_url : '/' . $language_code . $_SERVER['REQUEST_URI'];
330
+ break;
331
+ case 'sub_domain':
332
+ $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
333
+ $href = ($language_code == $default_language) ? $current_url : str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $language_code . '.' . $domain, $current_url);
334
+ break;
335
+ default:
336
+ break;
337
+ }
338
+ }
339
+
340
+ return "<a href='".$href."' class='nturl notranslate ".$language_code." ".$language_name_flag." single-language flag' title='".$language."'>".($image=='yes' ? "<span class='flag size".$image_size."'></span>" : '') .($text=='yes' ? $label : '')."</a>";
341
  }
342
 
343
  public function footer_script() {
362
  $floating_widget_text_translation_allowed = get_option ('googlelanguagetranslator_floating_widget_text_allow_translation');
363
  $is_active = get_option ( 'googlelanguagetranslator_active' );
364
  $is_multilanguage = get_option('googlelanguagetranslator_multilanguage');
365
+ $glt_url_structure = get_option('googlelanguagetranslator_url_structure');
366
+ $glt_seo_active = get_option('googlelanguagetranslator_seo_active');
367
  $str = '';
368
 
369
  if( $is_active == 1) {
394
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
395
  $language_name_flag = 'brazil';
396
  }
397
+
398
+ $href = '#';
399
+ if($glt_seo_active == '1') {
400
+ $current_url = network_home_url(add_query_arg(null, null));
401
+ switch($glt_url_structure) {
402
+ case 'sub_directory':
403
+ $href = ($language_code == $default_language) ? $current_url : '/' . $language_code . $_SERVER['REQUEST_URI'];
404
+ break;
405
+ case 'sub_domain':
406
+ $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
407
+ $href = ($language_code == $default_language) ? $current_url : str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $language_code . '.' . $domain, $current_url);
408
+ break;
409
+ default:
410
+ break;
411
+ }
412
+ }
413
+
414
+ $str .= '<li id="'.$language_name.'"><a href="'.$href.'" title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a></li>';
415
+ } //empty
416
  }//foreach
417
  } else {
418
  if ($new_languages_array_count != count($get_language_choices)):
433
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
434
  $language_name_flag = 'brazil';
435
  }
436
+
437
+ $href = '#';
438
+ if($glt_seo_active == '1') {
439
+ $current_url = network_home_url(add_query_arg(null, null));
440
+ switch($glt_url_structure) {
441
+ case 'sub_directory':
442
+ $href = ($language_code == $default_language) ? $current_url : '/' . $language_code . $_SERVER['REQUEST_URI'];
443
+ break;
444
+ case 'sub_domain':
445
+ $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
446
+ $href = ($language_code == $default_language) ? $current_url : str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $language_code . '.' . $domain, $current_url);
447
+ break;
448
+ default:
449
+ break;
450
+ }
451
+ }
452
+
453
+ $str.='<li id="'.$language_name.'"><a href="'.$href.'" title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a></li>';
454
  } //foreach
455
  else:
456
  foreach ($new_languages_array_codes as $value) {
470
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
471
  $language_name_flag = 'brazil';
472
  }
473
+
474
+ $href = '#';
475
+ if($glt_seo_active == '1') {
476
+ $current_url = network_home_url(add_query_arg(null, null));
477
+ switch($glt_url_structure) {
478
+ case 'sub_directory':
479
+ $href = ($language_code == $default_language) ? $current_url : '/' . $language_code . $_SERVER['REQUEST_URI'];
480
+ break;
481
+ case 'sub_domain':
482
+ $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
483
+ $href = ($language_code == $default_language) ? $current_url : str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $language_code . '.' . $domain, $current_url);
484
+ break;
485
+ default:
486
+ break;
487
+ }
488
+ }
489
+
490
+ $str.='<li id="'.$language_name.'"><a href="'.$href.'" title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a></li>';
491
  }//foreach
492
  endif;
493
  }//endif
507
 
508
  if ($is_multilanguage == 1):
509
  $multilanguagePage = ', multilanguagePage:true';
510
+ if($glt_seo_active != '1')
511
+ $str.="<div id='glt-footer'>".(!isset($vertical) && !isset($horizontal) ? '<div id="google_language_translator" class="default-language-'.$default_language.'"></div>' : '')."</div><script>function GoogleLanguageTranslatorInit() { new google.translate.TranslateElement({pageLanguage: '".$default_language."'".$language_choices . ($layout=='Horizontal' ? $horizontal_layout : ($layout=='SIMPLE' ? $simple_layout : '')) . $auto_display . $multilanguagePage . $this->analytics()."}, 'google_language_translator');}</script>";
512
  echo $str;
513
  elseif ($is_multilanguage == 0):
514
+ if($glt_seo_active != '1')
515
+ $str.="<div id='glt-footer'>".(!isset($vertical) && !isset($horizontal) ? '<div id="google_language_translator" class="default-language-'.$default_language.'"></div>' : '')."</div><script>function GoogleLanguageTranslatorInit() { new google.translate.TranslateElement({pageLanguage: '".$default_language."'".$language_choices . ($layout=='Horizontal' ? $horizontal_layout : ($layout=='SIMPLE' ? $simple_layout : '')) . $auto_display . $this->analytics()."}, 'google_language_translator');}</script>";
516
  echo $str;
517
  endif; //is_multilanguage
518
  }
536
  $is_active = get_option ( 'googlelanguagetranslator_active' );
537
  $language_choices = $this->googlelanguagetranslator_included_languages();
538
  $floating_widget = get_option ('googlelanguagetranslator_floating_widget');
539
+ $glt_url_structure = get_option('googlelanguagetranslator_url_structure');
540
+ $glt_seo_active = get_option('googlelanguagetranslator_seo_active');
541
+
542
+ $default_language = $default_language_code;
543
  $str = '';
544
 
545
  if ($is_active==1):
566
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
567
  $language_name_flag = 'brazil';
568
  }
569
+
570
+ $href = '#';
571
+ if($glt_seo_active == '1') {
572
+ $current_url = network_home_url(add_query_arg(null, null));
573
+ switch($glt_url_structure) {
574
+ case 'sub_directory':
575
+ $href = ($language_code == $default_language) ? $current_url : '/' . $language_code . $_SERVER['REQUEST_URI'];
576
+ break;
577
+ case 'sub_domain':
578
+ $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
579
+ $href = ($language_code == $default_language) ? $current_url : str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $language_code . '.' . $domain, $current_url);
580
+ break;
581
+ default:
582
+ break;
583
+ }
584
+ }
585
+
586
+ $str.="<li id='".$language_name."'><a href='".$href."' title='".$language_name."' class='nturl notranslate flag ".$language_code." ".$language_name_flag."'></a></li>";
587
  } //endif
588
  }//foreach
589
  else:
606
  $language_name_flag = 'brazil';
607
  }
608
 
609
+ $href = '#';
610
+ if($glt_seo_active == '1') {
611
+ $current_url = network_home_url(add_query_arg(null, null));
612
+ switch($glt_url_structure) {
613
+ case 'sub_directory':
614
+ $href = ($language_code == $default_language) ? $current_url : '/' . $language_code . $_SERVER['REQUEST_URI'];
615
+ break;
616
+ case 'sub_domain':
617
+ $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
618
+ $href = ($language_code == $default_language) ? $current_url : str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $language_code . '.' . $domain, $current_url);
619
+ break;
620
+ default:
621
+ break;
622
+ }
623
+ }
624
+
625
+ $str.='<li id="'.$language_name.'"><a href="'.$href.'" title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a></li>';
626
  } //foreach
627
  else:
628
  foreach ($new_languages_array_codes as $value) {
642
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
643
  $language_name_flag = 'brazil';
644
  }
645
+
646
+ $href = '#';
647
+ if($glt_seo_active == '1') {
648
+ $current_url = network_home_url(add_query_arg(null, null));
649
+ switch($glt_url_structure) {
650
+ case 'sub_directory':
651
+ $href = ($language_code == $default_language) ? $current_url : '/' . $language_code . $_SERVER['REQUEST_URI'];
652
+ break;
653
+ case 'sub_domain':
654
+ $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
655
+ $href = ($language_code == $default_language) ? $current_url : str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $language_code . '.' . $domain, $current_url);
656
+ break;
657
+ default:
658
+ break;
659
+ }
660
+ }
661
+
662
+ $str.='<li id="'.$language_name.'"><a href="'.$href.'" title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a></li>';
663
  }//foreach
664
  endif;
665
  endif;
669
 
670
  endif; //show_flags
671
 
672
+ if($glt_seo_active == '1') {
673
+ $str .= '<div id="google_language_translator" class="default-language-'.$default_language_code.'">';
674
+ $str .= '<select aria-label="Website Language Selector" class="notranslate"><option value="">Select Language</option>';
675
+
676
+ $get_language_choices = get_option ('language_display_settings');
677
+ foreach($get_language_choices as $key => $value) {
678
+ if($value == 1)
679
+ $str .= '<option value="'.$default_language.'|'.$key.'">'.$this->languages_array[$key].'</option>';
680
+ }
681
+ $str .= '</select></div>';
682
+
683
+ $str .= '<script>';
684
+ if($glt_url_structure == 'sub_directory') {
685
+ $str .= "function doGLTTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof _gaq!='undefined'){_gaq.push(['_trackEvent', 'GTranslate', lang, location.pathname+location.search]);}else {if(typeof ga!='undefined')ga('send', 'event', 'GTranslate', lang, location.pathname+location.search);}var plang=location.pathname.split('/')[1];if(plang.length !=2 && plang != 'zh-CN' && plang != 'zh-TW' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='$default_language';if(lang == '$default_language')location.href=location.protocol+'//'+location.host+glt_request_uri;else location.href=location.protocol+'//'+location.host+'/'+lang+glt_request_uri;}";
686
+ } elseif($glt_url_structure == 'sub_domain') {
687
+ $str .= "function doGLTTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof _gaq!='undefined'){_gaq.push(['_trackEvent', 'GTranslate', lang, location.hostname+location.pathname+location.search]);}else {if(typeof ga!='undefined')ga('send', 'event', 'GTranslate', lang, location.hostname+location.pathname+location.search);}var plang=location.hostname.split('.')[0];if(plang.length !=2 && plang.toLowerCase() != 'zh-cn' && plang.toLowerCase() != 'zh-tw' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='$default_language';location.href=location.protocol+'//'+(lang == '$default_language' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '[.]'), '')+glt_request_uri;}";
688
+ }
689
+ $str .= '</script>';
690
+
691
+ } else
692
+ $str.='<div id="google_language_translator" class="default-language-'.$default_language_code.'"></div>';
693
+
694
+ return $str;
695
 
696
  endif;
697
  } // End glt_vertical
715
  $is_active = get_option ( 'googlelanguagetranslator_active' );
716
  $language_choices = $this->googlelanguagetranslator_included_languages();
717
  $floating_widget = get_option ('googlelanguagetranslator_floating_widget');
718
+ $glt_url_structure = get_option('googlelanguagetranslator_url_structure');
719
+ $glt_seo_active = get_option('googlelanguagetranslator_seo_active');
720
+
721
+ $default_language = $default_language_code;
722
  $str = '';
723
 
724
  if ($is_active==1):
745
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
746
  $language_name_flag = 'brazil';
747
  }
748
+
749
+ $href = '#';
750
+ if($glt_seo_active == '1') {
751
+ $current_url = network_home_url(add_query_arg(null, null));
752
+ switch($glt_url_structure) {
753
+ case 'sub_directory':
754
+ $href = ($language_code == $default_language) ? $current_url : '/' . $language_code . $_SERVER['REQUEST_URI'];
755
+ break;
756
+ case 'sub_domain':
757
+ $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
758
+ $href = ($language_code == $default_language) ? $current_url : str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $language_code . '.' . $domain, $current_url);
759
+ break;
760
+ default:
761
+ break;
762
+ }
763
+ }
764
+
765
+ $str.="<li id='".$language_name."'><a href='".$href."' title='".$language_name."' class='nturl notranslate flag ".$language_code." ".$language_name_flag."'></a></li>";
766
  } //endif
767
  }//foreach
768
  else:
784
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
785
  $language_name_flag = 'brazil';
786
  }
787
+
788
+ $href = '#';
789
+ if($glt_seo_active == '1') {
790
+ $current_url = network_home_url(add_query_arg(null, null));
791
+ switch($glt_url_structure) {
792
+ case 'sub_directory':
793
+ $href = ($language_code == $default_language) ? $current_url : '/' . $language_code . $_SERVER['REQUEST_URI'];
794
+ break;
795
+ case 'sub_domain':
796
+ $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
797
+ $href = ($language_code == $default_language) ? $current_url : str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $language_code . '.' . $domain, $current_url);
798
+ break;
799
+ default:
800
+ break;
801
+ }
802
+ }
803
+
804
+ $str.='<li id="'.$language_name.'"><a href="'.$href.'" title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a>';
805
  } //foreach
806
  else:
807
  foreach ($new_languages_array_codes as $value) {
821
  if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') {
822
  $language_name_flag = 'brazil';
823
  }
824
+
825
+ $href = '#';
826
+ if($glt_seo_active == '1') {
827
+ $current_url = network_home_url(add_query_arg(null, null));
828
+ switch($glt_url_structure) {
829
+ case 'sub_directory':
830
+ $href = ($language_code == $default_language) ? $current_url : '/' . $language_code . $_SERVER['REQUEST_URI'];
831
+ break;
832
+ case 'sub_domain':
833
+ $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
834
+ $href = ($language_code == $default_language) ? $current_url : str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $language_code . '.' . $domain, $current_url);
835
+ break;
836
+ default:
837
+ break;
838
+ }
839
+ }
840
+
841
+ $str.='<li id="'.$language_name.'"><a href="'.$href.'" title="'.$language_name.'" class="nturl notranslate '.$language_code.' flag '.$language_name_flag.'"></a>';
842
  }//foreach
843
  endif;
844
  endif;
847
 
848
  endif; //show_flags
849
 
850
+ if($glt_seo_active == '1') {
851
+ $str .= '<div id="google_language_translator" class="default-language-'.$default_language_code.'">';
852
+ $str .= '<select aria-label="Website Language Selector" class="notranslate"><option value="">Select Language</option>';
853
+
854
+ $get_language_choices = get_option ('language_display_settings');
855
+ foreach($get_language_choices as $key => $value) {
856
+ if($value == 1)
857
+ $str .= '<option value="'.$default_language.'|'.$key.'">'.$this->languages_array[$key].'</option>';
858
+ }
859
+ $str .= '</select></div>';
860
+
861
+ $str .= '<script>';
862
+ if($glt_url_structure == 'sub_directory') {
863
+ $str .= "function doGLTTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof _gaq!='undefined'){_gaq.push(['_trackEvent', 'GTranslate', lang, location.pathname+location.search]);}else {if(typeof ga!='undefined')ga('send', 'event', 'GTranslate', lang, location.pathname+location.search);}var plang=location.pathname.split('/')[1];if(plang.length !=2 && plang != 'zh-CN' && plang != 'zh-TW' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='$default_language';if(lang == '$default_language')location.href=location.protocol+'//'+location.host+glt_request_uri;else location.href=location.protocol+'//'+location.host+'/'+lang+glt_request_uri;}";
864
+ } elseif($glt_url_structure == 'sub_domain') {
865
+ $str .= "function doGLTTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof _gaq!='undefined'){_gaq.push(['_trackEvent', 'GTranslate', lang, location.hostname+location.pathname+location.search]);}else {if(typeof ga!='undefined')ga('send', 'event', 'GTranslate', lang, location.hostname+location.pathname+location.search);}var plang=location.hostname.split('.')[0];if(plang.length !=2 && plang.toLowerCase() != 'zh-cn' && plang.toLowerCase() != 'zh-tw' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='$default_language';location.href=location.protocol+'//'+(lang == '$default_language' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '[.]'), '')+glt_request_uri;}";
866
+ }
867
+ $str .= '</script>';
868
+ } else
869
+ $str.='<div id="google_language_translator" class="default-language-'.$default_language_code.'"></div>';
870
+
871
+ return $str;
872
 
873
  endif;
874
  } // End glt_horizontal
876
  public function initialize_settings() {
877
  add_settings_section('glt_settings','Settings','','google_language_translator');
878
 
879
+ $settings_name_array = array (
880
+ 'googlelanguagetranslator_active',
881
+ 'googlelanguagetranslator_language',
882
+ 'language_display_settings',
883
+ 'googlelanguagetranslator_flags',
884
+ 'googlelanguagetranslator_translatebox',
885
+ 'googlelanguagetranslator_display',
886
+ 'glt_language_switcher_width',
887
+ 'glt_language_switcher_text_color',
888
+ 'glt_language_switcher_bg_color',
889
+ 'googlelanguagetranslator_toolbar',
890
+ 'googlelanguagetranslator_showbranding',
891
+ 'googlelanguagetranslator_flags_alignment',
892
+ 'googlelanguagetranslator_analytics',
893
+ 'googlelanguagetranslator_analytics_id',
894
+ 'googlelanguagetranslator_css',
895
+ 'googlelanguagetranslator_multilanguage',
896
+ 'googlelanguagetranslator_floating_widget',
897
+ 'googlelanguagetranslator_flag_size',
898
+ 'googlelanguagetranslator_flags_order',
899
+ 'googlelanguagetranslator_english_flag_choice',
900
+ 'googlelanguagetranslator_spanish_flag_choice',
901
+ 'googlelanguagetranslator_portuguese_flag_choice',
902
+ 'googlelanguagetranslator_floating_widget_text',
903
+ 'glt_floating_widget_text_color',
904
+ 'googlelanguagetranslator_floating_widget_text_allow_translation',
905
+ 'glt_floating_widget_position',
906
+ 'glt_floating_widget_bg_color',
907
+ 'googlelanguagetranslator_seo_active',
908
+ 'googlelanguagetranslator_url_structure',
909
+ 'googlelanguagetranslator_url_translation_active',
910
+ 'googlelanguagetranslator_hreflang_tags_active',
911
+ );
912
 
913
  foreach ($settings_name_array as $setting) {
914
  add_settings_field( $setting,'',$setting.'_cb','google_language_translator','glt_settings');
1280
 
1281
  $options = get_option (''.$option_name.''); ?>
1282
 
1283
+ <input type="radio" name="googlelanguagetranslator_flags_alignment" id="flags_left" value="flags_left" <?php if($options=='flags_left'){echo "checked";}?>/> <label for="flags_left">Align Left</label><br/>
1284
+ <input type="radio" name="googlelanguagetranslator_flags_alignment" id="flags_right" value="flags_right" <?php if($options=='flags_right'){echo "checked";}?>/> <label for="flags_right">Align Right</label>
1285
  <?php }
1286
 
1287
  public function googlelanguagetranslator_analytics_cb() {
1414
  <?php
1415
  }
1416
 
1417
+ public function googlelanguagetranslator_seo_active_cb() {
1418
+ $option_name = 'googlelanguagetranslator_seo_active' ;
1419
+ $new_value = 0;
1420
+ if ( get_option( $option_name ) === false ) {
1421
+
1422
+ // The option does not exist, so we update it.
1423
+ update_option( $option_name, $new_value );
1424
+ }
1425
+
1426
+ $options = get_option (''.$option_name.'');
1427
+
1428
+ $html = '<input type="checkbox" name="googlelanguagetranslator_seo_active" id="googlelanguagetranslator_seo_active" value="1" '.checked(1,$options,false).'/>';
1429
+ echo $html;
1430
+ }
1431
+
1432
+ public function googlelanguagetranslator_url_structure_choice_cb() {
1433
+ $option_name = 'googlelanguagetranslator_url_structure' ;
1434
+
1435
+ if ( get_option( $option_name ) === false ) {
1436
+ // The option does not exist, so we update it.
1437
+ update_option( $option_name, 'sub_domain' );
1438
+ }
1439
+
1440
+ $options = get_option (''.$option_name.''); ?>
1441
+
1442
+ <input type="radio" name="googlelanguagetranslator_url_structure" id="sub_domain" value="sub_domain" <?php if($options=='sub_domain'){echo "checked";}?>/> <label for="sub_domain">Sub-domain (http://<b>es</b>.example.com/)</label><br/><br/>
1443
+ <input type="radio" name="googlelanguagetranslator_url_structure" id="sub_directory" value="sub_directory" <?php if($options=='sub_directory'){echo "checked";}?>/> <label for="sub_directory">Sub-directory (http://example.com/<b>de</b>/)</label>
1444
+ <?php }
1445
+
1446
+ public function googlelanguagetranslator_url_translation_active_cb() {
1447
+ $option_name = 'googlelanguagetranslator_url_translation_active' ;
1448
+ $new_value = 0;
1449
+ if ( get_option( $option_name ) === false ) {
1450
+
1451
+ // The option does not exist, so we update it.
1452
+ update_option( $option_name, $new_value );
1453
+ }
1454
+
1455
+ $options = get_option (''.$option_name.'');
1456
+
1457
+ $html = '<input type="checkbox" name="googlelanguagetranslator_url_translation_active" id="googlelanguagetranslator_url_translation_active" value="1" '.checked(1,$options,false).'/>';
1458
+ echo $html;
1459
+ }
1460
+
1461
+ public function googlelanguagetranslator_hreflang_tags_active_cb() {
1462
+ $option_name = 'googlelanguagetranslator_hreflang_tags_active' ;
1463
+ $new_value = 0;
1464
+ if ( get_option( $option_name ) === false ) {
1465
+
1466
+ // The option does not exist, so we update it.
1467
+ update_option( $option_name, $new_value );
1468
+ }
1469
+
1470
+ $options = get_option (''.$option_name.'');
1471
+
1472
+ $html = '<input type="checkbox" name="googlelanguagetranslator_hreflang_tags_active" id="googlelanguagetranslator_hreflang_tags_active" value="1" '.checked(1,$options,false).'/>';
1473
+ echo $html;
1474
+ }
1475
+
1476
  public function googlelanguagetranslator_css_cb() {
1477
 
1478
  $option_name = 'googlelanguagetranslator_css' ;
1486
 
1487
  $options = get_option (''.$option_name.'');
1488
 
1489
+ $html = '<textarea style="width:100%;" rows="5" name="googlelanguagetranslator_css" id="googlelanguagetranslator_css">'.$options.'</textarea>';
1490
  echo $html;
1491
  }
1492
 
1555
  </table>
1556
  </div> <!-- .postbox -->
1557
 
1558
+ <div class="postbox glt-seo-settings">
1559
+ <h3>SEO Settings (paid) <strong style="color:red">NEW!</strong></h3>
1560
+ <div class="inside">
1561
+ <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
1562
+ <tr class="notranslate">
1563
+ <td class="advanced">Enable search engine indexing: &nbsp;<a href="#TB_inline?width=200&height=150&inlineId=search-engine-indexing-description" title="What is search engine indexing?" class="thickbox">Learn more</a><div id="search-engine-indexing-description" style="display:none"><p>When turned on search engines will crawl your translated pages and index them, so that your website's translated pages can appear in search engines results pages. This will increase your international traffic. Search engine indexing is an essential feature for multilingual SEO.<br><br><i>Please Note:</i> You must have <a href="https://gtranslate.io/?xyz=3167#pricing" target="_blank">GTranslate paid plan</a> to be able to use this option.</p></div></td>
1564
+ <td class="advanced"><?php $this->googlelanguagetranslator_seo_active_cb(); ?></td>
1565
+ </tr>
1566
+
1567
+ <tr class="notranslate">
1568
+ <td class="advanced">URL Structure:</td>
1569
+ <td class="advanced"><?php $this->googlelanguagetranslator_url_structure_choice_cb(); ?></td>
1570
+ </tr>
1571
+
1572
+ <tr class="notranslate">
1573
+ <td class="advanced">URL Translation: &nbsp;<a href="#TB_inline?width=200&height=150&inlineId=url-translation-description" title="What is URL translation?" class="thickbox">Learn more</a><div id="url-translation-description" style="display:none"><p>When turned on your URL slugs will be translated which will create additional keywords in other languages and increase your ranking on search engine results pages. For example http://example.com/<b>about-us</b> will become http://de.example.com/<b>uber-uns</b> for German version.<br><br><i>Please Note:</i> This feature will work only if you have GTranslate plan with URL translation option included.</p></div></td>
1574
+ <td class="advanced"><?php $this->googlelanguagetranslator_url_translation_active_cb(); ?></td>
1575
+ </tr>
1576
+
1577
+ <tr class="notranslate">
1578
+ <td class="advanced">Add hreflang meta tags: &nbsp;<a href="#TB_inline?width=200&height=150&inlineId=hreflang-tags-description" title="What are hreflang tags?" class="thickbox">Learn more</a><div id="hreflang-tags-description" style="display:none"><p>Hreflang tags are a technical solution for sites that have similar content in multiple languages. The owner of a multilingual site wants search engines to send people to the content in their own language. Say a user is Dutch and the page that ranks is English, but there's also a Dutch version. You would want Google to show the Dutch page in the search results for that Dutch user. This is the kind of problem hreflang was designed to solve.</p></div></td>
1579
+ <td class="advanced"><?php $this->googlelanguagetranslator_hreflang_tags_active_cb(); ?></td>
1580
+ </tr>
1581
+ </table>
1582
+ </div> <!-- .inside -->
1583
+ </div> <!-- .postbox -->
1584
+
1585
  <div class="postbox glt-layout-settings" style="width: 100%">
1586
  <h3 class="notranslate">Language Switcher Settings</h3>
1587
  <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
1588
 
1589
  <tr class="notranslate">
1590
+ <td class="choose_flags_intro">Language switcher width:</td>
1591
  <td class="choose_flags_intro"><?php $this->glt_language_switcher_width_cb(); ?></td>
1592
  </tr>
1593
 
1594
  <tr class="notranslate">
1595
+ <td class="choose_flags_intro">Language switcher text color:</td>
1596
  <td class="choose_flags_intro"><?php $this->glt_language_switcher_text_color_cb(); ?></td>
1597
  </tr>
1598
 
1599
  <tr class="notranslate">
1600
+ <td class="choose_flags_intro">Language switcher background color:</td>
1601
  <td class="choose_flags_intro"><?php $this->glt_language_switcher_bg_color_cb(); ?></td>
1602
  </tr>
1603
 
1652
  </tr>
1653
 
1654
  <tr class="floating-widget floating-widget-position notranslate hidden">
1655
+ <td>Floating Widget Position:</td>
1656
  <td><?php $this->glt_floating_widget_position_cb(); ?></td>
1657
  </tr>
1658
 
1659
  <tr class="floating-widget floating-widget-text-color notranslate hidden">
1660
+ <td>Floating Widget Text Color:</td>
1661
  <td><?php $this->glt_floating_widget_text_color_cb(); ?></td>
1662
  </tr>
1663
 
1664
  <tr class="floating-widget floating-widget-color notranslate hidden">
1665
+ <td>Floating Widget Background Color</td>
1666
  <td><?php $this->glt_floating_widget_bg_color_cb(); ?></td>
1667
  </tr>
1668
  </table>
1669
  </div> <!-- .postbox -->
1670
 
1671
+ <div class="postbox glt-behavior-settings" style="width: 100%;display:none;">
1672
  <h3 class="notranslate">Behavior Settings</h3>
1673
  <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
1674
  <tr class="multilanguage notranslate">
1726
  </div> <!-- .single-language-shortcode-description -->
1727
  </td>
1728
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
1729
  </table>
1730
  </div> <!-- .postbox -->
1731
+
1732
+ <?php
1733
+ if (isset($_POST['submit'])) {
1734
+ if (empty($_POST['submit']) && !check_admin_referer( 'glt-save-settings', 'glt-save-settings-nonce' )) {
1735
+ wp_die();
1736
+ }
1737
+ }
1738
+ wp_nonce_field('glt-save-settings, glt-save-settings-nonce', false);
1739
+ submit_button();
1740
+ ?>
1741
+
1742
+ <p><a target="_blank" href="https://wordpress.org/support/plugin/google-language-translator/reviews/?filter=5"><?php _e('Love Google Language Translator? Give us 5 stars on WordPress.org :)', 'glt'); ?></a></p>
1743
+
1744
  </div> <!-- .metbox-holder -->
1745
 
1746
  <div class="metabox-holder" style="float:right; clear:right; width:33%">
1756
  </div> <!-- .metabox-holder -->
1757
 
1758
  <div class="metabox-holder box-right notranslate" style="float: right; width: 33%; clear:right">
1759
+ <div class="postbox glt-flag-settings">
1760
+ <h3>Flag Settings</h3>
1761
  <div class="inside">
1762
  <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table">
1763
  <tr class="notranslate">
1784
  </div> <!-- .postbox -->
1785
  </div> <!-- .metabox-holder -->
1786
 
1787
+ <div class="metabox-holder box-right notranslate" style="float: right; width: 33%;">
1788
+ <div class="postbox glt-gtranslate-ad">
1789
+ <h3>Enable SEO features with GTranslate</h3>
1790
+ <div class="inside">
1791
+ <a class="wp-studio-logo" href="https://gtranslate.io/?xyz=3167#pricing" target="_blank"><img style="width:177px;" src="<?php echo plugins_url( 'images/gt_logo.svg' , __FILE__ ); ?>"></a><br />
1792
+ <ul id="features" style="margin-left:15px">
1793
+ <li style="list-style:square outside"><?php _e('Search engine indexing', 'glt'); ?></li>
1794
+ <li style="list-style:square outside"><?php _e('Search engine friendly (SEF) URLs', 'glt'); ?></li>
1795
+ <li style="list-style:square outside"><?php _e('Human level neural translations', 'glt'); ?></li>
1796
+ <li style="list-style:square outside"><?php _e('Edit translations manually', 'glt'); ?></li>
1797
+ <li style="list-style:square outside"><?php _e('Meta data translation (keywords, page description, etc...)', 'glt'); ?></li>
1798
+ <li style="list-style:square outside"><?php _e('URL/slug translation', 'glt'); ?></li>
1799
+ <li style="list-style:square outside"><?php _e('Language hosting (custom domain like example.fr, example.es)', 'glt'); ?></li>
1800
+ <li style="list-style:square outside"><?php _e('Seamless updates', 'glt'); ?></li>
1801
+ <li style="list-style:square outside"><?php _e('Increased international traffic and AdSense revenue', 'glt'); ?></li>
1802
+ <li style="list-style:square outside"><?php _e('Works in China', 'glt'); ?></li>
1803
+ <li style="list-style:square outside"><?php _e('Priority Live Chat support', 'glt'); ?></li>
1804
+ </ul>
1805
+
1806
+ <p><?php _e('Prices starting from <b>$5.99/month</b>!', 'glt'); ?></p>
1807
+
1808
+ <a href="https://gtranslate.io/?xyz=3167#pricing" target="_blank" class="button-primary"><?php _e('Try Now (15 days free)', 'glt'); ?></a> <a href="https://gtranslate.io/?xyz=3167#faq" target="_blank" class="button-primary"><?php _e('FAQ', 'glt'); ?></a> <a href="https://gtranslate.io/?xyz=3167#contact" target="_blank" class="button-primary"><?php _e('Live Chat', 'glt'); ?></a>
1809
+ </div> <!-- .inside -->
1810
+ </div> <!-- .postbox -->
1811
+ </div> <!-- .metabox-holder -->
1812
+
1813
 
1814
  <div class="metabox-holder box-right notranslate" style="float: right; width: 33%;">
1815
  <div class="postbox glt-css-settings">
1822
  </div> <!-- .metabox-holder -->
1823
  <?php $this->googlelanguagetranslator_flags_order_cb(); ?>
1824
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1825
  </div> <!-- .wrap -->
1826
+
1827
+ <?php
1828
+ $default_language = get_option('googlelanguagetranslator_language');
1829
+ $glt_url_structure = get_option('googlelanguagetranslator_url_structure');
1830
+ $glt_seo_active = get_option('googlelanguagetranslator_seo_active');
1831
+
1832
+ $pro_version = $enterprise_version = null;
1833
+ if($glt_seo_active == '1' and $glt_url_structure == 'sub_domain')
1834
+ $pro_version = '1';
1835
+ if($glt_seo_active == '1' and $glt_url_structure == 'sub_directory')
1836
+ $enterprise_version = '1';
1837
+ ?>
1838
+ <script>window.intercomSettings = {app_id: "r70azrgx", 'platform': 'wordpress-glt', 'translate_from': '<?php echo $default_language; ?>', 'is_sub_directory': <?php echo (empty($pro_version) ? '0' : '1'); ?>, 'is_sub_domain': <?php echo (empty($enterprise_version) ? '0' : '1'); ?>};(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/r70azrgx';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
1839
  <?php
1840
  }
1841
  }
1842
+
1843
+ class GLT_Notices {
1844
+ protected $prefix = 'glt';
1845
+ public $notice_spam = 0;
1846
+ public $notice_spam_max = 3;
1847
+
1848
+ // Basic actions to run
1849
+ public function __construct() {
1850
+ // Runs the admin notice ignore function incase a dismiss button has been clicked
1851
+ add_action('admin_init', array($this, 'admin_notice_ignore'));
1852
+ // Runs the admin notice temp ignore function incase a temp dismiss link has been clicked
1853
+ add_action('admin_init', array($this, 'admin_notice_temp_ignore'));
1854
+
1855
+ // Adding notices
1856
+ add_action('admin_notices', array($this, 'glt_admin_notices'));
1857
+ }
1858
+
1859
+ // Checks to ensure notices aren't disabled and the user has the correct permissions.
1860
+ public function glt_admin_notice() {
1861
+
1862
+ $gt_settings = get_option($this->prefix . '_admin_notice');
1863
+ if (!isset($gt_settings['disable_admin_notices']) || (isset($gt_settings['disable_admin_notices']) && $gt_settings['disable_admin_notices'] == 0)) {
1864
+ if (current_user_can('manage_options')) {
1865
+ return true;
1866
+ }
1867
+ }
1868
+ return false;
1869
+ }
1870
+
1871
+ // Primary notice function that can be called from an outside function sending necessary variables
1872
+ public function admin_notice($admin_notices) {
1873
+
1874
+ // Check options
1875
+ if (!$this->glt_admin_notice()) {
1876
+ return false;
1877
+ }
1878
+
1879
+ foreach ($admin_notices as $slug => $admin_notice) {
1880
+ // Call for spam protection
1881
+
1882
+ if ($this->anti_notice_spam()) {
1883
+ return false;
1884
+ }
1885
+
1886
+ // Check for proper page to display on
1887
+ if (isset( $admin_notices[$slug]['pages']) and is_array( $admin_notices[$slug]['pages'])) {
1888
+
1889
+ if (!$this->admin_notice_pages($admin_notices[$slug]['pages'])) {
1890
+ return false;
1891
+ }
1892
+
1893
+ }
1894
+
1895
+ // Check for required fields
1896
+ if (!$this->required_fields($admin_notices[$slug])) {
1897
+
1898
+ // Get the current date then set start date to either passed value or current date value and add interval
1899
+ $current_date = current_time("n/j/Y");
1900
+ $start = (isset($admin_notices[$slug]['start']) ? $admin_notices[$slug]['start'] : $current_date);
1901
+ $start = date("n/j/Y", strtotime($start));
1902
+ $end = ( isset( $admin_notices[ $slug ]['end'] ) ? $admin_notices[ $slug ]['end'] : $start );
1903
+ $end = date( "n/j/Y", strtotime( $end ) );
1904
+ $date_array = explode('/', $start);
1905
+ $interval = (isset($admin_notices[$slug]['int']) ? $admin_notices[$slug]['int'] : 0);
1906
+ $date_array[1] += $interval;
1907
+ $start = date("n/j/Y", mktime(0, 0, 0, $date_array[0], $date_array[1], $date_array[2]));
1908
+ // This is the main notices storage option
1909
+ $admin_notices_option = get_option($this->prefix . '_admin_notice', array());
1910
+ // Check if the message is already stored and if so just grab the key otherwise store the message and its associated date information
1911
+ if (!array_key_exists( $slug, $admin_notices_option)) {
1912
+ $admin_notices_option[$slug]['start'] = $start;
1913
+ $admin_notices_option[$slug]['int'] = $interval;
1914
+ update_option($this->prefix . '_admin_notice', $admin_notices_option);
1915
+ }
1916
+
1917
+ // Sanity check to ensure we have accurate information
1918
+ // New date information will not overwrite old date information
1919
+ $admin_display_check = (isset($admin_notices_option[$slug]['dismissed']) ? $admin_notices_option[$slug]['dismissed'] : 0);
1920
+ $admin_display_start = (isset($admin_notices_option[$slug]['start']) ? $admin_notices_option[$slug]['start'] : $start);
1921
+ $admin_display_interval = (isset($admin_notices_option[$slug]['int']) ? $admin_notices_option[$slug]['int'] : $interval);
1922
+ $admin_display_msg = (isset($admin_notices[$slug]['msg']) ? $admin_notices[$slug]['msg'] : '');
1923
+ $admin_display_title = (isset($admin_notices[$slug]['title']) ? $admin_notices[$slug]['title'] : '');
1924
+ $admin_display_link = (isset($admin_notices[$slug]['link']) ? $admin_notices[$slug]['link'] : '');
1925
+ $admin_display_dismissible= (isset($admin_notices[$slug]['dismissible']) ? $admin_notices[$slug]['dismissible'] : true);
1926
+ $output_css = false;
1927
+
1928
+ // Ensure the notice hasn't been hidden and that the current date is after the start date
1929
+ if ($admin_display_check == 0 and strtotime($admin_display_start) <= strtotime($current_date)) {
1930
+ // Get remaining query string
1931
+ $query_str = esc_url(add_query_arg($this->prefix . '_admin_notice_ignore', $slug));
1932
+
1933
+ // Admin notice display output
1934
+ echo '<div class="update-nag glt-admin-notice">';
1935
+ echo '<div class="glt-notice-logo"></div>';
1936
+ echo ' <p class="glt-notice-title">';
1937
+ echo $admin_display_title;
1938
+ echo ' </p>';
1939
+ echo ' <p class="glt-notice-body">';
1940
+ echo $admin_display_msg;
1941
+ echo ' </p>';
1942
+ echo '<ul class="glt-notice-body glt-red">
1943
+ ' . $admin_display_link . '
1944
+ </ul>';
1945
+ if($admin_display_dismissible)
1946
+ echo '<a href="' . $query_str . '" class="dashicons dashicons-dismiss"></a>';
1947
+ echo '</div>';
1948
+
1949
+ $this->notice_spam += 1;
1950
+ $output_css = true;
1951
+ }
1952
+
1953
+ if ($output_css) {
1954
+ wp_enqueue_style($this->prefix . '-admin-notices', plugins_url(plugin_basename(dirname(__FILE__))) . '/css/glt-notices.css', array());
1955
+ }
1956
+ }
1957
+
1958
+ }
1959
+ }
1960
+
1961
+ // Spam protection check
1962
+ public function anti_notice_spam() {
1963
+ if ($this->notice_spam >= $this->notice_spam_max) {
1964
+ return true;
1965
+ }
1966
+ return false;
1967
+ }
1968
+
1969
+ // Ignore function that gets ran at admin init to ensure any messages that were dismissed get marked
1970
+ public function admin_notice_ignore() {
1971
+ // If user clicks to ignore the notice, update the option to not show it again
1972
+ if (isset($_GET[$this->prefix . '_admin_notice_ignore'])) {
1973
+ $admin_notices_option = get_option($this->prefix . '_admin_notice', array());
1974
+
1975
+ $key = $_GET[$this->prefix . '_admin_notice_ignore'];
1976
+ if(!preg_match('/^[a-z_0-9]+$/i', $key))
1977
+ return;
1978
+
1979
+ $admin_notices_option[$key]['dismissed'] = 1;
1980
+ update_option($this->prefix . '_admin_notice', $admin_notices_option);
1981
+ $query_str = remove_query_arg($this->prefix . '_admin_notice_ignore');
1982
+ wp_redirect($query_str);
1983
+ exit;
1984
+ }
1985
+ }
1986
+
1987
+ // Temp Ignore function that gets ran at admin init to ensure any messages that were temp dismissed get their start date changed
1988
+ public function admin_notice_temp_ignore() {
1989
+ // If user clicks to temp ignore the notice, update the option to change the start date - default interval of 14 days
1990
+ if (isset($_GET[$this->prefix . '_admin_notice_temp_ignore'])) {
1991
+ $admin_notices_option = get_option($this->prefix . '_admin_notice', array());
1992
+ $current_date = current_time("n/j/Y");
1993
+ $date_array = explode('/', $current_date);
1994
+ $interval = (isset($_GET['gt_int']) ? intval($_GET['gt_int']) : 14);
1995
+ $date_array[1] += $interval;
1996
+ $new_start = date("n/j/Y", mktime(0, 0, 0, $date_array[0], $date_array[1], $date_array[2]));
1997
+
1998
+ $key = $_GET[$this->prefix . '_admin_notice_temp_ignore'];
1999
+ if(!preg_match('/^[a-z_0-9]+$/i', $key))
2000
+ return;
2001
+
2002
+ $admin_notices_option[$key]['start'] = $new_start;
2003
+ $admin_notices_option[$key]['dismissed'] = 0;
2004
+ update_option($this->prefix . '_admin_notice', $admin_notices_option);
2005
+ $query_str = remove_query_arg(array($this->prefix . '_admin_notice_temp_ignore', 'gt_int'));
2006
+ wp_redirect( $query_str );
2007
+ exit;
2008
+ }
2009
+ }
2010
+
2011
+ public function admin_notice_pages($pages) {
2012
+ foreach ($pages as $key => $page) {
2013
+ if (is_array($page)) {
2014
+ if (isset($_GET['page']) and $_GET['page'] == $page[0] and isset($_GET['tab']) and $_GET['tab'] == $page[1]) {
2015
+ return true;
2016
+ }
2017
+ } else {
2018
+ if ($page == 'all') {
2019
+ return true;
2020
+ }
2021
+ if (get_current_screen()->id === $page) {
2022
+ return true;
2023
+ }
2024
+
2025
+ if (isset($_GET['page']) and $_GET['page'] == $page) {
2026
+ return true;
2027
+ }
2028
+ }
2029
+ }
2030
+
2031
+ return false;
2032
+ }
2033
+
2034
+ // Required fields check
2035
+ public function required_fields( $fields ) {
2036
+ if (!isset( $fields['msg']) or (isset($fields['msg']) and empty($fields['msg']))) {
2037
+ return true;
2038
+ }
2039
+ if (!isset( $fields['title']) or (isset($fields['title']) and empty($fields['title']))) {
2040
+ return true;
2041
+ }
2042
+ return false;
2043
+ }
2044
+
2045
+ // Special parameters function that is to be used in any extension of this class
2046
+ public function special_parameters($admin_notices) {
2047
+ // Intentionally left blank
2048
+ }
2049
+
2050
+ public function glt_admin_notices() {
2051
+
2052
+ $deactivate_plugins= array('WP Translator' => 'wptranslator/WPTranslator.php', 'TranslatePress' => 'translatepress-multilingual/index.php', 'Google Website Translator' => 'google-website-translator/google-website-translator.php', 'Weglot' => 'weglot/weglot.php', 'TransPosh' => 'transposh-translation-filter-for-wordpress/transposh.php');
2053
+ foreach($deactivate_plugins as $name => $plugin_file) {
2054
+ if(is_plugin_active($plugin_file)) {
2055
+ $deactivate_link = wp_nonce_url('plugins.php?action=deactivate&amp;plugin='.urlencode($plugin_file ).'&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $plugin_file);
2056
+ $notices['deactivate_plugin_'.strtolower(str_replace(' ', '', $name))] = array(
2057
+ 'title' => sprintf(__('Please deactivate %s plugin', 'glt'), $name),
2058
+ 'msg' => sprintf(__('%s plugin causes conflicts with Google Language Translator.', 'glt'), $name),
2059
+ 'link' => '<li><span class="dashicons dashicons-dismiss"></span><a href="'.$deactivate_link.'">' . sprintf(__('Deactivate %s plugin', 'glt'), $name) . '</a></li>',
2060
+ 'dismissible' => false,
2061
+ 'int' => 0
2062
+ );
2063
+ }
2064
+ }
2065
+
2066
+ $glt_announcement_ignore = esc_url(add_query_arg(array($this->prefix . '_admin_notice_ignore' => 'glt_announcement')));
2067
+ $glt_announcement_temp = esc_url(add_query_arg(array($this->prefix . '_admin_notice_temp_ignore' => 'glt_announcement', 'gt_int' => 2)));
2068
+
2069
+ $notices['glt_announcement'] = array(
2070
+ 'title' => __('Announcement - Google Language Translator', 'glt'),
2071
+ 'msg' => __("<p><b>Google Language Translator</b> plugin is now a part of <b>GTranslate</b> family!</p> <p>GTranslate is a leader in website translation technology. You can continue using this plugin and enjoy <b>new SEO features</b> and free <b>Live chat support</b> brought to you by GTranslate.</p>", 'glt'),
2072
+ 'link' => '<li><span class="dashicons dashicons-megaphone"></span><a href="https://gtranslate.io/blog/google-language-translator-becomes-part-of-gtranslate-family" target="_blank">' . __('Read More', 'glt') . '</a></li>' .
2073
+ '<li><span class="dashicons dashicons-external"></span><a href="https://gtranslate.io/?xyz=3167" target="_blank">' . __('Visit GTranslate', 'glt') . '</a></li>' .
2074
+ '<li><span class="dashicons dashicons-admin-settings"></span><a href="' . admin_url('options-general.php?page=google_language_translator') . '">' . __('Open Settings Page', 'glt') . '</a></li>' .
2075
+ '<li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $glt_announcement_temp . '">' . __('Remind me later', 'glt') . '</a></li>' .
2076
+ '<li><span class="dashicons dashicons-dismiss"></span><a href="' . $glt_announcement_ignore . '">' . __('Dismiss', 'glt') . '</a></li>',
2077
+ 'later_link' => $glt_announcement_temp,
2078
+ 'int' => 0
2079
+ );
2080
+
2081
+ $two_week_review_ignore = esc_url(add_query_arg(array($this->prefix . '_admin_notice_ignore' => 'two_week_review')));
2082
+ $two_week_review_temp = esc_url(add_query_arg(array($this->prefix . '_admin_notice_temp_ignore' => 'two_week_review', 'gt_int' => 6)));
2083
+
2084
+ $notices['two_week_review'] = array(
2085
+ 'title' => __('Please Leave a Review', 'glt'),
2086
+ 'msg' => __("We hope you have enjoyed using Google Language Translator! Would you mind taking a few minutes to write a review on WordPress.org? <br>Just writing a simple <b>'thank you'</b> will make us happy!", 'glt'),
2087
+ 'link' => '<li><span class="dashicons dashicons-external"></span><a href="https://wordpress.org/support/plugin/google-language-translator/reviews/?filter=5" target="_blank">' . __('Sure! I would love to!', 'glt') . '</a></li>' .
2088
+ '<li><span class="dashicons dashicons-smiley"></span><a href="' . $two_week_review_ignore . '">' . __('I have already left a review', 'glt') . '</a></li>' .
2089
+ '<li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $two_week_review_temp . '">' . __('Maybe later', 'glt') . '</a></li>' .
2090
+ '<li><span class="dashicons dashicons-dismiss"></span><a href="' . $two_week_review_ignore . '">' . __('Never show again', 'glt') . '</a></li>',
2091
+ 'later_link' => $two_week_review_temp,
2092
+ 'int' => 5
2093
+ );
2094
+
2095
+ $upgrade_tips_ignore = esc_url(add_query_arg(array($this->prefix . '_admin_notice_ignore' => 'upgrade_tips')));
2096
+ $upgrade_tips_temp = esc_url(add_query_arg(array($this->prefix . '_admin_notice_temp_ignore' => 'upgrade_tips', 'gt_int' => 7)));
2097
+
2098
+ if(get_option('googlelanguagetranslator_seo_active') != '1') {
2099
+ $notices['upgrade_tips'][] = array(
2100
+ 'title' => __('Did you know?', 'glt'),
2101
+ 'msg' => __('You can have <b>neural machine translations</b> which are human level with GTranslate paid version.', 'glt'),
2102
+ 'link' => '<li><span class="dashicons dashicons-external"></span><a href="https://gtranslate.io/?xyz=3167#pricing" target="_blank">' . __('Learn more', 'glt') . '</a></li>' .
2103
+ '<li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $upgrade_tips_temp . '">' . __('Maybe later', 'glt') . '</a></li>' .
2104
+ '<li><span class="dashicons dashicons-dismiss"></span><a href="' . $upgrade_tips_ignore . '">' . __('Never show again', 'glt') . '</a></li>',
2105
+ 'later_link' => $upgrade_tips_temp,
2106
+ 'int' => 2
2107
+ );
2108
+
2109
+ $notices['upgrade_tips'][] = array(
2110
+ 'title' => __('Did you know?', 'glt'),
2111
+ 'msg' => __('You can <b>increase</b> your international <b>traffic</b> with GTranslate paid version.', 'glt'),
2112
+ 'link' => '<li><span class="dashicons dashicons-external"></span><a href="https://gtranslate.io/?xyz=3167#pricing" target="_blank">' . __('Learn more', 'glt') . '</a></li>' .
2113
+ '<li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $upgrade_tips_temp . '">' . __('Maybe later', 'glt') . '</a></li>' .
2114
+ '<li><span class="dashicons dashicons-dismiss"></span><a href="' . $upgrade_tips_ignore . '">' . __('Never show again', 'glt') . '</a></li>',
2115
+ 'later_link' => $upgrade_tips_temp,
2116
+ 'int' => 2
2117
+ );
2118
+
2119
+ $notices['upgrade_tips'][] = array(
2120
+ 'title' => __('Did you know?', 'glt'),
2121
+ 'msg' => __('You can have your <b>translated pages indexed</b> in search engines with GTranslate paid version.', 'glt'),
2122
+ 'link' => '<li><span class="dashicons dashicons-external"></span><a href="https://gtranslate.io/?xyz=3167#pricing" target="_blank">' . __('Learn more', 'glt') . '</a></li>' .
2123
+ '<li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $upgrade_tips_temp . '">' . __('Maybe later', 'glt') . '</a></li>' .
2124
+ '<li><span class="dashicons dashicons-dismiss"></span><a href="' . $upgrade_tips_ignore . '">' . __('Never show again', 'glt') . '</a></li>',
2125
+ 'later_link' => $upgrade_tips_temp,
2126
+ 'int' => 2
2127
+ );
2128
+
2129
+ $notices['upgrade_tips'][] = array(
2130
+ 'title' => __('Did you know?', 'glt'),
2131
+ 'msg' => __('You can <b>increase</b> your <b>AdSense revenue</b> with GTranslate paid version.', 'glt'),
2132
+ 'link' => '<li><span class="dashicons dashicons-external"></span><a href="https://gtranslate.io/?xyz=3167#pricing" target="_blank">' . __('Learn more', 'glt') . '</a></li>' .
2133
+ '<li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $upgrade_tips_temp . '">' . __('Maybe later', 'glt') . '</a></li>' .
2134
+ '<li><span class="dashicons dashicons-dismiss"></span><a href="' . $upgrade_tips_ignore . '">' . __('Never show again', 'glt') . '</a></li>',
2135
+ 'later_link' => $upgrade_tips_temp,
2136
+ 'int' => 2
2137
+ );
2138
+
2139
+ $notices['upgrade_tips'][] = array(
2140
+ 'title' => __('Did you know?', 'glt'),
2141
+ 'msg' => __('You can <b>edit translations</b> with GTranslate paid version.', 'glt'),
2142
+ 'link' => '<li><span class="dashicons dashicons-external"></span><a href="https://gtranslate.io/?xyz=3167#pricing" target="_blank">' . __('Learn more', 'glt') . '</a></li>' .
2143
+ '<li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $upgrade_tips_temp . '">' . __('Maybe later', 'glt') . '</a></li>' .
2144
+ '<li><span class="dashicons dashicons-dismiss"></span><a href="' . $upgrade_tips_ignore . '">' . __('Never show again', 'glt') . '</a></li>',
2145
+ 'later_link' => $upgrade_tips_temp,
2146
+ 'int' => 2
2147
+ );
2148
+
2149
+ shuffle($notices['upgrade_tips']);
2150
+ $notices['upgrade_tips'] = $notices['upgrade_tips'][0];
2151
+ }
2152
+
2153
+ $this->admin_notice($notices);
2154
+ }
2155
+ }
2156
+
2157
+ if(is_admin()) {
2158
+ global $pagenow;
2159
+
2160
+ if(!defined('DOING_AJAX') or !DOING_AJAX)
2161
+ new GLT_Notices();
2162
+ }
2163
+
2164
+ global $glt_url_structure, $glt_seo_active;
2165
+
2166
+ $glt_url_structure = get_option('googlelanguagetranslator_url_structure');
2167
+ $glt_seo_active = get_option('googlelanguagetranslator_seo_active');
2168
+
2169
+ if($glt_seo_active == '1' and $glt_url_structure == 'sub_directory') { // gtranslate redirect rules with PHP (for environments with no .htaccess support (pantheon, flywheel, etc.), usually .htaccess rules override this)
2170
+
2171
+ @list($request_uri, $query_params) = explode('?', $_SERVER['REQUEST_URI']);
2172
+
2173
+ if(preg_match('/^\/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)\/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)\/(.*)$/', $request_uri, $matches)) {
2174
+ header('Location: ' . '/' . $matches[1] . '/' . $matches[3] . (empty($query_params) ? '' : '?'.$query_params), true, 301);
2175
+ exit;
2176
+ } // #1 redirect double language codes /es/en/...
2177
+
2178
+ if(preg_match('/^\/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)$/', $request_uri)) {
2179
+ header('Location: ' . $request_uri . '/' . (empty($query_params) ? '' : '?'.$query_params), true, 301);
2180
+ exit;
2181
+ } // #2 add trailing slash
2182
+
2183
+ $get_language_choices = get_option ('language_display_settings');
2184
+ $items = array();
2185
+ foreach($get_language_choices as $key => $value) {
2186
+ if($value == 1)
2187
+ $items[] = $key;
2188
+ }
2189
+ $allowed_languages = implode('|', $items); // ex: en|ru|it|de
2190
+
2191
+ if(preg_match('/^\/('.$allowed_languages.')\/(.*)/', $request_uri, $matches)) {
2192
+ $_GET['glang'] = $matches[1];
2193
+ $_GET['gurl'] = rawurldecode($matches[2]);
2194
+
2195
+ require_once dirname(__FILE__) . '/url_addon/gtranslate.php';
2196
+ exit;
2197
+ } // #3 proxy translation
2198
+ }
2199
+
2200
+ if($glt_seo_active == '1' and ($glt_url_structure == 'sub_directory' or $glt_url_structure == 'sub_domain')) {
2201
+ add_action('wp_head', 'glt_request_uri_var');
2202
+ if(isset($_GET['page']) and $_GET['page'] == 'google_language_translator')
2203
+ add_action('admin_head', 'glt_request_uri_var');
2204
+
2205
+ function glt_request_uri_var() {
2206
+ global $glt_url_structure;
2207
+
2208
+ echo '<script>';
2209
+ echo "var glt_request_uri = '".addslashes($_SERVER['REQUEST_URI'])."';";
2210
+ echo "var glt_url_structure = '".addslashes($glt_url_structure)."';";
2211
+ echo "var glt_default_lang = '".addslashes(get_option('googlelanguagetranslator_language'))."';";
2212
+ echo '</script>';
2213
+ }
2214
+
2215
+ if(get_option('googlelanguagetranslator_url_translation_active') == '1') {
2216
+ add_action('wp_head', 'glt_url_translation_meta', 1);
2217
+ function glt_url_translation_meta() {
2218
+ echo '<meta name="uri-translation" content="on" />';
2219
+ }
2220
+ }
2221
+
2222
+ if(get_option('googlelanguagetranslator_hreflang_tags_active') == '1') {
2223
+ add_action('wp_head', 'glt_add_hreflang_tags', 1);
2224
+
2225
+ function glt_add_hreflang_tags() {
2226
+ global $glt_url_structure;
2227
+
2228
+ $default_language = get_option('googlelanguagetranslator_language');
2229
+ $enabled_languages = array();
2230
+ $get_language_choices = get_option ('language_display_settings');
2231
+ foreach($get_language_choices as $key => $value) {
2232
+ if($value == 1)
2233
+ $enabled_languages[] = $key;
2234
+ }
2235
+
2236
+ //$current_url = wp_get_canonical_url();
2237
+ $current_url = network_home_url(add_query_arg(null, null));
2238
+
2239
+ if($current_url !== false) {
2240
+ // adding default language
2241
+ if($default_language === 'iw')
2242
+ echo '<link rel="alternate" hreflang="he" href="'.$current_url.'" />'."\n";
2243
+ elseif($default_language === 'jw')
2244
+ echo '<link rel="alternate" hreflang="jv" href="'.$current_url.'" />'."\n";
2245
+ else
2246
+ echo '<link rel="alternate" hreflang="'.$default_language.'" href="'.$current_url.'" />'."\n";
2247
+
2248
+ // adding enabled languages
2249
+ foreach($enabled_languages as $lang) {
2250
+ $href = '';
2251
+ $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
2252
+
2253
+ if($glt_url_structure == 'sub_domain')
2254
+ $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $lang . '.' . $domain, $current_url);
2255
+ elseif($glt_url_structure == 'sub_directory')
2256
+ $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $_SERVER['HTTP_HOST'] . '/' . $lang, $current_url);
2257
+
2258
+ if(!empty($href) and $lang != $default_language) {
2259
+ if($lang === 'iw')
2260
+ echo '<link rel="alternate" hreflang="he" href="'.$href.'" />'."\n";
2261
+ elseif($lang === 'jw')
2262
+ echo '<link rel="alternate" hreflang="jv" href="'.$href.'" />'."\n";
2263
+ else
2264
+ echo '<link rel="alternate" hreflang="'.$lang.'" href="'.$href.'" />'."\n";
2265
+ }
2266
+ }
2267
+ }
2268
+ }
2269
+ }
2270
+ }
2271
+
2272
+
2273
+ // translate WP REST API posts and categories data in JSON response
2274
+ if($glt_seo_active == '1') {
2275
+ function glt_rest_post($response, $post, $request) {
2276
+ if(isset($response->data['content']) and is_array($response->data['content']))
2277
+ $response->data['content']['gt_translate_keys'] = array(array('key' => 'rendered', 'format' => 'html'));
2278
+
2279
+ if(isset($response->data['excerpt']) and is_array($response->data['excerpt']))
2280
+ $response->data['excerpt']['gt_translate_keys'] = array(array('key' => 'rendered', 'format' => 'html'));
2281
+
2282
+ if(isset($response->data['title']) and is_array($response->data['title']))
2283
+ $response->data['title']['gt_translate_keys'] = array(array('key' => 'rendered', 'format' => 'text'));
2284
+
2285
+ if(isset($response->data['link']))
2286
+ $response->data['gt_translate_keys'] = array(array('key' => 'link', 'format' => 'url'));
2287
+
2288
+ // more fields can be added here
2289
+
2290
+ return $response;
2291
+ }
2292
+
2293
+ function glt_rest_category($response, $category, $request) {
2294
+ if(isset($response->data['description']))
2295
+ $response->data['gt_translate_keys'][] = array('key' => 'description', 'format' => 'html');
2296
+
2297
+ if(isset($response->data['name']))
2298
+ $response->data['gt_translate_keys'][] = array('key' => 'name', 'format' => 'text');
2299
+
2300
+ if(isset($response->data['link']))
2301
+ $response->data['gt_translate_keys'][] = array('key' => 'link', 'format' => 'url');
2302
+
2303
+ // more fields can be added here
2304
+
2305
+ return $response;
2306
+ }
2307
+
2308
+ add_filter('rest_prepare_post', 'glt_rest_post', 10, 3);
2309
+ add_filter('rest_prepare_category', 'glt_rest_category', 10, 3);
2310
+ }
2311
+
2312
+ // convert wp_localize_script format into JSON + JS parser
2313
+ if($glt_seo_active == '1') {
2314
+ function glt_filter_l10n_scripts() {
2315
+ global $wp_scripts;
2316
+
2317
+ $translate_handles = array(
2318
+ 'agile-store-locator-script',
2319
+ 'wmc-wizard',
2320
+ 'wc-address-i18n',
2321
+ 'wc-checkout',
2322
+ 'wc-country-select',
2323
+ 'wc-add-to-cart',
2324
+ 'wc-password-strength-meter',
2325
+ 'googlecode_regular',
2326
+ 'googlecode_property',
2327
+ 'googlecode_contact',
2328
+ 'mapfunctions',
2329
+
2330
+ );
2331
+
2332
+ //echo '<!--' . print_r($wp_scripts, true). '-->';
2333
+ //return;
2334
+
2335
+ foreach($wp_scripts->registered as $handle => $script) {
2336
+ if(isset($script->extra['data']) and in_array($handle, $translate_handles)) {
2337
+ $l10n = $script->extra['data'];
2338
+ preg_match_all('/var (.+) = ({(.*)});/', $l10n, $matches);
2339
+ //echo '<!--' . print_r($matches, true). '-->';
2340
+
2341
+ if(isset($matches[1]) and isset($matches[2])) {
2342
+ $vars = $matches[1];
2343
+ $scripts = $matches[2];
2344
+ } else
2345
+ continue;
2346
+
2347
+ foreach($vars as $i => $var_name) {
2348
+ $attribute_ids = $wp_scripts->get_data($handle, 'attribute-ids');
2349
+ $attribute_ids[] = $var_name . '-glt-l10n-'.$i;
2350
+ $jsons = $wp_scripts->get_data($handle, 'jsons');
2351
+ $jsons[] = $scripts[$i];
2352
+ $jss = $wp_scripts->get_data($handle, 'jss');
2353
+ $jss[] = "var $var_name = JSON.parse(document.getElementById('$var_name-glt-l10n-$i').innerHTML);";
2354
+
2355
+ $wp_scripts->add_data($handle, 'attribute-ids', $attribute_ids);
2356
+ $wp_scripts->add_data($handle, 'jsons', $jsons);
2357
+ $wp_scripts->add_data($handle, 'jss', $jss);
2358
+ }
2359
+
2360
+ unset($wp_scripts->registered[$handle]->extra['data']);
2361
+ }
2362
+ }
2363
+
2364
+ //echo '<!--' . print_r($wp_scripts, true). '-->';
2365
+
2366
+ }
2367
+
2368
+ function glt_add_script_attributes($tag, $handle) {
2369
+ global $wp_scripts;
2370
+
2371
+ glt_filter_l10n_scripts();
2372
+
2373
+ if(isset($wp_scripts->registered[$handle]->extra['attribute-ids'])) {
2374
+ $attribute_ids = $wp_scripts->get_data($handle, 'attribute-ids');
2375
+ $jsons = $wp_scripts->get_data($handle, 'jsons');
2376
+ $jss = $wp_scripts->get_data($handle, 'jss');
2377
+
2378
+ $return = '';
2379
+ foreach($attribute_ids as $i => $attribute_id) {
2380
+ $json = $jsons[$i];
2381
+ $js = $jss[$i];
2382
+
2383
+ $return .= "<script id='$attribute_id' type='application/json'>$json</script>\n<script type='text/javascript'>$js</script>\n";
2384
+ }
2385
+
2386
+ return $return . $tag;
2387
+ }
2388
+
2389
+ return $tag;
2390
+ }
2391
+
2392
+ // filter for woocommerce script params
2393
+ function glt_filter_woocommerce_scripts_data($data, $handle) {
2394
+ switch($handle) {
2395
+ case 'wc-address-i18n': {
2396
+ $data['gt_translate_keys'] = array(
2397
+ array('key' => 'locale', 'format' => 'json'),
2398
+ 'i18n_required_text',
2399
+ 'i18n_optional_text',
2400
+ );
2401
+
2402
+ $locale = json_decode($data['locale']);
2403
+
2404
+ if(isset($locale->default->address_1))
2405
+ $locale->default->address_1->gt_translate_keys = array('label', 'placeholder');
2406
+ if(isset($locale->default->address_2))
2407
+ $locale->default->address_2->gt_translate_keys = array('label', 'placeholder');
2408
+ if(isset($locale->default->city))
2409
+ $locale->default->city->gt_translate_keys = array('label', 'placeholder');
2410
+ if(isset($locale->default->postcode))
2411
+ $locale->default->postcode->gt_translate_keys = array('label', 'placeholder');
2412
+ if(isset($locale->default->state))
2413
+ $locale->default->state->gt_translate_keys = array('label', 'placeholder');
2414
+
2415
+ if(isset($locale->default->shipping->address_1))
2416
+ $locale->default->shipping->address_1->gt_translate_keys = array('label', 'placeholder');
2417
+ if(isset($locale->default->shipping->address_2))
2418
+ $locale->default->shipping->address_2->gt_translate_keys = array('label', 'placeholder');
2419
+ if(isset($locale->default->shipping->city))
2420
+ $locale->default->shipping->city->gt_translate_keys = array('label', 'placeholder');
2421
+ if(isset($locale->default->shipping->postcode))
2422
+ $locale->default->shipping->postcode->gt_translate_keys = array('label', 'placeholder');
2423
+ if(isset($locale->default->shipping->state))
2424
+ $locale->default->shipping->state->gt_translate_keys = array('label', 'placeholder');
2425
+
2426
+ if(isset($locale->default->billing->address_1))
2427
+ $locale->default->billing->address_1->gt_translate_keys = array('label', 'placeholder');
2428
+ if(isset($locale->default->billing->address_2))
2429
+ $locale->default->billing->address_2->gt_translate_keys = array('label', 'placeholder');
2430
+ if(isset($locale->default->billing->city))
2431
+ $locale->default->billing->city->gt_translate_keys = array('label', 'placeholder');
2432
+ if(isset($locale->default->billing->postcode))
2433
+ $locale->default->billing->postcode->gt_translate_keys = array('label', 'placeholder');
2434
+ if(isset($locale->default->billing->state))
2435
+ $locale->default->billing->state->gt_translate_keys = array('label', 'placeholder');
2436
+
2437
+ $data['locale'] = json_encode($locale);
2438
+ } break;
2439
+
2440
+ case 'wc-checkout': {
2441
+ $data['gt_translate_keys'] = array('i18n_checkout_error');
2442
+ } break;
2443
+
2444
+ case 'wc-country-select': {
2445
+ $data['gt_translate_keys'] = array('i18n_ajax_error', 'i18n_input_too_long_1', 'i18n_input_too_long_n', 'i18n_input_too_short_1', 'i18n_input_too_short_n', 'i18n_load_more', 'i18n_no_matches', 'i18n_searching', 'i18n_select_state_text', 'i18n_selection_too_long_1', 'i18n_selection_too_long_n');
2446
+ } break;
2447
+
2448
+ case 'wc-add-to-cart': {
2449
+ $data['gt_translate_keys'] = array('i18n_view_cart', array('key' => 'cart_url', 'format' => 'url'));
2450
+ } break;
2451
+
2452
+ case 'wc-password-strength-meter': {
2453
+ $data['gt_translate_keys'] = array('i18n_password_error', 'i18n_password_hint', '');
2454
+ } break;
2455
+
2456
+ default: break;
2457
+ }
2458
+
2459
+ return $data;
2460
+ }
2461
+
2462
+ function glt_woocommerce_geolocate_ip($false) {
2463
+ if(isset($_SERVER['HTTP_X_GT_VIEWER_IP']))
2464
+ $_SERVER['HTTP_X_REAL_IP'] = $_SERVER['HTTP_X_GT_VIEWER_IP'];
2465
+ elseif(isset($_SERVER['HTTP_X_GT_CLIENTIP']))
2466
+ $_SERVER['HTTP_X_REAL_IP'] = $_SERVER['HTTP_X_GT_CLIENTIP'];
2467
+
2468
+ return $false;
2469
+ }
2470
+
2471
+ //add_action('wp_print_scripts', 'glt_filter_l10n_scripts', 1);
2472
+ //add_action('wp_print_header_scripts', 'glt_filter_l10n_scripts', 1);
2473
+ //add_action('wp_print_footer_scripts', 'glt_filter_l10n_scripts', 1);
2474
+
2475
+ add_filter('script_loader_tag', 'glt_add_script_attributes', 100, 2);
2476
+
2477
+ add_filter('woocommerce_get_script_data', 'glt_filter_woocommerce_scripts_data', 10, 2 );
2478
+
2479
+ add_filter('woocommerce_geolocate_ip', 'glt_woocommerce_geolocate_ip', 10, 4);
2480
+ }
2481
+
2482
+ $google_language_translator = new google_language_translator();
2483
+
2484
+ function glt_update_option($old_value, $value, $option_name) {
2485
+ if(get_option('googlelanguagetranslator_seo_active') == '1' and get_option('googlelanguagetranslator_url_structure') == 'sub_directory') { // check if rewrite rules are in place
2486
+ $htaccess_file = get_home_path() . '.htaccess';
2487
+ // todo: use insert_with_markers functions instead
2488
+ if(is_writeable($htaccess_file)) {
2489
+ $htaccess = file_get_contents($htaccess_file);
2490
+ if(strpos($htaccess, 'gtranslate.php') === false) { // no config rules
2491
+ $rewrite_rules = file_get_contents(dirname(__FILE__) . '/url_addon/rewrite.txt');
2492
+ $rewrite_rules = str_replace('GLT_PLUGIN_PATH', str_replace(str_replace(array('https:', 'http:'), array(':', ':'), home_url()), '', str_replace(array('https:', 'http:'), array(':', ':'), plugins_url())) . '/google-language-translator', $rewrite_rules);
2493
+
2494
+ $htaccess = $rewrite_rules . "\r\n\r\n" . $htaccess;
2495
+ if(!empty($htaccess)) { // going to update .htaccess
2496
+ file_put_contents($htaccess_file, $htaccess);
2497
+
2498
+ add_settings_error(
2499
+ 'glt_settings_notices',
2500
+ esc_attr( 'settings_updated' ),
2501
+ '<p style="color:red;">' . __('.htaccess file updated', 'glt') . '</p>',
2502
+ 'updated'
2503
+ );
2504
+ }
2505
+ }
2506
+ } else {
2507
+ $rewrite_rules = file_get_contents(dirname(__FILE__) . '/url_addon/rewrite.txt');
2508
+ $rewrite_rules = str_replace('GLT_PLUGIN_PATH', str_replace(home_url(), '', plugins_url()) . '/google-language-translator', $rewrite_rules);
2509
+
2510
+ add_settings_error(
2511
+ 'glt_settings_notices',
2512
+ esc_attr( 'settings_updated' ),
2513
+ '<p style="color:red;">' . __('Please add the following rules to the top of your .htaccess file', 'glt') . '</p><pre style="background-color:#eaeaea;">' . $rewrite_rules . '</pre>',
2514
+ 'error'
2515
+ );
2516
+ }
2517
+
2518
+ // update main_lang in config.php
2519
+ $config_file = dirname(__FILE__) . '/url_addon/config.php';
2520
+ if(is_writable($config_file)) {
2521
+ $config = file_get_contents($config_file);
2522
+ $config = preg_replace('/\$main_lang = \'[a-z-]{2,5}\'/i', '$main_lang = \''.get_option('googlelanguagetranslator_language').'\'', $config);
2523
+ file_put_contents($config_file, $config);
2524
+ } else {
2525
+ add_settings_error(
2526
+ 'glt_settings_notices',
2527
+ esc_attr( 'settings_updated' ),
2528
+ '<p style="color:red;">' . __('Cannot update google-language-translator/url_addon/config.php file. Make sure to update it manually and set correct $main_lang.', 'glt') . '</p>',
2529
+ 'error'
2530
+ );
2531
+ }
2532
+
2533
+ } else { // todo: remove rewrite rules
2534
+ // do nothing
2535
+ }
2536
+ }
2537
+
2538
+ add_action('update_option_googlelanguagetranslator_seo_active', 'glt_update_option', 10, 3);
2539
+ add_action('update_option_googlelanguagetranslator_url_structure', 'glt_update_option', 10, 3);
2540
+ add_action('update_option_googlelanguagetranslator_language', 'glt_update_option', 10, 3);
images/gt_logo.svg ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="65 82 266 60" xml:space="preserve">
2
+ <style type="text/css">
3
+ .st18{fill:#252972;}
4
+ .st35{fill:none;stroke:#FFAE1F;stroke-width:2.3229;stroke-miterlimit:10;}
5
+ </style>
6
+ <g>
7
+ <g>
8
+ <path class="st18" d="M70.1,111.4L70.1,111.4c0-9.8,7.6-17.8,17.9-17.8c6.1,0,9.9,1.7,13.4,4.7l-4.7,5.7c-2.6-2.2-5-3.5-8.9-3.5
9
+ c-5.5,0-9.8,4.8-9.8,10.6v0.1c0,6.2,4.3,10.8,10.3,10.8c2.7,0,5.2-0.7,7.1-2v-4.9h-7.6v-6.5h14.8v14.8c-3.5,3-8.3,5.4-14.6,5.4
10
+ C77.5,128.9,70.1,121.5,70.1,111.4z"/>
11
+ <path class="st18" d="M131.2,122v-16.3h-3.6v-2.2h3.6v-8h2.4v8h8.7v2.2h-8.7v16c0,3.6,2.1,4.8,5,4.8c1.2,0,2.2-0.2,3.7-0.9v2.2
12
+ c-1.3,0.6-2.5,0.9-4,0.9C134.3,128.8,131.2,126.7,131.2,122z"/>
13
+ <path class="st18" d="M149.4,103.5h2.4v7.1c2-4.4,6.1-7.7,11-7.5v2.6h-0.2c-5.8,0-10.8,4.3-10.8,12.4v10.2h-2.4V103.5z"/>
14
+ <path class="st18" d="M165.6,121.1L165.6,121.1c0-5.3,4.4-8.2,10.9-8.2c3.5,0,5.9,0.4,8.2,1.1v-1.1c0-5-3.1-7.6-8.2-7.6
15
+ c-3,0-5.5,0.8-7.8,2l-0.9-2.1c2.7-1.3,5.4-2.1,8.8-2.1c3.4,0,6,0.9,7.9,2.7c1.7,1.7,2.5,4,2.5,7v15.5h-2.3v-4.1
16
+ c-1.7,2.4-4.8,4.7-9.5,4.7C170.6,128.9,165.6,126.3,165.6,121.1z M184.8,119v-2.8c-2.1-0.5-4.9-1.1-8.4-1.1
17
+ c-5.3,0-8.2,2.3-8.2,5.8v0.1c0,3.6,3.4,5.7,7.2,5.7C180.4,126.7,184.8,123.6,184.8,119z"/>
18
+ <path class="st18" d="M195.7,103.5h2.4v4.6c1.7-2.9,4.4-5.2,9-5.2c6.3,0,10,4.3,10,10.2v15.2h-2.4v-14.8c0-5.1-2.9-8.5-7.9-8.5
19
+ c-4.9,0-8.6,3.7-8.6,8.9v14.4h-2.4V103.5z"/>
20
+ <path class="st18" d="M223.4,125.2l1.4-1.9c2.7,2.1,5.8,3.3,8.9,3.3c3.4,0,6-1.9,6-4.7v-0.1c0-2.9-3.1-4-6.6-5
21
+ c-4-1.2-8.5-2.4-8.5-6.8v-0.1c0-4,3.4-6.9,8.2-6.9c3,0,6.3,1.1,8.8,2.7l-1.3,2c-2.3-1.5-5-2.5-7.7-2.5c-3.4,0-5.7,1.9-5.7,4.3
22
+ v0.1c0,2.8,3.4,3.8,6.9,4.8c4,1.1,8.2,2.6,8.2,7v0.1c0,4.4-3.8,7.3-8.6,7.3C230,128.8,226,127.4,223.4,125.2z"/>
23
+ <path class="st18" d="M250.1,92.7h2.4v35.6h-2.4V92.7z"/>
24
+ <path class="st18" d="M259.9,121.1L259.9,121.1c0-5.3,4.4-8.2,10.9-8.2c3.5,0,5.9,0.4,8.2,1.1v-1.1c0-5-3.1-7.6-8.2-7.6
25
+ c-3,0-5.5,0.8-7.8,2l-0.9-2.1c2.7-1.3,5.4-2.1,8.8-2.1c3.4,0,6,0.9,7.9,2.7c1.7,1.7,2.5,4,2.5,7v15.5H279v-4.1
26
+ c-1.7,2.4-4.8,4.7-9.5,4.7C264.9,128.9,259.9,126.3,259.9,121.1z M279.1,119v-2.8c-2.1-0.5-4.9-1.1-8.4-1.1
27
+ c-5.3,0-8.2,2.3-8.2,5.8v0.1c0,3.6,3.4,5.7,7.2,5.7C274.7,126.7,279.1,123.6,279.1,119z"/>
28
+ <path class="st18" d="M291,122v-16.3h-3.6v-2.2h3.6v-8h2.4v8h8.7v2.2h-8.7v16c0,3.6,2.1,4.8,5,4.8c1.2,0,2.2-0.2,3.7-0.9v2.2
29
+ c-1.3,0.6-2.5,0.9-4,0.9C294.1,128.8,291,126.7,291,122z"/>
30
+ <path class="st18" d="M306.8,116L306.8,116c0-7.3,5.1-13.1,11.8-13.1c7,0,11.4,5.7,11.4,13c0,0.4,0,0.6,0,1h-20.6
31
+ c0.4,6.2,4.9,9.8,9.8,9.8c3.9,0,6.5-1.7,8.5-3.9l1.7,1.5c-2.5,2.7-5.5,4.7-10.3,4.7C312.4,128.9,306.8,123.7,306.8,116z
32
+ M327.4,114.7c-0.3-5-3.2-9.7-8.9-9.7c-4.9,0-8.7,4.1-9.2,9.7H327.4z"/>
33
+ </g>
34
+ <line class="st35" x1="117" y1="139.7" x2="117" y2="85.3"/>
35
+ </g>
36
+ </svg>
images/logo.png DELETED
Binary file
js/scripts.js CHANGED
@@ -18,13 +18,15 @@ function GLTFireEvent(lang_pair, lang_dest) {
18
  }
19
 
20
  function doGoogleLanguageTranslator(lang_pair) {
 
 
21
  if (lang_pair.value) lang_pair = lang_pair.value;
22
  if (lang_pair == '') return;
23
  var lang_dest = lang_pair.split('|')[1];
24
  var event;
25
  var classic = jQuery('.goog-te-combo');
26
  var simple = jQuery('.goog-te-menu-frame:first');
27
- var simpleValue = simple.contents().find('.goog-te-menu2-item span.text:contains('+lang_text+')');
28
  if (classic.length == 0) {
29
  for (var i = 0; i < simple.length; i++) {
30
  event = simple[i];
@@ -32,7 +34,7 @@ function doGoogleLanguageTranslator(lang_pair) {
32
  }
33
  } else {
34
  for (var i = 0; i < classic.length; i++) {
35
- event = classic[i];
36
  //alert('Classic is active.');
37
  }
38
  }
@@ -47,19 +49,19 @@ function doGoogleLanguageTranslator(lang_pair) {
47
  } else {
48
  event.value = lang_dest;
49
  if (lang_prefix != default_lang) {
50
- simpleValue.click();
51
  } else {
52
  jQuery('.goog-te-banner-frame:first').contents().find('.goog-close-link').get(0).click();
53
- }
54
- }
55
  }
56
  }
57
 
58
  jQuery(document).ready(function($) {
59
  $('#glt-translate-trigger,#glt-translate-trigger font').toolbar({
60
- content: '#flags',
61
- position: 'top',
62
- hideOnClick: true,
63
  event: 'click',
64
  style: 'primary'
65
  });
@@ -134,13 +136,13 @@ if ( typeof Object.create !== 'function' ) {
134
 
135
  setTrigger: function() {
136
  var self = this;
137
-
138
- if (self.options.event == 'onload') {
139
  $(window).load(function(event) {
140
  event.preventDefault();
141
  self.show();
142
  });
143
- }
144
 
145
  if (self.options.event == 'click') {
146
  self.$elem.on('click', function(event) {
@@ -216,7 +218,8 @@ if ( typeof Object.create !== 'function' ) {
216
 
217
  location.html(content);
218
  location.find('.tool-item').on('click', function(event) {
219
- event.preventDefault();
 
220
  self.$elem.trigger('toolbarItemClick', this);
221
  });
222
  },
@@ -299,8 +302,8 @@ if ( typeof Object.create !== 'function' ) {
299
  self.toolbar.show().css({'opacity': 1}).addClass('animate-'+self.options.animation);
300
  self.$elem.trigger('toolbarShown');
301
  },
302
-
303
- hide: function() {
304
  var self = this;
305
  var animation = {'opacity': 0};
306
  self.$elem.removeClass('pressed');
@@ -359,19 +362,25 @@ jQuery(function($) {
359
  $('#flags a, a.single-language, .tool-items a').each(function() {
360
  $(this).attr('data-lang', $(this).attr('title'));
361
  });
362
-
363
  $(document.body).on("click", "a.flag", function() {
364
- lang_text = $(this).attr('data-lang');
365
- default_lang = $('#google_language_translator').attr('class').split("-").pop();
366
  lang_prefix = $(this).attr("class").split(" ")[2];
367
- lang_prefix == default_lang ? l() : n();
368
  function l() {
369
  doGoogleLanguageTranslator(default_lang + "|" + default_lang);
370
  }
371
  function n() {
372
  doGoogleLanguageTranslator(default_lang + "|" + lang_prefix);
373
  }
374
- $(".tool-container").hide();
375
  });
 
 
 
 
 
 
376
  });
377
 
18
  }
19
 
20
  function doGoogleLanguageTranslator(lang_pair) {
21
+ if(window.glt_request_uri) return true;
22
+
23
  if (lang_pair.value) lang_pair = lang_pair.value;
24
  if (lang_pair == '') return;
25
  var lang_dest = lang_pair.split('|')[1];
26
  var event;
27
  var classic = jQuery('.goog-te-combo');
28
  var simple = jQuery('.goog-te-menu-frame:first');
29
+ var simpleValue = simple.contents().find('.goog-te-menu2-item span.text:contains('+lang_text+')');
30
  if (classic.length == 0) {
31
  for (var i = 0; i < simple.length; i++) {
32
  event = simple[i];
34
  }
35
  } else {
36
  for (var i = 0; i < classic.length; i++) {
37
+ event = classic[i];
38
  //alert('Classic is active.');
39
  }
40
  }
49
  } else {
50
  event.value = lang_dest;
51
  if (lang_prefix != default_lang) {
52
+ simpleValue.click();
53
  } else {
54
  jQuery('.goog-te-banner-frame:first').contents().find('.goog-close-link').get(0).click();
55
+ }
56
+ }
57
  }
58
  }
59
 
60
  jQuery(document).ready(function($) {
61
  $('#glt-translate-trigger,#glt-translate-trigger font').toolbar({
62
+ content: '#flags',
63
+ position: 'top',
64
+ hideOnClick: true,
65
  event: 'click',
66
  style: 'primary'
67
  });
136
 
137
  setTrigger: function() {
138
  var self = this;
139
+
140
+ if (self.options.event == 'onload') {
141
  $(window).load(function(event) {
142
  event.preventDefault();
143
  self.show();
144
  });
145
+ }
146
 
147
  if (self.options.event == 'click') {
148
  self.$elem.on('click', function(event) {
218
 
219
  location.html(content);
220
  location.find('.tool-item').on('click', function(event) {
221
+ if(typeof window.glt_request_uri == 'undefined')
222
+ event.preventDefault();
223
  self.$elem.trigger('toolbarItemClick', this);
224
  });
225
  },
302
  self.toolbar.show().css({'opacity': 1}).addClass('animate-'+self.options.animation);
303
  self.$elem.trigger('toolbarShown');
304
  },
305
+
306
+ hide: function() {
307
  var self = this;
308
  var animation = {'opacity': 0};
309
  self.$elem.removeClass('pressed');
362
  $('#flags a, a.single-language, .tool-items a').each(function() {
363
  $(this).attr('data-lang', $(this).attr('title'));
364
  });
365
+
366
  $(document.body).on("click", "a.flag", function() {
367
+ lang_text = $(this).attr('data-lang');
368
+ default_lang = window.glt_default_lang || $('#google_language_translator').attr('class').split("-").pop();
369
  lang_prefix = $(this).attr("class").split(" ")[2];
370
+ lang_prefix == default_lang ? l() : n();
371
  function l() {
372
  doGoogleLanguageTranslator(default_lang + "|" + default_lang);
373
  }
374
  function n() {
375
  doGoogleLanguageTranslator(default_lang + "|" + lang_prefix);
376
  }
377
+ $(".tool-container").hide();
378
  });
379
+
380
+ if(window.glt_request_uri) {
381
+ $('#google_language_translator select').on('change', function() {
382
+ doGLTTranslate($(this).val());
383
+ })
384
+ }
385
  });
386
 
readme.txt CHANGED
@@ -1,21 +1,67 @@
1
  === Google Language Translator ===
2
  Contributors: edo888
3
- Donate link: https://gtranslate.io/?xyz=998#pricing
4
  Author: Translate AI Multilingual Solutions
5
- Author URI: https://gtranslate.io/?xyz=998
6
  Tags: translate wordpress, translate, translator, translation, language, multi language
7
  Requires at least: 2.9
8
- Tested up to: 5.2.2
9
- Stable tag: 5.0.49
10
 
11
- Google Language Translator plugin allows you to insert Google Translate widget anywhere on your website using shortcode.
12
 
13
  == Description ==
14
 
15
- 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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  == Installation ==
18
-
19
  1. Download the zip folder named google-language-translator.zip
20
  2. Unzip the folder and put it in the plugins directory of your wordpress installation. (wp-content/plugins).
21
  3. Activate the plugin through the plugin window in the admin panel.
@@ -24,415 +70,377 @@ Settings include: inline or vertical layout, show/hide specific languages, hide/
24
  6. Do not use the shortcode twice on a single page - it will not work.
25
 
26
  == Frequently Asked Questions ==
27
-
28
- Q: What should I do if the translate widget does not show on my website?
29
-
30
  1. Make sure that the plugin is installed and activated.
31
  2. Verify that a check mark is placed in the activation setting located at "Settings > Google Language Translator".
32
  3. Verify that the native Wordpress function, wp_footer(), is included in your theme's footer file.
33
  4. Verify that "Show Language Box?" setting is enabled at "Settings > Google Language Translator".
34
  5. Use your browser's web tools to ensure that CSS styles are not hiding the translation widget.
35
- 6. Contact support at http://www.wp-studio.net/submit-ticket.
36
-
37
- Q: What should I do if there are no languages being displayed in the language box?
38
 
 
39
  1. Make sure that the plugin is installed and activated.
40
  2. Verify that a check mark is placed in the activation setting located at "Settings > Google Language Translator".
41
- 3. Verify that Adobe Flash is installed in your web browser. Google uses Flash in order to display their language box.
42
- 4. Contact support at http://www.wp-studio.net/submit-ticket.
43
 
44
- Q: Can I exclude certain areas of my website from being translated?
45
-
46
- 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>
47
 
48
  == Changelog ==
 
 
 
 
 
49
 
50
- 5.0.49
51
- - Added new contributor to the plugin's readme.txt.
52
-
53
- 5.0.48
54
- - Added new setting: Floating Widget Text Color.
55
-
56
- 5.0.47
57
- - Fixed an undefined index error in google-language-translator.php.
58
-
59
- 5.0.46
60
- - Added new setting: Language Switcher Background Color.
61
-
62
- 5.0.45
63
- - Added new setting: Floating Widget background color.
64
- - Removed border-radius from the floating widget for a more standard look and feel. Please email me if you need the CSS to add back rounded edges.
65
-
66
- 5.0.44
67
- - Added new setting: Language Switcher Text Color.
68
-
69
- 5.0.43
70
- - Added new setting: Floating Widget position.
71
-
72
- 5.0.42
73
- - Added new setting: langauge switcher width.
74
- - Removed most javascript away from the document body, and into an external javascript file, scripts.js.
75
- - Added plugin version information to be appended to script and stylesheet files.
76
-
77
- 5.0.41
78
- - Re-factored code in google-language-translator.php to remove the duplicate id "flags".
79
-
80
- 5.0.40
81
- - Fixed a minor 'undefined index' error in google-language-translator.php
82
-
83
- 5.0.39
84
- - Fixed a CSS issue associated with the settings panel changes from the previous update.
85
 
86
- 5.0.38
87
- - Fixed a CSS issue associated with the settings panel changes from the previous update. Flags were not aligning properly with align left/right settings.
88
 
89
- 5.0.37
90
- - Made some additional adjustments in code for the settings page.
91
 
92
- 5.0.36
93
- - Removed undefined variable PHP errors.
94
 
95
- 5.0.35
96
- - Updated the plugin to delete an unused option from the database, used in the settings panel.
 
97
 
98
- 5.0.34
99
- - Updated the settings panel to function more logically. Now users choose the languages they want, and can turn on/off flags associated with those langauges.
100
 
101
- 5.0.33
102
- - Removed a deprecated jQuery function, and replaced with updated code in the footer_script() function.
103
 
104
- 5.0.32
105
- - Fixed the issue with menu translation not working on some mobile devices.
106
- - Moved element.js script to the footer.
 
107
 
108
- 5.0.31
109
- - Fixed an issue with menu shortcode not displaying the correct flag choice (i.e. for English/Spanish/Portuguese flags).
110
 
111
- 5.0.30
112
- - Organized the settings page into sections.
113
- - Upgraded Wordpress.org plugin banner.
114
- - Added additional attributes to single language shortcodes. Users now have ability to display flag images, change flag sizes, or show/hide the text label.
115
- - Changed Chinese (Traditional) language flag to the Flag of Taiwan.
116
- - Fixed a minor display issue with the Google Analytics setting in Wordpress Dashboard.
117
 
118
- 5.0.29
119
- - Fixed CSS display issues with the floating widget.
120
 
121
- 5.0.28
122
- - Fixed CSS display issues with the floating widget.
123
 
124
- 5.0.27
125
- - Removed toolbar.js and flags.js and combined to existing files (to improve efficiency of page load and http requests).
126
- - Added new setting to allow or prevent floating widget text to translate.
127
 
128
- 5.0.26
129
- - Fixed a small error in adding the setting for Floating Widget text.
130
 
131
- 5.0.25
132
- - Added new setting for custom text in the Floating Widget.
133
- - Removed "notranslate" class from the Floating Widget text to allow for translation.
134
 
135
- 5.0.24
136
- - Improved functionality for flags. Users are now returned to original language when the flag is displayed. The Google Toolbar will be hidden once returning back to the original language. The Google Toolbar will appear again when another translation is made.
137
- - Fixed the issue with flags not functioning with SIMPLE layout.
138
- - Removed SIMPLE layout option (which was not working properly) for browsers not using English browsers. The coding challenge for implementing this option is difficult and must be postponed until we find a practical solution.
139
 
140
- 5.0.23
141
- - Reverted back to an older version of flags.js. We still have some bugs to work out before releasing the updated version. We apologize for the inconvenience.
142
 
143
- 5.0.22
144
- - Changed a line of text on the settings page.
145
- - Removed a line of redundant javascript to reduce unnecessary page load.
146
- - Fixed an HTML attribute issue displaying in the menu shortcode.
147
- - Improved functionality for flags. The flag for default language will now be disabled once users click it's flag. Flag will be re-enabled once user makes another translation.
148
 
149
- 5.0.21
150
- - Added 6 new languages with their associated flags: Hawaiian, Kurdish, Kyrgyz, Luxembourgish, Pashto, and Shona. You can now use these langauges using the menu shortcode, as well.
151
- - Added a "Select All / Clear All" feature to the settings page. No more finger cramps!
152
 
153
- 5.0.20
154
- - Added Corsican as a new language with its associated flag.
 
 
 
 
155
 
156
- 5.0.19
157
- - Added Frisian as a new language with its associated flag.
158
 
159
- 5.0.18
160
- - Added Sindhi as a new language with its associated flag.
161
 
162
- 5.0.17
163
- - Added Samoan as a new language with its associated flag.
164
- - Added mobile-responsive CSS to the GLT settings page.
165
 
166
- 5.0.16
167
- - Added Xhosa as a new language with its associated flag.
168
 
169
- 5.0.15
170
- - Added Amharic as a new language with its associated flag.
 
171
 
172
- 5.0.14
173
- - Fixed a file naming error in google-language-translator.php. This caused flags not to display - we apologize for the inconvenience.
 
 
174
 
175
- 5.0.13
176
- - Renamed some of the wp_enqueue_script calls to include more unique file names, thus avoiding conflict with other plugins overriding these files.
177
- - Corrected some file paths to be more accurate/secure.
178
- - Removed WP Helpdesk logo from the settings page. We are no longer offering these services officially.
179
 
180
- 5.0.12
181
- - Revert malicious changes made in 5.0.10
 
 
 
182
 
183
- 5.0.11
184
- - Fixed incorrect link
 
185
 
186
- 5.0.10
187
- - Tested up to 4.6
188
 
189
- 5.0.09
190
- - Turned off error reporting. I apologize for the inconvenience.
191
 
192
- 5.0.08
193
- - Added a new popup-style layout". You can find this new layout in the settings page located in "Settings > Google Language Translator".
194
 
195
- 5.0.07
196
- - Changed the flag for Chinese(Traditional) to the Taiwanese flag. Requested long ago by a few users - thanks for your months of patience!
 
197
 
198
- 5.0.06
199
- - Fixed a XSS Cross Scripting Vulnerability in the plugin, as requested by Wordpress.org. Unnecessary code (during testing) was being posted to the settings page, so the code was removed.
200
 
201
- 5.0.05
202
- - Added 3 new options to the settings page: English, Spanish, and Portuguese flag image variations.
203
- - Fixed an error with the Floating Widget: order of flags was not being honored in certain cases.
204
 
205
- 5.0.04
206
- - Corrected the text on the settings page to reflect 91 total flags, instead of 81 flags.
207
 
208
- 5.0.03
209
- - Added 10 new languages and associated flags: Chichewa, Kazakh, Malagasy, Malayalam, Myanmar(Burmese), Sesotho, Sinhala, Sundanese, Tajik, and Uzbek.
 
 
210
 
211
- 5.0.02
212
- - Updated the Tamil flag to use the Indian flag, instead of Tamil Tigers flag.
213
 
214
- 5.0.01
215
- - Updated style.css to reflect the syntax error connecting to the Chinese flag.
216
 
217
- 5.0.0
218
- - Wordpress security updates added to the settings page [wp_nonce_field()].
219
- - Removed 3 outside Javascript files - these files are now called upon directly from Wordpress CMS.
220
- - Unpacked flags.js p,a,c,k,e,r code. Unknowingly, this method of coding violated Wordpress plugin policy.
221
- - Updated pricing display for GLT Premium. It was displaying $15 previously, but the price had increased since the last update.
222
 
223
- 4.0.9
224
- - Replaced: incorrect Catalonian flag image, with the correct image. I apologize for any inconvenience.
225
- - Fixed: Floating Widget issue - previously it loaded 2 times when shortcode was added, which caused it not to work.
226
 
227
- 4.0.8
228
- - Fixed the small syntax issue related to the Google Analytics tracking number - it was another cause of the language box not displaying.
229
 
230
- 4.0.7
231
- - Fixed a CSS error in the settings panel display.
232
- - Fixed the coding issue when "Specific Languages" option is chosen - the shortcode was not displaying the language dropdown.
233
 
234
- 4.0.6
 
235
 
236
- - Removed: "onclick" events from diplaying directly inside HTML. Converted those events to jQuery.
237
- - Fixed the shortcode that allows adding single languages to Wordpress menus. (New example is shown on settings page.)
238
- - Consolidated all flag images into image sprites!
239
- - Re-designed 10 flag images to match the quality of the other flags.
240
- - Fixed the incorrect "alt" tags associated with flag images. The "alt" tag now displays the language name.
241
- - Modified text on the settings page - also added some lightbox pop-ups to help explain settings.
242
- - New updates have also been provided for our Premium version (currently version 4.0.1) located at http://www.wp-studio.net/
243
 
244
- 4.0.5
 
245
 
246
- - Fixed: Display bug when using single language shortcode.
247
- - Added: New link on the Plugins menu page, which links directly to Google Language Translator settings.
248
 
 
 
249
 
250
- 4.0.4
 
251
 
252
- - Added NEW shortcode! Allows placement of single languages into the navigation menu, pages, and posts. See settings panel for usage details.
253
- - Re-factored code in googlelanguagetranslator.php which reduced code to around 950 lines.
254
- - 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.
255
- - Updated CSS styles for the flags area to prevent themes from overriding layouts.
256
 
257
- 4.0.3
 
 
258
 
259
- - Adjusted CSS styles for the flag display.
 
260
 
261
- 4.0.2
 
 
262
 
263
- - Eliminated all (or most) HTML validation errors. Big improvement!
264
- - Re-factored more code to increase efficiency.
265
- - 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.)
266
- - 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.
 
 
 
267
 
268
- 4.0.1
 
 
269
 
270
- - Fixed PHP errors that were neglected in upgrade to 4.0.
271
- - Added conditionals to prevent scripts from loading when the floating widget is turned off.
272
 
273
- 4.0
 
 
 
 
274
 
275
- - Added 2 new features: 1) Drag/drop flags to re-arrange their order, and 2) Custom flag sizes (16px to 24px).
276
- - Re-factored code in google-language-translator.php. Languages are now loaded dynamically and are not hard-coded.
277
- - 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
278
 
279
- 3.0.9
 
 
 
 
280
 
281
- - Added a title field to the Google Language Translator widget.
282
- - Removed "unexpected text characters" error upon activation (due to error in activation hook).
 
283
 
284
- 3.0.8
 
 
285
 
286
- - Added 9 new languages into the plugin (Hausa, Igbo, Maori, Mongolian, Nepali, Punjabi, Somali, Yoruba, Zulu).
287
- - Corrected an "undefined variable" error that was being generated in Vertical and Horizontal layouts.
288
- - Re-structured coding once again into an Object-Oriented approach.
289
- - Moved all functions of the base class into 'googlelanguagetranslator.php' and the widget into 'widget.php'.
290
- - Moved all javascript files into it's own JS folder.
291
- - Fixed an display issue with "Edit Translations" - they were being hidden when "No branding" option was chosen.
292
- - Corrected various "comma" errors in the string that outputs the script for loading the translator.
293
- - Changed Changelog in readme.txt to show most recent changes first, instead of last.
294
 
295
- 3.0.7
 
 
 
 
 
 
 
 
296
 
297
- - Removed an unnecessary CSS file, left over from development. Sorry for any inconvenience if you received display errors.
 
298
 
299
- 3.0.6
 
300
 
301
- - Corrected a small display error in displaying the floating widget correctly.
302
-
303
- 3.0.5
304
-
305
- - 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.
306
- - Fixed the issue with Dashboard styles loading on the wrong pages. This was causing some annoying display issues on the Wordpress Dashboard.
307
-
308
- 3.0.4
309
-
310
- - Re-factored/re-arranged more code in google languagetransltor.php by placing them into separate files.
311
- - 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.
312
- - Removed style2.php file, which is unnecessary and was being used in testing.
313
-
314
- 3.0.3
315
-
316
- - Re-factored/re-arranged some of the code in googlelanguagetranslator.php by placing them into separate files.
317
- - Fixed a minor coding issue in glt_widget.php - this was generating an error in Wordpress when debugging.
318
- - Moved all CSS code into a single file. The result is nice, clean inline CSS code that is now called only once.
319
- - Fixed some additional CSS display issues.
320
-
321
- 3.0.2
322
-
323
- - Adjusted additional minor invalid HTML issues on the settings page, and also in the front-end plugin display.
324
-
325
- 3.0.1
326
-
327
- - 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.
328
- - Adjusted some minor spacing issues in the settings page HTML (caused some annoying red HTML errors when using "View Source" in right-click menu).
329
- - 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.
330
-
331
- 3.0
332
-
333
- - Correct a small CSS error that affected the showing/hiding of the Google toolbar.
334
-
335
- 2.9
336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  ***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.
 
 
 
 
338
 
339
- - Fixed Google Translation toolbar display issue
340
- - Fixed the Edit Translation interface by hiding it temporarily until Google fixes this
341
- - Removed some unneeded styles from the style sheet.
342
- - Fixed some CSS issues for the Google Branding display, which was affected by Google's most recent update
343
-
344
- 2.8
345
 
346
- - 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.
347
- - 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.)
348
- - Added more flexible styles to the settings page, so that left and right panels display nicely to the user.
 
 
 
349
 
350
- 2.7
 
351
 
352
- - Added Google Analytics tracking capability to the plugin.
 
 
353
 
354
- - Added a "CSS Styles" box in the settings panel.
 
355
 
356
- - Changed the Catalonian flag to its correct flag image.
 
 
 
 
 
357
 
358
- - 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.
 
 
 
359
 
360
- - 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.
 
 
361
 
362
- 2.6
 
363
 
364
- - Added defaults to all options to ensure there are no more issues with the translator displaying upon installation. Again, sorry for any inconvenience.
 
 
 
 
 
 
 
365
 
366
- 2.5
 
367
 
368
- - Eliminated an internal Wordpress error being generated from a coding mistake.
 
369
 
370
- - Added a default option for the Translator alingment. Previously, this was causing the plugin to disapppear.
 
371
 
372
- 2.4
 
373
 
374
- - Found a couple of small display errors in the settings page after uploading version 2.3. Sorry for any inconvenience!
 
375
 
376
- 2.3
 
377
 
378
- - Added a "Preview" area on the settings page that allows you to see your settings in action.
 
379
 
380
- - Added custom flag support for all languages (custom flags available ONLY when selecting the "ALL Languages" setting.
381
-
382
- - Added an option that allows left/right alignment of the translation tool.
383
-
384
- - Added the "Google Language Translator" widget.
385
-
386
- - Updated googlelanguagetranslator.php to properly register setting in the admin settings panel.
387
-
388
- 2.2
389
-
390
- - Added language "Portuguese" and "German" to the Original Language drop-down option on the settings page.
391
-
392
- - Changed flag image for the English language (changed United States flag to the United Kingdom flag).
393
-
394
- - Added link in the settings panel that points to Google's Attribution Policy.
395
-
396
- 2.1
397
-
398
- - Added language "Dutch" to the Original Language drop-down option on the settings page.
399
-
400
- - 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.
401
-
402
- 2.0 Corrected some immediate errors in the 1.9 update.
403
-
404
- 1.9
405
-
406
- - 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).
407
-
408
- - Added 6 additional languages to the translator, as provided in Google's most recent updates ( new languages include Bosnian, Cebuano, Khmer, Marathi, Hmong, Javanese ).
409
-
410
- - Corrected a minor technical issue where the Czech option (on the backend) was incorrectly displaying the Croatian language on the front end.
411
-
412
- - Added jQuery functionality to the settings panel to improve the user experience.
413
-
414
- - Added an option for users to display/hide the flag images.
415
-
416
- - Added an option for users to display/hide the translate box when flags are displayed.
417
-
418
- - Removed the settings.css file - I found a better way of displaying the options without CSS.
419
-
420
- 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.
421
-
422
- 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.
423
-
424
- 1.6 Added "Specific Language" support to the plugin settings, which allows the user to choose specific languages that are displayed to website visitors.
425
-
426
- 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.
427
-
428
- 1.4 Corrected display problems associated with CSS styles not being placed correctly in wp_head.
429
-
430
- 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.
431
-
432
- 1.2 Shortcode support is now available for adding [google-translator] to text widgets. I apologize for any inconvenience this may have caused.
433
-
434
- 1.1 The shortcode supplied on the settings page was updated to display '[google-translator]'.
435
 
436
  == Screenshots ==
437
-
438
  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: edo888
3
+ Donate link: https://gtranslate.io/?xyz=3167#pricing
4
  Author: Translate AI Multilingual Solutions
5
+ Author URI: https://gtranslate.io/?xyz=3167
6
  Tags: translate wordpress, translate, translator, translation, language, multi language
7
  Requires at least: 2.9
8
+ Tested up to: 5.2
9
+ Stable tag: 6.0.0
10
 
11
+ Translate WordPress with Google Language Translator multilanguage plugin which allows to insert Google Translate widget anywhere on your website.
12
 
13
  == Description ==
14
 
15
+ Google Language Translator plugin is now a part of GTranslate family!
16
+
17
+ GTranslate is a leading website translation services provider since 2008 and powers more than 500.000 multilingual websites worldwide.
18
+
19
+ Please use [Google Language Translator Support](https://wordpress.org/support/plugin/google-language-translator/) for your questions and support requests! We are multilingual!
20
+
21
+ Please check our [FAQ](https://gtranslate.io/?xyz=998#faq) to get quick answers.
22
+
23
+ **Features**
24
+
25
+ * Free Google automatic machine translation
26
+ * Hides "Suggest better translation" pop-up
27
+ * Hides Google top frame after translation
28
+ * Google Analytics integration
29
+ * Translates the site on the fly
30
+ * Posts and pages translation
31
+ * Categories and tags translation
32
+ * Menus and widgets translation
33
+ * Themes and plugins translation
34
+ * Right to left language support
35
+ * Floating language selector
36
+ * Language bar with flags in menu
37
+ * WooCommerce shop translation
38
+
39
+ **Paid Features**
40
+
41
+ * Multilingual SEO - Enable search engine indexing
42
+ * Neural machine translations with human level translation quality
43
+ * Increase traffic and AdSense revenue
44
+ * Search engine friendly (SEF) URLs
45
+ * Yoast SEO compatible
46
+ * WooCommerce compatible
47
+ * You can have sub-directory (example.com/**es**/) or sub-domain (**es.**example.com) URL structure
48
+ * URL Translation aka slug translation is possible (example.com/about-us &rarr; example.es/sobre-nosotros)
49
+ * Add hreflang tags for translated alternatives
50
+ * You can manually correct translations
51
+ * In context translation interface (make corrections without losing the context)
52
+ * Meta data translation (meta keywords, meta description)
53
+ * Translating schema.org microdata for better search engine appearance
54
+ * Seamless updates (cloud service updated on our side - SaaS, you do not need to worry about backups on your side)
55
+ * JSON format translation
56
+ * AMP translation (Accelerated Mobile Pages translation)
57
+ * Image localization - Media translation
58
+ * Translation Proxy (aka Translation Delivery Network)
59
+ * Centralized Translation Cache - We revise and improve translations over time
60
+ * Language Hosting (**example.fr**)
61
+ * User Dashboard with Analytics
62
+ * Live Chat Support
63
 
64
  == Installation ==
 
65
  1. Download the zip folder named google-language-translator.zip
66
  2. Unzip the folder and put it in the plugins directory of your wordpress installation. (wp-content/plugins).
67
  3. Activate the plugin through the plugin window in the admin panel.
70
  6. Do not use the shortcode twice on a single page - it will not work.
71
 
72
  == Frequently Asked Questions ==
73
+ = What should I do if the translate widget does not show on my website? =
 
 
74
  1. Make sure that the plugin is installed and activated.
75
  2. Verify that a check mark is placed in the activation setting located at "Settings > Google Language Translator".
76
  3. Verify that the native Wordpress function, wp_footer(), is included in your theme's footer file.
77
  4. Verify that "Show Language Box?" setting is enabled at "Settings > Google Language Translator".
78
  5. Use your browser's web tools to ensure that CSS styles are not hiding the translation widget.
79
+ 6. Contact support at https://gtranslate.io/?xyz=3167#contact
 
 
80
 
81
+ = What should I do if there are no languages being displayed in the language box? =
82
  1. Make sure that the plugin is installed and activated.
83
  2. Verify that a check mark is placed in the activation setting located at "Settings > Google Language Translator".
84
+ 3. Contact support at https://gtranslate.io/?xyz=3167#contact
 
85
 
86
+ = Can I exclude certain areas of my website from being translated? =
87
+ 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>
 
88
 
89
  == Changelog ==
90
+ = 6.0.0 =
91
+ * Added SEO features (paid only): search engines can index translated pages, URL/slug translation, define hreflang tags
92
+ * Added Live Chat support by GTranslate support team directly in the plugin settings page
93
+ * Google Analytics feature is now on by default
94
+ * Settings page updated for better user experience
95
 
96
+ = 5.0.49 =
97
+ * Added new contributor to the plugin's readme.txt.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
+ = 5.0.48 =
100
+ * Added new setting: Floating Widget Text Color.
101
 
102
+ = 5.0.47 =
103
+ * Fixed an undefined index error in google-language-translator.php.
104
 
105
+ = 5.0.46 =
106
+ * Added new setting: Language Switcher Background Color.
107
 
108
+ = 5.0.45 =
109
+ * Added new setting: Floating Widget background color.
110
+ * Removed border-radius from the floating widget for a more standard look and feel. Please email me if you need the CSS to add back rounded edges.
111
 
112
+ = 5.0.44 =
113
+ * Added new setting: Language Switcher Text Color.
114
 
115
+ = 5.0.43 =
116
+ * Added new setting: Floating Widget position.
117
 
118
+ = 5.0.42 =
119
+ * Added new setting: langauge switcher width.
120
+ * Removed most javascript away from the document body, and into an external javascript file, scripts.js.
121
+ * Added plugin version information to be appended to script and stylesheet files.
122
 
123
+ = 5.0.41 =
124
+ * Re-factored code in google-language-translator.php to remove the duplicate id "flags".
125
 
126
+ = 5.0.40 =
127
+ * Fixed a minor 'undefined index' error in google-language-translator.php
 
 
 
 
128
 
129
+ = 5.0.39 =
130
+ * Fixed a CSS issue associated with the settings panel changes from the previous update.
131
 
132
+ = 5.0.38 =
133
+ * Fixed a CSS issue associated with the settings panel changes from the previous update. Flags were not aligning properly with align left/right settings.
134
 
135
+ = 5.0.37 =
136
+ * Made some additional adjustments in code for the settings page.
 
137
 
138
+ = 5.0.36 =
139
+ * Removed undefined variable PHP errors.
140
 
141
+ = 5.0.35 =
142
+ * Updated the plugin to delete an unused option from the database, used in the settings panel.
 
143
 
144
+ = 5.0.34 =
145
+ * Updated the settings panel to function more logically. Now users choose the languages they want, and can turn on/off flags associated with those langauges.
 
 
146
 
147
+ = 5.0.33 =
148
+ * Removed a deprecated jQuery function, and replaced with updated code in the footer_script() function.
149
 
150
+ = 5.0.32 =
151
+ * Fixed the issue with menu translation not working on some mobile devices.
152
+ * Moved element.js script to the footer.
 
 
153
 
154
+ = 5.0.31 =
155
+ * Fixed an issue with menu shortcode not displaying the correct flag choice (i.e. for English/Spanish/Portuguese flags).
 
156
 
157
+ = 5.0.30 =
158
+ * Organized the settings page into sections.
159
+ * Upgraded Wordpress.org plugin banner.
160
+ * Added additional attributes to single language shortcodes. Users now have ability to display flag images, change flag sizes, or show/hide the text label.
161
+ * Changed Chinese (Traditional) language flag to the Flag of Taiwan.
162
+ * Fixed a minor display issue with the Google Analytics setting in Wordpress Dashboard.
163
 
164
+ = 5.0.29 =
165
+ * Fixed CSS display issues with the floating widget.
166
 
167
+ = 5.0.28 =
168
+ * Fixed CSS display issues with the floating widget.
169
 
170
+ = 5.0.27 =
171
+ * Removed toolbar.js and flags.js and combined to existing files (to improve efficiency of page load and http requests).
172
+ * Added new setting to allow or prevent floating widget text to translate.
173
 
174
+ = 5.0.26 =
175
+ * Fixed a small error in adding the setting for Floating Widget text.
176
 
177
+ = 5.0.25 =
178
+ * Added new setting for custom text in the Floating Widget.
179
+ * Removed "notranslate" class from the Floating Widget text to allow for translation.
180
 
181
+ = 5.0.24 =
182
+ * Improved functionality for flags. Users are now returned to original language when the flag is displayed. The Google Toolbar will be hidden once returning back to the original language. The Google Toolbar will appear again when another translation is made.
183
+ * Fixed the issue with flags not functioning with SIMPLE layout.
184
+ * Removed SIMPLE layout option (which was not working properly) for browsers not using English browsers. The coding challenge for implementing this option is difficult and must be postponed until we find a practical solution.
185
 
186
+ = 5.0.23 =
187
+ * Reverted back to an older version of flags.js. We still have some bugs to work out before releasing the updated version. We apologize for the inconvenience.
 
 
188
 
189
+ = 5.0.22 =
190
+ * Changed a line of text on the settings page.
191
+ * Removed a line of redundant javascript to reduce unnecessary page load.
192
+ * Fixed an HTML attribute issue displaying in the menu shortcode.
193
+ * Improved functionality for flags. The flag for default language will now be disabled once users click it's flag. Flag will be re-enabled once user makes another translation.
194
 
195
+ = 5.0.21 =
196
+ * Added 6 new languages with their associated flags: Hawaiian, Kurdish, Kyrgyz, Luxembourgish, Pashto, and Shona. You can now use these langauges using the menu shortcode, as well.
197
+ * Added a "Select All / Clear All" feature to the settings page. No more finger cramps!
198
 
199
+ = 5.0.20 =
200
+ * Added Corsican as a new language with its associated flag.
201
 
202
+ = 5.0.19 =
203
+ * Added Frisian as a new language with its associated flag.
204
 
205
+ = 5.0.18 =
206
+ * Added Sindhi as a new language with its associated flag.
207
 
208
+ = 5.0.17 =
209
+ * Added Samoan as a new language with its associated flag.
210
+ * Added mobile-responsive CSS to the GLT settings page.
211
 
212
+ = 5.0.16 =
213
+ * Added Xhosa as a new language with its associated flag.
214
 
215
+ = 5.0.15 =
216
+ * Added Amharic as a new language with its associated flag.
 
217
 
218
+ = 5.0.14 =
219
+ * Fixed a file naming error in google-language-translator.php. This caused flags not to display - we apologize for the inconvenience.
220
 
221
+ = 5.0.13 =
222
+ * Renamed some of the wp_enqueue_script calls to include more unique file names, thus avoiding conflict with other plugins overriding these files.
223
+ * Corrected some file paths to be more accurate/secure.
224
+ * Removed WP Helpdesk logo from the settings page. We are no longer offering these services officially.
225
 
226
+ = 5.0.12 =
227
+ * Revert malicious changes made in 5.0.10
228
 
229
+ = 5.0.11 =
230
+ * Fixed incorrect link
231
 
232
+ = 5.0.10 =
233
+ * Tested up to 4.6
 
 
 
234
 
235
+ = 5.0.09 =
236
+ * Turned off error reporting. I apologize for the inconvenience.
 
237
 
238
+ = 5.0.08 =
239
+ * Added a new popup-style layout". You can find this new layout in the settings page located in "Settings > Google Language Translator".
240
 
241
+ = 5.0.07 =
242
+ * Changed the flag for Chinese(Traditional) to the Taiwanese flag. Requested long ago by a few users - thanks for your months of patience!
 
243
 
244
+ = 5.0.06 =
245
+ * Fixed a XSS Cross Scripting Vulnerability in the plugin, as requested by Wordpress.org. Unnecessary code (during testing) was being posted to the settings page, so the code was removed.
246
 
247
+ = 5.0.05 =
248
+ * Added 3 new options to the settings page: English, Spanish, and Portuguese flag image variations.
249
+ * Fixed an error with the Floating Widget: order of flags was not being honored in certain cases.
 
 
 
 
250
 
251
+ = 5.0.04 =
252
+ * Corrected the text on the settings page to reflect 91 total flags, instead of 81 flags.
253
 
254
+ = 5.0.03 =
255
+ * Added 10 new languages and associated flags: Chichewa, Kazakh, Malagasy, Malayalam, Myanmar(Burmese), Sesotho, Sinhala, Sundanese, Tajik, and Uzbek.
256
 
257
+ = 5.0.02 =
258
+ * Updated the Tamil flag to use the Indian flag, instead of Tamil Tigers flag.
259
 
260
+ = 5.0.01 =
261
+ * Updated style.css to reflect the syntax error connecting to the Chinese flag.
262
 
263
+ = 5.0.0 =
264
+ * Wordpress security updates added to the settings page [wp_nonce_field()].
265
+ * Removed 3 outside Javascript files - these files are now called upon directly from Wordpress CMS.
266
+ * Unpacked flags.js p,a,c,k,e,r code. Unknowingly, this method of coding violated Wordpress plugin policy.
267
 
268
+ = 4.0.9 =
269
+ * Replaced: incorrect Catalonian flag image, with the correct image. I apologize for any inconvenience.
270
+ * Fixed: Floating Widget issue - previously it loaded 2 times when shortcode was added, which caused it not to work.
271
 
272
+ = 4.0.8 =
273
+ * Fixed the small syntax issue related to the Google Analytics tracking number - it was another cause of the language box not displaying.
274
 
275
+ = 4.0.7 =
276
+ * Fixed a CSS error in the settings panel display.
277
+ * Fixed the coding issue when "Specific Languages" option is chosen - the shortcode was not displaying the language dropdown.
278
 
279
+ = 4.0.6 =
280
+ * Removed: "onclick" events from diplaying directly inside HTML. Converted those events to jQuery.
281
+ * Fixed the shortcode that allows adding single languages to Wordpress menus. (New example is shown on settings page.)
282
+ * Consolidated all flag images into image sprites!
283
+ * Re-designed 10 flag images to match the quality of the other flags.
284
+ * Fixed the incorrect "alt" tags associated with flag images. The "alt" tag now displays the language name.
285
+ * Modified text on the settings page - also added some lightbox pop-ups to help explain settings.
286
 
287
+ = 4.0.5 =
288
+ * Fixed: Display bug when using single language shortcode.
289
+ * Added: New link on the Plugins menu page, which links directly to Google Language Translator settings.
290
 
 
 
291
 
292
+ = 4.0.4 =
293
+ * Added NEW shortcode! Allows placement of single languages into the navigation menu, pages, and posts. See settings panel for usage details.
294
+ * Re-factored code in googlelanguagetranslator.php which reduced code to around 950 lines.
295
+ * 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.
296
+ * Updated CSS styles for the flags area to prevent themes from overriding layouts.
297
 
298
+ = 4.0.3 =
299
+ * Adjusted CSS styles for the flag display.
 
300
 
301
+ = 4.0.2 =
302
+ * Eliminated all (or most) HTML validation errors. Big improvement!
303
+ * Re-factored more code to increase efficiency.
304
+ * 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.)
305
+ * 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.
306
 
307
+ = 4.0.1 =
308
+ * Fixed PHP errors that were neglected in upgrade to 4.0.
309
+ * Added conditionals to prevent scripts from loading when the floating widget is turned off.
310
 
311
+ = 4.0 =
312
+ * Added 2 new features: 1) Drag/drop flags to re-arrange their order, and 2) Custom flag sizes (16px to 24px).
313
+ * Re-factored code in google-language-translator.php. Languages are now loaded dynamically and are not hard-coded.
314
 
315
+ = 3.0.9 =
316
+ * Added a title field to the Google Language Translator widget.
317
+ * Removed "unexpected text characters" error upon activation (due to error in activation hook).
 
 
 
 
 
318
 
319
+ = 3.0.8 =
320
+ * Added 9 new languages into the plugin (Hausa, Igbo, Maori, Mongolian, Nepali, Punjabi, Somali, Yoruba, Zulu).
321
+ * Corrected an "undefined variable" error that was being generated in Vertical and Horizontal layouts.
322
+ * Re-structured coding once again into an Object-Oriented approach.
323
+ * Moved all functions of the base class into 'googlelanguagetranslator.php' and the widget into 'widget.php'.
324
+ * Moved all javascript files into it's own JS folder.
325
+ * Fixed an display issue with "Edit Translations" - they were being hidden when "No branding" option was chosen.
326
+ * Corrected various "comma" errors in the string that outputs the script for loading the translator.
327
+ * Changed Changelog in readme.txt to show most recent changes first, instead of last.
328
 
329
+ = 3.0.7 =
330
+ * Removed an unnecessary CSS file, left over from development. Sorry for any inconvenience if you received display errors.
331
 
332
+ = 3.0.6 =
333
+ * Corrected a small display error in displaying the floating widget correctly.
334
 
335
+ = 3.0.5 =
336
+ * 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.
337
+ * Fixed the issue with Dashboard styles loading on the wrong pages. This was causing some annoying display issues on the Wordpress Dashboard.
338
+
339
+ = 3.0.4 =
340
+ * Re-factored/re-arranged more code in google languagetransltor.php by placing them into separate files.
341
+ * 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.
342
+ * Removed style2.php file, which is unnecessary and was being used in testing.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
 
344
+ = 3.0.3 =
345
+ * Re-factored/re-arranged some of the code in googlelanguagetranslator.php by placing them into separate files.
346
+ * Fixed a minor coding issue in glt_widget.php - this was generating an error in Wordpress when debugging.
347
+ * Moved all CSS code into a single file. The result is nice, clean inline CSS code that is now called only once.
348
+ * Fixed some additional CSS display issues.
349
+
350
+ = 3.0.2 =
351
+ * Adjusted additional minor invalid HTML issues on the settings page, and also in the front-end plugin display.
352
+
353
+ = 3.0.1 =
354
+ * 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.
355
+ * Adjusted some minor spacing issues in the settings page HTML (caused some annoying red HTML errors when using "View Source" in right-click menu).
356
+ * 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.
357
+
358
+ = 3.0 =
359
+ * Correct a small CSS error that affected the showing/hiding of the Google toolbar.
360
+
361
+ = 2.9 =
362
  ***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.
363
+ * Fixed Google Translation toolbar display issue
364
+ * Fixed the Edit Translation interface by hiding it temporarily until Google fixes this
365
+ * Removed some unneeded styles from the style sheet.
366
+ * Fixed some CSS issues for the Google Branding display, which was affected by Google's most recent update
367
 
368
+ = 2.8 =
369
+ * 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.
370
+ * 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.)
371
+ * Added more flexible styles to the settings page, so that left and right panels display nicely to the user.
 
 
372
 
373
+ = 2.7 =
374
+ * Added Google Analytics tracking capability to the plugin.
375
+ * Added a "CSS Styles" box in the settings panel.
376
+ * Changed the Catalonian flag to its correct flag image.
377
+ * 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.
378
+ * 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.
379
 
380
+ = 2.6 =
381
+ * Added defaults to all options to ensure there are no more issues with the translator displaying upon installation. Again, sorry for any inconvenience.
382
 
383
+ = 2.5 =
384
+ * Eliminated an internal Wordpress error being generated from a coding mistake.
385
+ * Added a default option for the Translator alingment. Previously, this was causing the plugin to disapppear.
386
 
387
+ = 2.4 =
388
+ * Found a couple of small display errors in the settings page after uploading version 2.3. Sorry for any inconvenience!
389
 
390
+ = 2.3 =
391
+ * Added a "Preview" area on the settings page that allows you to see your settings in action.
392
+ * Added custom flag support for all languages (custom flags available ONLY when selecting the "ALL Languages" setting.
393
+ * Added an option that allows left/right alignment of the translation tool.
394
+ * Added the "Google Language Translator" widget.
395
+ * Updated googlelanguagetranslator.php to properly register setting in the admin settings panel.
396
 
397
+ = 2.2 =
398
+ * Added language "Portuguese" and "German" to the Original Language drop-down option on the settings page.
399
+ * Changed flag image for the English language (changed United States flag to the United Kingdom flag).
400
+ * Added link in the settings panel that points to Google's Attribution Policy.
401
 
402
+ = 2.1 =
403
+ * Added language "Dutch" to the Original Language drop-down option on the settings page.
404
+ * 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.
405
 
406
+ = 2.0 =
407
+ * Corrected some immediate errors in the 1.9 update.
408
 
409
+ = 1.9 =
410
+ * 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).
411
+ * Added 6 additional languages to the translator, as provided in Google's most recent updates ( new languages include Bosnian, Cebuano, Khmer, Marathi, Hmong, Javanese ).
412
+ * Corrected a minor technical issue where the Czech option (on the backend) was incorrectly displaying the Croatian language on the front end.
413
+ * Added jQuery functionality to the settings panel to improve the user experience.
414
+ * Added an option for users to display/hide the flag images.
415
+ * Added an option for users to display/hide the translate box when flags are displayed.
416
+ * Removed the settings.css file - I found a better way of displaying the options without CSS.
417
 
418
+ = 1.8 =
419
+ * 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.
420
 
421
+ = 1.7 =
422
+ * 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.
423
 
424
+ = 1.6 =
425
+ * Added "Specific Language" support to the plugin settings, which allows the user to choose specific languages that are displayed to website visitors.
426
 
427
+ = 1.5 =
428
+ 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.
429
 
430
+ = 1.4 =
431
+ Corrected display problems associated with CSS styles not being placed correctly in wp_head.
432
 
433
+ = 1.3 =
434
+ * 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.
435
 
436
+ = 1.2 =
437
+ * Shortcode support is now available for adding [google-translator] to text widgets. I apologize for any inconvenience this may have caused.
438
 
439
+ = 1.1 =
440
+ * The shortcode supplied on the settings page was updated to display '[google-translator]'.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
441
 
442
  == Screenshots ==
 
443
  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.
444
+ 2. Floating language selector
445
+ 3. Flags and dropdown language selector
446
+ 4. Language selector in menu with flags
screenshot-1.png DELETED
Binary file
url_addon/cacert.pem ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDmzCCAoOgAwIBAgIJALjD5B2Tw5WVMA0GCSqGSIb3DQEBCwUAMGQxCzAJBgNV
3
+ BAYTAlVTMQswCQYDVQQIDAJDQTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEXMBUG
4
+ A1UECgwOR1RyYW5zbGF0ZSBJbmMxFzAVBgNVBAMMDmd0cmFuc2xhdGUuY29tMB4X
5
+ DTE5MDIyMDE2NDcwN1oXDTI5MDIxNzE2NDcwN1owZDELMAkGA1UEBhMCVVMxCzAJ
6
+ BgNVBAgMAkNBMRYwFAYDVQQHDA1TYW4gRnJhbmNpc2NvMRcwFQYDVQQKDA5HVHJh
7
+ bnNsYXRlIEluYzEXMBUGA1UEAwwOZ3RyYW5zbGF0ZS5jb20wggEiMA0GCSqGSIb3
8
+ DQEBAQUAA4IBDwAwggEKAoIBAQC3wWCPu05M9T9rpJR8rY/RYPEkyL5EmGUcirMe
9
+ EJncOQnv0cKEU722xBuLBN2RPT/+pM2nVcMKbp/aFbJ5PX8BR6ZXKaGDQMPHdASV
10
+ nM20yt1RJc+qNHDUL1vDvIlNfV+ux3by+k/dNNCXYj2BBzVbhqoJefHNtry3QnQ3
11
+ AJ5hf09PHKtLAMS6PeaVmHn6XfCsKK2iQ5hD6qN85C8x7GiltEJD0Np0zM9nTim2
12
+ ilQfpvF5JaDM0lf9vNJDseQ7JOlBM/WcQ3BtgbswFvq3kIMcIGTjqsw/dtNcUUpV
13
+ PsGwz797bq31aFug0J0a9DMYMgbErPlC0r6JkazU3hdBvcF7AgMBAAGjUDBOMB0G
14
+ A1UdDgQWBBTHGSln6Hs9Rk7iLECUbjMcB99b4jAfBgNVHSMEGDAWgBTHGSln6Hs9
15
+ Rk7iLECUbjMcB99b4jAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBZ
16
+ RWN7otrYojEehmjd3ybFrU95R9W4uLWV/LBUlW+sARAmunmQve0hARG8nOP0Tg4m
17
+ 5I0v1vxY1wVnYV6hi1+gba+ynBnNt7XkebqXC1Qq99WdQfi2M/a1clIbFZUJhWec
18
+ Wv5WqXaafW102b/z7syZkRtrtZ6YhGSMtwd071C9KQbE025wqDVM2TioL6viSpZG
19
+ YDYks7e7ogS4fUAorODAxT0FZ1GZM0HaZ/XQG33SpoG5saHHxflMqTh4dLcnh5KN
20
+ W++ZZCwEYKrLi5slHjlyciZU7EWJNLWOnqNMZUxLX2yZ/hh9idzazEzm9IoQYrGP
21
+ dAifs/vxi/FmcAllKc1Y
22
+ -----END CERTIFICATE-----
url_addon/config.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Specify the original language code of your website
3
+ $main_lang = 'en';
4
+
5
+ /*
6
+ List of available language codes:
7
+
8
+ en -> English
9
+ ar -> Arabic
10
+ bg -> Bulgarian
11
+ zh-CN -> Chinese (Simplified)
12
+ zh-TW -> Chinese (Traditional)
13
+ hr -> Croatian
14
+ cs -> Czech
15
+ da -> Danish
16
+ nl -> Dutch
17
+ fi -> Finnish
18
+ fr -> French
19
+ de -> German
20
+ el -> Greek
21
+ hi -> Hindi
22
+ it -> Italian
23
+ ja -> Japanese
24
+ ko -> Korean
25
+ no -> Norwegian
26
+ pl -> Polish
27
+ pt -> Portuguese
28
+ ro -> Romanian
29
+ ru -> Russian
30
+ es -> Spanish
31
+ sv -> Swedish
32
+ ca -> Catalan
33
+ tl -> Filipino
34
+ iw -> Hebrew
35
+ id -> Indonesian
36
+ lv -> Latvian
37
+ lt -> Lithuanian
38
+ sr -> Serbian
39
+ sk -> Slovak
40
+ sl -> Slovenian
41
+ uk -> Ukrainian
42
+ vi -> Vietnamese
43
+ sq -> Albanian
44
+ et -> Estonian
45
+ gl -> Galician
46
+ hu -> Hungarian
47
+ mt -> Maltese
48
+ th -> Thai
49
+ tr -> Turkish
50
+ fa -> Persian
51
+ af -> Afrikaans
52
+ ms -> Malay
53
+ sw -> Swahili
54
+ ga -> Irish
55
+ cy -> Welsh
56
+ be -> Belarusian
57
+ is -> Icelandic
58
+ mk -> Macedonian
59
+ yi -> Yiddish
60
+ hy -> Armenian
61
+ az -> Azerbaijani
62
+ eu -> Basque
63
+ ka -> Georgian
64
+ ht -> Haitian Creole
65
+ ur -> Urdu
66
+ bn -> Bengali
67
+ bs -> Bosnian
68
+ ceb -> Cebuano
69
+ eo -> Esperanto
70
+ gu -> Gujarati
71
+ ha -> Hausa
72
+ hmn -> Hmong
73
+ ig -> Igbo
74
+ jw -> Javanese
75
+ kn -> Kannada
76
+ km -> Khmer
77
+ lo -> Lao
78
+ la -> Latin
79
+ mi -> Maori
80
+ mr -> Marathi
81
+ mn -> Mongolian
82
+ ne -> Nepali
83
+ pa -> Punjabi
84
+ so -> Somali
85
+ ta -> Tamil
86
+ te -> Telugu
87
+ yo -> Yoruba
88
+ zu -> Zulu
89
+ my -> Myanmar (Burmese)
90
+ ny -> Chichewa
91
+ kk -> Kazakh
92
+ mg -> Malagasy
93
+ ml -> Malayalam
94
+ si -> Sinhala
95
+ st -> Sesotho
96
+ su -> Sudanese
97
+ tg -> Tajik
98
+ uz -> Uzbek
99
+ am -> Amharic
100
+ co -> Corsican
101
+ haw -> Hawaiian
102
+ ku -> Kurdish (Kurmanji)
103
+ ky -> Kyrgyz
104
+ lb -> Luxembourgish
105
+ ps -> Pashto
106
+ sm -> Samoan
107
+ gd -> Scottish Gaelic
108
+ sn -> Shona
109
+ sd -> Sindhi
110
+ fy -> Frisian
111
+ xh -> Xhosa
112
+ */
113
+
114
+ $servers = array('van', 'kars', 'sis', 'dvin', 'ani', 'evn');
115
+ $debug = false;
url_addon/debug.txt ADDED
File without changes
url_addon/gtranslate.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ error_reporting(0);
3
+
4
+ include 'config.php';
5
+
6
+ if(!isset($_GET['glang']) or !isset($_GET['gurl']))
7
+ exit;
8
+
9
+ $glang = $_GET['glang'];
10
+
11
+ // pick a server based on hostname
12
+ $server_id = intval(substr(md5(preg_replace('/^www\./', '', $_SERVER['HTTP_HOST'])), 0, 5), 16) % count($servers);
13
+ $server = $servers[$server_id];
14
+
15
+ $page_url = '/'.$_GET['gurl'];
16
+
17
+ $page_url_segments = explode('/', $page_url);
18
+ foreach($page_url_segments as $i => $segment) {
19
+ $page_url_segments[$i] = rawurlencode($segment);
20
+ }
21
+ $page_url = implode('/', $page_url_segments);
22
+
23
+ $get_params = $_GET;
24
+ if(isset($get_params['glang']))
25
+ unset($get_params['glang']);
26
+ if(isset($get_params['gurl']))
27
+ unset($get_params['gurl']);
28
+
29
+ if(count($get_params)) {
30
+ $page_url .= '?' . http_build_query($get_params);
31
+ }
32
+
33
+ $main_lang = isset($data['default_language']) ? $data['default_language'] : $main_lang;
34
+
35
+ if($glang == $main_lang) {
36
+ $page_url = preg_replace('/^[\/]+/', '/', $page_url);
37
+
38
+ header('Location: ' . $page_url, true, 301);
39
+ exit;
40
+ }
41
+
42
+ $page_url = $server.'.tdn.gtranslate.net' . $page_url;
43
+
44
+ $protocol = ((isset($_SERVER['HTTPS']) and ($_SERVER['HTTPS'] == 'on' or $_SERVER['HTTPS'] == 1)) or (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https' : 'http';
45
+ $page_url = $protocol . '://' . $page_url;
46
+
47
+ if(!in_array(strtolower($glang), array('en','ar','bg','zh-cn','zh-tw','hr','cs','da','nl','fi','fr','de','el','hi','it','ja','ko','no','pl','pt','ro','ru','es','sv','ca','tl','iw','id','lv','lt','sr','sk','sl','uk','vi','sq','et','gl','hu','mt','th','tr','fa','af','ms','sw','ga','cy','be','is','mk','yi','hy','az','eu','ka','ht','ur','bn','bs','ceb','eo','gu','ha','hmn','ig','jw','kn','km','lo','la','mi','mr','mn','ne','pa','so','ta','te','yo','zu','my','ny','kk','mg','ml','si','st','su','tg','uz','am','co','haw','ku','ky','lb','ps','sm','gd','sn','sd','fy','xh')))
48
+ exit;
49
+
50
+ if(!function_exists("getallheaders")) {
51
+ //Adapted from http://www.php.net/manual/en/function.getallheaders.php#99814
52
+ function getallheaders() {
53
+ $result = array();
54
+ foreach($_SERVER as $key => $value) {
55
+ if (substr($key, 0, 5) == "HTTP_") {
56
+ $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
57
+ $result[$key] = $value;
58
+ } else if ($key == "CONTENT_TYPE") {
59
+ $result["Content-Type"] = $value;
60
+ }
61
+ }
62
+ return $result;
63
+ }
64
+ }
65
+
66
+ $request_headers = getallheaders();
67
+
68
+ if(isset($request_headers['X-GT-Lang']) or isset($request_headers['X-Gt-Lang']) or isset($request_headers['x-gt-lang'])) {
69
+ echo 'Please remove DNS cname records for GTranslate!';
70
+ exit;
71
+ }
72
+
73
+ $host = $glang . '.' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
74
+ $request_headers['Host'] = $host;
75
+ if(isset($request_headers['HOST'])) unset($request_headers['HOST']);
76
+ if(isset($request_headers['host'])) unset($request_headers['host']);
77
+
78
+ if(!function_exists('gzdecode'))
79
+ $request_headers['Accept-Encoding'] = '';
80
+ else
81
+ $request_headers['Accept-Encoding'] = 'gzip';
82
+
83
+ if(isset($request_headers['accept-encoding'])) unset($request_headers['accept-encoding']);
84
+
85
+ if(isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
86
+ $request_headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
87
+ if(isset($request_headers['authorization'])) unset($request_headers['authorization']);
88
+ }
89
+ //print_r($request_headers);
90
+ //exit;
91
+
92
+ if(isset($request_headers['content-type'])) {
93
+ $request_headers['Content-Type'] = $request_headers['content-type'];
94
+ unset($request_headers['content-type']);
95
+ }
96
+
97
+ if(isset($request_headers['Content-Type']) and strpos($request_headers['Content-Type'], 'multipart/form-data;') !== false) {
98
+ //$request_headers['Content-Type'] = 'multipart/form-data'; // remove boundary
99
+ $request_headers['Content-Type'] = 'application/x-www-form-urlencoded';
100
+ $is_multipart = true;
101
+ $request_headers['Content-Length'] = '';
102
+
103
+ if(isset($request_headers['content-length']))
104
+ unset($request_headers['content-length']);
105
+ }
106
+
107
+ $headers = array();
108
+ foreach($request_headers as $key => $val) {
109
+ // remove cloudflare CF headers: CF-IPCountry, CF-Ray, etc...
110
+ if(preg_match('/^CF-/i', $key))
111
+ continue;
112
+ else
113
+ $headers[] = $key . ': ' . $val;
114
+ }
115
+
116
+ // add real visitor IP header
117
+ if(isset($_SERVER['HTTP_CLIENT_IP']) and !empty($_SERVER['HTTP_CLIENT_IP']))
118
+ $viewer_ip_address = $_SERVER['HTTP_CLIENT_IP'];
119
+ if(isset($_SERVER['HTTP_CF_CONNECTING_IP']) and !empty($_SERVER['HTTP_CF_CONNECTING_IP']))
120
+ $viewer_ip_address = $_SERVER['HTTP_CF_CONNECTING_IP'];
121
+ if(isset($_SERVER['HTTP_X_SUCURI_CLIENTIP']) and !empty($_SERVER['HTTP_X_SUCURI_CLIENTIP']))
122
+ $viewer_ip_address = $_SERVER['HTTP_X_SUCURI_CLIENTIP'];
123
+ if(!isset($viewer_ip_address))
124
+ $viewer_ip_address = $_SERVER['REMOTE_ADDR'];
125
+
126
+ $headers[] = 'X-GT-Viewer-IP: ' . $viewer_ip_address;
127
+
128
+ // add X-Forwarded-For
129
+ if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) and !empty($_SERVER['HTTP_X_FORWARDED_FOR']))
130
+ $headers[] = 'X-GT-Forwarded-For: ' . $_SERVER['HTTP_X_FORWARDED_FOR'];
131
+
132
+ //print_r($headers);
133
+ //exit;
134
+
135
+ if(!function_exists('curl_init')) {
136
+ if(function_exists('http_response_code'))
137
+ http_response_code(500);
138
+
139
+ echo 'PHP Curl library is required';
140
+ exit;
141
+ }
142
+
143
+ // proxy request
144
+ $ch = curl_init();
145
+ curl_setopt($ch, CURLOPT_URL, $page_url);
146
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
147
+ curl_setopt($ch, CURLOPT_HEADER, true);
148
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
149
+ //curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
150
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
151
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
152
+ curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/cacert.pem');
153
+
154
+ switch($_SERVER['REQUEST_METHOD']) {
155
+ case 'POST': {
156
+ curl_setopt($ch, CURLOPT_POST, true);
157
+ if(isset($is_multipart)) {
158
+ http_build_query_for_curl($_POST, $new_post);
159
+ $new_post2 = array();
160
+ foreach($new_post as $key => $value)
161
+ $new_post2[] = $key.'='.urlencode($value);
162
+ $new_post = implode('&', $new_post2);
163
+ $headers[] = 'Content-Length: '.strlen($new_post);
164
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
165
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $new_post);
166
+
167
+ } elseif(isset($request_headers['Content-Type']) and strpos($request_headers['Content-Type'], 'multipart/form-data') !== false) {
168
+ http_build_query_for_curl($_POST, $new_post);
169
+
170
+ $new_post = array('a'=>1,'b'=>2);
171
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $new_post); // todo: think about $_FILES: http://php.net/manual/en/class.curlfile.php
172
+ //curl_setopt($ch, CURLOPT_HTTPHEADER, array());
173
+ file_put_contents(dirname(__FILE__).'/debug.txt', print_r($new_post, true)."\n", FILE_APPEND);
174
+ } else {
175
+ curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('php://input'));
176
+ }
177
+ }; break;
178
+
179
+ case 'PUT': {
180
+ curl_setopt($ch, CURLOPT_PUT, true);
181
+ curl_setopt($ch, CURLOPT_INFILE, fopen('php://input', 'r'));
182
+ }; break;
183
+ }
184
+
185
+ // Debug
186
+ if($debug or isset($_GET['enable_debug'])) {
187
+ $fh = fopen(dirname(__FILE__).'/debug.txt', 'a');
188
+ curl_setopt($ch, CURLOPT_VERBOSE, true);
189
+ curl_setopt($ch, CURLOPT_STDERR, $fh);
190
+ }
191
+
192
+ $response = curl_exec($ch);
193
+ $response_info = curl_getinfo($ch);
194
+ curl_close($ch);
195
+
196
+ //print_r($response_info);
197
+
198
+ $header_size = $response_info['header_size'];
199
+ $header = substr($response, 0, $header_size);
200
+ $html = substr($response, $header_size);
201
+
202
+ if(function_exists('gzdecode')) {
203
+ $return_gz = false;
204
+ $html_gunzip = @gzdecode($html);
205
+
206
+ if($html_gunzip !== false) {
207
+ $html = $html_gunzip;
208
+ unset($html_gunzip);
209
+
210
+ if(strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {
211
+ $return_gz = true;
212
+ header('Content-Encoding: gzip');
213
+ header('Vary: Accept-Encoding');
214
+ }
215
+ }
216
+ }
217
+
218
+ $response_headers = explode(PHP_EOL, $header);
219
+ //print_r($response_headers);
220
+ $headers_sent = '';
221
+ foreach($response_headers as $header) {
222
+ if(!empty($header) and !preg_match('/Content\-Length:|Transfer\-Encoding:|Content\-Encoding:|Link:/i', $header)) {
223
+
224
+ if(preg_match('/^Location:/i', $header)) {
225
+ $header = str_ireplace($host, $_SERVER['HTTP_HOST'] . '/' . $glang, $header);
226
+ $header = str_ireplace('Location: /', 'Location: /' . $glang . '/', $header);
227
+ $header = str_replace('/' . $glang . '/' . $glang . '/', '/' . $glang . '/', $header);
228
+ }
229
+
230
+ // woocommerce cookie path fix
231
+ if(preg_match('/^Set-Cookie:/i', $header) and strpos($header, 'woocommerce') !== false) {
232
+ $header = preg_replace('/path=\/.*\/;/', 'path=/;', $header);
233
+ }
234
+
235
+ $headers_sent .= $header;
236
+ header($header, false);
237
+ }
238
+ }
239
+ //echo $headers_sent;
240
+
241
+ // TODO: modify URLs
242
+ $html = str_ireplace($host, $_SERVER['HTTP_HOST'] . '/' . $glang, $html);
243
+ $html = str_ireplace('href="/', 'href="/' . $glang . '/', $html);
244
+ $html = preg_replace('/href=\"\/' . $glang . '\/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)\//i', 'href="/$1/', $html); // fix double language code
245
+ $html = str_ireplace('href="/' . $glang . '//', 'href="//', $html);
246
+ $html = str_ireplace('action="/', 'action="/' . $glang . '/', $html);
247
+ $html = str_ireplace('action=\'/', 'action=\'/' . $glang . '/', $html);
248
+ $html = str_ireplace('action="/' . $glang . '//', 'action="//', $html);
249
+ $html = str_ireplace('action=\'/' . $glang . '//', 'action=\'//', $html);
250
+ $html = str_ireplace('action="//' . $_SERVER['HTTP_HOST'], 'action="//' . $_SERVER['HTTP_HOST'] . '/' . $glang, $html);
251
+ $html = str_ireplace('action=\'//' . $_SERVER['HTTP_HOST'], 'action=\'//' . $_SERVER['HTTP_HOST'] . '/' . $glang, $html);
252
+
253
+ // woocommerce specific changes
254
+ $html = str_ireplace(
255
+ array('ajax_url":"\\/', '"checkout_url":"\\/' ),
256
+ array('ajax_url":"\\/'.$glang.'\\/', '"checkout_url":"\\/'.$glang.'\\/' ),
257
+ $html
258
+ );
259
+
260
+ if(isset($_GET['language_edit'])) {
261
+ $html = str_replace('/tdn-static/', $protocol . '://tdns.gtranslate.net/tdn-static/', $html);
262
+ $html = str_replace('/tdn-bin/', $protocol . '://' . $_SERVER['HTTP_HOST'] . '/' . $glang . '/tdn-bin/', $html);
263
+ }
264
+
265
+ if(function_exists('gzencode') and isset($return_gz) and $return_gz and zlib_get_coding_type() == false)
266
+ echo gzencode($html);
267
+ else
268
+ echo $html;
269
+
270
+ function http_build_query_for_curl($arrays, &$new = array(), $prefix = null) { // flatten multidimentional array for post
271
+ if(is_object($arrays)) {
272
+ $arrays = get_object_vars($arrays);
273
+ }
274
+
275
+ foreach($arrays AS $key => $value) {
276
+ $k = isset($prefix) ? $prefix . '[' . $key . ']' : $key;
277
+ if(is_array($value) or is_object($value)) {
278
+ http_build_query_for_curl($value, $new, $k);
279
+ } else {
280
+ $new[$k] = $value;
281
+ }
282
+ }
283
+ }
url_addon/rewrite.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ ### BEGIN GTranslate config ###
2
+ RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(.*)$ /$1/$3 [R=301,L]
3
+ RewriteCond %{REQUEST_FILENAME} !-f
4
+ RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(.*)$ GLT_PLUGIN_PATH/url_addon/gtranslate.php?glang=$1&gurl=$2 [L,QSA]
5
+ RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)$ /$1/ [R=301,L]
6
+ ### END GTranslate config ###
widget.php CHANGED
@@ -1,39 +1,40 @@
1
  <?php
2
- class glt_widget extends WP_Widget {
3
- function __construct() {
4
  parent::__construct(
5
- 'glt_widget', __('Google Language Translator', 'text_domain'), array( 'description' => __( 'Add the Google Language Translator website tool.', 'text_domain' ), )
6
  );
7
- }
8
 
9
- public function widget( $args, $instance ) {
10
- $title = apply_filters( 'widget_title', $instance['title'] );
11
- echo $args['before_widget'];
12
- if ( ! empty( $title ) )
13
- echo $args['before_title'] . $title . $args['after_title'];
14
- echo do_shortcode('[google-translator]');
15
- echo $args['after_widget'];
16
- }
17
 
18
- public function form( $instance ) {
19
- if ( isset( $instance[ 'title' ] ) ) {
20
- $title = $instance[ 'title' ];
21
- } else {
22
- $title = __( 'Translate:', 'text_domain' );
23
- } ?>
24
 
25
  <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label><input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"></p>
26
- <?php
27
- }
28
-
29
- public function update( $new_instance, $old_instance ) {
30
- $instance = array();
31
- $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
32
- return $instance;
33
- }
34
  } // class glt_widget
35
 
36
  function register_glt_widget() {
37
  register_widget( 'glt_widget' );
38
  }
 
39
  add_action( 'widgets_init', 'register_glt_widget' );
1
  <?php
2
+ class glt_widget extends WP_Widget {
3
+ function __construct() {
4
  parent::__construct(
5
+ 'glt_widget', __('Google Language Translator', 'text_domain'), array( 'description' => __( 'Add the Google Language Translator website tool.', 'text_domain' ), )
6
  );
7
+ }
8
 
9
+ public function widget( $args, $instance ) {
10
+ $title = apply_filters( 'widget_title', $instance['title'] );
11
+ echo $args['before_widget'];
12
+ if ( ! empty( $title ) )
13
+ echo $args['before_title'] . $title . $args['after_title'];
14
+ echo do_shortcode('[google-translator]');
15
+ echo $args['after_widget'];
16
+ }
17
 
18
+ public function form( $instance ) {
19
+ if ( isset( $instance[ 'title' ] ) ) {
20
+ $title = $instance[ 'title' ];
21
+ } else {
22
+ $title = __( 'Translate:', 'text_domain' );
23
+ } ?>
24
 
25
  <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label><input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"></p>
26
+ <?php
27
+ }
28
+
29
+ public function update( $new_instance, $old_instance ) {
30
+ $instance = array();
31
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
32
+ return $instance;
33
+ }
34
  } // class glt_widget
35
 
36
  function register_glt_widget() {
37
  register_widget( 'glt_widget' );
38
  }
39
+
40
  add_action( 'widgets_init', 'register_glt_widget' );