Translate WordPress with GTranslate - Version 2.8.40

Version Description

  • Updated Hebrew language code for hreflang (he instead of iw)
  • Added translation for ajax_url javascript variables, previously only wp_ajax_url were translated
  • Multisite support added for hreflang tags
  • Fix woocommerce cart cookie path when wp in installed in folder
  • Fix for incorrect http response headers regex
Download this release

Release Info

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

Code changes from version 2.8.39 to 2.8.40

Files changed (3) hide show
  1. gtranslate.php +8 -4
  2. readme.txt +8 -1
  3. url_addon/gtranslate.php +8 -3
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.39
7
  Author: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
@@ -1952,7 +1952,7 @@ if($data['add_hreflang_tags'] and ($data['pro_version'] or $data['enterprise_ver
1952
  $enabled_languages = $data['incl_langs'];
1953
 
1954
  //$current_url = wp_get_canonical_url();
1955
- $current_url = home_url(add_query_arg(null, null));
1956
 
1957
  if($current_url !== false) {
1958
  // adding default language
@@ -1968,8 +1968,12 @@ if($data['add_hreflang_tags'] and ($data['pro_version'] or $data['enterprise_ver
1968
  elseif($data['pro_version'])
1969
  $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $_SERVER['HTTP_HOST'] . '/' . $lang, $current_url);
1970
 
1971
- if(!empty($href) and $lang != $data['default_language'])
1972
- echo '<link rel="alternate" hreflang="'.$lang.'" href="'.$href.'" />'."\n";
 
 
 
 
1973
  }
1974
  }
1975
  }
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.40
7
  Author: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
1952
  $enabled_languages = $data['incl_langs'];
1953
 
1954
  //$current_url = wp_get_canonical_url();
1955
+ $current_url = network_home_url(add_query_arg(null, null));
1956
 
1957
  if($current_url !== false) {
1958
  // adding default language
1968
  elseif($data['pro_version'])
1969
  $href = str_ireplace('://' . $_SERVER['HTTP_HOST'], '://' . $_SERVER['HTTP_HOST'] . '/' . $lang, $current_url);
1970
 
1971
+ if(!empty($href) and $lang != $data['default_language']) {
1972
+ if($lang == 'iw')
1973
+ echo '<link rel="alternate" hreflang="he" href="'.$href.'" />'."\n";
1974
+ else
1975
+ echo '<link rel="alternate" hreflang="'.$lang.'" href="'.$href.'" />'."\n";
1976
+ }
1977
  }
1978
  }
1979
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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: 4.9
7
- Stable tag: 2.8.39
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
@@ -220,6 +220,13 @@ You need to go to the language you want to edit, for instance, French: http://do
220
 
221
  == Changelog ==
222
 
 
 
 
 
 
 
 
223
  = 2.8.39 =
224
  * 2 more translation proxy servers added: ani, evn
225
 
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: 4.9
7
+ Stable tag: 2.8.40
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
220
 
221
  == Changelog ==
222
 
223
+ = 2.8.40 =
224
+ * Updated Hebrew language code for hreflang (he instead of iw)
225
+ * Added translation for ajax_url javascript variables, previously only wp_ajax_url were translated
226
+ * Multisite support added for hreflang tags
227
+ * Fix woocommerce cart cookie path when wp in installed in folder
228
+ * Fix for incorrect http response headers regex
229
+
230
  = 2.8.39 =
231
  * 2 more translation proxy servers added: ani, evn
232
 
url_addon/gtranslate.php CHANGED
@@ -193,13 +193,18 @@ $response_headers = explode(PHP_EOL, $header);
193
  //print_r($response_headers);
194
  $headers_sent = '';
195
  foreach($response_headers as $header) {
196
- if(!empty($header) and !preg_match('/Content\-Length|Transfer\-Encoding|Content\-Encoding|Link/i', $header)) {
197
 
198
  if(preg_match('/^Location:/i', $header)) {
199
  $header = str_ireplace($host, $_SERVER['HTTP_HOST'] . '/' . $glang, $header);
200
  $header = str_ireplace('Location: /', 'Location: /' . $glang . '/', $header);
201
  }
202
 
 
 
 
 
 
203
  $headers_sent .= $header;
204
  header($header, false);
205
  }
@@ -220,8 +225,8 @@ $html = str_ireplace('action=\'//' . $_SERVER['HTTP_HOST'], 'action=\'//' . $_SE
220
 
221
  // woocommerce specific changes
222
  $html = str_ireplace(
223
- array('"wc_ajax_url":"\\/', '"checkout_url":"\\/', 'var wc_country_select_params', 'var wc_address_i18n_params' ),
224
- array('"wc_ajax_url":"\\/'.$glang.'\\/', '"checkout_url":"\\/'.$glang.'\\/', 'var wc_country_select_params2', 'var wc_address_i18n_params2'),
225
  $html
226
  );
227
 
193
  //print_r($response_headers);
194
  $headers_sent = '';
195
  foreach($response_headers as $header) {
196
+ if(!empty($header) and !preg_match('/Content\-Length:|Transfer\-Encoding:|Content\-Encoding:|Link:/i', $header)) {
197
 
198
  if(preg_match('/^Location:/i', $header)) {
199
  $header = str_ireplace($host, $_SERVER['HTTP_HOST'] . '/' . $glang, $header);
200
  $header = str_ireplace('Location: /', 'Location: /' . $glang . '/', $header);
201
  }
202
 
203
+ // woocommerce cookie path fix
204
+ if(preg_match('/^Set-Cookie:/i', $header) and strpos($header, 'woocommerce') !== false) {
205
+ $header = preg_replace('/path=\/.*\/;/', 'path=/;', $header);
206
+ }
207
+
208
  $headers_sent .= $header;
209
  header($header, false);
210
  }
225
 
226
  // woocommerce specific changes
227
  $html = str_ireplace(
228
+ array('ajax_url":"\\/', '"checkout_url":"\\/', 'var wc_country_select_params', 'var wc_address_i18n_params' ),
229
+ array('ajax_url":"\\/'.$glang.'\\/', '"checkout_url":"\\/'.$glang.'\\/', 'var wc_country_select_params2', 'var wc_address_i18n_params2'),
230
  $html
231
  );
232