TranslatePress – Translate Multilingual sites - Version 1.3.3

Version Description

  • Fixed issue with Woocommerce ajax strings that were broken in editor on default language in some cases
  • Speed improvements
Download this release

Release Info

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

Code changes from version 1.3.2 to 1.3.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.3.2' );
43
 
44
  $this->load_dependencies();
45
  $this->initialize_components();
@@ -129,7 +129,7 @@ class TRP_Translate_Press{
129
  * Hooks methods used in front-end
130
  */
131
  protected function define_frontend_hooks(){
132
- $this->loader->add_action( 'init', $this->translation_render, 'start_output_buffer', -1 );
133
  $this->loader->add_action( 'admin_init', $this->translation_render, 'start_output_buffer' );
134
  $this->loader->add_action( 'wp_enqueue_scripts', $this->translation_render, 'enqueue_dynamic_translation', 1 );
135
  $this->loader->add_filter( 'wp_redirect', $this->translation_render, 'force_preview_on_url_redirect', 99, 2 );
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.3.3' );
43
 
44
  $this->load_dependencies();
45
  $this->initialize_components();
129
  * Hooks methods used in front-end
130
  */
131
  protected function define_frontend_hooks(){
132
+ $this->loader->add_action( 'init', $this->translation_render, 'start_output_buffer', 0 );
133
  $this->loader->add_action( 'admin_init', $this->translation_render, 'start_output_buffer' );
134
  $this->loader->add_action( 'wp_enqueue_scripts', $this->translation_render, 'enqueue_dynamic_translation', 1 );
135
  $this->loader->add_filter( 'wp_redirect', $this->translation_render, 'force_preview_on_url_redirect', 99, 2 );
includes/class-translation-render.php CHANGED
@@ -36,10 +36,6 @@ class TRP_Translation_Render{
36
  return;
37
  }
38
 
39
-
40
- /*if($_SERVER['REQUEST_URI'] == '/it/wp-json/wp/v2/posts/')
41
- return;*/
42
-
43
  mb_http_output("UTF-8");
44
  ob_start(array($this, 'translate_page'));
45
  }
@@ -684,7 +680,7 @@ class TRP_Translation_Render{
684
  $a_href->setAttribute( 'data-trp-original-href', $url );
685
  }
686
 
687
- if ( $this->settings['force-language-to-custom-links'] == 'yes' && !$is_external_link && $this->url_converter->get_lang_from_url_string( $url ) == null && !$is_admin_link && strpos($url, '#TRPLINKPROCESSED') === false ){
688
  $a_href->href = apply_filters( 'trp_force_custom_links', $this->url_converter->get_url_for_language( $TRP_LANGUAGE, $url ), $url, $TRP_LANGUAGE, $a_href );
689
  $url = $a_href->href;
690
  }
36
  return;
37
  }
38
 
 
 
 
 
39
  mb_http_output("UTF-8");
40
  ob_start(array($this, 'translate_page'));
41
  }
680
  $a_href->setAttribute( 'data-trp-original-href', $url );
681
  }
682
 
683
+ if ( $TRP_LANGUAGE == $this->settings['default-language'] && $this->settings['force-language-to-custom-links'] == 'yes' && !$is_external_link && $this->url_converter->get_lang_from_url_string( $url ) == null && !$is_admin_link && strpos($url, '#TRPLINKPROCESSED') === false ){
684
  $a_href->href = apply_filters( 'trp_force_custom_links', $this->url_converter->get_url_for_language( $TRP_LANGUAGE, $url ), $url, $TRP_LANGUAGE, $a_href );
685
  $url = $a_href->href;
686
  }
