Version Description
- Fix for conflict with WP Rocket plugin when "Load JavaScript deferred" option is enabled
Download this release
Release Info
Developer | edo888 |
Plugin | Translate WordPress with GTranslate |
Version | 2.9.12 |
Comparing to | |
See all releases |
Code changes from version 2.9.10 to 2.9.12
- gtranslate.php +27 -16
- readme.txt +8 -2
gtranslate.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: GTranslate
|
4 |
Plugin URI: https://gtranslate.io/?xyz=998
|
5 |
Description: Translate your website and make it multilingual. For support visit <a href="https://wordpress.org/support/plugin/gtranslate">GTranslate Support Forum</a>.
|
6 |
-
Version: 2.9.
|
7 |
Author: Translate AI Multilingual Solutions
|
8 |
Author URI: https://gtranslate.io
|
9 |
Text Domain: gtranslate
|
@@ -115,9 +115,9 @@ class GTranslate extends WP_Widget {
|
|
115 |
|
116 |
// avoid caching issues
|
117 |
if($data['widget_look'] == 'dropdown_with_flags' and ($data['pro_version'] or $data['enterprise_version'])) {
|
118 |
-
echo '<script>(function gt_jquery_ready() {if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".switcher div.option a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'.switcher div.selected a\').html(lang_html.replace("data-gt-lazy-", ""))});})();</script>';
|
119 |
} elseif($data['widget_look'] == 'popup' and ($data['pro_version'] or $data['enterprise_version'])) {
|
120 |
-
echo '<script>(function gt_jquery_ready() {if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".gt_languages a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'a.switcher-popup\').html(lang_html.replace("data-gt-lazy-", "")+\'<span style=\"color:#666;font-size:8px;font-weight:bold;\">▼</span>\');});})();</script>';
|
121 |
}
|
122 |
|
123 |
// detect browser language
|
@@ -130,7 +130,7 @@ class GTranslate extends WP_Widget {
|
|
130 |
$allowed_languages = $data['incl_langs'];
|
131 |
$allowed_languages = json_encode($allowed_languages);
|
132 |
|
133 |
-
echo "<script>(function gt_jquery_ready() {if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {";
|
134 |
echo "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;case 'he': var preferred_language = 'iw'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
|
135 |
if($data['widget_look'] == 'dropdown_with_flags') {
|
136 |
echo "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
|
@@ -156,9 +156,9 @@ class GTranslate extends WP_Widget {
|
|
156 |
|
157 |
// avoid caching issues
|
158 |
if($data['widget_look'] == 'dropdown_with_flags' and ($data['pro_version'] or $data['enterprise_version'])) {
|
159 |
-
echo '<script>(function gt_jquery_ready() {if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".switcher div.option a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'.switcher div.selected a\').html(lang_html.replace("data-gt-lazy-", ""))});})();</script>';
|
160 |
} elseif($data['widget_look'] == 'popup' and ($data['pro_version'] or $data['enterprise_version'])) {
|
161 |
-
echo '<script>(function gt_jquery_ready() {if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".gt_languages a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'a.switcher-popup\').html(lang_html.replace("data-gt-lazy-", "")+\'<span style=\"color:#666;font-size:8px;font-weight:bold;\">▼</span>\');});})();</script>';
|
162 |
}
|
163 |
|
164 |
// detect browser language
|
@@ -171,7 +171,7 @@ class GTranslate extends WP_Widget {
|
|
171 |
$allowed_languages = $data['incl_langs'];
|
172 |
$allowed_languages = json_encode($allowed_languages);
|
173 |
|
174 |
-
echo "<script>(function gt_jquery_ready() {if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {";
|
175 |
echo "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;case 'he': var preferred_language = 'iw'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
|
176 |
if($data['widget_look'] == 'dropdown_with_flags') {
|
177 |
echo "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
|
@@ -194,9 +194,9 @@ class GTranslate extends WP_Widget {
|
|
194 |
|
195 |
// avoid caching issues
|
196 |
if($data['widget_look'] == 'dropdown_with_flags' and ($data['pro_version'] or $data['enterprise_version'])) {
|
197 |
-
$data['widget_code'] .= '<script>(function gt_jquery_ready() {if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".switcher div.option a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'.switcher div.selected a\').html(lang_html.replace("data-gt-lazy-", ""))});})();</script>';
|
198 |
} elseif($data['widget_look'] == 'popup' and ($data['pro_version'] or $data['enterprise_version'])) {
|
199 |
-
$data['widget_code'] .= '<script>(function gt_jquery_ready() {if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".gt_languages a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'a.switcher-popup\').html(lang_html.replace("data-gt-lazy-", "")+\'<span style=\"color:#666;font-size:8px;font-weight:bold;\">▼</span>\');});})();</script>';
|
200 |
}
|
201 |
|
202 |
//$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'ru-Ru'; // debug
|
@@ -211,7 +211,7 @@ class GTranslate extends WP_Widget {
|
|
211 |
$allowed_languages = $data['incl_langs'];
|
212 |
$allowed_languages = json_encode($allowed_languages);
|
213 |
|
214 |
-
$data['widget_code'] .= "<script>(function gt_jquery_ready() {if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {";
|
215 |
$data['widget_code'] .= "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;case 'he': var preferred_language = 'iw'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
|
216 |
if($data['widget_look'] == 'dropdown_with_flags') {
|
217 |
$data['widget_code'] .= "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
|
@@ -605,7 +605,7 @@ function RefreshDoWidgetCode() {
|
|
605 |
widget_preview += '}}'+new_line;
|
606 |
widget_preview += "function hideGSatelites($) { $('.gsatelite').each(function(i) { $(this).delay(($('.gsatelite').length - i - 1) * 10).fadeOut('fast');});}"+new_line;
|
607 |
widget_preview += "(function gt_jquery_ready() {"+new_line;
|
608 |
-
widget_preview += " if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);"+new_line;
|
609 |
widget_preview += " (function($) { $('body').click(function() {hideGSatelites($);});$('.gglobe').click(function(e) {e.stopPropagation();renderGSatelites($, e);});})(jQuery);"+new_line;
|
610 |
widget_preview += '})();'+new_line;
|
611 |
widget_preview += '<\/script>'+new_line;
|
@@ -727,7 +727,7 @@ function RefreshDoWidgetCode() {
|
|
727 |
widget_preview += "function closeGTPopup() {jQuery('.gt_white_content').css('display', 'none');jQuery('.gt_black_overlay').css('display', 'none');}"+new_line;
|
728 |
widget_preview += "function changeGTLanguage(pair, a) {doGTranslate(pair);jQuery('a.switcher-popup').html(jQuery(a).html()+'<span style=\"color:#666;font-size:8px;font-weight:bold;\">▼</span>');closeGTPopup();}"+new_line;
|
729 |
widget_preview += "(function gt_jquery_ready() {"+new_line;
|
730 |
-
widget_preview += " if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);"+new_line;
|
731 |
widget_preview += " jQuery('.gt_black_overlay').click(function(e) {if(jQuery('.gt_white_content').is(':visible')) {closeGTPopup()}});"+new_line;
|
732 |
widget_preview += '})();'+new_line;
|
733 |
widget_preview += '<\/script>'+new_line;
|
@@ -850,7 +850,7 @@ function RefreshDoWidgetCode() {
|
|
850 |
// Adding slider javascript
|
851 |
widget_preview += '<script>'+new_line;
|
852 |
widget_preview += "(function gt_jquery_ready() {"+new_line;
|
853 |
-
widget_preview += " if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);"+new_line;
|
854 |
widget_preview += " jQuery('.switcher .selected').click(function() {jQuery('.switcher .option a img').each(function() {if(!jQuery(this)[0].hasAttribute('src'))jQuery(this).attr('src', jQuery(this).attr('data-gt-lazy-src'))});if(!(jQuery('.switcher .option').is(':visible'))) {jQuery('.switcher .option').stop(true,true).delay(100).slideDown(500);jQuery('.switcher .selected a').toggleClass('open')}});"+new_line;
|
855 |
widget_preview += " jQuery('.switcher .option').bind('mousewheel', function(e) {var options = jQuery('.switcher .option');if(options.is(':visible'))options.scrollTop(options.scrollTop() - e.originalEvent.wheelDelta/10);return false;});"+new_line;
|
856 |
widget_preview += " jQuery('body').not('.switcher').click(function(e) {if(jQuery('.switcher .option').is(':visible') && e.target != jQuery('.switcher .option').get(0)) {jQuery('.switcher .option').stop(true,true).delay(100).slideUp(500);jQuery('.switcher .selected a').toggleClass('open')}});"+new_line;
|
@@ -885,12 +885,12 @@ function RefreshDoWidgetCode() {
|
|
885 |
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;
|
886 |
if(widget_look == 'dropdown_with_flags') {
|
887 |
widget_code += "(function gt_jquery_ready() {"+new_line;
|
888 |
-
widget_code += " if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);"+new_line;
|
889 |
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;
|
890 |
widget_code += '})();'+new_line;
|
891 |
} else if(widget_look == 'popup') {
|
892 |
widget_code += "(function gt_jquery_ready() {"+new_line;
|
893 |
-
widget_code += " if(!window.jQuery) return setTimeout(gt_jquery_ready, 20);"+new_line;
|
894 |
widget_code += ' if(GTranslateGetCurrentLang() != null)jQuery(document).ready(function() {var lang_html = jQuery(".gt_languages a[onclick*=\'|"+GTranslateGetCurrentLang()+"\']").html();if(typeof lang_html != "undefined")jQuery(\'a.switcher-popup\').html(lang_html.replace("data-gt-lazy-", "")+\'<span style=\"color:#666;font-size:8px;font-weight:bold;\">▼</span>\');});'+new_line;
|
895 |
widget_code += '})();'+new_line;
|
896 |
}
|
@@ -2781,4 +2781,15 @@ if(($data['enterprise_version'] or $data['pro_version']) == false) {
|
|
2781 |
|
2782 |
// WP Rocket
|
2783 |
add_filter('rocket_exclude_js', 'cache_exclude_js_gtranslate');
|
2784 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
Plugin Name: GTranslate
|
4 |
Plugin URI: https://gtranslate.io/?xyz=998
|
5 |
Description: Translate your website and make it multilingual. For support visit <a href="https://wordpress.org/support/plugin/gtranslate">GTranslate Support Forum</a>.
|
6 |
+
Version: 2.9.12
|
7 |
Author: Translate AI Multilingual Solutions
|
8 |
Author URI: https://gtranslate.io
|
9 |
Text Domain: gtranslate
|
115 |
|
116 |
// avoid caching issues
|
117 |
if($data['widget_look'] == 'dropdown_with_flags' and ($data['pro_version'] or $data['enterprise_version'])) {
|
118 |
+
echo '<script>(function gt_jquery_ready() {if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".switcher div.option a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'.switcher div.selected a\').html(lang_html.replace("data-gt-lazy-", ""))});})();</script>';
|
119 |
} elseif($data['widget_look'] == 'popup' and ($data['pro_version'] or $data['enterprise_version'])) {
|
120 |
+
echo '<script>(function gt_jquery_ready() {if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".gt_languages a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'a.switcher-popup\').html(lang_html.replace("data-gt-lazy-", "")+\'<span style=\"color:#666;font-size:8px;font-weight:bold;\">▼</span>\');});})();</script>';
|
121 |
}
|
122 |
|
123 |
// detect browser language
|
130 |
$allowed_languages = $data['incl_langs'];
|
131 |
$allowed_languages = json_encode($allowed_languages);
|
132 |
|
133 |
+
echo "<script>(function gt_jquery_ready() {if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {";
|
134 |
echo "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;case 'he': var preferred_language = 'iw'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
|
135 |
if($data['widget_look'] == 'dropdown_with_flags') {
|
136 |
echo "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
|
156 |
|
157 |
// avoid caching issues
|
158 |
if($data['widget_look'] == 'dropdown_with_flags' and ($data['pro_version'] or $data['enterprise_version'])) {
|
159 |
+
echo '<script>(function gt_jquery_ready() {if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".switcher div.option a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'.switcher div.selected a\').html(lang_html.replace("data-gt-lazy-", ""))});})();</script>';
|
160 |
} elseif($data['widget_look'] == 'popup' and ($data['pro_version'] or $data['enterprise_version'])) {
|
161 |
+
echo '<script>(function gt_jquery_ready() {if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".gt_languages a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'a.switcher-popup\').html(lang_html.replace("data-gt-lazy-", "")+\'<span style=\"color:#666;font-size:8px;font-weight:bold;\">▼</span>\');});})();</script>';
|
162 |
}
|
163 |
|
164 |
// detect browser language
|
171 |
$allowed_languages = $data['incl_langs'];
|
172 |
$allowed_languages = json_encode($allowed_languages);
|
173 |
|
174 |
+
echo "<script>(function gt_jquery_ready() {if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {";
|
175 |
echo "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;case 'he': var preferred_language = 'iw'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
|
176 |
if($data['widget_look'] == 'dropdown_with_flags') {
|
177 |
echo "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
|
194 |
|
195 |
// avoid caching issues
|
196 |
if($data['widget_look'] == 'dropdown_with_flags' and ($data['pro_version'] or $data['enterprise_version'])) {
|
197 |
+
$data['widget_code'] .= '<script>(function gt_jquery_ready() {if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".switcher div.option a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'.switcher div.selected a\').html(lang_html.replace("data-gt-lazy-", ""))});})();</script>';
|
198 |
} elseif($data['widget_look'] == 'popup' and ($data['pro_version'] or $data['enterprise_version'])) {
|
199 |
+
$data['widget_code'] .= '<script>(function gt_jquery_ready() {if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {var lang_html = jQuery(".gt_languages a[onclick*=\'|"+jQuery(\'html\').attr(\'lang\')+"\']").html();if(typeof lang_html != "undefined")jQuery(\'a.switcher-popup\').html(lang_html.replace("data-gt-lazy-", "")+\'<span style=\"color:#666;font-size:8px;font-weight:bold;\">▼</span>\');});})();</script>';
|
200 |
}
|
201 |
|
202 |
//$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'ru-Ru'; // debug
|
211 |
$allowed_languages = $data['incl_langs'];
|
212 |
$allowed_languages = json_encode($allowed_languages);
|
213 |
|
214 |
+
$data['widget_code'] .= "<script>(function gt_jquery_ready() {if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);jQuery(document).ready(function() {";
|
215 |
$data['widget_code'] .= "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;case 'he': var preferred_language = 'iw'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
|
216 |
if($data['widget_look'] == 'dropdown_with_flags') {
|
217 |
$data['widget_code'] .= "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
|
605 |
widget_preview += '}}'+new_line;
|
606 |
widget_preview += "function hideGSatelites($) { $('.gsatelite').each(function(i) { $(this).delay(($('.gsatelite').length - i - 1) * 10).fadeOut('fast');});}"+new_line;
|
607 |
widget_preview += "(function gt_jquery_ready() {"+new_line;
|
608 |
+
widget_preview += " if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);"+new_line;
|
609 |
widget_preview += " (function($) { $('body').click(function() {hideGSatelites($);});$('.gglobe').click(function(e) {e.stopPropagation();renderGSatelites($, e);});})(jQuery);"+new_line;
|
610 |
widget_preview += '})();'+new_line;
|
611 |
widget_preview += '<\/script>'+new_line;
|
727 |
widget_preview += "function closeGTPopup() {jQuery('.gt_white_content').css('display', 'none');jQuery('.gt_black_overlay').css('display', 'none');}"+new_line;
|
728 |
widget_preview += "function changeGTLanguage(pair, a) {doGTranslate(pair);jQuery('a.switcher-popup').html(jQuery(a).html()+'<span style=\"color:#666;font-size:8px;font-weight:bold;\">▼</span>');closeGTPopup();}"+new_line;
|
729 |
widget_preview += "(function gt_jquery_ready() {"+new_line;
|
730 |
+
widget_preview += " if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);"+new_line;
|
731 |
widget_preview += " jQuery('.gt_black_overlay').click(function(e) {if(jQuery('.gt_white_content').is(':visible')) {closeGTPopup()}});"+new_line;
|
732 |
widget_preview += '})();'+new_line;
|
733 |
widget_preview += '<\/script>'+new_line;
|
850 |
// Adding slider javascript
|
851 |
widget_preview += '<script>'+new_line;
|
852 |
widget_preview += "(function gt_jquery_ready() {"+new_line;
|
853 |
+
widget_preview += " if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);"+new_line;
|
854 |
widget_preview += " jQuery('.switcher .selected').click(function() {jQuery('.switcher .option a img').each(function() {if(!jQuery(this)[0].hasAttribute('src'))jQuery(this).attr('src', jQuery(this).attr('data-gt-lazy-src'))});if(!(jQuery('.switcher .option').is(':visible'))) {jQuery('.switcher .option').stop(true,true).delay(100).slideDown(500);jQuery('.switcher .selected a').toggleClass('open')}});"+new_line;
|
855 |
widget_preview += " jQuery('.switcher .option').bind('mousewheel', function(e) {var options = jQuery('.switcher .option');if(options.is(':visible'))options.scrollTop(options.scrollTop() - e.originalEvent.wheelDelta/10);return false;});"+new_line;
|
856 |
widget_preview += " jQuery('body').not('.switcher').click(function(e) {if(jQuery('.switcher .option').is(':visible') && e.target != jQuery('.switcher .option').get(0)) {jQuery('.switcher .option').stop(true,true).delay(100).slideUp(500);jQuery('.switcher .selected a').toggleClass('open')}});"+new_line;
|
885 |
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;
|
886 |
if(widget_look == 'dropdown_with_flags') {
|
887 |
widget_code += "(function gt_jquery_ready() {"+new_line;
|
888 |
+
widget_code += " if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);"+new_line;
|
889 |
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;
|
890 |
widget_code += '})();'+new_line;
|
891 |
} else if(widget_look == 'popup') {
|
892 |
widget_code += "(function gt_jquery_ready() {"+new_line;
|
893 |
+
widget_code += " if(!window.jQuery||!jQuery.fn.click) return setTimeout(gt_jquery_ready, 20);"+new_line;
|
894 |
widget_code += ' if(GTranslateGetCurrentLang() != null)jQuery(document).ready(function() {var lang_html = jQuery(".gt_languages a[onclick*=\'|"+GTranslateGetCurrentLang()+"\']").html();if(typeof lang_html != "undefined")jQuery(\'a.switcher-popup\').html(lang_html.replace("data-gt-lazy-", "")+\'<span style=\"color:#666;font-size:8px;font-weight:bold;\">▼</span>\');});'+new_line;
|
895 |
widget_code += '})();'+new_line;
|
896 |
}
|
2781 |
|
2782 |
// WP Rocket
|
2783 |
add_filter('rocket_exclude_js', 'cache_exclude_js_gtranslate');
|
2784 |
+
}
|
2785 |
+
|
2786 |
+
// WP Rocket inline script exclusions
|
2787 |
+
function rocket_exclude_inline_gt_scripts($excluded_patterns) {
|
2788 |
+
if(is_array($excluded_patterns)) {
|
2789 |
+
$excluded_patterns[] = 'doGTranslate';
|
2790 |
+
return $excluded_patterns;
|
2791 |
+
}
|
2792 |
+
|
2793 |
+
return array('doGTranslate');
|
2794 |
+
}
|
2795 |
+
add_filter('rocket_defer_inline_exclusions', 'rocket_exclude_inline_gt_scripts', 1000, 1);
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: edo888
|
|
3 |
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:
|
7 |
-
Stable tag: 2.9.
|
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,12 @@ If you want us to translate your website professionally or provide you a proofre
|
|
251 |
8. User Dashboard
|
252 |
|
253 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
= 2.9.10 =
|
255 |
* Added support for deffered jQuery library loading, this should fix issues with Divi theme jQuery library defer option
|
256 |
|
3 |
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: 6.0
|
7 |
+
Stable tag: 2.9.12
|
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.12 =
|
255 |
+
* Fix for conflict with WP Rocket plugin when "Load JavaScript deferred" option is enabled
|
256 |
+
|
257 |
+
= 2.9.11 =
|
258 |
+
* Fix for Divi when both "Defer jQuery" and "Enqueue jQuery Compatibility Script" are enabled in Divi Theme Performance options
|
259 |
+
|
260 |
= 2.9.10 =
|
261 |
* Added support for deffered jQuery library loading, this should fix issues with Divi theme jQuery library defer option
|
262 |
|