TranslatePress – Translate Multilingual sites - Version 1.2.3

Version Description

  • Fixed back-end css style not being targeted only for TranslatePress Settings page
  • Add filter to not remove detected dynamic strings until the ajax is finished
  • Fixed data-no-translation not taken into account in some cases of Dynamic strings
  • Fixed translated slug not being included in url sometimes
  • Fixed issue with gettext string on non visible html attr that prevented other attr from being translated
  • Fixed bug with translating dom changes not working for complex HTML hierarchy
  • Corrected flag for Afrikaans.
  • Fixed compatibility issues with older jQuery versions
Download this release

Release Info

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

Code changes from version 1.2.2 to 1.2.3

assets/css/trp-back-end-style.css CHANGED
@@ -38,22 +38,6 @@ span.select2-container{
38
  box-shadow: none;
39
  }
40
 
41
- #wpadminbar #wp-admin-bar-trp_edit_translation .ab-icon:before {
42
- content: '\f326';
43
- top: 3px;
44
- }
45
-
46
- @media screen and ( max-width: 782px ) {
47
-
48
- #wpadminbar #wp-admin-bar-trp_edit_translation > .ab-item {
49
- text-indent: 0;
50
- }
51
-
52
- #wpadminbar li#wp-admin-bar-trp_edit_translation {
53
- display: block;
54
- }
55
-
56
- }
57
 
58
  /**************************************************/
59
  /* Extra styling for admin notices
38
  box-shadow: none;
39
  }
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  /**************************************************/
43
  /* Extra styling for admin notices
assets/images/flags/af.png CHANGED
Binary file
assets/js/trp-translate-dom-changes.js CHANGED
@@ -163,15 +163,22 @@ function TRP_Translator(){
163
  }
164
  }else{
165
  var all_nodes = jQuery( mutation.addedNodes[i]).find( '*').addBack();
166
- var all_strings = all_nodes.contents().filter(get_string_from_node);
 
 
 
 
 
167
  if ( typeof parent.trpEditor !== 'undefined' ) {
168
  all_strings.wrap('<translate-press></translate-press>');
169
  }
170
  var all_strings_length = all_strings.length;
171
  for (var j = 0; j < all_strings_length; j++ ) {
172
  if ( _this.trim( all_strings[j].textContent, except_characters ) != '' ) {
173
- strings.push({node: all_strings[j], original: _this.trim( all_strings[j].textContent, trim_characters )});
174
- all_strings[j].textContent = '';
 
 
175
  }
176
  }
177
  }
@@ -185,11 +192,8 @@ function TRP_Translator(){
185
  };
186
 
187
  function get_string_from_node( node ){
188
- if ( node == false ){
189
- node = this;
190
- }
191
  if( node.nodeType === 3 && /\S/.test(node.nodeValue) ){
192
- if ( jQuery(node).closest( '[data-trpgettextoriginal]').length == 0 && jQuery(node).closest( '[data-trp-translate-id]').length == 0 ){
193
  return node;
194
  }
195
  }
163
  }
164
  }else{
165
  var all_nodes = jQuery( mutation.addedNodes[i]).find( '*').addBack();
166
+ var all_strings = all_nodes.contents().filter(function(){
167
+ if( this.nodeType === 3 && /\S/.test(this.nodeValue) ){
168
+ if ( jQuery(this).closest( '[data-trpgettextoriginal]').length == 0 && jQuery(this).closest( '[data-trp-translate-id]').length == 0 && jQuery(this).parents( '[data-no-translation]' ).length == 0 ){
169
+ return this;
170
+ }
171
+ }});
172
  if ( typeof parent.trpEditor !== 'undefined' ) {
173
  all_strings.wrap('<translate-press></translate-press>');
174
  }
175
  var all_strings_length = all_strings.length;
176
  for (var j = 0; j < all_strings_length; j++ ) {
177
  if ( _this.trim( all_strings[j].textContent, except_characters ) != '' ) {
178
+ strings.push({node: all_strings[j], original: all_strings[j].textContent });
179
+ if ( trp_localized_text ['showdynamiccontentbeforetranslation'] == false ) {
180
+ all_strings[j].textContent = '';
181
+ }
182
  }
183
  }
184
  }
192
  };
193
 
194
  function get_string_from_node( node ){
 
 
 
195
  if( node.nodeType === 3 && /\S/.test(node.nodeValue) ){
196
+ if ( jQuery(node).closest( '[data-trpgettextoriginal]').length == 0 && jQuery(node).closest( '[data-trp-translate-id]').length == 0 && jQuery(this).parents( '[data-no-translation]' ).length == 0 ){
197
  return node;
198
  }
199
  }
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.2.2' );
43
 
44
  $this->load_dependencies();
45
  $this->initialize_components();
@@ -151,6 +151,7 @@ class TRP_Translate_Press{
151
  $this->loader->add_filter( 'template_include', $this->translation_manager, 'translation_editor', 9999 );
152
  $this->loader->add_action( 'wp_enqueue_scripts', $this->translation_manager, 'enqueue_preview_scripts_and_styles' );
153
  $this->loader->add_action( 'admin_bar_menu', $this->translation_manager, 'add_shortcut_to_translation_editor', 90, 1 );
 
154
  $this->loader->add_filter( 'show_admin_bar', $this->translation_manager, 'hide_admin_bar_when_in_editor', 90 );
155
 
156
 
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.2.3' );
43
 
44
  $this->load_dependencies();
45
  $this->initialize_components();
151
  $this->loader->add_filter( 'template_include', $this->translation_manager, 'translation_editor', 9999 );
152
  $this->loader->add_action( 'wp_enqueue_scripts', $this->translation_manager, 'enqueue_preview_scripts_and_styles' );
153
  $this->loader->add_action( 'admin_bar_menu', $this->translation_manager, 'add_shortcut_to_translation_editor', 90, 1 );
154
+ $this->loader->add_action( 'admin_head', $this->translation_manager, 'add_styling_to_admin_bar_button', 10 );
155
  $this->loader->add_filter( 'show_admin_bar', $this->translation_manager, 'hide_admin_bar_when_in_editor', 90 );
156
 
157
 
includes/class-settings.php CHANGED
@@ -283,7 +283,7 @@ class TRP_Settings{
283
  * @param string $hook Admin page.
284
  */