includes/class-url-converter.php CHANGED
@@ -160,35 +160,20 @@ class TRP_Url_Converter {
160
  * need our own url_to_postid()This is due to the fact that we're using get_permalink that's filtered to get the correct url based on language with SEO Addon.
161
  * url_to_postid() can be slow because it's doing a query for each bloody url.
162
  * this is not a problem with pages that have fewer links, however, it is a problem
163
- * with archive pages that list a ton of tags/categories the post is in.
164
- * so we're doing a quick ignore of possible taxonomy links that contain /tag/ or /category/ in them
165
- *
166
  */
167
- if ( $this->url_is_taxonomy($url) ){
168
- $post_id = 0;
169
- } else {
170
- $post_id = url_to_postid( $url );
171
- }
172
 
173
  if( empty( $url ) ) {
174
  $url = $this->cur_page_url();
175
- if ( $this->url_is_taxonomy($url) ){
176
- $post_id = 0;
177
- } else {
178
- $url_to_postid = url_to_postid( $url );
179
- $post_id = ( $url_to_postid ) ? ( $url_to_postid ) : ( $trp_backup_post_id );
180
- }
181
  }
182
 
183
- if ( $post_id == 0 ) {
184
- $TRP_LANGUAGE = $this->settings['default-language'];
185
- if ( $this->url_is_taxonomy($url) ){
186
- $post_id = 0;
187
- } else {
188
- $post_id = url_to_postid( $url );
189
- }
190
- $TRP_LANGUAGE = $trp_language_copy;
191
- }
192
 
193
  if( $post_id ){
194
  /*
@@ -275,32 +260,6 @@ class TRP_Url_Converter {
275
  return is_file($path);
276
  }
277
 
278
- /**
279
- * Check is a url is an taxonomy.
280
- *
281
- * @param string $url
282
- * @return bool
283
- */
284
- public function url_is_taxonomy( $url = null ){
285
-
286
- $taxonomies = wp_cache_get( 'trp_taxonomies' );
287
- if ( false === $taxonomies ){
288
- $taxonomies = get_taxonomies(array( 'public' => true ));
289
- wp_cache_set('trp_taxonomies', $taxonomies);
290
- }
291
-
292
- $url_is_taxonomy = false;
293
- foreach ($taxonomies as $tax){
294
- if ( strpos($url, '/'.$tax.'/' ) === true ){
295
- $url_is_taxonomy = true;
296
- break;
297
- }
298
- }
299
-
300
- return $url_is_taxonomy;
301
-
302
- }
303
-
304
  /**
305
  * Get language code slug to use in url.
306
  *
160
  * need our own url_to_postid()This is due to the fact that we're using get_permalink that's filtered to get the correct url based on language with SEO Addon.
161
  * url_to_postid() can be slow because it's doing a query for each bloody url.
162
  * this is not a problem with pages that have fewer links, however, it is a problem
163
+ * with pages that list a ton of links
 
 
164
  */
165
+ $post_id = url_to_postid( $url );
 
 
 
 
166
 
167
  if( empty( $url ) ) {
168
  $url = $this->cur_page_url();
169
+ $post_id = ( url_to_postid( $url ) ) ? ( url_to_postid( $url ) ) : ( $trp_backup_post_id );
 
 
 
 
 
170
  }
171
 
172
+ if ( $post_id == 0 ) {
173
+ $TRP_LANGUAGE = $this->settings['default-language'];
174
+ $post_id = url_to_postid( $url );
175
+ $TRP_LANGUAGE = $trp_language_copy;
176
+ }
 
 
 
 
177
 
178
  if( $post_id ){
179
  /*
260
  return is_file($path);
261
  }
262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  /**
264
  * Get language code slug to use in url.
265
  *
includes/functions.php CHANGED
@@ -551,8 +551,8 @@ function trp_remove_accents( $string ){
551
  * @return string
552
  */
553
 
554
- add_filter('ginger_iframe_banner', 'trpc_do_shortcode', 999 );
555
- add_filter('ginger_text_banner', 'trpc_do_shortcode', 999 );
556
- function trpc_do_shortcode($content){
557
  return do_shortcode(stripcslashes($content));
558
  }
551
  * @return string
552
  */
553
 
554
+ add_filter('ginger_iframe_banner', 'trp_do_shortcode', 999 );
555
+ add_filter('ginger_text_banner', 'trp_do_shortcode', 999 );
556
+ function trp_do_shortcode($content){
557
  return do_shortcode(stripcslashes($content));
558
  }
includes/trp-ajax.php CHANGED
@@ -23,7 +23,7 @@ class TRP_Ajax{
23
 
24
  if ( $this->connect_to_db() ){
25
 
26
- $this->output_translations( $this->sanitize_strings( $_POST['strings'] ), filter_var( $_POST['language'], FILTER_SANITIZE_STRING ), filter_var( $_POST['original_language'], FILTER_SANITIZE_STRING ) );
27
  //Successful connection to DB
28
  mysqli_close($this->connection);
29
  }else{
@@ -46,7 +46,7 @@ class TRP_Ajax{
46
  if ( is_array( $strings ) ) {
47
  foreach ($strings as $key => $string) {
48
  if ( isset($string->original ) ) {
49
- $original_array[$key] = filter_var( $string->original, FILTER_SANITIZE_STRING );
50
  }
51
  }
52
  }
23
 
24
  if ( $this->connect_to_db() ){
25
 
26
+ $this->output_translations( $this->sanitize_strings( $_POST['strings'] ), mysqli_real_escape_string(filter_var( $_POST['language'], FILTER_SANITIZE_STRING), $this->connection), mysqli_real_escape_string(filter_var( $_POST['language'], FILTER_SANITIZE_STRING ), $this->connection));
27
  //Successful connection to DB
28
  mysqli_close($this->connection);
29
  }else{
46
  if ( is_array( $strings ) ) {
47
  foreach ($strings as $key => $string) {
48
  if ( isset($string->original ) ) {
49
+ $original_array[$key] = mysqli_real_escape_string(filter_var( $string->original, FILTER_SANITIZE_STRING ), $this->connection);
50
  }
51
  }
52
  }
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.3.2
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, with full support for WooCommerce and site builders.
6
+ Version: 1.3.3
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
@@ -233,35 +233,35 @@ msgstr ""
233
  msgid "Security check"
234
  msgstr ""
235
 
236
- #: ../translatepress/includes/class-translation-render.php:163
237
  msgid "Description"
238
  msgstr ""
239
 
240
- #: ../translatepress/includes/class-translation-render.php:169
241
  msgid "OG Title"
242
  msgstr ""
243
 
244
- #: ../translatepress/includes/class-translation-render.php:175
245
  msgid "OG Site Name"
246
  msgstr ""
247
 
248
- #: ../translatepress/includes/class-translation-render.php:181
249
  msgid "OG Description"
250
  msgstr ""
251
 
252
- #: ../translatepress/includes/class-translation-render.php:187
253
  msgid "Twitter Title"
254
  msgstr ""
255
 
256
- #: ../translatepress/includes/class-translation-render.php:193
257
  msgid "Twitter Description"
258
  msgstr ""
259
 
260
- #: ../translatepress/includes/class-translation-render.php:199
261
  msgid "Post Slug"
262
  msgstr ""
263
 
264
- #: ../translatepress/includes/class-translation-render.php:203
265
  msgid "Page Title"
266
  msgstr ""
267
 
233
  msgid "Security check"
234
  msgstr ""
235
 
236
+ #: ../translatepress/includes/class-translation-render.php:159
237
  msgid "Description"
238
  msgstr ""
239
 
240
+ #: ../translatepress/includes/class-translation-render.php:165
241
  msgid "OG Title"
242
  msgstr ""
243
 
244
+ #: ../translatepress/includes/class-translation-render.php:171
245
  msgid "OG Site Name"
246
  msgstr ""
247
 
248
+ #: ../translatepress/includes/class-translation-render.php:177
249
  msgid "OG Description"
250
  msgstr ""
251
 
252
+ #: ../translatepress/includes/class-translation-render.php:183
253
  msgid "Twitter Title"
254
  msgstr ""
255
 
256
+ #: ../translatepress/includes/class-translation-render.php:189
257
  msgid "Twitter Description"
258
  msgstr ""
259
 
260
+ #: ../translatepress/includes/class-translation-render.php:195
261
  msgid "Post Slug"
262
  msgstr ""
263
 
264
+ #: ../translatepress/includes/class-translation-render.php:199
265
  msgid "Page Title"
266
  msgstr ""
267
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.cozmoslabs.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: 4.9.8
7
- Stable tag: 1.3.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -124,6 +124,10 @@ For more information please check out [TranslatePress - Multilingual plugin docu
124
  6. Menu Language Switcher
125
 
126
  == Changelog ==
 
 
 
 
127
  = 1.3.2 =
128
  * Speed improvements
129
  * Add support for the Ginger – EU Cookie Law plugin
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: 4.9.8
7
+ Stable tag: 1.3.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
124
  6. Menu Language Switcher
125
 
126
  == Changelog ==
127
+ = 1.3.3 =
128
+ * Fixed issue with Woocommerce ajax strings that were broken in editor on default language in some cases
129
+ * Speed improvements
130
+
131
  = 1.3.2 =
132
  * Speed improvements
133
  * Add support for the Ginger – EU Cookie Law plugin