Translate WordPress with GTranslate - Version 2.8.47

Version Description

  • Fix for hebrew hreflang code when hebrew is the original language
  • Visitor real IP detection fixed for woocommerce plugin
  • Show warning when PHP Curl library is missing
  • Fix {lang}.www.test.com case when auto-redirecting to browser language
Download this release

Release Info

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

Code changes from version 2.8.46 to 2.8.47

Files changed (3) hide show
  1. gtranslate.php +17 -3
  2. readme.txt +8 -2
  3. url_addon/gtranslate.php +8 -0
gtranslate.php CHANGED
@@ -3,7 +3,7 @@
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.8.46
7
  Author: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
@@ -1944,7 +1944,10 @@ if($data['add_hreflang_tags'] and ($data['pro_version'] or $data['enterprise_ver
1944
 
1945
  if($current_url !== false) {
1946
  // adding default language
1947
- echo '<link rel="alternate" hreflang="'.$data['default_language'].'" href="'.$current_url.'" />'."\n";
 
 
 
1948
 
1949
  // adding enabled languages
1950
  foreach($enabled_languages as $lang) {
@@ -2031,7 +2034,7 @@ if(($data['pro_version'] or $data['enterprise_version']) and $data['detect_brows
2031
  if($data['pro_version'])
2032
  header('Location: ' . home_url() . '/' . $accept_language . '/');
2033
  if($data['enterprise_version'] and isset($_SERVER['HTTP_HOST']))
2034
- header('Location: ' . str_replace('://'.$_SERVER['HTTP_HOST'], '://'.$accept_language.'.'.$_SERVER['HTTP_HOST'], site_url()));
2035
 
2036
  // todo: special redirect for language hosting
2037
 
@@ -2190,6 +2193,15 @@ if($data['pro_version'] or $data['enterprise_version']) {
2190
  return $data;
2191
  }
2192
 
 
 
 
 
 
 
 
 
 
2193
  //add_action('wp_print_scripts', 'gtranslate_filter_l10n_scripts', 1);
2194
  //add_action('wp_print_header_scripts', 'gtranslate_filter_l10n_scripts', 1);
2195
  //add_action('wp_print_footer_scripts', 'gtranslate_filter_l10n_scripts', 1);
@@ -2197,4 +2209,6 @@ if($data['pro_version'] or $data['enterprise_version']) {
2197
  add_filter('script_loader_tag', 'gtranslate_add_script_attributes', 100, 2);
2198
 
2199
  add_filter('woocommerce_get_script_data', 'gt_filter_woocommerce_scripts_data', 10, 2 );
 
 
2200
  }
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.8.47
7
  Author: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
1944
 
1945
  if($current_url !== false) {
1946
  // adding default language
1947
+ if($data['default_language'] == 'iw')
1948
+ echo '<link rel="alternate" hreflang="he" href="'.$current_url.'" />'."\n";
1949
+ else
1950
+ echo '<link rel="alternate" hreflang="'.$data['default_language'].'" href="'.$current_url.'" />'."\n";
1951
 
1952
  // adding enabled languages
1953
  foreach($enabled_languages as $lang) {
2034
  if($data['pro_version'])
2035
  header('Location: ' . home_url() . '/' . $accept_language . '/');
2036
  if($data['enterprise_version'] and isset($_SERVER['HTTP_HOST']))
2037
+ header('Location: ' . str_replace('://'.$_SERVER['HTTP_HOST'], '://'.$accept_language.'.'.preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']), site_url()));
2038
 
2039
  // todo: special redirect for language hosting
2040
 
2193
  return $data;
2194
  }
2195
 
2196
+ function gt_woocommerce_geolocate_ip($false) {
2197
+ if(isset($_SERVER['HTTP_X_GT_VIEWER_IP']))
2198
+ $_SERVER['HTTP_X_REAL_IP'] = $_SERVER['HTTP_X_GT_VIEWER_IP'];
2199
+ elseif(isset($_SERVER['HTTP_X_GT_CLIENTIP']))
2200
+ $_SERVER['HTTP_X_REAL_IP'] = $_SERVER['HTTP_X_GT_CLIENTIP'];
2201
+
2202
+ return $false;
2203
+ }
2204
+
2205
  //add_action('wp_print_scripts', 'gtranslate_filter_l10n_scripts', 1);
2206
  //add_action('wp_print_header_scripts', 'gtranslate_filter_l10n_scripts', 1);
2207
  //add_action('wp_print_footer_scripts', 'gtranslate_filter_l10n_scripts', 1);
2209
  add_filter('script_loader_tag', 'gtranslate_add_script_attributes', 100, 2);
2210
 
2211
  add_filter('woocommerce_get_script_data', 'gt_filter_woocommerce_scripts_data', 10, 2 );
2212
+
2213
+ add_filter('woocommerce_geolocate_ip', 'gt_woocommerce_geolocate_ip', 10, 4);
2214
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: edo888
3
  Author: Translate AI Multilingual Solutions
4
  Tags: translate wordpress, multilingual, translate, translation, language, bilingual, localization, translation proxy, i18n, l10n, localisation, multilanguage, google translate
5
  Requires at least: 2.8.1
6
- Tested up to: 5.1
7
- Stable tag: 2.8.46
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
@@ -221,6 +221,12 @@ You need to go to the language you want to edit, for instance, French: http://do
221
  8. User Dashboard
222
 
223
  == Changelog ==
 
 
 
 
 
 
224
  = 2.8.46 =
225
  * Fix for relative path issue for some hosts
226
 
3
  Author: Translate AI Multilingual Solutions
4
  Tags: translate wordpress, multilingual, translate, translation, language, bilingual, localization, translation proxy, i18n, l10n, localisation, multilanguage, google translate
5
  Requires at least: 2.8.1
6
+ Tested up to: 5.2
7
+ Stable tag: 2.8.47
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
221
  8. User Dashboard
222
 
223
  == Changelog ==
224
+ = 2.8.47 =
225
+ * Fix for hebrew hreflang code when hebrew is the original language
226
+ * Visitor real IP detection fixed for woocommerce plugin
227
+ * Show warning when PHP Curl library is missing
228
+ * Fix {lang}.www.test.com case when auto-redirecting to browser language
229
+
230
  = 2.8.46 =
231
  * Fix for relative path issue for some hosts
232
 
url_addon/gtranslate.php CHANGED
@@ -132,6 +132,14 @@ if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) and !empty($_SERVER['HTTP_X_FORWARDED
132
  //print_r($headers);
133
  //exit;
134
 
 
 
 
 
 
 
 
 
135
  // proxy request
136
  $ch = curl_init();
137
  curl_setopt($ch, CURLOPT_URL, $page_url);
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);