285
  public function enqueue_scripts_and_styles( $hook ) {
286
- if ( $hook == 'settings_page_translate-press' || 'settings_page_trp_license_key' ) {
287
  wp_enqueue_style(
288
  'trp-settings-style',
289
  TRP_PLUGIN_URL . 'assets/css/trp-back-end-style.css',
283
  * @param string $hook Admin page.
284
  */
285
  public function enqueue_scripts_and_styles( $hook ) {
286
+ if ( $hook == 'settings_page_translate-press' || $hook == 'settings_page_trp_license_key' ) {
287
  wp_enqueue_style(
288
  'trp-settings-style',
289
  TRP_PLUGIN_URL . 'assets/css/trp-back-end-style.css',
includes/class-translation-manager.php CHANGED
@@ -89,6 +89,7 @@ class TRP_Translation_Manager{
89
  'splittbnonce' => __( wp_create_nonce('split_translation_block'), 'translatepress-multilingual' ),
90
  'gettextgettranslationsnonce' => __( wp_create_nonce('gettext_get_translations'), 'translatepress-multilingual' ),
91
  'gettextsavetranslationsnonce' => __( wp_create_nonce('gettext_save_translations'), 'translatepress-multilingual' ),
 
92
  );
93
  return $text;
94
  }
@@ -438,7 +439,7 @@ class TRP_Translation_Manager{
438
  $this->save_translations_of_strings( $strings );
439
  }
440
  }
441
-
442
  die();
443
  }
444
 
@@ -475,6 +476,7 @@ class TRP_Translation_Manager{
475
  }
476
  }
477
  }
 
478
  die();
479
  }
480
 
@@ -663,7 +665,24 @@ class TRP_Translation_Manager{
663
 
664
  }
665
 
666
- /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667
  * Function to hide admin bar when in editor preview mode.
668
  *
669
  * Hooked to show_admin_bar.
89
  'splittbnonce' => __( wp_create_nonce('split_translation_block'), 'translatepress-multilingual' ),
90
  'gettextgettranslationsnonce' => __( wp_create_nonce('gettext_get_translations'), 'translatepress-multilingual' ),
91
  'gettextsavetranslationsnonce' => __( wp_create_nonce('gettext_save_translations'), 'translatepress-multilingual' ),
92
+ 'showdynamiccontentbeforetranslation' => apply_filters( 'trp_show_dynamic_content_before_translation', false )
93
  );
94
  return $text;
95
  }
439
  $this->save_translations_of_strings( $strings );
440
  }
441
  }
442
+ echo trp_safe_json_encode( array() );
443
  die();
444
  }
445
 
476
  }
477
  }
478
  }
479
+ echo trp_safe_json_encode( array() );
480
  die();
481
  }
482
 
665
 
666
  }
667
 
