TranslatePress – Translate Multilingual sites - Version 1.3.9

Version Description

  • Fixed some issues with url translations
  • Speed improvements
  • Add Javanese flag
  • Fixed issue with trimming dynamic strings in our own ajax calls
Download this release

Release Info

Developer madalin.ungureanu
Plugin Icon 128x128 TranslatePress – Translate Multilingual sites
Version 1.3.9
Comparing to
See all releases

Code changes from version 1.3.8 to 1.3.9

assets/images/flags/jv_ID.png ADDED
Binary file
class-translate-press.php CHANGED
@@ -40,7 +40,7 @@ class TRP_Translate_Press{
40
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
42
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
43
- define( 'TRP_PLUGIN_VERSION', '1.3.8' );
44
 
45
  wp_cache_add_non_persistent_groups(array('trp'));
46
 
40
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
42
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
43
+ define( 'TRP_PLUGIN_VERSION', '1.3.9' );
44
 
45
  wp_cache_add_non_persistent_groups(array('trp'));
46
 
includes/class-translation-render.php CHANGED
@@ -96,6 +96,8 @@ class TRP_Translation_Render{
96
  * @return string Trimmed string.
97
  */
98
  public function full_trim( $string ) {
 
 
99
  /* Apparently the � char in the trim function turns some strings in an empty string so they can't be translated but I don't really know if we should remove it completely
100
  Removed chr( 194 ) . chr( 160 ) because it altered some special characters (¿¡)
101
  Also removed \xA0 (the same as chr(160) for altering special characters */
@@ -393,7 +395,9 @@ class TRP_Translation_Render{
393
  $trp_rows[count( $row->children )][] = $row;
394
  }
395
  else{
396
- $trp_attr_rows[] = $row;
 
 
397
  if ( $translate_normal_strings ) {
398
  $translation_block = $this->find_translation_block( $row, $all_existing_translation_blocks, $merge_rules );
399
  if ( $translation_block ) {
96
  * @return string Trimmed string.
97
  */
98
  public function full_trim( $string ) {
99
+ /* Make sure you update full_trim function from trp-ajax too*/
100
+
101
  /* Apparently the � char in the trim function turns some strings in an empty string so they can't be translated but I don't really know if we should remove it completely
102
  Removed chr( 194 ) . chr( 160 ) because it altered some special characters (¿¡)
103
  Also removed \xA0 (the same as chr(160) for altering special characters */
395
  $trp_rows[count( $row->children )][] = $row;
396
  }
397
  else{
398
+ if( $row->nodetype !== 5 && $row->nodetype !== 3 )//add all tags that are not root or text, text nodes can't have attributes
399
+ $trp_attr_rows[] = $row;
400
+
401
  if ( $translate_normal_strings ) {
402
  $translation_block = $this->find_translation_block( $row, $all_existing_translation_blocks, $merge_rules );
403
  if ( $translation_block ) {
includes/class-url-converter.php CHANGED
@@ -262,11 +262,13 @@ class TRP_Url_Converter {
262
  } else {
263
  // we're just adding the new language to the url
264
  $new_url_obj = $url_obj;
265
-
 
 
266
  if( $this->get_lang_from_url_string($url) === null ){
267
  // these are the custom url. They don't have language
268
  $abs_home_considered_path = trim(str_replace($abs_home_url_obj->getPath(), '', $url_obj->getPath()), '/');
269
- $new_url_obj->setPath( trailingslashit($abs_home_url_obj->getPath()) . trailingslashit($this->get_url_slug( $language )) . $abs_home_considered_path );
270
  $new_url = $new_url_obj->getUri();
271
 
272
  trp_bulk_debug($debug, array('url' => $url, 'new url' => $new_url, 'lang' => $language, 'url type' => 'custom url without language parameter'));
@@ -283,7 +285,7 @@ class TRP_Url_Converter {
283
  $url_lang_slug = trailingslashit($this->get_url_slug( $language ));
284
  }
285
 
286
- $new_url_obj->setPath( trailingslashit($abs_home_url_obj->getPath()) . $url_lang_slug . ltrim($no_lang_orig_path, '/') );
287
  $new_url = $new_url_obj->getUri();
288
 
289
  trp_bulk_debug($debug, array('url' => $url, 'new url' => $new_url, 'lang' => $language, 'url type' => 'custom url with language', 'abs home path' => $abs_home_url_obj->getPath()));
@@ -431,6 +433,9 @@ class TRP_Url_Converter {
431
  }
432
 
433
  if( $url_obj->getPath() ){
 
 
 
434
  $possible_path = str_replace($abs_home_url_obj->getPath(), '', $url_obj->getPath());
435
  $lang = ltrim( $possible_path,'/' );
436
  $lang = explode('/', $lang);
262
  } else {
263
  // we're just adding the new language to the url
264
  $new_url_obj = $url_obj;
265
+ if ($abs_home_url_obj->getPath() == "/"){
266
+ $abs_home_url_obj->setPath('');
267
+ }
268
  if( $this->get_lang_from_url_string($url) === null ){
269
  // these are the custom url. They don't have language
270
  $abs_home_considered_path = trim(str_replace($abs_home_url_obj->getPath(), '', $url_obj->getPath()), '/');
271
+ $new_url_obj->setPath( trailingslashit( trailingslashit($abs_home_url_obj->getPath()) . trailingslashit($this->get_url_slug( $language )) . $abs_home_considered_path ) );
272
  $new_url = $new_url_obj->getUri();
273
 
274
  trp_bulk_debug($debug, array('url' => $url, 'new url' => $new_url, 'lang' => $language, 'url type' => 'custom url without language parameter'));
285
  $url_lang_slug = trailingslashit($this->get_url_slug( $language ));
286
  }
287
 
288
+ $new_url_obj->setPath( trailingslashit( trailingslashit($abs_home_url_obj->getPath()) . $url_lang_slug . ltrim($no_lang_orig_path, '/') ) );
289
  $new_url = $new_url_obj->getUri();
290
 
291
  trp_bulk_debug($debug, array('url' => $url, 'new url' => $new_url, 'lang' => $language, 'url type' => 'custom url with language', 'abs home path' => $abs_home_url_obj->getPath()));
433
  }
434
 
435
  if( $url_obj->getPath() ){
436
+ if ($abs_home_url_obj->getPath() == "/"){
437
+ $abs_home_url_obj->setPath('');
438
+ }
439
  $possible_path = str_replace($abs_home_url_obj->getPath(), '', $url_obj->getPath());
440
  $lang = ltrim( $possible_path,'/' );
441
  $lang = explode('/', $lang);
includes/trp-ajax.php CHANGED
@@ -50,7 +50,7 @@ class TRP_Ajax{
50
  if ( is_array( $strings ) ) {
51
  foreach ($strings as $key => $string) {
52
  if ( isset($string->original ) ) {
53
- $original_array[$key] = mysqli_real_escape_string( $this->connection, $this->full_trim( filter_var( $string->original, FILTER_SANITIZE_STRING ) ) );
54
  }
55
  }
56
  }
@@ -143,8 +143,34 @@ class TRP_Ajax{
143
  * @param string $word String to trim.
144
  * @return string Trimmed string.
145
  */
146
- protected function full_trim( $word ) {
147
- return trim( $word," \t\n\r\0\x0B\xA0�" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  }
149
 
150
  /**
50
  if ( is_array( $strings ) ) {
51
  foreach ($strings as $key => $string) {
52
  if ( isset($string->original ) ) {
53
+ $original_array[$key] = mysqli_real_escape_string( $this->connection, $this->full_trim( $string->original ) );
54
  }
55
  }
56
  }
143
  * @param string $word String to trim.
144
  * @return string Trimmed string.
145
  */
146
+ protected function full_trim( $string ) {
147
+ /* Make sure you update full_trim function from translation-render too*/
148
+
149
+ /* Apparently the � char in the trim function turns some strings in an empty string so they can't be translated but I don't really know if we should remove it completely
150
+ Removed chr( 194 ) . chr( 160 ) because it altered some special characters (¿¡)
151
+ Also removed \xA0 (the same as chr(160) for altering special characters */
152
+ //$word = trim($word," \t\n\r\0\x0B\xA0�".chr( 194 ) . chr( 160 ) );
153
+
154
+ /* Solution to replace the chr(194).chr(160) from trim function, in order to escape the whitespace character ( \xc2\xa0 ), an old bug that couldn't be replicated anymore. */
155
+ $prefix = "\xc2\xa0";
156
+ $prefix_length = strlen($prefix);
157
+ do{
158
+ $previous_iteration_string = $string;
159
+ $string = trim( $string," \t\n\r\0\x0B");
160
+ if ( substr( $string, 0, $prefix_length ) == $prefix ) {
161
+ $string = substr( $string, $prefix_length );
162
+ }
163
+ if ( substr( $string, - $prefix_length, $prefix_length ) == $prefix ) {
164
+ $string = substr( $string, 0, - $prefix_length );
165
+ }
166
+ }while( $string != $previous_iteration_string );
167
+
168
+ if ( strip_tags( $string ) == "" || trim ($string, " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>1234567890'\"" ) == '' ){
169
+ $string = '';
170
+ }
171
+
172
+ return $string;
173
+
174
  }
175
 
176
  /**
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: TranslatePress - Multilingual
4
  Plugin URI: https://translatepress.com/
5
  Description: Experience a better way of translating your WordPress site, with full support for WooCommerce and site builders.
6
- Version: 1.3.8
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
3
  Plugin Name: TranslatePress - Multilingual
4
  Plugin URI: https://translatepress.com/
5
  Description: Experience a better way of translating your WordPress site, with full support for WooCommerce and site builders.
6
+ Version: 1.3.9
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
languages/translatepress-multilingual.pot CHANGED
@@ -17,59 +17,59 @@ msgstr ""
17
  msgid "Error! Duplicate Url slug values."
18
  msgstr ""
19
 
20
- #: ../tp-add-on-navigation-based-on-language/class-navigation-based-on-language.php:85
21
  msgid "Limit this menu item to the following languages"
22
  msgstr ""
23
 
24
- #: ../tp-add-on-seo-pack/class-seo-pack.php:158
25
  msgid "The Yoast SEO Sitemaps will now contain the default language slug: example.com/en/sitemap_index.xml <br/> This works perfectly, just take it into account when you submit the sitemap to Google."
26
  msgstr ""
27
 
28
- #: includes/class-ald-settings.php:37
29
  msgid "First by browser language, then IP address (recommended)"
30
  msgstr ""
31
 
32
- #: includes/class-ald-settings.php:38
33
  msgid "First by IP address, then browser language"
34
  msgstr ""
35
 
36
- #: includes/class-ald-settings.php:39
37
  msgid "Only by browser language"
38
  msgstr ""
39
 
40
- #: includes/class-ald-settings.php:40
41
  msgid "Only by IP address"
42
  msgstr ""
43
 
44
- #: includes/class-ald-settings.php:110
45
  msgid "<div class=\"warning\">WARNING. Cannot determine your language preference based on your current IP.<br>This is most likely because the website is on a local environment.</div>"
46
  msgstr ""
47
 
48
- #: partials/license-settings-page.php:4, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:4, ../tp-add-on-extra-languages/partials/license-settings-page.php:4, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:4, ../tp-add-on-seo-pack/partials/license-settings-page.php:4, ../translatepress/partials/addons-settings-page.php:3, ../translatepress/partials/main-settings-page.php:5, ../translatepress/partials/test-google-key-settings-page.php:10, ../translatepress/partials/trp-remove-duplicate-rows.php:3, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:4
49
  msgid "TranslatePress Settings"
50
  msgstr ""
51
 
52
- #: partials/license-settings-page.php:10, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:10, ../tp-add-on-extra-languages/partials/license-settings-page.php:10, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:10, ../tp-add-on-seo-pack/partials/license-settings-page.php:10, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:10
53
  msgid "License Key"
54
  msgstr ""
55
 
56
- #: partials/license-settings-page.php:15, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:15, ../tp-add-on-extra-languages/partials/license-settings-page.php:15, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:15, ../tp-add-on-seo-pack/partials/license-settings-page.php:15, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:15
57
  msgid "Enter your license key."
58
  msgstr ""
59
 
60
- #: partials/license-settings-page.php:22, partials/license-settings-page.php:31, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:22, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:31, ../tp-add-on-extra-languages/partials/license-settings-page.php:22, ../tp-add-on-extra-languages/partials/license-settings-page.php:31, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:22, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:31, ../tp-add-on-seo-pack/partials/license-settings-page.php:22, ../tp-add-on-seo-pack/partials/license-settings-page.php:31, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:22, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:31
61
  msgid "Activate License"
62
  msgstr ""
63
 
64
- #: partials/license-settings-page.php:28, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:28, ../tp-add-on-extra-languages/partials/license-settings-page.php:28, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:28, ../tp-add-on-seo-pack/partials/license-settings-page.php:28, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:28
65
  msgid "Deactivate License"
66
  msgstr ""
67
 
68
- #: partials/settings-option.php:2
69
  msgid "Method of language detection"
70
  msgstr ""
71
 
72
- #: partials/settings-option.php:14
73
  msgid "Select how the language should be detected for first time visitors.<br>The visitor's last displayed language will be remembered through cookies."
74
  msgstr ""
75
 
@@ -241,35 +241,35 @@ msgstr ""
241
  msgid "Security check"
242
  msgstr ""
243
 
244
- #: ../translatepress/includes/class-translation-render.php:164
245
  msgid "Description"
246
  msgstr ""
247
 
248
- #: ../translatepress/includes/class-translation-render.php:170
249
  msgid "OG Title"
250
  msgstr ""
251
 
252
- #: ../translatepress/includes/class-translation-render.php:176
253
  msgid "OG Site Name"
254
  msgstr ""
255
 
256
- #: ../translatepress/includes/class-translation-render.php:182
257
  msgid "OG Description"
258
  msgstr ""
259
 
260
- #: ../translatepress/includes/class-translation-render.php:188
261
  msgid "Twitter Title"
262
  msgstr ""
263
 
264
- #: ../translatepress/includes/class-translation-render.php:194
265
  msgid "Twitter Description"
266
  msgstr ""
267
 
268
- #: ../translatepress/includes/class-translation-render.php:200
269
  msgid "Post Slug"
270
  msgstr ""
271
 
272
- #: ../translatepress/includes/class-translation-render.php:204
273
  msgid "Page Title"
274
  msgstr ""
275
 
17
  msgid "Error! Duplicate Url slug values."
18
  msgstr ""
19
 
20
+ #: class-navigation-based-on-language.php:85
21
  msgid "Limit this menu item to the following languages"
22
  msgstr ""
23
 
24
+ #: ../tp-add-on-seo-pack/class-seo-pack.php:160
25
  msgid "The Yoast SEO Sitemaps will now contain the default language slug: example.com/en/sitemap_index.xml <br/> This works perfectly, just take it into account when you submit the sitemap to Google."
26
  msgstr ""
27
 
28
+ #: ../tp-add-on-automatic-language-detection/includes/class-ald-settings.php:37
29
  msgid "First by browser language, then IP address (recommended)"
30
  msgstr ""
31
 
32
+ #: ../tp-add-on-automatic-language-detection/includes/class-ald-settings.php:38
33
  msgid "First by IP address, then browser language"
34
  msgstr ""
35
 
36
+ #: ../tp-add-on-automatic-language-detection/includes/class-ald-settings.php:39
37
  msgid "Only by browser language"
38
  msgstr ""
39
 
40
+ #: ../tp-add-on-automatic-language-detection/includes/class-ald-settings.php:40
41
  msgid "Only by IP address"
42
  msgstr ""
43
 
44
+ #: ../tp-add-on-automatic-language-detection/includes/class-ald-settings.php:110
45
  msgid "<div class=\"warning\">WARNING. Cannot determine your language preference based on your current IP.<br>This is most likely because the website is on a local environment.</div>"
46
  msgstr ""
47
 
48
+ #: ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:4, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:4, ../tp-add-on-extra-languages/partials/license-settings-page.php:4, partials/license-settings-page.php:4, ../tp-add-on-seo-pack/partials/license-settings-page.php:4, ../translatepress/partials/addons-settings-page.php:3, ../translatepress/partials/main-settings-page.php:5, ../translatepress/partials/test-google-key-settings-page.php:10, ../translatepress/partials/trp-remove-duplicate-rows.php:3, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:4
49
  msgid "TranslatePress Settings"
50
  msgstr ""
51
 
52
+ #: ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:10, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:10, ../tp-add-on-extra-languages/partials/license-settings-page.php:10, partials/license-settings-page.php:10, ../tp-add-on-seo-pack/partials/license-settings-page.php:10, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:10
53
  msgid "License Key"
54
  msgstr ""
55
 
56
+ #: ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:15, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:15, ../tp-add-on-extra-languages/partials/license-settings-page.php:15, partials/license-settings-page.php:15, ../tp-add-on-seo-pack/partials/license-settings-page.php:15, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:15
57
  msgid "Enter your license key."
58
  msgstr ""
59
 
60
+ #: ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:22, ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:31, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:22, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:31, ../tp-add-on-extra-languages/partials/license-settings-page.php:22, ../tp-add-on-extra-languages/partials/license-settings-page.php:31, partials/license-settings-page.php:22, partials/license-settings-page.php:31, ../tp-add-on-seo-pack/partials/license-settings-page.php:22, ../tp-add-on-seo-pack/partials/license-settings-page.php:31, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:22, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:31
61
  msgid "Activate License"
62
  msgstr ""
63
 
64
+ #: ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:28, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:28, ../tp-add-on-extra-languages/partials/license-settings-page.php:28, partials/license-settings-page.php:28, ../tp-add-on-seo-pack/partials/license-settings-page.php:28, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:28
65
  msgid "Deactivate License"
66
  msgstr ""
67
 
68
+ #: ../tp-add-on-automatic-language-detection/partials/settings-option.php:2
69
  msgid "Method of language detection"
70
  msgstr ""
71
 
72
+ #: ../tp-add-on-automatic-language-detection/partials/settings-option.php:14
73
  msgid "Select how the language should be detected for first time visitors.<br>The visitor's last displayed language will be remembered through cookies."
74
  msgstr ""
75
 
241
  msgid "Security check"
242
  msgstr ""
243
 
244
+ #: ../translatepress/includes/class-translation-render.php:166
245
  msgid "Description"
246
  msgstr ""
247
 
248
+ #: ../translatepress/includes/class-translation-render.php:172
249
  msgid "OG Title"
250
  msgstr ""
251
 
252
+ #: ../translatepress/includes/class-translation-render.php:178
253
  msgid "OG Site Name"
254
  msgstr ""
255
 
256
+ #: ../translatepress/includes/class-translation-render.php:184
257
  msgid "OG Description"
258
  msgstr ""
259
 
260
+ #: ../translatepress/includes/class-translation-render.php:190
261
  msgid "Twitter Title"
262
  msgstr ""
263
 
264
+ #: ../translatepress/includes/class-translation-render.php:196
265
  msgid "Twitter Description"
266
  msgstr ""
267
 
268
+ #: ../translatepress/includes/class-translation-render.php:202
269
  msgid "Post Slug"
270
  msgstr ""
271
 
272
+ #: ../translatepress/includes/class-translation-render.php:206
273
  msgid "Page Title"
274
  msgstr ""
275
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: cozmoslabs, razvan.mo, madalin.ungureanu, cristophor
3
  Donate link: https://www.cozmoslabs.com/
4
  Tags: translate, translation, multilingual, automatic translation, bilingual, front-end translation, google translate, language
5
  Requires at least: 3.1.0
6
- Tested up to: 4.9.8
7
- Stable tag: 1.3.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -124,6 +124,12 @@ For more information please check out [TranslatePress - Multilingual plugin docu
124
  6. Menu Language Switcher
125
 
126
  == Changelog ==
 
 
 
 
 
 
127
  = 1.3.8 =
128
  * Speed improvements
129
  * Remove notices from Editor when we don't have translation languages
3
  Donate link: https://www.cozmoslabs.com/
4
  Tags: translate, translation, multilingual, automatic translation, bilingual, front-end translation, google translate, language
5
  Requires at least: 3.1.0
6
+ Tested up to: 5.0.1
7
+ Stable tag: 1.3.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
124
  6. Menu Language Switcher
125
 
126
  == Changelog ==
127
+ = 1.3.9 =
128
+ * Fixed some issues with url translations
129
+ * Speed improvements
130
+ * Add Javanese flag
131
+ * Fixed issue with trimming dynamic strings in our own ajax calls
132
+
133
  = 1.3.8 =
134
  * Speed improvements
135
  * Remove notices from Editor when we don't have translation languages