TranslatePress – Translate Multilingual sites - Version 2.2.9

Version Description

  • Fix: compatibility issue between translation interface and Thrive Architect
  • Fix: make sure processed links are stripped of extra tags
  • Fix: a potential error in the url converter
Download this release

Release Info

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

Code changes from version 2.2.8 to 2.2.9

class-translate-press.php CHANGED
@@ -60,7 +60,7 @@ class TRP_Translate_Press{
60
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
61
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
62
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
63
- define( 'TRP_PLUGIN_VERSION', '2.2.8' );
64
 
65
  wp_cache_add_non_persistent_groups(array('trp'));
66
 
60
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
61
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
62
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
63
+ define( 'TRP_PLUGIN_VERSION', '2.2.9' );
64
 
65
  wp_cache_add_non_persistent_groups(array('trp'));
66
 
includes/class-translation-manager.php CHANGED
@@ -948,7 +948,18 @@ class TRP_Translation_Manager
948
  if (did_action('init') && isset($trp_output_buffer_started) && $trp_output_buffer_started) {//check here for our global $trp_output_buffer_started, don't wrap the gettexts if they are not processed by our cleanup callbacks for the buffers
949
  if ((!empty($TRP_LANGUAGE) && $this->settings["default-language"] != $TRP_LANGUAGE) || (isset($_REQUEST['trp-edit-translation']) && $_REQUEST['trp-edit-translation'] == 'preview')) {
950
  //add special start and end tags so that it does not influence html in any way. we will replace them with < and > at the start of the translate function
951
- $translation = apply_filters('trp_process_gettext_tags', '#!trpst#trp-gettext data-trpgettextoriginal=' . $db_id . '#!trpen#' . $translation . '#!trpst#/trp-gettext#!trpen#', $translation, $skip_gettext_querying, $text, $domain);
 
 
 
 
 
 
 
 
 
 
 
952
  }
953
  }
954
  }
948
  if (did_action('init') && isset($trp_output_buffer_started) && $trp_output_buffer_started) {//check here for our global $trp_output_buffer_started, don't wrap the gettexts if they are not processed by our cleanup callbacks for the buffers
949
  if ((!empty($TRP_LANGUAGE) && $this->settings["default-language"] != $TRP_LANGUAGE) || (isset($_REQUEST['trp-edit-translation']) && $_REQUEST['trp-edit-translation'] == 'preview')) {
950
  //add special start and end tags so that it does not influence html in any way. we will replace them with < and > at the start of the translate function
951
+ /**
952
+ * Compatibility with Woocomerce Payments
953
+ *
954
+ * In the file woocommerce-payments/includes/class-wc-payments-customer-service.php there is this line of code
955
+ * $description = sprintf( __( 'Name: %1$s, Username: %2$s', 'woocommerce-payments' ), $name, $wc_customer->get_username() ); that should return admin or guest
956
+ * but for some reason it returns our gettext string without the stripped gettext.
957
+ */
958
+
959
+ if ( $text != 'Name: %1$s, Username: %2$s' && $text != 'Name: %1$s, Guest' ) {
960
+ $translation = apply_filters( 'trp_process_gettext_tags', '#!trpst#trp-gettext data-trpgettextoriginal=' . $db_id . '#!trpen#' . $translation . '#!trpst#/trp-gettext#!trpen#', $translation, $skip_gettext_querying, $text, $domain );
961
+
962
+ }
963
  }
964
  }
965
  }
includes/class-translation-render.php CHANGED
@@ -1770,6 +1770,7 @@ class TRP_Translation_Render{
1770
  }
1771
 
1772
  $item = $this->url_converter->get_url_for_language( $form_language, $item );
 
1773
  }
1774
  }
1775
 
1770
  }
1771
 
1772
  $item = $this->url_converter->get_url_for_language( $form_language, $item );
1773
+ $item = str_replace('#TRPLINKPROCESSED', '', $item);
1774
  }
1775
  }
1776
 