668
+ /**
669
+ * Add the glyph icon for Translate Site button in admin bar
670
+ *
671
+ * hooked to admin_head action
672
+ */
673
+ public function add_styling_to_admin_bar_button() {
674
+ echo "<style type='text/css'> #wpadminbar #wp-admin-bar-trp_edit_translation .ab-icon:before { content: '\\f326'; top: 3px;}
675
+ #wpadminbar #wp-admin-bar-trp_edit_translation > .ab-item {
676
+ text-indent: 0;
677
+ }
678
+
679
+ #wpadminbar li#wp-admin-bar-trp_edit_translation {
680
+ display: block;
681
+ }</style>";
682
+ }
683
+
684
+
685
+ /**
686
  * Function to hide admin bar when in editor preview mode.
687
  *
688
  * Hooked to show_admin_bar.
includes/class-translation-render.php CHANGED
@@ -9,6 +9,7 @@ class TRP_Translation_Render{
9
  protected $settings;
10
  protected $machine_translator;
11
  protected $trp_query;
 
12
  protected $url_converter;
13
  /* @var TRP_Translation_Manager */
14
  protected $translation_manager;
@@ -322,8 +323,9 @@ class TRP_Translation_Render{
322
  }
323
 
324
  /**
325
- * tries to fix the html document. It is off by default. use at own risk
326
- * */
 
