Translate WordPress with GTranslate - Version 2.9.5

Version Description

  • Fix for javascript error introduced in 2.9.4
Download this release

Release Info

Developer edo888
Plugin Icon 128x128 Translate WordPress with GTranslate
Version 2.9.5
Comparing to
See all releases

Code changes from version 2.9.3 to 2.9.5

Files changed (2) hide show
  1. gtranslate.php +183 -48
  2. readme.txt +9 -1
gtranslate.php CHANGED
@@ -3,14 +3,14 @@
3
  Plugin Name: GTranslate
4
  Plugin URI: https://gtranslate.io/?xyz=998
5
  Description: Makes your website <strong>multilingual</strong> and available to the world using Google Translate. For support visit <a href="https://wordpress.org/support/plugin/gtranslate">GTranslate Support</a>.
6
- Version: 2.9.3
7
  Author: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
10
 
11
  */
12
 
13
- /* Copyright 2010 - 2020 Edvard Ananyan (email : edo888@gmail.com)
14
 
15
  This program is free software; you can redistribute it and/or modify
16
  it under the terms of the GNU General Public License as published by
@@ -299,6 +299,49 @@ if(language_codes2.length == 0)
299
 
300
  var languages_map = {en_x: 0, en_y: 0, ar_x: 100, ar_y: 0, bg_x: 200, bg_y: 0, zhCN_x: 300, zhCN_y: 0, zhTW_x: 400, zhTW_y: 0, hr_x: 500, hr_y: 0, cs_x: 600, cs_y: 0, da_x: 700, da_y: 0, nl_x: 0, nl_y: 100, fi_x: 100, fi_y: 100, fr_x: 200, fr_y: 100, de_x: 300, de_y: 100, el_x: 400, el_y: 100, hi_x: 500, hi_y: 100, it_x: 600, it_y: 100, ja_x: 700, ja_y: 100, ko_x: 0, ko_y: 200, no_x: 100, no_y: 200, pl_x: 200, pl_y: 200, pt_x: 300, pt_y: 200, ro_x: 400, ro_y: 200, ru_x: 500, ru_y: 200, es_x: 600, es_y: 200, sv_x: 700, sv_y: 200, ca_x: 0, ca_y: 300, tl_x: 100, tl_y: 300, iw_x: 200, iw_y: 300, id_x: 300, id_y: 300, lv_x: 400, lv_y: 300, lt_x: 500, lt_y: 300, sr_x: 600, sr_y: 300, sk_x: 700, sk_y: 300, sl_x: 0, sl_y: 400, uk_x: 100, uk_y: 400, vi_x: 200, vi_y: 400, sq_x: 300, sq_y: 400, et_x: 400, et_y: 400, gl_x: 500, gl_y: 400, hu_x: 600, hu_y: 400, mt_x: 700, mt_y: 400, th_x: 0, th_y: 500, tr_x: 100, tr_y: 500, fa_x: 200, fa_y: 500, af_x: 300, af_y: 500, ms_x: 400, ms_y: 500, sw_x: 500, sw_y: 500, ga_x: 600, ga_y: 500, cy_x: 700, cy_y: 500, be_x: 0, be_y: 600, is_x: 100, is_y: 600, mk_x: 200, mk_y: 600, yi_x: 300, yi_y: 600, hy_x: 400, hy_y: 600, az_x: 500, az_y: 600, eu_x: 600, eu_y: 600, ka_x: 700, ka_y: 600, ht_x: 0, ht_y: 700, ur_x: 100, ur_y: 700};
301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  function RefreshDoWidgetCode() {
303
  var new_line = "\\n";
304
  var widget_preview = '<!-- GTranslate: https://gtranslate.io/ -->'+new_line;
@@ -310,11 +353,12 @@ function RefreshDoWidgetCode() {
310
  var monochrome_flags = jQuery('#monochrome_flags:checked').length > 0 ? true : false;
311
  var pro_version = jQuery('#pro_version:checked').length > 0 ? true : false;
312
  var enterprise_version = jQuery('#enterprise_version:checked').length > 0 ? true : false;
 
 
313
  var new_window = jQuery('#new_window:checked').length > 0 ? true : false;
314
  var show_in_menu = jQuery('#show_in_menu').val();
315
  var floating_language_selector = jQuery('#floating_language_selector').val();
316
  var native_language_names = jQuery('#native_language_names:checked').length > 0 ? true : false;
317
- var analytics = jQuery('#analytics:checked').length > 0 ? true : false;
318
  var detect_browser_language = jQuery('#detect_browser_language:checked').length > 0 ? true : false;
319
  var email_translation = jQuery('#email_translation:checked').length > 0 ? true : false;
320
  var switcher_text_color = jQuery('#switcher_text_color').val();
@@ -335,20 +379,32 @@ function RefreshDoWidgetCode() {
335
 
336
  if(pro_version || enterprise_version) {
337
  translation_method = 'redirect';
 
 
 
 
 
 
 
 
 
 
 
338
  jQuery('#new_window_option').show();
339
  jQuery('#url_translation_option').show();
340
  jQuery('#hreflang_tags_option').show();
341
  jQuery('#email_translation_option').show();
342
  if(email_translation)
343
  jQuery('#email_translation_debug_option').show();
344
- //jQuery('#auto_switch_option').hide();
 
345
  } else {
 
346
  jQuery('#new_window_option').hide();
347
  jQuery('#url_translation_option').hide();
348
  jQuery('#hreflang_tags_option').hide();
349
  jQuery('#email_translation_option').hide();
350
  jQuery('#email_translation_debug_option').hide();
351
- //jQuery('#auto_switch_option').show();
352
  }
353
 
354
  if(widget_look == 'dropdown' || widget_look == 'flags_dropdown' || widget_look == 'globe' || widget_look == 'lang_names' || widget_look == 'lang_codes') {
@@ -419,8 +475,12 @@ function RefreshDoWidgetCode() {
419
  if(pro_version) {
420
  href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(0, 3).join('/'), '$site_url'.split('/').slice(0, 3).join('/')+'/'+lang);
421
  if(lang != default_language && href.endsWith('/'+lang)) href += '/';
422
- } else if(enterprise_version)
423
- href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(2, 3)[0].replace('www.', ''), lang + '.' + '$site_url'.split('/').slice(2, 3)[0].replace('www.', '')).replace('://www.', '://');
 
 
 
 
424
 
425
  widget_preview += '<a href="'+href+'" onclick="doGTranslate(\''+default_language+'|'+lang+'\');return false;" title="'+lang_name+'" class="glink nturl notranslate">';
426
 
@@ -579,8 +639,12 @@ function RefreshDoWidgetCode() {
579
  if(pro_version) {
580
  href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(0, 3).join('/'), '$site_url'.split('/').slice(0, 3).join('/')+'/'+lang);
581
  if(lang != default_language && href.endsWith('/'+lang)) href += '/';
582
- } else if(enterprise_version)
583
- href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(2, 3)[0].replace('www.', ''), lang + '.' + '$site_url'.split('/').slice(2, 3)[0].replace('www.', '')).replace('://www.', '://');
 
 
 
 
584
 
585
  widget_preview += '<a href="'+href+'" onclick="changeGTLanguage(\''+default_language+'|'+lang+'\', this);return false;" title="'+lang_name+'" class="glink nturl'+(default_language == lang ? ' selected' : '')+'">';
586
 
@@ -739,8 +803,12 @@ function RefreshDoWidgetCode() {
739
  if(pro_version) {
740
  href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(0, 3).join('/'), '$site_url'.split('/').slice(0, 3).join('/')+'/'+lang);
741
  if(lang != default_language && href.endsWith('/'+lang)) href += '/';
742
- } else if(enterprise_version)
743
- href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(2, 3)[0].replace('www.', ''), lang + '.' + '$site_url'.split('/').slice(2, 3)[0].replace('www.', '')).replace('://www.', '://');
 
 
 
 
744
 
745
  widget_preview += '<a href="'+href+'" onclick="doGTranslate(\''+default_language+'|'+lang+'\');jQuery(\'div.switcher div.selected a\').html(jQuery(this).html());return false;" title="'+lang_name+'" class="nturl'+(default_language == lang ? ' selected' : '')+'">';
746
 
@@ -780,33 +848,26 @@ function RefreshDoWidgetCode() {
780
  widget_code += '<script>'+new_line;
781
  if(pro_version && translation_method == 'redirect' && new_window) {
782
  widget_code += "function openTab(url) {var form=document.createElement('form');form.method='post';form.action=url;form.target='_blank';document.body.appendChild(form);form.submit();}"+new_line;
783
- if(analytics)
784
- widget_code += "function doGTranslate(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+"')openTab(location.protocol+'//'+location.host+gt_request_uri);else openTab(location.protocol+'//'+location.host+'/'+lang+gt_request_uri);}"+new_line;
785
- else
786
- widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];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+"')openTab(location.protocol+'//'+location.host+gt_request_uri);else openTab(location.protocol+'//'+location.host+'/'+lang+gt_request_uri);}"+new_line;
787
  } else if(pro_version && translation_method == 'redirect') {
788
- if(analytics)
789
- widget_code += "function doGTranslate(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+gt_request_uri;else location.href=location.protocol+'//'+location.host+'/'+lang+gt_request_uri;}"+new_line;
790
- else
791
- widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];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+gt_request_uri;else location.href=location.protocol+'//'+location.host+'/'+lang+gt_request_uri;}"+new_line;
792
  } else if(enterprise_version && translation_method == 'redirect' && new_window) {
793
  widget_code += "function openTab(url) {var form=document.createElement('form');form.method='post';form.action=url;form.target='_blank';document.body.appendChild(form);form.submit();}"+new_line;
794
- if(analytics)
795
- widget_code += "function doGTranslate(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+"';openTab(location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '[.]'), '')+gt_request_uri);}"+new_line;
796
- else
797
- widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];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+"';openTab(location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '[.]'), '')+gt_request_uri);}"+new_line;
 
798
  } else if(enterprise_version && translation_method == 'redirect') {
799
- if(analytics)
800
- widget_code += "function doGTranslate(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 + '[.]'), '')+gt_request_uri;}"+new_line;
801
- else
802
- widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];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 + '[.]'), '')+gt_request_uri;}"+new_line;
 
803
  } else if(translation_method == 'onfly') {
804
  widget_code += "function GTranslateGetCurrentLang() {var keyValue = document['cookie'].match('(^|;) ?googtrans=([^;]*)(;|$)');return keyValue ? keyValue[2].split('/')[2] : null;}"+new_line;
805
  widget_code += "function GTranslateFireEvent(element,event){try{if(document.createEventObject){var evt=document.createEventObject();element.fireEvent('on'+event,evt)}else{var evt=document.createEvent('HTMLEvents');evt.initEvent(event,true,true);element.dispatchEvent(evt)}}catch(e){}}"+new_line;
806
- if(analytics)
807
- widget_code += "function doGTranslate(lang_pair){if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(GTranslateGetCurrentLang() == null && lang == lang_pair.split('|')[0])return;if(typeof ga!='undefined'){ga('send', 'event', 'GTranslate', lang, location.hostname+location.pathname+location.search);}else{if(typeof _gaq!='undefined')_gaq.push(['_trackEvent', 'GTranslate', lang, location.hostname+location.pathname+location.search]);}var teCombo;var sel=document.getElementsByTagName('select');for(var i=0;i<sel.length;i++)if(sel[i].className.indexOf('goog-te-combo')!=-1){teCombo=sel[i];break;}if(document.getElementById('google_translate_element2')==null||document.getElementById('google_translate_element2').innerHTML.length==0||teCombo.length==0||teCombo.innerHTML.length==0){setTimeout(function(){doGTranslate(lang_pair)},500)}else{teCombo.value=lang;GTranslateFireEvent(teCombo,'change');GTranslateFireEvent(teCombo,'change')}}"+new_line;
808
- else
809
- widget_code += "function doGTranslate(lang_pair){if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(GTranslateGetCurrentLang() == null && lang == lang_pair.split('|')[0])return;var teCombo;var sel=document.getElementsByTagName('select');for(var i=0;i<sel.length;i++)if(sel[i].className.indexOf('goog-te-combo')!=-1){teCombo=sel[i];break;}if(document.getElementById('google_translate_element2')==null||document.getElementById('google_translate_element2').innerHTML.length==0||teCombo.length==0||teCombo.innerHTML.length==0){setTimeout(function(){doGTranslate(lang_pair)},500)}else{teCombo.value=lang;GTranslateFireEvent(teCombo,'change');GTranslateFireEvent(teCombo,'change')}}"+new_line;
810
  if(widget_look == 'dropdown_with_flags') {
811
  widget_code += "if(GTranslateGetCurrentLang() != null)jQuery(document).ready(function() {var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+GTranslateGetCurrentLang()+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));});"+new_line;
812
  } else if(widget_look == 'popup') {
@@ -836,6 +897,7 @@ function ShowWidgetPreview(widget_preview) {
836
 
837
  jQuery('#pro_version').attr('checked', '$pro_version'.length > 0);
838
  jQuery('#enterprise_version').attr('checked', '$enterprise_version'.length > 0);
 
839
  jQuery('#url_translation').attr('checked', '$url_translation'.length > 0);
840
  jQuery('#add_hreflang_tags').attr('checked', '$add_hreflang_tags'.length > 0);
841
  jQuery('#email_translation').attr('checked', '$email_translation'.length > 0);
@@ -844,7 +906,6 @@ jQuery('#new_window').attr('checked', '$new_window'.length > 0);
844
  jQuery('#show_in_menu').val('$show_in_menu');
845
  jQuery('#floating_language_selector').val('$floating_language_selector');
846
  jQuery('#native_language_names').attr('checked', '$native_language_names'.length > 0);
847
- jQuery('#analytics').attr('checked', '$analytics'.length > 0);
848
  jQuery('#detect_browser_language').attr('checked', '$detect_browser_language'.length > 0);
849
  jQuery('#add_new_line').attr('checked', '$add_new_line'.length > 0);
850
  jQuery('#default_language').val('$default_language');
@@ -862,13 +923,25 @@ jQuery('#dropdown_hover_color').val('$dropdown_hover_color');
862
  jQuery('#dropdown_background_color').val('$dropdown_background_color');
863
 
864
  if(jQuery('#pro_version:checked').length || jQuery('#enterprise_version:checked').length) {
 
 
 
 
 
 
 
 
 
 
 
865
  jQuery('#new_window_option').show();
866
  jQuery('#url_translation_option').show();
867
  jQuery('#hreflang_tags_option').show();
868
  jQuery('#email_translation_option').show();
869
  if(jQuery('#email_translation:checked').length)
870
  jQuery('#email_translation_debug_option').show();
871
- //jQuery('#auto_switch_option').hide();
 
872
  }
873
 
874
  if('$widget_look' == 'dropdown' || '$widget_look' == 'flags_dropdown' || '$widget_look' == 'globe' || '$widget_look' == 'lang_names' || '$widget_look' == 'lang_codes') {
@@ -1129,6 +1202,10 @@ EOT;
1129
  <td class="option_name">* <?php _e('Sub-domain URL structure', 'gtranslate'); ?>:<br><code><small>http://<b>es</b>.example.com/</small></code></td>
1130
  <td><input id="enterprise_version" name="enterprise_version" value="1" type="checkbox" onclick="if(jQuery('#pro_version').is(':checked') && jQuery('#enterprise_version').is(':checked'))jQuery('#pro_version').prop('checked', false);RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/> <a href="https://gtranslate.io/?xyz=998#pricing" target="_blank" title="If you already have a subscription, you can enable this.">* <?php _e('for paid plans only', 'gtranslate'); ?></a></td>
1131
  </tr>
 
 
 
 
1132
  <tr id="url_translation_option" style="display:none;">
1133
  <td class="option_name"><?php _e('Enable URL Translation', 'gtranslate'); ?>:</td>
1134
  <td><input id="url_translation" name="url_translation" value="1" type="checkbox"/></td>
@@ -1149,10 +1226,6 @@ EOT;
1149
  <td class="option_name"><?php _e('Open in new window', 'gtranslate'); ?>:</td>
1150
  <td><input id="new_window" name="new_window" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
1151
  </tr>
1152
- <tr>
1153
- <td class="option_name"><?php _e('Analytics', 'gtranslate'); ?>:</td>
1154
- <td><input id="analytics" name="analytics" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
1155
- </tr>
1156
  <tr id="auto_switch_option">
1157
  <td class="option_name"><?php _e('Auto switch to browser language', 'gtranslate'); ?>:</td>
1158
  <td><input id="detect_browser_language" name="detect_browser_language" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
@@ -1313,6 +1386,31 @@ EOT;
1313
  </div>
1314
  </div>
1315
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1316
  <div id="poststuff" class="switcher_color_options">
1317
  <div class="postbox">
1318
  <h3 id="settings"><?php _e('Color options', 'gtranslate'); ?> ( <a href="#" onclick="return light_color_scheme()">light</a> | <a href="#" onclick="return dark_color_scheme()">dark</a> )</h3>
@@ -1431,6 +1529,7 @@ EOT;
1431
  <li><a href="https://my.gtranslate.io/" target="_blank"><?php _e('User dashboard', 'gtranslate'); ?></a></li>
1432
  <li><a href="https://gtranslate.io/?xyz=998#pricing" target="_blank"><?php _e('Compare plans', 'gtranslate'); ?></a></li>
1433
  <li><a href="https://gtranslate.io/website-translation-quote" target="_blank"><?php _e('Website Translation Quote', 'gtranslate'); ?></a></li>
 
1434
  <li><a href="https://wordpress.org/support/plugin/gtranslate/reviews/" target="_blank"><?php _e('Reviews', 'gtranslate'); ?></a></li>
1435
  </ul>
1436
  </td>
@@ -1463,6 +1562,8 @@ EOT;
1463
  <script><?php echo $script; ?></script>
1464
  <style>
1465
  #widget_preview a:focus {box-shadow:none;outline:none;}
 
 
1466
  .switcher_color_options button {box-shadow:none !important;border:1px solid #b4b9be !important;border-radius:0 !important;}
1467
  .switcher_color_options h3 a {text-decoration:none;font-weight:400;}
1468
  .switcher_color_options h3 a:hover {text-decoration:underline;}
@@ -1483,6 +1584,12 @@ EOT;
1483
 
1484
  .connectedSortable1, .connectedSortable1 li, .connectedSortable2, .connectedSortable2 li {margin:0;padding:0;}
1485
  .connectedSortable1 li label, .connectedSortable2 li label {cursor:move;}
 
 
 
 
 
 
1486
  </style>
1487
 
1488
  <script>window.intercomSettings = {app_id: "r70azrgx", 'platform': 'wordpress', '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>
@@ -1499,6 +1606,8 @@ EOT;
1499
 
1500
  $data['pro_version'] = isset($_POST['pro_version']) ? intval($_POST['pro_version']) : '';
1501
  $data['enterprise_version'] = isset($_POST['enterprise_version']) ? intval($_POST['enterprise_version']) : '';
 
 
1502
  $data['url_translation'] = isset($_POST['url_translation']) ? intval($_POST['url_translation']) : '';
1503
  $data['add_hreflang_tags'] = isset($_POST['add_hreflang_tags']) ? intval($_POST['add_hreflang_tags']) : '';
1504
  $data['email_translation'] = isset($_POST['email_translation']) ? intval($_POST['email_translation']) : '';
@@ -1507,7 +1616,6 @@ EOT;
1507
  $data['show_in_menu'] = isset($_POST['show_in_menu']) ? sanitize_text_field($_POST['show_in_menu']) : '';
1508
  $data['floating_language_selector'] = isset($_POST['floating_language_selector']) ? sanitize_text_field($_POST['floating_language_selector']) : 'no';
1509
  $data['native_language_names'] = isset($_POST['native_language_names']) ? intval($_POST['native_language_names']) : '';
1510
- $data['analytics'] = isset($_POST['analytics']) ? intval($_POST['analytics']) : '';
1511
  $data['detect_browser_language'] = isset($_POST['detect_browser_language']) ? intval($_POST['detect_browser_language']) : '';
1512
  $data['add_new_line'] = isset($_POST['add_new_line']) ? intval($_POST['add_new_line']) : '';
1513
  $data['default_language'] = isset($_POST['default_language']) ? sanitize_text_field($_POST['default_language']) : 'en';
@@ -1584,6 +1692,8 @@ EOT;
1584
 
1585
  $data['pro_version'] = isset($data['pro_version']) ? $data['pro_version'] : '';
1586
  $data['enterprise_version'] = isset($data['enterprise_version']) ? $data['enterprise_version'] : '';
 
 
1587
  $data['url_translation'] = isset($data['url_translation']) ? $data['url_translation'] : '';
1588
  $data['add_hreflang_tags'] = isset($data['add_hreflang_tags']) ? $data['add_hreflang_tags'] : '';
1589
  $data['email_translation'] = isset($data['email_translation']) ? $data['email_translation'] : '';
@@ -1592,7 +1702,6 @@ EOT;
1592
  $data['show_in_menu'] = isset($data['show_in_menu']) ? $data['show_in_menu'] : ((isset($data['show_in_primary_menu']) and $data['show_in_primary_menu'] == 1) ? 'primary' : '');
1593
  $data['floating_language_selector'] = isset($data['floating_language_selector']) ? $data['floating_language_selector'] : 'no';
1594
  $data['native_language_names'] = isset($data['native_language_names']) ? $data['native_language_names'] : '';
1595
- $data['analytics'] = isset($data['analytics']) ? $data['analytics'] : '';
1596
  $data['detect_browser_language'] = isset($data['detect_browser_language']) ? $data['detect_browser_language'] : '';
1597
  $data['add_new_line'] = isset($data['add_new_line']) ? $data['add_new_line'] : '1';
1598
 
@@ -1911,7 +2020,7 @@ class GTranslate_Notices {
1911
 
1912
  public function gt_admin_notices() {
1913
 
1914
- $deactivate_plugins= array('WP Translator' => 'wptranslator/WPTranslator.php', 'TranslatePress' => 'translatepress-multilingual/index.php', 'Google Language Translator' => 'google-language-translator/google-language-translator.php', 'Google Website Translator' => 'google-website-translator/google-website-translator.php', 'Weglot' => 'weglot/weglot.php', 'TransPosh' => 'transposh-translation-filter-for-wordpress/transposh.php');
1915
  foreach($deactivate_plugins as $name => $plugin_file) {
1916
  if(is_plugin_active($plugin_file)) {
1917
  $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);
@@ -2189,9 +2298,16 @@ if($data['add_hreflang_tags'] and ($data['pro_version'] or $data['enterprise_ver
2189
  $href = '';
2190
  $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
2191
 
2192
- if($data['enterprise_version'])
2193
- $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $lang . '.' . $domain, $current_url);
2194
- elseif($data['pro_version'])
 
 
 
 
 
 
 
2195
  $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $_SERVER['HTTP_HOST'] . '/' . $lang, $current_url);
2196
 
2197
  if(!empty($href) and $lang != $data['default_language']) {
@@ -2272,10 +2388,20 @@ if(($data['pro_version'] or $data['enterprise_version']) and $data['detect_brows
2272
 
2273
  if($data['pro_version'])
2274
  header('Location: ' . home_url() . '/' . $accept_language . '/');
2275
- if($data['enterprise_version'] and isset($_SERVER['HTTP_HOST']))
2276
- header('Location: ' . str_replace('://'.$_SERVER['HTTP_HOST'], '://'.$accept_language.'.'.preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']), site_url()));
2277
 
2278
- // todo: special redirect for language hosting
 
 
 
 
 
 
 
 
 
 
 
 
2279
 
2280
  exit;
2281
  }
@@ -2550,9 +2676,18 @@ if($data['pro_version'] or $data['enterprise_version']) {
2550
  if($data['enterprise_version']) {
2551
  // solve wp_get_referer issue
2552
  function gt_allowed_redirect_hosts($hosts) {
2553
- $gt_hosts = array();
 
 
 
 
 
 
 
 
 
2554
  if(isset($_SERVER['HTTP_X_GT_LANG']))
2555
- $gt_hosts[] = $_SERVER['HTTP_X_GT_LANG'] . '.' . str_replace('www.', '', $_SERVER['HTTP_HOST']);
2556
 
2557
  return array_merge($hosts, $gt_hosts);
2558
  }
3
  Plugin Name: GTranslate
4
  Plugin URI: https://gtranslate.io/?xyz=998
5
  Description: Makes your website <strong>multilingual</strong> and available to the world using Google Translate. For support visit <a href="https://wordpress.org/support/plugin/gtranslate">GTranslate Support</a>.
6
+ Version: 2.9.5
7
  Author: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
10
 
11
  */
