TranslatePress – Translate Multilingual sites - Version 1.8.8

Version Description

  • Improved compatibility with Oxygen builder.
  • Fixed a issue with pagination on blog page displaying page 0
Download this release

Release Info

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

Code changes from version 1.8.7 to 1.8.8

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.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.8.8' );
61
 
62
  wp_cache_add_non_persistent_groups(array('trp'));
63
 
includes/class-language-switcher.php CHANGED
@@ -86,28 +86,29 @@ class TRP_Language_Switcher{
86
  * Redirects to language stored in global $TRP_NEEDED_LANGUAGE
87
  */
88
  public function redirect_to_correct_language(){
89
- if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || is_customize_preview() ) {
90
- return;
91
- }
92
 
93
- global $TRP_NEEDED_LANGUAGE;
94
- if ( ! $this->url_converter ){
95
- $trp = TRP_Translate_Press::get_trp_instance();
96
- $this->url_converter = $trp->get_component( 'url_converter' );
97
- }
 
 
 
 
 
 
 
98
 
99
- if ($this->url_converter->is_sitemap_path()){
100
- return;
101
- }
102
 
103
- $link_to_redirect = apply_filters( 'trp_link_to_redirect_to', $this->url_converter->get_url_for_language( $TRP_NEEDED_LANGUAGE, null, '' ), $TRP_NEEDED_LANGUAGE );
 
 
 
104
 
105
- if( isset( $this->settings['add-subdirectory-to-default-language'] ) && $this->settings['add-subdirectory-to-default-language'] === 'yes' && isset( $this->settings['default-language'] ) && $this->settings['default-language'] === $TRP_NEEDED_LANGUAGE )
106
- wp_redirect( $link_to_redirect, 301 );
107
- else
108
- wp_redirect( $link_to_redirect );
109
 
110
- exit;
111
  }
112
 
113
  /**
86
  * Redirects to language stored in global $TRP_NEEDED_LANGUAGE
87
  */
88
  public function redirect_to_correct_language(){
 
 
 
89
 
90
+ if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || is_customize_preview() )
91
+ return;
92
+
93
+ global $TRP_NEEDED_LANGUAGE;
94
+
95
+ if ( ! $this->url_converter ){
96
+ $trp = TRP_Translate_Press::get_trp_instance();
97
+ $this->url_converter = $trp->get_component( 'url_converter' );
98
+ }
99
+
100
+ if ( $this->url_converter->is_sitemap_path() )
101
+ return;
102
 
103
+ $link_to_redirect = apply_filters( 'trp_link_to_redirect_to', $this->url_converter->get_url_for_language( $TRP_NEEDED_LANGUAGE, null, '' ), $TRP_NEEDED_LANGUAGE );
 
 
104
 
105
+ if( isset( $this->settings['add-subdirectory-to-default-language'] ) && $this->settings['add-subdirectory-to-default-language'] === 'yes' && isset( $this->settings['default-language'] ) && $this->settings['default-language'] === $TRP_NEEDED_LANGUAGE )
106
+ wp_redirect( $link_to_redirect, 301 );
107
+ else
108
+ wp_redirect( $link_to_redirect );
109
 
110
+ exit;
 
 
 
111
 
 
112
  }
113
 
114
  /**
includes/class-query.php CHANGED
@@ -521,7 +521,7 @@ class TRP_Query{
521
  meta_id bigint(20) AUTO_INCREMENT NOT NULL PRIMARY KEY,
522
  original_id bigint(20) NOT NULL,
523
  meta_key varchar(255),
524
- meta_value longtext,
525
  UNIQUE KEY meta_id (meta_id) )
526
  $charset_collate;";
527
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
@@ -1164,10 +1164,10 @@ class TRP_Query{
1164
  ' . $table_name . ' AS `b`
1165
  WHERE
1166
  -- IMPORTANT: Ensures one version remains
1167
- `a`.ID < ' . $batch . '
1168
- AND `b`.ID < ' . $batch . '
1169
  AND `a`.`ID` < `b`.`ID`
1170
-
1171
  -- Check for all duplicates. Binary ensure case sensitive comparison
1172
  AND (`a`.`original` COLLATE '.$charset.'_bin = `b`.`original` OR `a`.`original` IS NULL AND `b`.`original` IS NULL)
1173
  AND (`a`.`translated` COLLATE '.$charset.'_bin = `b`.`translated` OR `a`.`translated` IS NULL AND `b`.`translated` IS NULL)
521
  meta_id bigint(20) AUTO_INCREMENT NOT NULL PRIMARY KEY,
522
  original_id bigint(20) NOT NULL,
523
  meta_key varchar(255),
524
+ meta_value longtext,
525
  UNIQUE KEY meta_id (meta_id) )
526
  $charset_collate;";
527
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1164
  ' . $table_name . ' AS `b`
1165
  WHERE
1166
  -- IMPORTANT: Ensures one version remains
1167
+ `a`.ID < ' . $batch . '
1168
+ AND `b`.ID < ' . $batch . '
1169
  AND `a`.`ID` < `b`.`ID`
1170
+
1171
  -- Check for all duplicates. Binary ensure case sensitive comparison
1172
  AND (`a`.`original` COLLATE '.$charset.'_bin = `b`.`original` OR `a`.`original` IS NULL AND `b`.`original` IS NULL)
1173
  AND (`a`.`translated` COLLATE '.$charset.'_bin = `b`.`translated` OR `a`.`translated` IS NULL AND `b`.`translated` IS NULL)
includes/class-translation-render.php CHANGED
@@ -407,9 +407,8 @@ class TRP_Translation_Render{
407
  */