327
  if( apply_filters( 'trp_try_fixing_invalid_html', false ) ) {
328
  if( class_exists('DOMDocument') ) {
329
  $dom = new DOMDocument();
@@ -439,7 +441,7 @@ class TRP_Translation_Render{
439
  $nfv_row->outertext = $nfv_row->innertext();
440
  $row->setAttribute($attr_name, $node_from_value->save() );
441
  if( !$row->has_child() ){// if the node doesn't have children set the needed attributes, else it means that there are other nodes inside so probably they are the ones displayed
442
- if( empty( $row->innertext ) )// add the no translate attribute only if it does not contain any kind of text
443
  $row->setAttribute($no_translate_attribute, '');
444
  // we are in the editor
445
  if (isset($_REQUEST['trp-edit-translation']) && $_REQUEST['trp-edit-translation'] == 'preview') {
9
  protected $settings;
10
  protected $machine_translator;
11
  protected $trp_query;
12
+ /* @var TRP_Url_Converter */
13
  protected $url_converter;
14
  /* @var TRP_Translation_Manager */
15
  protected $translation_manager;
323
  }
324
 
325
  /**
326
+ * Tries to fix the HTML document. It is off by default. Use at own risk.
327
+ * Solves the problem where a duplicate attribute inside a tag causes the plugin to remove the duplicated attribute and all the other attributes to the right of the it.
328
+ */
329
  if( apply_filters( 'trp_try_fixing_invalid_html', false ) ) {
330
  if( class_exists('DOMDocument') ) {
331
  $dom = new DOMDocument();
441
  $nfv_row->outertext = $nfv_row->innertext();
442
  $row->setAttribute($attr_name, $node_from_value->save() );
443
  if( !$row->has_child() ){// if the node doesn't have children set the needed attributes, else it means that there are other nodes inside so probably they are the ones displayed
444
+ if( empty( $row->innertext ) && ( $attr_name == 'placeholder' || $attr_name == 'value' || $attr_name == 'alt' ) )// add the no translate attribute only if it does not contain any kind of text or it is an attribute we search for
445
  $row->setAttribute($no_translate_attribute, '');
446
  // we are in the editor
447
  if (isset($_REQUEST['trp-edit-translation']) && $_REQUEST['trp-edit-translation'] == 'preview') {
includes/class-url-converter.php CHANGED
@@ -192,6 +192,11 @@ class TRP_Url_Converter {
192
  $url = $this->cur_page_url();
193
  $post_id = ( url_to_postid( $url ) ) ? ( url_to_postid( $url ) ) : ( $trp_backup_post_id );
194
  }
 
 
 
 
 
195
 
196
  if( $post_id ){
197
  $TRP_LANGUAGE = $language;
192
  $url = $this->cur_page_url();
193
  $post_id = ( url_to_postid( $url ) ) ? ( url_to_postid( $url ) ) : ( $trp_backup_post_id );
194
  }
195
+ if ( $post_id == 0 ) {
196
+ $TRP_LANGUAGE = $this->settings['default-language'];
197
+ $post_id = url_to_postid( $url );
198
+ $TRP_LANGUAGE = $trp_language_copy;
199
+ }
200
 
201
  if( $post_id ){
202
  $TRP_LANGUAGE = $language;
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.2.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.2.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
@@ -117,7 +117,7 @@ msgstr ""
117
  msgid "General"
118
  msgstr ""
119
 
120
- #: ../translatepress/includes/class-settings.php:397, ../translatepress/includes/class-translation-manager.php:624
121
  msgid "Translate Site"
122
  msgstr ""
123
 
@@ -164,47 +164,47 @@ msgstr ""
164
  #: ../translatepress/includes/class-translation-manager.php:87, ../translatepress/includes/class-translation-manager.php:88, ../translatepress/includes/class-translation-manager.php:89, ../translatepress/includes/class-translation-manager.php:90, ../translatepress/includes/class-translation-manager.php:91
165
  msgstr ""
166
 
167
- #: ../translatepress/includes/class-translation-manager.php:636
168
  msgid "Translate Page"
169
  msgstr ""
170
 
171
- #: ../translatepress/includes/class-translation-manager.php:655
172
  msgid "Settings"
173
  msgstr ""
174
 
175
- #: ../translatepress/includes/class-translation-manager.php:1095
176
  msgid "Security check"
177
  msgstr ""
178
 
179
- #: ../translatepress/includes/class-translation-render.php:166
180
  msgid "Description"
181
  msgstr ""
182
 
183
- #: ../translatepress/includes/class-translation-render.php:172
184
  msgid "OG Title"
185
  msgstr ""
186
 
187
- #: ../translatepress/includes/class-translation-render.php:178
188
  msgid "OG Site Name"
189
  msgstr ""
190
 
191
- #: ../translatepress/includes/class-translation-render.php:184
192
  msgid "OG Description"
193
  msgstr ""
194
 
195
- #: ../translatepress/includes/class-translation-render.php:190
196
  msgid "Twitter Title"
197
  msgstr ""
198
 
199
- #: ../translatepress/includes/class-translation-render.php:196
200
  msgid "Twitter Description"
201
  msgstr ""
202
 
203
- #: ../translatepress/includes/class-translation-render.php:202
204
  msgid "Post Slug"
205
  msgstr ""
206
 
207
- #: ../translatepress/includes/class-translation-render.php:206
208
  msgid "Page Title"
209
  msgstr ""
210
 
117
  msgid "General"
118
  msgstr ""
119
 
120
+ #: ../translatepress/includes/class-settings.php:397, ../translatepress/includes/class-translation-manager.php:626
121
  msgid "Translate Site"
122
  msgstr ""
123
 
164
  #: ../translatepress/includes/class-translation-manager.php:87, ../translatepress/includes/class-translation-manager.php:88, ../translatepress/includes/class-translation-manager.php:89, ../translatepress/includes/class-translation-manager.php:90, ../translatepress/includes/class-translation-manager.php:91
165
  msgstr ""
166
 
167
+ #: ../translatepress/includes/class-translation-manager.php:638
168
  msgid "Translate Page"
169
  msgstr ""
170
 
171
+ #: ../translatepress/includes/class-translation-manager.php:657
172
  msgid "Settings"
173
  msgstr ""
174
 
175
+ #: ../translatepress/includes/class-translation-manager.php:1097
176
  msgid "Security check"
177
  msgstr ""
178
 
179
+ #: ../translatepress/includes/class-translation-render.php:167
180
  msgid "Description"
181
  msgstr ""
182
 
183
+ #: ../translatepress/includes/class-translation-render.php:173
184
  msgid "OG Title"
185
  msgstr ""
186
 
187
+ #: ../translatepress/includes/class-translation-render.php:179
188
  msgid "OG Site Name"
189
  msgstr ""
190
 
191
+ #: ../translatepress/includes/class-translation-render.php:185
192
  msgid "OG Description"
193
  msgstr ""
194
 
195
+ #: ../translatepress/includes/class-translation-render.php:191
196
  msgid "Twitter Title"
197
  msgstr ""
198
 
199
+ #: ../translatepress/includes/class-translation-render.php:197
200
  msgid "Twitter Description"
201
  msgstr ""
202
 
203
+ #: ../translatepress/includes/class-translation-render.php:203
204
  msgid "Post Slug"
205
  msgstr ""
206
 
207
+ #: ../translatepress/includes/class-translation-render.php:207
208
  msgid "Page Title"
209
  msgstr ""
210
 
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.5
7
- Stable tag: 1.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -117,6 +117,16 @@ For more information please check out [TranslatePress documentation](https://tra
117
  6. Menu Language Switcher
118
 
119
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
120
  = 1.2.2 =
121
  * Added Translation Block feature in which you can translate multiple html elements together
122
  * Improvement: make it possible for the SEO Addon to automatically translate page slugs using Google Translate
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.5
7
+ Stable tag: 1.2.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
117
  6. Menu Language Switcher
118
 
119
  == Changelog ==
120
+ = 1.2.3 =
121
+ * Fixed back-end css style not being targeted only for TranslatePress Settings page
122
+ * Add filter to not remove detected dynamic strings until the ajax is finished
123
+ * Fixed data-no-translation not taken into account in some cases of Dynamic strings
124
+ * Fixed translated slug not being included in url sometimes
125
+ * Fixed issue with gettext string on non visible html attr that prevented other attr from being translated
126
+ * Fixed bug with translating dom changes not working for complex HTML hierarchy
127
+ * Corrected flag for Afrikaans.
128
+ * Fixed compatibility issues with older jQuery versions
129
+
130
  = 1.2.2 =
131
  * Added Translation Block feature in which you can translate multiple html elements together
132
  * Improvement: make it possible for the SEO Addon to automatically translate page slugs using Google Translate