TranslatePress – Translate Multilingual sites - Version 1.8.2

Version Description

  • Added compatibility with RECON gateway for WooCommerce
  • Hooked changing locale to a higher priority. Fixes conflict with Divi theme
  • Fix WooCommerce remove from cart action for certain languages
Download this release

Release Info

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

Code changes from version 1.8.1 to 1.8.2

class-translate-press.php CHANGED
@@ -57,7 +57,7 @@ class TRP_Translate_Press{
57
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
58
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
59
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
60
- define( 'TRP_PLUGIN_VERSION', '1.8.1' );
61
 
62
  wp_cache_add_non_persistent_groups(array('trp'));
63
 
@@ -320,7 +320,7 @@ class TRP_Translate_Press{
320
  $this->loader->add_filter( 'widget_text', null, 'shortcode_unautop', 11 );
321
 
322
  /* handle dynamic texts with gettext */
323
- $this->loader->add_filter( 'locale', $this->languages, 'change_locale' );
324
 
325
  $this->loader->add_action( 'init', $this->translation_manager, 'create_gettext_translated_global' );
326
  $this->loader->add_action( 'init', $this->translation_manager, 'initialize_gettext_processing' );
57
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
58
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
59
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
60
+ define( 'TRP_PLUGIN_VERSION', '1.8.2' );
61
 
62
  wp_cache_add_non_persistent_groups(array('trp'));
63
 
320
  $this->loader->add_filter( 'widget_text', null, 'shortcode_unautop', 11 );
321
 
322
  /* handle dynamic texts with gettext */
323
+ $this->loader->add_filter( 'locale', $this->languages, 'change_locale', 99999 );
324
 
325
  $this->loader->add_action( 'init', $this->translation_manager, 'create_gettext_translated_global' );
326
  $this->loader->add_action( 'init', $this->translation_manager, 'initialize_gettext_processing' );
includes/class-translation-render.php CHANGED
@@ -876,7 +876,7 @@ class TRP_Translation_Render{
876
  // based on this we're filtering wp_redirect to include the proper URL when returning to the current page.
877
  foreach ( $html->find('form') as $k => $row ){
878
  $row->setAttribute( 'data-trp-original-action', $row->action );
879
- $row->innertext .= apply_filters( 'trp_form_inputs', '<input type="hidden" name="trp-form-language" value="'. $this->settings['url-slugs'][$TRP_LANGUAGE] .'"/>', $TRP_LANGUAGE, $this->settings['url-slugs'][$TRP_LANGUAGE] );
880
  $form_action = $row->action;
881
 
882
  $is_external_link = $this->is_external_link( $form_action, $home_url );
876
  // based on this we're filtering wp_redirect to include the proper URL when returning to the current page.
877
  foreach ( $html->find('form') as $k => $row ){
878
  $row->setAttribute( 'data-trp-original-action', $row->action );
879
+ $row->innertext .= apply_filters( 'trp_form_inputs', '<input type="hidden" name="trp-form-language" value="'. $this->settings['url-slugs'][$TRP_LANGUAGE] .'"/>', $TRP_LANGUAGE, $this->settings['url-slugs'][$TRP_LANGUAGE], $row );
880
  $form_action = $row->action;
881
 
882
  $is_external_link = $this->is_external_link( $form_action, $home_url );
includes/class-url-converter.php CHANGED
@@ -36,7 +36,7 @@ class TRP_Url_Converter {
36
  return $url;
37
  }
38
 
39
- if( is_customize_preview() || $this->is_admin_request() || $this->is_sitemap_link( $path ) )
40
  return $url;
41
 
42
  $url_slug = $this->get_url_slug( $TRP_LANGUAGE );
@@ -98,7 +98,7 @@ class TRP_Url_Converter {
98
  * @param $path the path that is passed inside home_url
99
  * @return bool
100
  */
101
- public function is_sitemap_link( $path = '' ) {
102
  global $wp_current_filter;
103
 
104
  if( empty( $path ) || $path === '/' ){
@@ -225,7 +225,7 @@ class TRP_Url_Converter {
225
 
226
  // actual logic of the function
227
 
228
- if ( $this->is_sitemap_link('') ){
229
  trp_bulk_debug($debug, array('url' => $url, 'abort' => 'is file'));
230
  wp_cache_set('get_url_for_language_' . $hash, $url . $trp_link_is_processed, 'trp');
231
  return $url . $trp_link_is_processed; //abort for files
36
  return $url;
37
  }
38
 
39
+ if( is_customize_preview() || $this->is_admin_request() || $this->is_sitemap_path( $path ) )
40
  return $url;
41
 
42
  $url_slug = $this->get_url_slug( $TRP_LANGUAGE );
98
  * @param $path the path that is passed inside home_url
99
  * @return bool
100
  */
101
+ public function is_sitemap_path( $path = '' ) {
102
  global $wp_current_filter;
103
 
104
  if( empty( $path ) || $path === '/' ){
225
 
226
  // actual logic of the function
227
 
228
+ if ( $this->is_sitemap_path('') ){
229
  trp_bulk_debug($debug, array('url' => $url, 'abort' => 'is file'));
230
  wp_cache_set('get_url_for_language_' . $hash, $url . $trp_link_is_processed, 'trp');
231
  return $url . $trp_link_is_processed; //abort for files
includes/compatibility-functions.php CHANGED
@@ -437,6 +437,28 @@ function trp_woo_translate_product_title_added_to_cart( ...$args ){
437
  }
438
  return $title;
439
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
440
  /**
441
  * Compatibility with WooTour plugin
442
  *
@@ -824,3 +846,17 @@ if( function_exists('architect_init') ) {
824
  return $bool;
825
  }
826
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
437
  }
438
  return $title;
439
  }
440
+
441
+ /**
442
+ * Compatibility with WooCommerce "remove from cart" action
443
+ *
444
+ * In some cases (eg for Taiwanese) the product name and double quotes &ldquo &rdquo HTML entities
445
+ * were translated/parsed wrongly.
446
+ * We provide a fix by adding spaces between the quotes and product name
447
+ *
448
+ */
449
+
450
+ if( class_exists( 'WooCommerce' ) ) {
451
+ add_filter( 'woocommerce_cart_item_removed_title', 'trp_woo_fix_product_remove_from_cart_notice', 10, 2 );
452
+
453
+ function trp_woo_fix_product_remove_from_cart_notice($message, $cart_item){
454
+ $product = wc_get_product( $cart_item['product_id'] );
455
+ if ($product){
456
+ $message = sprintf( _x( '&ldquo; %s &rdquo;', 'Item name in quotes', 'woocommerce' ), $product->get_name() );
457
+ }
458
+ return $message;
459
+ }
460
+ }
461
+
462
  /**
463
  * Compatibility with WooTour plugin
464
  *
846
  return $bool;
847
  }
848
  }
849
+
850
+ /**
851
+ * Compatibility with the RECON gateway for woocommerce. We must not send the "trp-form-language" hidden field in the post request to the gateway
852
+ */
853
+ if( class_exists('WC_Gateway_RECON') ) {
854
+ add_filter('trp_form_inputs', 'trp_recon_gateway_compatibility', 10, 4);
855
+ function trp_recon_gateway_compatibility($input, $trp_language, $slug, $row)
856
+ {
857
+ if (isset($row->attr['name']) && $row->attr['name'] === 'checkout') {
858
+ $input = '';
859
+ }
860
+ return $input;
861
+ }
862
+ }
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: 1.8.1
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: 1.8.2
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: cozmoslabs, razvan.mo, madalin.ungureanu, sareiodata, cristophor
3
  Donate link: https://www.translatepress.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.5
7
  Requires PHP: 5.6.20
8
- Stable tag: 1.8.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -138,6 +138,11 @@ For more information please check out our [documentation](https://translatepress
138
 
139
 
140
  == Changelog ==
 
 
 
 
 
141
  = 1.8.1 =
142
  * Fixed a problem with sitemap categories not being displayed correctly in Yoast SEO
143
  * Changed a redirect status from 302 to 301 in certain cases
@@ -729,4 +734,4 @@ For more information please check out our [documentation](https://translatepress
729
  * Fixed JS error Uncaught Error: Syntax error, unrecognized expression
730
 
731
  = 1.0.0 =
732
- * Initial release.
3
  Donate link: https://www.translatepress.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.5.1
7
  Requires PHP: 5.6.20
8
+ Stable tag: 1.8.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
138
 
139
 
140
  == Changelog ==
141
+ = 1.8.2 =
142
+ * Added compatibility with RECON gateway for WooCommerce
143
+ * Hooked changing locale to a higher priority. Fixes conflict with Divi theme
144
+ * Fix WooCommerce remove from cart action for certain languages
145
+
146
  = 1.8.1 =
147
  * Fixed a problem with sitemap categories not being displayed correctly in Yoast SEO
148
  * Changed a redirect status from 302 to 301 in certain cases
734
  * Fixed JS error Uncaught Error: Syntax error, unrecognized expression
735
 
736
  = 1.0.0 =
737
+ * Initial release.