includes/class-url-converter.php CHANGED
@@ -411,15 +411,18 @@ class TRP_Url_Converter {
411
  if( isset( $trp_current_url_term_slug ) && isset($trp_current_url_taxonomy) && $new_url_has_been_determined === false){
412
  // check here if it is a term link
413
  $current_term_link = get_term_link( $trp_current_url_term_slug, $trp_current_url_taxonomy);
414
- $language_to_replace = $TRP_LANGUAGE;
415
- $TRP_LANGUAGE = $language;
416
- $current_term_link= apply_filters( 'trp_get_url_for_language', $current_term_link, $url, $language_to_replace, $this->get_abs_home(), $this->get_lang_from_url_string($url), $this->get_url_slug( $language ) );
 
417
  $check_term_link = get_term_link($trp_current_url_term_slug, $trp_current_url_taxonomy);
418
  if (!is_wp_error($check_term_link) && strpos(urldecode( $url ), $current_term_link) === 0) {
419
  $new_url = str_replace( $current_term_link, $check_term_link, urldecode( $url ) );
 
420
  $new_url_has_been_determined = true;
421
  }
422
  $TRP_LANGUAGE = $trp_language_copy;
 
423
  }
424
 
425
  /**
@@ -689,7 +692,7 @@ class TRP_Url_Converter {
689
  if ($abs_home_url_obj->getPath() == "/"){
690
  $abs_home_url_obj->setPath('');
691
  }
692
- $possible_path = str_replace($abs_home_url_obj->getPath(), '', $url_obj->getPath());
693
  $lang = ltrim( $possible_path,'/' );
694
  $lang = explode('/', $lang);
695
  if( $lang == false ){
411
  if( isset( $trp_current_url_term_slug ) && isset($trp_current_url_taxonomy) && $new_url_has_been_determined === false){
412
  // check here if it is a term link
413
  $current_term_link = get_term_link( $trp_current_url_term_slug, $trp_current_url_taxonomy);
414
+ if (!is_wp_error($current_term_link)){
415
+ $language_to_replace = $TRP_LANGUAGE;
416
+ $TRP_LANGUAGE = $language;
417
+ $current_term_link= apply_filters( 'trp_get_url_for_language', $current_term_link, $url, $language_to_replace, $this->get_abs_home(), $this->get_lang_from_url_string($url), $this->get_url_slug( $language ) );
418
  $check_term_link = get_term_link($trp_current_url_term_slug, $trp_current_url_taxonomy);
419
  if (!is_wp_error($check_term_link) && strpos(urldecode( $url ), $current_term_link) === 0) {
420
  $new_url = str_replace( $current_term_link, $check_term_link, urldecode( $url ) );
421
+ $new_url = apply_filters( 'trp_get_url_for_language', $new_url, $url, $language, $this->get_abs_home(), $this->get_lang_from_url_string($url), $this->get_url_slug( $language ) );
422
  $new_url_has_been_determined = true;
423
  }
424
  $TRP_LANGUAGE = $trp_language_copy;
425
+ }
426
  }
427
 
428
  /**
692
  if ($abs_home_url_obj->getPath() == "/"){
693
  $abs_home_url_obj->setPath('');
694
  }
695
+ $possible_path = str_replace( $abs_home_url_obj->getPath(), '', $url_obj->getPath() );
696
  $lang = ltrim( $possible_path,'/' );
697
  $lang = explode('/', $lang);
698
  if( $lang == false ){
includes/compatibility-functions.php CHANGED
@@ -1025,6 +1025,22 @@ function trp_thrive_arhitect_compatibility($bool) {
1025
 
1026
  return $bool;
1027
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1028
 
1029
  /**
1030
  * Compatibility with the RECON gateway for woocommerce. We must not send the "trp-form-language" hidden field in the post request to the gateway
1025
 
1026
  return $bool;
1027
  }
1028
+ // do not redirect the URL's that are used inside Thrive Architect Editor
1029
+ add_filter( 'trp_allow_language_redirect', 'trp_thrive_no_redirect_in_editor', 10, 3 );
1030
+ function trp_thrive_no_redirect_in_editor( $allow_redirect, $needed_language, $current_page_url ){
1031
+ if ( strpos($current_page_url, 'tve=true&tcbf')!== false ){
1032
+ return false;
1033
+ }
1034
+ return $allow_redirect;
1035
+ };
1036
+ // skip the URL's that are used inside Thrive Architect Editor as they are stripped of parameters in certain cases and the editor isn't working.
1037
+ add_filter('trp_skip_url_for_language', 'trp_thrive_skip_language_in_editor', 10, 2);
1038
+ function trp_thrive_skip_language_in_editor($skip, $url){
1039
+ if ( strpos($url, 'tve=true&tcbf') !== false ){
1040
+ return true;
1041
+ }
1042
+ return $skip;
1043
+ }
1044
 
1045
  /**
1046
  * Compatibility with the RECON gateway for woocommerce. We must not send the "trp-form-language" hidden field in the post request to the gateway
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 using a visual front-end translation editor, with full support for WooCommerce and site builders.
6
- Version: 2.2.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 using a visual front-end translation editor, with full support for WooCommerce and site builders.
6
+ Version: 2.2.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
@@ -725,11 +725,11 @@ msgstr ""
725
  msgid "Translate Page"
726
  msgstr ""
727
 
728
- #: includes/class-translation-manager.php:1272
729
  msgid "Security check"
730
  msgstr ""
731
 
732
- #: includes/class-translation-manager.php:1346
733
  msgid "<strong>Warning:</strong> Some strings have possibly incorrectly encoded characters. This may result in breaking the queries, rendering the page untranslated in live mode. Consider revising the following strings or their method of outputting."
734
  msgstr ""
735
 
@@ -905,7 +905,7 @@ msgstr ""
905
  msgid "<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server."
906
  msgstr ""
907
 
908
- #: includes/compatibility-functions.php:1538
909
  msgid "Detected long query limitation on WPEngine hosting. Some large pages may appear untranslated. You can remove limitation by adding the following to your site’s wp-config.php: define( 'WPE_GOVERNOR', false ); "
910
  msgstr ""
911
 
725
  msgid "Translate Page"
726
  msgstr ""
727
 
728
+ #: includes/class-translation-manager.php:1283
729
  msgid "Security check"
730
  msgstr ""
731
 
732
+ #: includes/class-translation-manager.php:1357
733
  msgid "<strong>Warning:</strong> Some strings have possibly incorrectly encoded characters. This may result in breaking the queries, rendering the page untranslated in live mode. Consider revising the following strings or their method of outputting."
734
  msgstr ""
735
 
905
  msgid "<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server."
906
  msgstr ""
907
 
908
+ #: includes/compatibility-functions.php:1554
909
  msgid "Detected long query limitation on WPEngine hosting. Some large pages may appear untranslated. You can remove limitation by adding the following to your site’s wp-config.php: define( 'WPE_GOVERNOR', false ); "
910
  msgstr ""
911
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: translate, translation, multilingual, automatic translation, bilingual, fr
5
  Requires at least: 3.1.0
6
  Tested up to: 6.0
7
  Requires PHP: 5.6.20
8
- Stable tag: 2.2.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -140,6 +140,11 @@ For more information please check out our [documentation](https://translatepress
140
 
141
 
142
  == Changelog ==
 
 
 
 
 
143
  = 2.2.8 =
144
  * Fixed truncated archive urls on front page on translated pages
145
  * Fixed bug with language switcher not working properly for posts with translated slugs when using Advanced option to Exclude Paths From Translation
5
  Requires at least: 3.1.0
6
  Tested up to: 6.0
7
  Requires PHP: 5.6.20
8
+ Stable tag: 2.2.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
140
 
141
 
142
  == Changelog ==
143
+ = 2.2.9 =
144
+ * Fix: compatibility issue between translation interface and Thrive Architect
145
+ * Fix: make sure processed links are stripped of extra tags
146
+ * Fix: a potential error in the url converter
147
+
148
  = 2.2.8 =
149
  * Fixed truncated archive urls on front page on translated pages
150
  * Fixed bug with language switcher not working properly for posts with translated slugs when using Advanced option to Exclude Paths From Translation