12
 
13
+ /* Copyright 2010 - 2021 GTranslate Inc. ( website: https://gtranslate.com )
14
 
15
  This program is free software; you can redistribute it and/or modify
16
  it under the terms of the GNU General Public License as published by
299
 
300
  var languages_map = {en_x: 0, en_y: 0, ar_x: 100, ar_y: 0, bg_x: 200, bg_y: 0, zhCN_x: 300, zhCN_y: 0, zhTW_x: 400, zhTW_y: 0, hr_x: 500, hr_y: 0, cs_x: 600, cs_y: 0, da_x: 700, da_y: 0, nl_x: 0, nl_y: 100, fi_x: 100, fi_y: 100, fr_x: 200, fr_y: 100, de_x: 300, de_y: 100, el_x: 400, el_y: 100, hi_x: 500, hi_y: 100, it_x: 600, it_y: 100, ja_x: 700, ja_y: 100, ko_x: 0, ko_y: 200, no_x: 100, no_y: 200, pl_x: 200, pl_y: 200, pt_x: 300, pt_y: 200, ro_x: 400, ro_y: 200, ru_x: 500, ru_y: 200, es_x: 600, es_y: 200, sv_x: 700, sv_y: 200, ca_x: 0, ca_y: 300, tl_x: 100, tl_y: 300, iw_x: 200, iw_y: 300, id_x: 300, id_y: 300, lv_x: 400, lv_y: 300, lt_x: 500, lt_y: 300, sr_x: 600, sr_y: 300, sk_x: 700, sk_y: 300, sl_x: 0, sl_y: 400, uk_x: 100, uk_y: 400, vi_x: 200, vi_y: 400, sq_x: 300, sq_y: 400, et_x: 400, et_y: 400, gl_x: 500, gl_y: 400, hu_x: 600, hu_y: 400, mt_x: 700, mt_y: 400, th_x: 0, th_y: 500, tr_x: 100, tr_y: 500, fa_x: 200, fa_y: 500, af_x: 300, af_y: 500, ms_x: 400, ms_y: 500, sw_x: 500, sw_y: 500, ga_x: 600, ga_y: 500, cy_x: 700, cy_y: 500, be_x: 0, be_y: 600, is_x: 100, is_y: 600, mk_x: 200, mk_y: 600, yi_x: 300, yi_y: 600, hy_x: 400, hy_y: 600, az_x: 500, az_y: 600, eu_x: 600, eu_y: 600, ka_x: 700, ka_y: 600, ht_x: 0, ht_y: 700, ur_x: 100, ur_y: 700};
301
 
302
+ function SyncCustomDomains() {
303
+ jQuery('#custom_domains_status_sync').show();
304
+
305
+ jQuery.ajax({
306
+ url: 'https://tdns.gtranslate.net/tdn-bin/load-custom-domains',
307
+ type: 'GET',
308
+ dataType: 'json',
309
+ headers: {"X-GT-Domain": window.gt_debug_main_domain||location.hostname},
310
+ success: function(data) {
311
+ jQuery('#custom_domains_status_sync').hide();
312
+
313
+ if(data.err) { // todo: nice alert box
314
+ if(data.err == 'no license')
315
+ alert('No subscription found for "' + (window.gt_debug_main_domain||location.hostname) + '". Please subscribe at https://gtranslate.io/');
316
+ else if(data.err == 'no settings')
317
+ alert('Make sure your subscription for "' + (window.gt_debug_main_domain||location.hostname) + '" has Language Hosting feature and Custom domains are configured in your GTranslate dashboard: https://my.gtranslate.io/settings#advanced');
318
+ else
319
+ alert(data.err);
320
+
321
+ jQuery('#custom_domains').prop('checked', false);
322
+ RefreshDoWidgetCode();
323
+
324
+ return;
325
+ }
326
+
327
+ jQuery('#custom_domains_data').val(JSON.stringify(data));
328
+ jQuery('#custom_domains_list_tbl tr.lang_domain_row').remove();
329
+ for(l in data)
330
+ jQuery('#custom_domains_list_tbl tr:last').after('<tr class="lang_domain_row"><td>'+l+'</td><td>'+data[l]+'</td></tr>');
331
+ jQuery('.custom_domains_list').show();
332
+ },
333
+ error: function(e) {
334
+ alert('Something strange happened, please try again later.');
335
+
336
+ jQuery('#custom_domains').prop('checked', false);
337
+ RefreshDoWidgetCode();
338
+
339
+ jQuery('#custom_domains_status_sync').hide();
340
+ jQuery('.custom_domains_list').hide();
341
+ }
342
+ });
343
+ }
344
+
345
  function RefreshDoWidgetCode() {
346
  var new_line = "\\n";
347
  var widget_preview = '<!-- GTranslate: https://gtranslate.io/ -->'+new_line;
353
  var monochrome_flags = jQuery('#monochrome_flags:checked').length > 0 ? true : false;
354
  var pro_version = jQuery('#pro_version:checked').length > 0 ? true : false;
355
  var enterprise_version = jQuery('#enterprise_version:checked').length > 0 ? true : false;
356
+ var custom_domains = jQuery('#custom_domains:checked').length > 0 ? true : false;
357
+ var custom_domains_data = JSON.parse(jQuery('#custom_domains_data').val()||'{}');
358
  var new_window = jQuery('#new_window:checked').length > 0 ? true : false;
359
  var show_in_menu = jQuery('#show_in_menu').val();
360
  var floating_language_selector = jQuery('#floating_language_selector').val();
361
  var native_language_names = jQuery('#native_language_names:checked').length > 0 ? true : false;
 
362
  var detect_browser_language = jQuery('#detect_browser_language:checked').length > 0 ? true : false;
363
  var email_translation = jQuery('#email_translation:checked').length > 0 ? true : false;
364
  var switcher_text_color = jQuery('#switcher_text_color').val();
379
 
380
  if(pro_version || enterprise_version) {
381
  translation_method = 'redirect';
382
+ if(enterprise_version) {
383
+ jQuery('#custom_domains_option').show();
384
+ if(custom_domains)
385
+ jQuery('.custom_domains_list').show();
386
+ else
387
+ jQuery('.custom_domains_list').hide();
388
+ } else {
389
+ jQuery('#custom_domains_option').hide();
390
+ jQuery('.custom_domains_list').hide();
391
+ }
392
+
393
  jQuery('#new_window_option').show();
394
  jQuery('#url_translation_option').show();
395
  jQuery('#hreflang_tags_option').show();
396
  jQuery('#email_translation_option').show();
397
  if(email_translation)
398
  jQuery('#email_translation_debug_option').show();
399
+ else
400
+ jQuery('#email_translation_debug_option').hide();
401
  } else {
402
+ jQuery('#custom_domains_option').hide();
403
  jQuery('#new_window_option').hide();
404
  jQuery('#url_translation_option').hide();
405
  jQuery('#hreflang_tags_option').hide();
406
  jQuery('#email_translation_option').hide();
407
  jQuery('#email_translation_debug_option').hide();
 
408
  }
409
 
410
  if(widget_look == 'dropdown' || widget_look == 'flags_dropdown' || widget_look == 'globe' || widget_look == 'lang_names' || widget_look == 'lang_codes') {
475
  if(pro_version) {
476
  href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(0, 3).join('/'), '$site_url'.split('/').slice(0, 3).join('/')+'/'+lang);
477
  if(lang != default_language && href.endsWith('/'+lang)) href += '/';
478
+ } else if(enterprise_version) {
479
+ if(custom_domains && typeof custom_domains_data == 'object' && custom_domains_data[lang])
480
+ href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(2, 3)[0].replace('www.', ''), custom_domains_data[lang]);
481
+ else
482
+ href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(2, 3)[0].replace('www.', ''), lang + '.' + '$site_url'.split('/').slice(2, 3)[0].replace('www.', '')).replace('://www.', '://');
483
+ }
484
 
485
  widget_preview += '<a href="'+href+'" onclick="doGTranslate(\''+default_language+'|'+lang+'\');return false;" title="'+lang_name+'" class="glink nturl notranslate">';
486
 
639
  if(pro_version) {
640
  href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(0, 3).join('/'), '$site_url'.split('/').slice(0, 3).join('/')+'/'+lang);
641
  if(lang != default_language && href.endsWith('/'+lang)) href += '/';
642
+ } else if(enterprise_version) {
643
+ if(custom_domains && typeof custom_domains_data == 'object' && custom_domains_data[lang])
644
+ href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(2, 3)[0].replace('www.', ''), custom_domains_data[lang]);
645
+ else
646
+ href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(2, 3)[0].replace('www.', ''), lang + '.' + '$site_url'.split('/').slice(2, 3)[0].replace('www.', '')).replace('://www.', '://');
647
+ }
648
 
649
  widget_preview += '<a href="'+href+'" onclick="changeGTLanguage(\''+default_language+'|'+lang+'\', this);return false;" title="'+lang_name+'" class="glink nturl'+(default_language == lang ? ' selected' : '')+'">';
650
 
803
  if(pro_version) {
804
  href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(0, 3).join('/'), '$site_url'.split('/').slice(0, 3).join('/')+'/'+lang);
805
  if(lang != default_language && href.endsWith('/'+lang)) href += '/';
806
+ } else if(enterprise_version) {
807
+ if(custom_domains && typeof custom_domains_data == 'object' && custom_domains_data[lang])
808
+ href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(2, 3)[0].replace('www.', ''), custom_domains_data[lang]);
809
+ else
810
+ href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(2, 3)[0].replace('www.', ''), lang + '.' + '$site_url'.split('/').slice(2, 3)[0].replace('www.', '')).replace('://www.', '://');
811
+ }
812
 
813
  widget_preview += '<a href="'+href+'" onclick="doGTranslate(\''+default_language+'|'+lang+'\');jQuery(\'div.switcher div.selected a\').html(jQuery(this).html());return false;" title="'+lang_name+'" class="nturl'+(default_language == lang ? ' selected' : '')+'">';
814
 
848
  widget_code += '<script>'+new_line;
849
  if(pro_version && translation_method == 'redirect' && new_window) {
850
  widget_code += "function openTab(url) {var form=document.createElement('form');form.method='post';form.action=url;form.target='_blank';document.body.appendChild(form);form.submit();}"+new_line;
851
+ widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof ga=='function'){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+"')openTab(location.protocol+'//'+location.host+gt_request_uri);else openTab(location.protocol+'//'+location.host+'/'+lang+gt_request_uri);}"+new_line;
 
 
 
852
  } else if(pro_version && translation_method == 'redirect') {
853
+ widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof ga=='function'){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+gt_request_uri;else location.href=location.protocol+'//'+location.host+'/'+lang+gt_request_uri;}"+new_line;
 
 
 
854
  } else if(enterprise_version && translation_method == 'redirect' && new_window) {
855
  widget_code += "function openTab(url) {var form=document.createElement('form');form.method='post';form.action=url;form.target='_blank';document.body.appendChild(form);form.submit();}"+new_line;
856
+ if(custom_domains && typeof custom_domains_data == 'object') {
857
+ widget_code += "var gt_custom_domains = "+JSON.stringify(custom_domains_data)+";"+new_line;
858
+ widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof ga=='function'){ga('send', 'event', 'GTranslate', lang, location.hostname+location.pathname+location.search);}if(gt_custom_domains[lang]){openTab(location.protocol+'//'+gt_custom_domains[lang]+gt_request_uri);}else{openTab(location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+'"+location.hostname+"'+gt_request_uri);}}"+new_line;
859
+ } else
860
+ widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof ga=='function'){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+"';openTab(location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '[.]'), '')+gt_request_uri);}"+new_line;
861
  } else if(enterprise_version && translation_method == 'redirect') {
862
+ if(custom_domains && typeof custom_domains_data == 'object') {
863
+ widget_code += "var gt_custom_domains = "+JSON.stringify(custom_domains_data)+";"+new_line;
864
+ widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof ga=='function'){ga('send', 'event', 'GTranslate', lang, location.hostname+location.pathname+location.search);}if(gt_custom_domains[lang]){location.href=location.protocol+'//'+gt_custom_domains[lang]+gt_request_uri;}else{location.href=location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+'"+location.hostname+"'+gt_request_uri;}}"+new_line;
865
+ } else
866
+ widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof ga=='function'){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 + '[.]'), '')+gt_request_uri;}"+new_line;
867
  } else if(translation_method == 'onfly') {
868
  widget_code += "function GTranslateGetCurrentLang() {var keyValue = document['cookie'].match('(^|;) ?googtrans=([^;]*)(;|$)');return keyValue ? keyValue[2].split('/')[2] : null;}"+new_line;
869
  widget_code += "function GTranslateFireEvent(element,event){try{if(document.createEventObject){var evt=document.createEventObject();element.fireEvent('on'+event,evt)}else{var evt=document.createEvent('HTMLEvents');evt.initEvent(event,true,true);element.dispatchEvent(evt)}}catch(e){}}"+new_line;
870
+ widget_code += "function doGTranslate(lang_pair){if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(GTranslateGetCurrentLang() == null && lang == lang_pair.split('|')[0])return;if(typeof ga=='function'){ga('send', 'event', 'GTranslate', lang, location.hostname+location.pathname+location.search);}var teCombo;var sel=document.getElementsByTagName('select');for(var i=0;i<sel.length;i++)if(sel[i].className.indexOf('goog-te-combo')!=-1){teCombo=sel[i];break;}if(document.getElementById('google_translate_element2')==null||document.getElementById('google_translate_element2').innerHTML.length==0||teCombo.length==0||teCombo.innerHTML.length==0){setTimeout(function(){doGTranslate(lang_pair)},500)}else{teCombo.value=lang;GTranslateFireEvent(teCombo,'change');GTranslateFireEvent(teCombo,'change')}}"+new_line;
 
 
 
871
  if(widget_look == 'dropdown_with_flags') {
872
  widget_code += "if(GTranslateGetCurrentLang() != null)jQuery(document).ready(function() {var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+GTranslateGetCurrentLang()+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));});"+new_line;
873
  } else if(widget_look == 'popup') {
897
 
898
  jQuery('#pro_version').attr('checked', '$pro_version'.length > 0);
899
  jQuery('#enterprise_version').attr('checked', '$enterprise_version'.length > 0);
900
+ jQuery('#custom_domains').attr('checked', '$custom_domains'.length > 0);
901
  jQuery('#url_translation').attr('checked', '$url_translation'.length > 0);
902
  jQuery('#add_hreflang_tags').attr('checked', '$add_hreflang_tags'.length > 0);
903
  jQuery('#email_translation').attr('checked', '$email_translation'.length > 0);
906
  jQuery('#show_in_menu').val('$show_in_menu');
907
  jQuery('#floating_language_selector').val('$floating_language_selector');
908
  jQuery('#native_language_names').attr('checked', '$native_language_names'.length > 0);
 
909
  jQuery('#detect_browser_language').attr('checked', '$detect_browser_language'.length > 0);
910
  jQuery('#add_new_line').attr('checked', '$add_new_line'.length > 0);
911
  jQuery('#default_language').val('$default_language');
923
  jQuery('#dropdown_background_color').val('$dropdown_background_color');
924
 
925
  if(jQuery('#pro_version:checked').length || jQuery('#enterprise_version:checked').length) {
926
+ if(jQuery('#enterprise_version:checked').length) {
927
+ jQuery('#custom_domains_option').show();
928
+ if(jQuery('#custom_domains:checked').length)
929
+ jQuery('.custom_domains_list').show();
930
+ else
931
+ jQuery('.custom_domains_list').hide();
932
+ } else {
933
+ jQuery('#custom_domains_option').hide();
934
+ jQuery('.custom_domains_list').hide();
935
+ }
936
+
937
  jQuery('#new_window_option').show();
938
  jQuery('#url_translation_option').show();
939
  jQuery('#hreflang_tags_option').show();
940
  jQuery('#email_translation_option').show();
941
  if(jQuery('#email_translation:checked').length)
942
  jQuery('#email_translation_debug_option').show();
943
+ else
944
+ jQuery('#email_translation_debug_option').hide();
945
  }
946
 
947
  if('$widget_look' == 'dropdown' || '$widget_look' == 'flags_dropdown' || '$widget_look' == 'globe' || '$widget_look' == 'lang_names' || '$widget_look' == 'lang_codes') {
1202
  <td class="option_name">* <?php _e('Sub-domain URL structure', 'gtranslate'); ?>:<br><code><small>http://<b>es</b>.example.com/</small></code></td>
1203
  <td><input id="enterprise_version" name="enterprise_version" value="1" type="checkbox" onclick="if(jQuery('#pro_version').is(':checked') && jQuery('#enterprise_version').is(':checked'))jQuery('#pro_version').prop('checked', false);RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/> <a href="https://gtranslate.io/?xyz=998#pricing" target="_blank" title="If you already have a subscription, you can enable this.">* <?php _e('for paid plans only', 'gtranslate'); ?></a></td>
1204
  </tr>
1205
+ <tr id="custom_domains_option" style="display:none;">
1206
+ <td class="option_name"><?php _e('Custom domains', 'gtranslate'); ?>:<br><code><small>http://example.<b>es</b>/</small></code></td>
1207
+ <td><input id="custom_domains" name="custom_domains" value="1" type="checkbox" onclick="if(jQuery('#custom_domains').is(':checked'))SyncCustomDomains();RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/> <span id="custom_domains_status_sync" style="display:none;"><span class="dashicons dashicons-update gt-icon-spin"></span> <?php _e('Synchronizing...', 'gtranslate'); ?></span> <input type="hidden" id="custom_domains_data" name="custom_domains_data" value="<?php echo esc_attr(stripslashes($data['custom_domains_data'])); ?>"></td>
1208
+ </tr>
1209
  <tr id="url_translation_option" style="display:none;">
1210
  <td class="option_name"><?php _e('Enable URL Translation', 'gtranslate'); ?>:</td>
1211
  <td><input id="url_translation" name="url_translation" value="1" type="checkbox"/></td>
1226
  <td class="option_name"><?php _e('Open in new window', 'gtranslate'); ?>:</td>
1227
  <td><input id="new_window" name="new_window" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
1228
  </tr>
 
 
 
 
1229
  <tr id="auto_switch_option">
1230
  <td class="option_name"><?php _e('Auto switch to browser language', 'gtranslate'); ?>:</td>
1231
  <td><input id="detect_browser_language" name="detect_browser_language" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
1386
  </div>
1387
  </div>
1388
 
1389
+ <div id="poststuff" class="custom_domains_list" style="display:none;">
1390
+ <div class="postbox">
1391
+ <h3 id="settings"><?php _e('Language hosting', 'gtranslate'); ?></h3>
1392
+ <div class="inside">
1393
+ <table id="custom_domains_list_tbl" style="width:100%;" cellpadding="0">
1394
+ <tr>
1395
+ <th><?php _e('Language', 'gtranslate'); ?></th>
1396
+ <th><?php _e('Domain', 'gtranslate'); ?></th>
1397
+ </tr>
1398
+ <?php
1399
+ if(isset($data['custom_domains_data']) and !empty($data['custom_domains_data'])) {
1400
+ $custom_domains_data = json_decode(stripslashes($data['custom_domains_data']), true);
1401
+
1402
+ if(is_array($custom_domains_data))
1403
+ foreach($custom_domains_data as $k => $v)
1404
+ echo '<tr class="lang_domain_row"><td>'.esc_html($k).'</td><td>'.esc_html($v).'</td></tr>';
1405
+ }
1406
+ ?>
1407
+ </table>
1408
+ <br>
1409
+ <input type="button" class="button-secondary" value="Synchronize" onclick="SyncCustomDomains();RefreshDoWidgetCode();" title="<?php esc_attr_e('Synchronize custom domains with GTranslate dashboard: https://my.gtranslate.io', 'gtranslate'); ?>">
1410
+ </div>
1411
+ </div>
1412
+ </div>
1413
+
1414
  <div id="poststuff" class="switcher_color_options">
1415
  <div class="postbox">
1416
  <h3 id="settings"><?php _e('Color options', 'gtranslate'); ?> ( <a href="#" onclick="return light_color_scheme()">light</a> | <a href="#" onclick="return dark_color_scheme()">dark</a> )</h3>
1529
  <li><a href="https://my.gtranslate.io/" target="_blank"><?php _e('User dashboard', 'gtranslate'); ?></a></li>
1530
  <li><a href="https://gtranslate.io/?xyz=998#pricing" target="_blank"><?php _e('Compare plans', 'gtranslate'); ?></a></li>
1531
  <li><a href="https://gtranslate.io/website-translation-quote" target="_blank"><?php _e('Website Translation Quote', 'gtranslate'); ?></a></li>
1532
+ <li><a href="https://gtranslate.io/detect-browser-language" target="_blank"><?php _e('Detect browser language', 'gtranslate'); ?></a></li>
1533
  <li><a href="https://wordpress.org/support/plugin/gtranslate/reviews/" target="_blank"><?php _e('Reviews', 'gtranslate'); ?></a></li>
1534
  </ul>
1535
  </td>
1562
  <script><?php echo $script; ?></script>
1563
  <style>
1564
  #widget_preview a:focus {box-shadow:none;outline:none;}
1565
+ #custom_domains_list_tbl th {text-align:left;}
1566
+ #custom_domains_list_tbl td {padding:5px 0;}
1567
  .switcher_color_options button {box-shadow:none !important;border:1px solid #b4b9be !important;border-radius:0 !important;}
1568
  .switcher_color_options h3 a {text-decoration:none;font-weight:400;}
1569
  .switcher_color_options h3 a:hover {text-decoration:underline;}
1584
 
1585
  .connectedSortable1, .connectedSortable1 li, .connectedSortable2, .connectedSortable2 li {margin:0;padding:0;}
1586
  .connectedSortable1 li label, .connectedSortable2 li label {cursor:move;}
1587
+
1588
+ @keyframes gt-icon-spin-animation {
1589
+ 0% {transform:rotate(0deg);}
1590
+ 100% {transform:rotate(359deg);}
1591
+ }
1592
+ .gt-icon-spin {animation:gt-icon-spin-animation 2s infinite linear;}
1593
  </style>
1594
 
1595
  <script>window.intercomSettings = {app_id: "r70azrgx", 'platform': 'wordpress', '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>
1606
 
1607
  $data['pro_version'] = isset($_POST['pro_version']) ? intval($_POST['pro_version']) : '';
1608
  $data['enterprise_version'] = isset($_POST['enterprise_version']) ? intval($_POST['enterprise_version']) : '';
1609
+ $data['custom_domains'] = isset($_POST['custom_domains']) ? intval($_POST['custom_domains']) : '';
1610
+ $data['custom_domains_data'] = isset($_POST['custom_domains_data']) ? sanitize_text_field($_POST['custom_domains_data']) : '';
1611
  $data['url_translation'] = isset($_POST['url_translation']) ? intval($_POST['url_translation']) : '';
1612
  $data['add_hreflang_tags'] = isset($_POST['add_hreflang_tags']) ? intval($_POST['add_hreflang_tags']) : '';
1613
  $data['email_translation'] = isset($_POST['email_translation']) ? intval($_POST['email_translation']) : '';
1616
  $data['show_in_menu'] = isset($_POST['show_in_menu']) ? sanitize_text_field($_POST['show_in_menu']) : '';
1617
  $data['floating_language_selector'] = isset($_POST['floating_language_selector']) ? sanitize_text_field($_POST['floating_language_selector']) : 'no';
1618
  $data['native_language_names'] = isset($_POST['native_language_names']) ? intval($_POST['native_language_names']) : '';
 
1619
  $data['detect_browser_language'] = isset($_POST['detect_browser_language']) ? intval($_POST['detect_browser_language']) : '';
1620
  $data['add_new_line'] = isset($_POST['add_new_line']) ? intval($_POST['add_new_line']) : '';
1621
  $data['default_language'] = isset($_POST['default_language']) ? sanitize_text_field($_POST['default_language']) : 'en';
1692
 
1693
  $data['pro_version'] = isset($data['pro_version']) ? $data['pro_version'] : '';
1694
  $data['enterprise_version'] = isset($data['enterprise_version']) ? $data['enterprise_version'] : '';
1695
+ $data['custom_domains'] = isset($data['custom_domains']) ? $data['custom_domains'] : '';
1696
+ $data['custom_domains_data'] = isset($data['custom_domains_data']) ? $data['custom_domains_data'] : '';
1697
  $data['url_translation'] = isset($data['url_translation']) ? $data['url_translation'] : '';
1698
  $data['add_hreflang_tags'] = isset($data['add_hreflang_tags']) ? $data['add_hreflang_tags'] : '';
1699
  $data['email_translation'] = isset($data['email_translation']) ? $data['email_translation'] : '';
1702
  $data['show_in_menu'] = isset($data['show_in_menu']) ? $data['show_in_menu'] : ((isset($data['show_in_primary_menu']) and $data['show_in_primary_menu'] == 1) ? 'primary' : '');
1703
  $data['floating_language_selector'] = isset($data['floating_language_selector']) ? $data['floating_language_selector'] : 'no';
1704
  $data['native_language_names'] = isset($data['native_language_names']) ? $data['native_language_names'] : '';
 
1705
  $data['detect_browser_language'] = isset($data['detect_browser_language']) ? $data['detect_browser_language'] : '';
1706
  $data['add_new_line'] = isset($data['add_new_line']) ? $data['add_new_line'] : '1';
1707
 
2020
 
2021
  public function gt_admin_notices() {
2022
 
2023
+ $deactivate_plugins= array('WP Translator' => 'wptranslator/WPTranslator.php', 'TranslatePress' => 'translatepress-multilingual/index.php', 'Google Language Translator' => 'google-language-translator/google-language-translator.php', 'Google Website Translator' => 'google-website-translator/google-website-translator.php', 'Weglot' => 'weglot/weglot.php', 'TransPosh' => 'transposh-translation-filter-for-wordpress/transposh.php', 'Advanced Google Translate' => 'advanced-google-translate/advanced-google-translate.php', 'My WP Translate' => 'my-wp-translate/my-wp-translate.php');
2024
  foreach($deactivate_plugins as $name => $plugin_file) {
2025
  if(is_plugin_active($plugin_file)) {
2026
  $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);
2298
  $href = '';
2299
  $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
2300
 
2301
+ if($data['enterprise_version']) {
2302
+ if($data['custom_domains'] and !empty($data['custom_domains_data'])) {
2303
+ $custom_domains_data = json_decode(stripslashes($data['custom_domains_data']), true);
2304
+ if(isset($custom_domains_data[$lang]))
2305
+ $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $custom_domains_data[$lang], $current_url);
2306
+ else
2307
+ $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $lang . '.' . $domain, $current_url);
2308
+ } else
2309
+ $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $lang . '.' . $domain, $current_url);
2310
+ } elseif($data['pro_version'])
2311
  $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $_SERVER['HTTP_HOST'] . '/' . $lang, $current_url);
2312
 
2313
  if(!empty($href) and $lang != $data['default_language']) {
2388
 
2389
  if($data['pro_version'])
2390
  header('Location: ' . home_url() . '/' . $accept_language . '/');
 
 
2391
 
2392
+ if($data['enterprise_version'] and isset($_SERVER['HTTP_HOST'])) {
2393
+ if($data['custom_domains'] and !empty($data['custom_domains_data'])) {
2394
+ $custom_domains_data = json_decode(stripslashes($data['custom_domains_data']), true);
2395
+ if(isset($custom_domains_data[$accept_language]))
2396
+ $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $custom_domains_data[$accept_language], site_url());
2397
+ else
2398
+ $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $accept_language . '.' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']), site_url());
2399
+ } else
2400
+ $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $accept_language . '.' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']), site_url());
2401
+ header('Location: ' . $href);
2402
+ }
2403
+
2404
+ header('Vary: Accept-Language');
2405
 
2406
  exit;
2407
  }
2676
  if($data['enterprise_version']) {
2677
  // solve wp_get_referer issue
2678
  function gt_allowed_redirect_hosts($hosts) {
2679
+ $data = get_option('GTranslate');
2680
+ GTranslate::load_defaults($data);
2681
+
2682
+ if($data['custom_domains'] and !empty($data['custom_domains_data'])) {
2683
+ $custom_domains_data = json_decode(stripslashes($data['custom_domains_data']), true);
2684
+ $gt_hosts = array_values($custom_domains_data);
2685
+ } else {
2686
+ $gt_hosts = array();
2687
+ }
2688
+
2689
  if(isset($_SERVER['HTTP_X_GT_LANG']))
2690
+ $gt_hosts[] = $_SERVER['HTTP_X_GT_LANG'] . '.' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
2691
 
2692
  return array_merge($hosts, $gt_hosts);
2693
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Author: Translate AI Multilingual Solutions
4
  Tags: translate, translate wordpress, multilingual, translation, translate language, bilingual, localization, translation proxy, localisation, multilanguage, google translate
5
  Requires at least: 2.8.1
6
  Tested up to: 5.8
7
- Stable tag: 2.9.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Donate link: https://gtranslate.io/?xyz=998#pricing
@@ -251,6 +251,14 @@ If you want us to translate your website professionally or provide you a proofre
251
  8. User Dashboard
252
 
253
  == Changelog ==
 
 
 
 
 
 
 
 
254
  = 2.9.3 =
255
  * Avoid minification of Google Translate javascript library by LiteSpeed Cache and WP Rocket cache plugins in the free version
256
 
4
  Tags: translate, translate wordpress, multilingual, translation, translate language, bilingual, localization, translation proxy, localisation, multilanguage, google translate
5
  Requires at least: 2.8.1
6
  Tested up to: 5.8
7
+ Stable tag: 2.9.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Donate link: https://gtranslate.io/?xyz=998#pricing
251
  8. User Dashboard
252
 
253
  == Changelog ==
254
+ = 2.9.5 =
255
+ * Fix for javascript error introduced in 2.9.4
256
+
257
+ = 2.9.4 =
258
+ * New interface for paid plans to easily configure custom domains for languages
259
+ * Adding Vary: Accept-Language response header when auto redirecting to browser language
260
+ * Google Analytics event tracking is on by default when analytics.js is present on the website, old ga.js support is removed
261
+
262
  = 2.9.3 =
263
  * Avoid minification of Google Translate javascript library by LiteSpeed Cache and WP Rocket cache plugins in the free version
264