TranslatePress – Translate Multilingual sites - Version 2.2.4

Version Description

  • Prevent automatic translation of names and addresses in WooCommerce emails
  • Added external function for devs to easily create custom language switchers: trp_custom_language_switcher
  • Fixed issue with not including hreflang tags for some languages when Advanced option to Remove hreflang with Country Locale is used
  • Fixed warning related to using custom language flags
Download this release

Release Info

Developer razvan.mo
Plugin Icon 128x128 TranslatePress – Translate Multilingual sites
Version 2.2.4
Comparing to
See all releases

Code changes from version 2.2.3 to 2.2.4

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.3' );
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.4' );
64
 
65
  wp_cache_add_non_persistent_groups(array('trp'));
66
 
includes/class-url-converter.php CHANGED
@@ -180,13 +180,11 @@ class TRP_Url_Converter {
180
  }
181
 
182
  if ( apply_filters( 'trp_add_region_independent_hreflang_tags', true ) ) {
183
- if ( strpos( $language, '_' ) !== false ) {
184
- $language_independent_hreflang = strtok( $language, '_' );
185
- if ( !empty( $language_independent_hreflang ) && !in_array( $language_independent_hreflang, $region_independent_languages ) ) {
186
- $region_independent_languages[] = $language_independent_hreflang;
187
- $hreflang_duplicates_region_independent[$language] = '<link rel="alternate" hreflang="' . esc_attr( $language_independent_hreflang ) . '" href="' . esc_url( $this->get_url_for_language( $language ) ) . '"/>' . "\n";
188
 
189
- }
190
  }
191
  }
192
  }
180
  }
181
 
182
  if ( apply_filters( 'trp_add_region_independent_hreflang_tags', true ) ) {
183
+ $language_independent_hreflang = strtok( $language, '_' );
184
+ if ( !empty( $language_independent_hreflang ) && !in_array( $language_independent_hreflang, $region_independent_languages ) ) {
185
+ $region_independent_languages[] = $language_independent_hreflang;
186
+ $hreflang_duplicates_region_independent[$language] = '<link rel="alternate" hreflang="' . esc_attr( $language_independent_hreflang ) . '" href="' . esc_url( $this->get_url_for_language( $language ) ) . '"/>' . "\n";
 
187
 
 
188
  }
189
  }
190
  }
includes/compatibility-functions.php CHANGED
@@ -247,6 +247,17 @@ function trp_woo_skip_dynamic_translation( $skip_selectors ){
247
  return $skip_selectors;
248
  }
249
 
 
 
 
 
 
 
 
 
 
 
 
250
 
251
  /**
252
  * Compatibility with WooCommerce product variation.
247
  return $skip_selectors;
248
  }
249
 
250
+ /**
251
+ * Prevent translation of names and addresses in WooCommerce emails.
252
+ */
253
+ if( class_exists( 'WooCommerce' ) ){
254
+ add_filter( 'woocommerce_order_get_formatted_shipping_address', 'trp_woo_address_no_translate', 10, 3 );
255
+ add_filter( 'woocommerce_order_get_formatted_billing_address', 'trp_woo_address_no_translate', 10, 3 );
256
+
257
+ function trp_woo_address_no_translate( $address, $raw_address, $order ){
258
+ return empty( $address ) ? $address : '<span data-no-translation>' . $address . '</span>';
259
+ }
260
+ }
261
 
