TranslatePress – Translate Multilingual sites - Version 1.1.3

Version Description

  • Fix issue where the language switcher didn't work for BuddyPress pages
  • Fixed issue with CDATA in post content that was breaking the translation
  • Added a filter that can be activated and that tries to fix invalid html: trp_try_fixing_invalid_html
Download this release

Release Info

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

Code changes from version 1.1.2 to 1.1.3

class-translate-press.php CHANGED
@@ -39,7 +39,7 @@ class TRP_Translate_Press{
39
define( 'TRP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
40
define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41
define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
42
- define( 'TRP_PLUGIN_VERSION', '1.1.2' );
43
44
$this->load_dependencies();
45
$this->initialize_components();
@@ -132,6 +132,8 @@ class TRP_Translate_Press{
132
$this->loader->add_filter( 'wp_redirect', $this->translation_render, 'force_language_on_form_url_redirect', 99, 2 );
133
$this->loader->add_filter( 'trp_before_translate_content', $this->translation_render, 'force_preview_on_url_in_ajax', 10 );
134
$this->loader->add_filter( 'trp_before_translate_content', $this->translation_render, 'force_form_language_on_url_in_ajax', 20 );
135
136
137
$this->loader->add_action( 'wp_enqueue_scripts', $this->language_switcher, 'enqueue_language_switcher_scripts' );
39
define( 'TRP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
40
define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41
define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
42
+ define( 'TRP_PLUGIN_VERSION', '1.1.3' );
43
44
$this->load_dependencies();
45
$this->initialize_components();
132
$this->loader->add_filter( 'wp_redirect', $this->translation_render, 'force_language_on_form_url_redirect', 99, 2 );
133
$this->loader->add_filter( 'trp_before_translate_content', $this->translation_render, 'force_preview_on_url_in_ajax', 10 );
134
$this->loader->add_filter( 'trp_before_translate_content', $this->translation_render, 'force_form_language_on_url_in_ajax', 20 );
135
+ /* handle CDATA str replacement from the content as it is messing up the renderer */
136
+ $this->loader->add_filter( "trp_before_translate_content", $this->translation_render, 'handle_cdata', 1000 );
137
138
139
$this->loader->add_action( 'wp_enqueue_scripts', $this->language_switcher, 'enqueue_language_switcher_scripts' );
includes/class-language-switcher.php CHANGED
@@ -201,7 +201,7 @@ class TRP_Language_Switcher{
201
<div id="trp-floater-ls-current-language" class="<?php echo $floater_flags_class ?>">
202
<a href="javascript:void(0)" class="trp-floater-ls-disabled-language" onclick="void(0)"><?php echo ( $floater_settings['flags'] ? $this->add_flag( $current_language['code'], $current_language['name'] ) : '' ); echo $current_language_label; ?></a>
203
</div>
204
- <div id="trp-floater-ls-language-list" class="<?php echo $floater_flags_class;?>" <?php echo ( isset( $_GET['trp-edit-translation'] ) && $_GET['trp-edit-translation'] == 'preview' ) ? 'data-trp-unpreviewable="trp-unpreviewable"' : ''?>">
205
<?php
206
foreach( $other_languages as $code => $name ) {
207
$language_label = '';
201
<div id="trp-floater-ls-current-language" class="<?php echo $floater_flags_class ?>">
202
<a href="javascript:void(0)" class="trp-floater-ls-disabled-language" onclick="void(0)"><?php echo ( $floater_settings['flags'] ? $this->add_flag( $current_language['code'], $current_language['name'] ) : '' ); echo $current_language_label; ?></a>
203
</div>
204
+ <div id="trp-floater-ls-language-list" class="<?php echo $floater_flags_class;?>" <?php echo ( isset( $_GET['trp-edit-translation'] ) && $_GET['trp-edit-translation'] == 'preview' ) ? 'data-trp-unpreviewable="trp-unpreviewable"' : ''?>>
205
<?php
206
foreach( $other_languages as $code => $name ) {
207
$language_label = '';
includes/class-translation-manager.php CHANGED
@@ -860,8 +860,10 @@ class TRP_Translation_Manager{
860
}
861
return $classes;
862
}
863
-
864
-
865
public function trp_view_as_user(){
866
if( !is_admin() || $this::is_ajax_on_frontend() ) {
867
if (isset($_REQUEST['trp-edit-translation']) && $_REQUEST['trp-edit-translation'] === 'preview' && isset($_REQUEST['trp-view-as']) && isset($_REQUEST['trp-view-as-nonce'])) {
860
}
861
return $classes;
862
}
863
+
864
+ /**
865
+ * Function that switches the view of the user to other roles
866
+ */
867
public function trp_view_as_user(){
868
if( !is_admin() || $this::is_ajax_on_frontend() ) {
869
if (isset($_REQUEST['trp-edit-translation']) && $_REQUEST['trp-edit-translation'] === 'preview' && isset($_REQUEST['trp-view-as']) && isset($_REQUEST['trp-view-as-nonce'])) {
includes/class-translation-render.php CHANGED
@@ -260,6 +260,18 @@ class TRP_Translation_Render{
260
}
261
}
262
263
$no_translate_attribute = 'data-no-translation';
264
265
$translateable_strings = array();
@@ -851,4 +863,14 @@ class TRP_Translation_Render{
851
$item = $this->url_converter->get_url_for_language( $form_language, $item );
852
}
853
}
854
}
260
}
261
}
262
263
+ /**
264
+ * tries to fix the html document. It is off by default. use at own risk
265
+ * */
266
+ if( apply_filters( 'trp_try_fixing_invalid_html', false ) ) {
267
+ if( class_exists('DOMDocument') ) {
268
+ $dom = new DOMDocument();
269
+ libxml_use_internal_errors(true);//so no warnings will show up for invalid html
270
+ $dom->loadHTML($output, LIBXML_NOWARNING);
271
+ $output = $dom->saveHTML();
272
+ }
273
+ }
274
+
275
$no_translate_attribute = 'data-no-translation';
276
277
$translateable_strings = array();
863
$item = $this->url_converter->get_url_for_language( $form_language, $item );
864
}
865
}
866
+
867
+ /**
868
+ * Function that reverses CDATA string replacement from the content because it breaks the renderer
869
+ * @param $content
870
+ * @return mixed
871
+ */
872
+ public function handle_cdata( $output ){
873
+ $output = str_replace( ']]&gt;', ']]>', $output );
874
+ return $output;
875
+ }
876
}
includes/class-url-converter.php CHANGED
@@ -126,6 +126,7 @@ class TRP_Url_Converter {
126
$language = $TRP_LANGUAGE;
127
}
128
129
// if we have the homepage, we replace it with the filtered homepage that contains the language url.
130
if( trailingslashit( $this->cur_page_url() ) == trailingslashit($this->get_abs_home()) ){
131
$TRP_LANGUAGE = $language;
@@ -135,7 +136,7 @@ class TRP_Url_Converter {
135
}
136
137
138
- if ( empty( $url ) && is_object( $post ) && is_singular() ) {
139
// if we have a $post we need to run the language switcher through get_permalink so we apply the correct slug that can be different.
140
$TRP_LANGUAGE = $language;
141
$new_url = get_permalink( $post->ID );
126
$language = $TRP_LANGUAGE;
127
}
128
129
+
130
// if we have the homepage, we replace it with the filtered homepage that contains the language url.
131
if( trailingslashit( $this->cur_page_url() ) == trailingslashit($this->get_abs_home()) ){
132
$TRP_LANGUAGE = $language;
136
}
137
138
139
+ if ( empty( $url ) && is_object( $post ) && ( $post->ID != '0' ) && is_singular() ) {
140
// if we have a $post we need to run the language switcher through get_permalink so we apply the correct slug that can be different.
141
$TRP_LANGUAGE = $language;
142
$new_url = get_permalink( $post->ID );
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.1.2
7
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
Author URI: https://cozmoslabs.com/
9
License: GPL2
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.1.3
7
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
Author URI: https://cozmoslabs.com/
9
License: GPL2
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.cozmoslabs.com/
4
Tags: translate, translation, multilingual, automatic translation, front-end translation, google translate, bilingual
5
Requires at least: 3.1.0
6
Tested up to: 4.9.1
7
- Stable tag: 1.1.2
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -107,13 +107,18 @@ For more information please check out [TranslatePress documentation](https://tra
107
108
== Changelog ==
109
110
= 1.1.2 =
111
- We now make sure that all forms when submitted redirect to the correct language
112
- Fixed an issue with missing slash from language switcher
113
- Fixed an issue where we were not redirecting to the correct url slug when switching languages
114
- Fixed a possible notice inside the get_language_names function
115
- Fixed html breaking because of unescaped quotes in translated meta content
116
- Removed a special character from the full_trim function that was causing some strings to not be selectable for translation
117
118
= 1.1.1 =
119
* Fixed js error with startsWith method not being supported in IE
4
Tags: translate, translation, multilingual, automatic translation, front-end translation, google translate, bilingual
5
Requires at least: 3.1.0
6
Tested up to: 4.9.1
7
+ Stable tag: 1.1.3
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
107
108
== Changelog ==
109
110
+ = 1.1.3 =
111
+ * Fix issue where the language switcher didn't work for BuddyPress pages
112
+ * Fixed issue with CDATA in post content that was breaking the translation
113
+ * Added a filter that can be activated and that tries to fix invalid html: trp_try_fixing_invalid_html
114
+
115
= 1.1.2 =
116
+ * We now make sure that all forms when submitted redirect to the correct language
117
+ * Fixed an issue with missing slash from language switcher
118
+ * Fixed an issue where we were not redirecting to the correct url slug when switching languages
119
+ * Fixed a possible notice inside the get_language_names function
120
+ * Fixed html breaking because of unescaped quotes in translated meta content
121
+ * Removed a special character from the full_trim function that was causing some strings to not be selectable for translation
122
123
= 1.1.1 =
124
* Fixed js error with startsWith method not being supported in IE