Version Description
- Added possibility to exclude hreflang from an original URL
- Fixed translating json inside json. It ensures compatibility with Brizy
- Fixed http 500 response in trp-ajax calls
Download this release
Release Info
Developer | madalin.ungureanu |
Plugin | TranslatePress – Translate Multilingual sites |
Version | 1.7.8 |
Comparing to | |
See all releases |
Code changes from version 1.7.7 to 1.7.8
- assets/js/trp-translate-dom-changes.js +3 -1
- class-translate-press.php +1 -1
- includes/class-translation-render.php +10 -1
- includes/class-url-converter.php +7 -0
- includes/external-functions.php +17 -10
- includes/trp-ajax.php +2 -1
- index.php +1 -1
- readme.txt +6 -1
assets/js/trp-translate-dom-changes.js
CHANGED
@@ -13,6 +13,7 @@ function TRP_Translator(){
|
|
13 |
characterData: false,//this could be CDATA so I set it to false in v 1.4.5
|
14 |
subtree: true
|
15 |
};
|
|
|
16 |
var custom_ajax_url = trp_data.trp_custom_ajax_url;
|
17 |
var wp_ajax_url = trp_data.trp_wp_ajax_url;
|
18 |
var language_to_query;
|
@@ -37,7 +38,8 @@ function TRP_Translator(){
|
|
37 |
original_language : original_language, // used for trp custom ajax
|
38 |
originals : JSON.stringify( string_originals ),
|
39 |
skip_machine_translation : JSON.stringify( skip_machine_translation ),
|
40 |
-
dynamic_strings : 'true'
|
|
|
41 |
},
|
42 |
success: function( response ) {
|
43 |
if ( response === 'error' ) {
|
13 |
characterData: false,//this could be CDATA so I set it to false in v 1.4.5
|
14 |
subtree: true
|
15 |
};
|
16 |
+
var translate_numerals_opt = trp_data.trp_translate_numerals_opt;
|
17 |
var custom_ajax_url = trp_data.trp_custom_ajax_url;
|
18 |
var wp_ajax_url = trp_data.trp_wp_ajax_url;
|
19 |
var language_to_query;
|
38 |
original_language : original_language, // used for trp custom ajax
|
39 |
originals : JSON.stringify( string_originals ),
|
40 |
skip_machine_translation : JSON.stringify( skip_machine_translation ),
|
41 |
+
dynamic_strings : 'true',
|
42 |
+
translate_numerals_opt : translate_numerals_opt
|
43 |
},
|
44 |
success: function( response ) {
|
45 |
if ( response === 'error' ) {
|
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.7.
|
61 |
|
62 |
wp_cache_add_non_persistent_groups(array('trp'));
|
63 |
|
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.7.8' );
|
61 |
|
62 |
wp_cache_add_non_persistent_groups(array('trp'));
|
63 |
|
includes/class-translation-render.php
CHANGED
@@ -1011,7 +1011,16 @@ class TRP_Translation_Render{
|
|
1011 |
//check if it a html text and translate
|
1012 |
$html_decoded_value = html_entity_decode( (string) $value );
|
1013 |
if ( $html_decoded_value != strip_tags( $html_decoded_value ) ) {
|
1014 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1015 |
/*the translate-press tag can appear on a gettext string without html and should not be left in the json
|
1016 |
as we don't know how it will be inserted into the page by js */
|
1017 |
$value = preg_replace( '/(<|<)translate-press (.*?)(>|>)/', '', $value );
|
1011 |
//check if it a html text and translate
|
1012 |
$html_decoded_value = html_entity_decode( (string) $value );
|
1013 |
if ( $html_decoded_value != strip_tags( $html_decoded_value ) ) {
|
1014 |
+
|
1015 |
+
$json_array = json_decode( $value, true );
|
1016 |
+
if( ! ( $json_array && $json_array != $value ) ) {
|
1017 |
+
/* stripslashes only if not json. Covers the case where we have json inside json.
|
1018 |
+
* Not sure why we need stripslashes for html though.
|
1019 |
+
* Keeping it because it's legacy and it might solve a use case we are unaware of right now */
|
1020 |
+
$value = stripslashes($value);
|
1021 |
+
}
|
1022 |
+
|
1023 |
+
$value = $this->translate_page( $value );
|
1024 |
/*the translate-press tag can appear on a gettext string without html and should not be left in the json
|
1025 |
as we don't know how it will be inserted into the page by js */
|
1026 |
$value = preg_replace( '/(<|<)translate-press (.*?)(>|>)/', '', $value );
|
includes/class-url-converter.php
CHANGED
@@ -129,6 +129,13 @@ class TRP_Url_Converter {
|
|
129 |
*/
|
130 |
public function add_hreflang_to_head(){
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
$languages = $this->settings['publish-languages'];
|
133 |
if ( isset( $_GET['trp-edit-translation'] ) && $_GET['trp-edit-translation'] == 'preview' ) {
|
134 |
$languages = $this->settings['translation-languages'];
|
129 |
*/
|
130 |
public function add_hreflang_to_head(){
|
131 |
|
132 |
+
// exclude hreflang for URL
|
133 |
+
$default_language= $this->settings["default-language"];
|
134 |
+
$original_url = str_replace('#TRPLINKPROCESSED', '', $this->get_url_for_language( $default_language ) ) ;
|
135 |
+
if ( apply_filters('trp-exclude-hreflang', false, $original_url) ){
|
136 |
+
return;
|
137 |
+
}
|
138 |
+
|
139 |
$languages = $this->settings['publish-languages'];
|
140 |
if ( isset( $_GET['trp-edit-translation'] ) && $_GET['trp-edit-translation'] == 'preview' ) {
|
141 |
$languages = $this->settings['translation-languages'];
|
includes/external-functions.php
CHANGED
@@ -1,24 +1,31 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
|
5 |
/**
|
6 |
* Trim strings.
|
7 |
*
|
8 |
* @param string $string Raw string.
|
9 |
*
|
|
|
|
|
10 |
* @return string Trimmed string.
|
11 |
*/
|
12 |
-
function trp_full_trim( $string ) {
|
13 |
-
|
14 |
-
$opt = get_option( 'trp_advanced_settings', false );
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
-
/* Make sure you update full_trim function from trp-ajax too*/
|
22 |
|
23 |
/* 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
|
24 |
Removed chr( 194 ) . chr( 160 ) because it altered some special characters (¿¡)
|
@@ -42,7 +49,7 @@ function trp_full_trim( $string ) {
|
|
42 |
}
|
43 |
}while( $string != $previous_iteration_string );
|
44 |
|
45 |
-
if ($
|
46 |
$filter_string = " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>'\"";
|
47 |
} else {
|
48 |
$filter_string = " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>1234567890'\"";
|
1 |
<?php
|
2 |
|
3 |
|
|
|
4 |
/**
|
5 |
* Trim strings.
|
6 |
*
|
7 |
* @param string $string Raw string.
|
8 |
*
|
9 |
+
* @param array $args Array of options eg. enable numerals translation
|
10 |
+
*
|
11 |
* @return string Trimmed string.
|
12 |
*/
|
|
|
|
|
|
|
13 |
|
14 |
+
/* NB: We don't always have access to WP get_option, for instance while calling trp_full_trim inside trp-ajax */
|
15 |
+
/* So this falls back to the option being transmitted either as a param from another function or obtained directly if get_option is available */
|
16 |
+
function trp_full_trim( $string, $args = array() ) {
|
17 |
+
if ( !isset( $args['numerals']) ) {
|
18 |
+
if ( function_exists( 'get_option' ) ) {
|
19 |
+
$opt = get_option( 'trp_advanced_settings', false );
|
20 |
+
if ( isset( $opt["enable_numerals_translation"] ) ) {
|
21 |
+
$args['numerals'] = $opt["enable_numerals_translation"];
|
22 |
+
} else {
|
23 |
+
$args['numerals'] = "no";
|
24 |
+
}
|
25 |
+
} else {
|
26 |
+
$args['numerals'] = "no";
|
27 |
+
}
|
28 |
}
|
|
|
29 |
|
30 |
/* 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
|
31 |
Removed chr( 194 ) . chr( 160 ) because it altered some special characters (¿¡)
|
49 |
}
|
50 |
}while( $string != $previous_iteration_string );
|
51 |
|
52 |
+
if ($args['numerals'] === "yes") {
|
53 |
$filter_string = " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>'\"";
|
54 |
} else {
|
55 |
$filter_string = " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>1234567890'\"";
|
includes/trp-ajax.php
CHANGED
@@ -48,10 +48,11 @@ class TRP_Ajax{
|
|
48 |
* @return array Sanitized array of strings.
|
49 |
*/
|
50 |
protected function sanitize_strings( $posted_strings){
|
|
|
51 |
$strings = json_decode( $posted_strings );
|
52 |
if ( is_array( $strings ) ) {
|
53 |
foreach ($strings as $key => $string) {
|
54 |
-
$strings[$key] = mysqli_real_escape_string( $this->connection, trp_full_trim( $string )
|
55 |
}
|
56 |
}
|
57 |
return $strings;
|
48 |
* @return array Sanitized array of strings.
|
49 |
*/
|
50 |
protected function sanitize_strings( $posted_strings){
|
51 |
+
$numerals_option = isset( $_POST['translate_numerals_opt'] ) ? $_POST['translate_numerals_opt'] : 'no';
|
52 |
$strings = json_decode( $posted_strings );
|
53 |
if ( is_array( $strings ) ) {
|
54 |
foreach ($strings as $key => $string) {
|
55 |
+
$strings[$key] = mysqli_real_escape_string( $this->connection, trp_full_trim( $string, array( 'numerals'=> $numerals_option ) ) );
|
56 |
}
|
57 |
}
|
58 |
return $strings;
|
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.7.
|
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.7.8
|
7 |
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
|
8 |
Author URI: https://cozmoslabs.com/
|
9 |
Text Domain: translatepress-multilingual
|
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.4.2
|
7 |
Requires PHP: 5.6.20
|
8 |
-
Stable tag: 1.7.
|
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.7.7 =
|
142 |
* Added option to enable translation of numerals
|
143 |
* Added capability to translate special URLs like tel, callto or mailto
|
5 |
Requires at least: 3.1.0
|
6 |
Tested up to: 5.4.2
|
7 |
Requires PHP: 5.6.20
|
8 |
+
Stable tag: 1.7.8
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
138 |
|
139 |
|
140 |
== Changelog ==
|
141 |
+
= 1.7.8 =
|
142 |
+
* Added possibility to exclude hreflang from an original URL
|
143 |
+
* Fixed translating json inside json. It ensures compatibility with Brizy
|
144 |
+
* Fixed http 500 response in trp-ajax calls
|
145 |
+
|
146 |
= 1.7.7 =
|
147 |
* Added option to enable translation of numerals
|
148 |
* Added capability to translate special URLs like tel, callto or mailto
|