262
  /**
263
  * Compatibility with WooCommerce product variation.
includes/custom-language.php CHANGED
@@ -103,7 +103,7 @@ function trpc_flags_path_custom( $original_flags_path, $language_code ) {
103
  foreach ( $option['custom_language']['cuslangname'] as $key => $value ) {
104
  if ($language_code === $option["custom_language"]["cuslangcode"][$key] && !empty($option["custom_language"]["cuslangflag"][$key]) ) {
105
  $attachment_array = wp_get_attachment_image_src(attachment_url_to_postid($option["custom_language"]["cuslangflag"][ $key ]), 'trp-custom-language-flag');
106
- return isset($attachment_array) ? $attachment_array[0] : $option["custom_language"]["cuslangflag"][ $key ];
107
  }
108
  }
109
  }
103
  foreach ( $option['custom_language']['cuslangname'] as $key => $value ) {
104
  if ($language_code === $option["custom_language"]["cuslangcode"][$key] && !empty($option["custom_language"]["cuslangflag"][$key]) ) {
105
  $attachment_array = wp_get_attachment_image_src(attachment_url_to_postid($option["custom_language"]["cuslangflag"][ $key ]), 'trp-custom-language-flag');
106
+ return isset($attachment_array) && $attachment_array ? $attachment_array[0] : $option["custom_language"]["cuslangflag"][ $key ];
107
  }
108
  }
109
  }
includes/functions.php CHANGED
@@ -623,4 +623,46 @@ function trp_force_slash_at_end_of_link( $settings ){
623
  return true;
624
  else
625
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
626
  }
623
  return true;
624
  else
625
  return false;
626
+ }
627
+
628
+ /**
629
+ * This function is used by users to create their own language switcher.
630
+ *It returns an array with all the necessary information for the user to create their own custom language switcher.
631
+ *
632
+ * @return array
633
+ *
634
+ * The array returned has the following indexes: language_name, language_code, short_language_name, flag_link, current_page_url
635
+ */
636
+
637
+ function trp_custom_language_switcher(){
638
+ $trp = TRP_Translate_Press::get_trp_instance();
639
+ $trp_languages = $trp->get_component( 'languages' );
640
+ $trp_settings = $trp->get_component('settings');
641
+ $settings = $trp_settings->get_settings();
642
+
643
+ $languages_to_display = $settings['publish-languages'];
644
+ $translation_languages = $trp_languages->get_language_names( $languages_to_display );
645
+
646
+ $url_converter = $trp->get_component('url_converter');
647
+
648
+ $custom_ls_array = array();
649
+
650
+ foreach ($translation_languages as $item=> $language){
651
+
652
+ $custom_ls_array[$item]['language_name'] = $language;
653
+ $custom_ls_array[$item]['language_code'] = $item;
654
+ $custom_ls_array[$item]['short_language_name'] = $url_converter->get_url_slug( $item, false );
655
+
656
+ $flags_path = TRP_PLUGIN_URL .'assets/images/flags/';
657
+ $flags_path = apply_filters( 'trp_flags_path', $flags_path, $item );
658
+
659
+ $flag_file_name = $item .'.png';
660
+ $flag_file_name = apply_filters( 'trp_flag_file_name', $flag_file_name, $item );
661
+
662
+ $custom_ls_array[$item]['flag_link'] = esc_url( $flags_path . $flag_file_name );
663
+
664
+ $custom_ls_array[$item]['current_page_url'] = esc_url( $url_converter->get_url_for_language( $item, null, '' ));
665
+ }
666
+
667
+ return $custom_ls_array;
668
  }
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.3
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.4
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
@@ -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:1496
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
 
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:1507
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: 5.9.2
7
  Requires PHP: 5.6.20
8
- Stable tag: 2.2.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -140,6 +140,12 @@ For more information please check out our [documentation](https://translatepress
140
 
141
 
142
  == Changelog ==
 
 
 
 
 
 
143
  = 2.2.3 =
144
  * Fixed XSS security vulnerability
145
  * Fixed sitemap containing urls with language slugs linking to paths excluded from translation
5
  Requires at least: 3.1.0
6
  Tested up to: 5.9.2
7
  Requires PHP: 5.6.20
8
+ Stable tag: 2.2.4
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.4 =
144
+ * Prevent automatic translation of names and addresses in WooCommerce emails
145
+ * Added external function for devs to easily create custom language switchers: trp_custom_language_switcher
146
+ * Fixed issue with not including hreflang tags for some languages when Advanced option to Remove hreflang with Country Locale is used
147
+ * Fixed warning related to using custom language flags
148
+
149
  = 2.2.3 =
150
  * Fixed XSS security vulnerability
151
  * Fixed sitemap containing urls with language slugs linking to paths excluded from translation