408
  if( $json_array && $json_array != $output ) {
409
  /* if it's one of our own ajax calls don't do nothing */
410
- if ( ! empty( $_REQUEST['action'] ) && strpos( $_REQUEST['action'], 'trp_' ) === 0 && $_REQUEST['action'] != 'trp_split_translation_block' ) {
411
  return $output;
412
- }
413
 
414
  //check if we have a json response
415
  if ( ! empty( $json_array ) ) {
407
  */
408
  if( $json_array && $json_array != $output ) {
409
  /* if it's one of our own ajax calls don't do nothing */
410
+ if ( ! empty( $_REQUEST['action'] ) && strpos( $_REQUEST['action'], 'trp_' ) === 0 && $_REQUEST['action'] != 'trp_split_translation_block' )
411
  return $output;
 
412
 
413
  //check if we have a json response
414
  if ( ! empty( $json_array ) ) {
includes/class-url-converter.php CHANGED
@@ -741,8 +741,8 @@ class TRP_Url_Converter {
741
  * @return string
742
  */
743
  function maybe_add_pagination_to_blog_page( $url ){
744
- $pagenum = get_query_var( 'paged', 1 );
745
- if( $pagenum !== 1 ) {
746
  global $wp_rewrite;
747
  $url = trailingslashit( $url ) . user_trailingslashit($wp_rewrite->pagination_base . '/' . $pagenum, 'paged' );
748
  }
741
  * @return string
742
  */
743
  function maybe_add_pagination_to_blog_page( $url ){
744
+ $pagenum = get_query_var( 'paged' );
745
+ if( !empty( $pagenum ) ) {
746
  global $wp_rewrite;
747
  $url = trailingslashit( $url ) . user_trailingslashit($wp_rewrite->pagination_base . '/' . $pagenum, 'paged' );
748
  }
includes/compatibility-functions.php CHANGED
@@ -812,8 +812,61 @@ if( function_exists('ct_is_show_builder') ) {
812
 
813
  return $output;
814
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
815
  }
816
 
 
 
817
  /**
818
  * Compatibility with Brizy editor
819
  */
@@ -1227,4 +1280,3 @@ function trp_woo_wc_api_handle_api_request( ){
1227
  add_filter( 'trp_skip_gettext_processing', '__return_true' );
1228
  add_filter( 'trp_stop_translating_page', '__return_true' );
1229
  }
1230
-
812
 
813
  return $output;
814
  }
815
+
816
+ /**
817
+ * Disable TRP when the Oxygen Builder is being loaded
818
+ */
819
+ add_filter( 'trp_stop_translating_page', 'trp_oxygen_disable_trp_in_builder');
820
+ function trp_oxygen_disable_trp_in_builder(){
821
+
822
+ if( defined( 'SHOW_CT_BUILDER' ) )
823
+ return true;
824
+
825
+ }
826
+
827
+ /**
828
+ * Used to redirect Oxygen Builder front-end to the default language.
829
+ * Hooked before TRP_Language_Switcher::redirect_to_correct_language() so we don't redirect twice
830
+ */
831
+ add_action( 'template_redirect', 'trp_oxygen_redirect_to_default_language', 10 );
832
+ function trp_oxygen_redirect_to_default_language(){
833
+
834
+ if( is_admin() || !isset( $_GET['ct_builder'] ) || $_GET['ct_builder'] != 'true' )
835
+ return;
836
+
837
+ $trp = TRP_Translate_Press::get_trp_instance();
838
+ $url_converter = $trp->get_component('url_converter');
839
+ $settings = ( new TRP_Settings() )->get_settings();
840
+
841
+ $current_url = $url_converter->cur_page_url();
842
+ $current_lang = $url_converter->get_lang_from_url_string( $current_url );
843
+
844
+ if( ( $current_lang == null && $settings['add-subdirectory-to-default-language'] == 'yes' ) || ( $current_lang != null && $current_lang != $settings['default-language'] ) ){
845
+ $link_to_redirect = $url_converter->get_url_for_language( $settings['default-language'], null, '' );
846
+
847
+ wp_redirect( $link_to_redirect, 301 );
848
+ exit;
849
+ }
850
+
851
+ }
852
+
853
+ /**
854
+ * Hide Floating Language Switcher when the Oxygen builder is being shown
855
+ * @var [type]
856
+ */
857
+ add_filter( 'trp_floating_ls_html', 'trp_oxygen_disable_language_switcher' );
858
+ function trp_oxygen_disable_language_switcher( $html ){
859
+
860
+ if( isset( $_GET['ct_builder'] ) && $_GET['ct_builder'] == 'true' )
861
+ return '';
862
+
863
+ return $html;
864
+
865
+ }
866
  }
867
 
868
+
869
+
870
  /**
871
  * Compatibility with Brizy editor
872
  */
1280
  add_filter( 'trp_skip_gettext_processing', '__return_true' );
1281
  add_filter( 'trp_stop_translating_page', '__return_true' );
1282
  }
 
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.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.8.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.5.3
7
  Requires PHP: 5.6.20
8
- Stable tag: 1.8.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -138,6 +138,10 @@ For more information please check out our [documentation](https://translatepress
138
 
139
 
140
  == Changelog ==
 
 
 
 
141
  = 1.8.7 =
142
  * Added region independent languages in hreflang meta tags
143
  * Fixed JS error in Translation Editor for some type of anchor tags.
5
  Requires at least: 3.1.0
6
  Tested up to: 5.5.3
7
  Requires PHP: 5.6.20
8
+ Stable tag: 1.8.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.8.8 =
142
+ * Improved compatibility with Oxygen builder.
143
+ * Fixed a issue with pagination on blog page displaying page 0
144
+
145
  = 1.8.7 =
146
  * Added region independent languages in hreflang meta tags
147
  * Fixed JS error in Translation Editor for some type of anchor tags.