TranslatePress – Translate Multilingual sites - Version 1.0.4

Version Description

  • Fixed issues with the pencil select icon in the translation editor not showing up in certain cases on the button element
  • Fixed issues with the pencil select icon in the translation editor not showing up in certain cases because of overflow hidden
  • Fixed a issue that was sometimes causing javascript errors with certain plugins
Download this release

Release Info

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

Code changes from version 1.0.3 to 1.0.4

assets/css/trp-preview-iframe-style.css CHANGED
@@ -3,8 +3,8 @@
3
  */
4
 
5
  span.trp-edit-translation {
6
- width: 30px;
7
- height: 30px;
8
  display: inline-block;
9
  position: absolute;
10
  margin-left: -30px !important;
@@ -61,4 +61,18 @@ span.trp-edit-translation svg {
61
 
62
  translate-press{
63
  pointer-events: all;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
3
  */
4
 
5
  span.trp-edit-translation {
6
+ width: 30px !important;
7
+ height: 30px !important;
8
  display: inline-block;
9
  position: absolute;
10
  margin-left: -30px !important;
61
 
62
  translate-press{
63
  pointer-events: all;
64
+ }
65
+
66
+ .trp-overflow-transform-fixer{
67
+ transform: translate3d(0,0,0);
68
+ -moz-transform: translate3d(0,0,0);
69
+ -webkit-transform: translate3d(0,0,0);
70
+ }
71
+
72
+ .trp-overflow-transform-fixer span.trp-edit-translation{
73
+ position:fixed;
74
+ }
75
+
76
+ .trp-overflow-inside-fixer span.trp-edit-translation{
77
+ margin-left:0 !important;
78
  }
assets/js/trp-editor-script.js CHANGED
@@ -21,6 +21,7 @@ function TRP_Editor(){
21
  var trp_lister = null;
22
  this.jquery_string_selector = jQuery( '#trp-string-categories' );
23
  this.change_tracker = null;
 
24
 
25
  /**
26
  * Change the language in the Editor from the dropdown.
@@ -419,6 +420,26 @@ function TRP_Editor(){
419
  jQuery( '#trp-preview-iframe').contents().find( '.trp-edit-translation' ).remove();
420
  };
421
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  /**
423
  * Make string selection dropdown to have options with descriptions below.
424
  *
@@ -636,6 +657,8 @@ function TRP_String( language, array_index ){
636
  text_to_set = initial_value.replace(initial_value.trim(), text_to_set);
637
  if ( jquery_object.attr( 'data-trp-attr' ) ){
638
  jquery_object.children().attr( jquery_object.attr('data-trp-attr'), text_to_set );
 
 
639
  }else {
640
  jquery_object.text(text_to_set);
641
  }
@@ -655,11 +678,15 @@ function TRP_String( language, array_index ){
655
  * Wrap buttons and placeholders so that we can display the pencil button and also replace with translation.
656
  */
657
  this.wrap_special_html_elements = function(){
658
- if ( jquery_object.attr( 'type' ) == 'submit' || jquery_object.attr( 'type' ) == 'button' ) {
 
 
 
 
659
  jquery_object.wrap('<trp-highlight data-trp-attr="value"></trp-highlight>');
660
  jquery_object = jquery_object.parent();
661
  }
662
- if ( jquery_object.attr( 'type' ) == 'search' ) {
663
  jquery_object.wrap('<trp-highlight data-trp-attr="placeholder"></trp-highlight>');
664
  jquery_object = jquery_object.parent();
665
  }
@@ -674,6 +701,7 @@ function TRP_String( language, array_index ){
674
  trpEditor.edit_translation_button = jquery_object.children('.trp-edit-translation');
675
  }else{
676
  _this.wrap_special_html_elements();
 
677
  jquery_object.prepend(trpEditor.edit_translation_button);
678
 
679
  }
@@ -1092,6 +1120,8 @@ jQuery(function(){
1092
  trpEditor.edit_translation_button = jQuery( '<span class="trp-edit-translation"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M13.89 3.39l2.71 2.72c.46.46.42 1.24.03 1.64l-8.01 8.02-5.56 1.16 1.16-5.58s7.6-7.63 7.99-8.03c.39-.39 1.22-.39 1.68.07zm-2.73 2.79l-5.59 5.61 1.11 1.11 5.54-5.65zm-2.97 8.23l5.58-5.6-1.07-1.08-5.59 5.6z"></path></svg></span>' );
1093
  }
1094
 
 
 
1095
  if ( jQuery(this).attr( 'type' ) == 'submit' || jQuery(this).attr( 'type' ) == 'button' || jQuery(this).attr('type') == 'search' ) {
1096
  if( jQuery(this).parent('trp-wrap').length == 0 )
1097
  jQuery(this).wrap('<trp-wrap class="trpgettext-wrap"></trp-wrap>');
21
  var trp_lister = null;
22
  this.jquery_string_selector = jQuery( '#trp-string-categories' );
23
  this.change_tracker = null;
24
+ this.maybe_overflow_fix = null;
25
 
26
  /**
27
  * Change the language in the Editor from the dropdown.
420
  jQuery( '#trp-preview-iframe').contents().find( '.trp-edit-translation' ).remove();
421
  };
422
 
423
+ /**
424
+ * if the edit icon button has a parent with overflow hidden and position relative it won't show so we want to change it's margin to 0 so it will appear inside the element
425
+ */
426
+ this.maybe_overflow_fix = function( icon ){
427
+ if (navigator.userAgent.search("Chrome") >= 0 || navigator.userAgent.search("Firefox") >= 0 || navigator.userAgent.search("Edge") >= 0 ) {
428
+ icon.parents().filter( function(){ var overflow = jQuery(this).css('overflow');
429
+ return overflow == 'hidden' && !jQuery(this).is('body'); } ).each( function(){
430
+ jQuery(this).parent().addClass('trp-overflow-transform-fixer');
431
+ return false;
432
+ });
433
+ }
434
+ else{
435
+ icon.parents().filter( function(){ var overflow = jQuery(this).css('overflow');
436
+ return overflow == 'hidden' && !jQuery(this).is('body'); } ).each( function(){
437
+ jQuery(this).addClass('trp-overflow-inside-fixer');
438
+ return false;
439
+ });
440
+ }
441
+ };
442
+
443
  /**
444
  * Make string selection dropdown to have options with descriptions below.
445
  *
657
  text_to_set = initial_value.replace(initial_value.trim(), text_to_set);
658
  if ( jquery_object.attr( 'data-trp-attr' ) ){
659
  jquery_object.children().attr( jquery_object.attr('data-trp-attr'), text_to_set );
660
+ }else if( jquery_object.attr( 'data-trp-button' ) ){
661
+ jquery_object.children('button').text(text_to_set);
662
  }else {
663
  jquery_object.text(text_to_set);
664
  }
678
  * Wrap buttons and placeholders so that we can display the pencil button and also replace with translation.
679
  */
680
  this.wrap_special_html_elements = function(){
681
+ if( jquery_object.is('button') ){
682
+ jquery_object.wrap('<trp-highlight data-trp-button="true"></trp-highlight>');
683
+ jquery_object = jquery_object.parent();
684
+ }
685
+ else if ( jquery_object.attr( 'type' ) == 'submit' || jquery_object.attr( 'type' ) == 'button' ) {
686
  jquery_object.wrap('<trp-highlight data-trp-attr="value"></trp-highlight>');
687
  jquery_object = jquery_object.parent();
688
  }
689
+ else if ( jquery_object.attr( 'type' ) == 'search' ) {
690
  jquery_object.wrap('<trp-highlight data-trp-attr="placeholder"></trp-highlight>');
691
  jquery_object = jquery_object.parent();
692
  }
701
  trpEditor.edit_translation_button = jquery_object.children('.trp-edit-translation');
702
  }else{
703
  _this.wrap_special_html_elements();
704
+ trpEditor.maybe_overflow_fix(trpEditor.edit_translation_button);
705
  jquery_object.prepend(trpEditor.edit_translation_button);
706
 
707
  }
1120
  trpEditor.edit_translation_button = jQuery( '<span class="trp-edit-translation"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M13.89 3.39l2.71 2.72c.46.46.42 1.24.03 1.64l-8.01 8.02-5.56 1.16 1.16-5.58s7.6-7.63 7.99-8.03c.39-.39 1.22-.39 1.68.07zm-2.73 2.79l-5.59 5.61 1.11 1.11 5.54-5.65zm-2.97 8.23l5.58-5.6-1.07-1.08-5.59 5.6z"></path></svg></span>' );
1121
  }
1122
 
1123
+ trpEditor.maybe_overflow_fix(trpEditor.edit_translation_button);
1124
+
1125
  if ( jQuery(this).attr( 'type' ) == 'submit' || jQuery(this).attr( 'type' ) == 'button' || jQuery(this).attr('type') == 'search' ) {
1126
  if( jQuery(this).parent('trp-wrap').length == 0 )
1127
  jQuery(this).wrap('<trp-wrap class="trpgettext-wrap"></trp-wrap>');
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' );
42
- define( 'TRP_PLUGIN_VERSION', '1.0.3' );
43
 
44
  $this->load_dependencies();
45
  $this->initialize_components();
39
  define( 'TRP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
40
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41
  define( 'TRP_PLUGIN_SLUG', 'translatepress' );
42
+ define( 'TRP_PLUGIN_VERSION', '1.0.4' );
43
 
44
  $this->load_dependencies();
45
  $this->initialize_components();
includes/class-translation-render.php CHANGED
@@ -287,10 +287,10 @@ class TRP_Translation_Render{
287
  foreach ($all_attributes as $attr_name => $attr_value) {
288
  if (strpos($attr_value, 'trp-gettext ') !== false) {
289
  // convert to a node
290
- $node_from_value = trp_str_get_html(html_entity_decode(htmlspecialchars_decode($attr_value, ENT_QUOTES)));
291
- foreach ($node_from_value->find('trp-gettext') as $nfv_row) {
292
- $gettext_translation = $nfv_row->innertext();
293
- $row->setAttribute($attr_name, $gettext_translation );
294
  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
295
  $row->setAttribute('data-no-translation', '');
296
  // we are in the editor
@@ -325,7 +325,11 @@ class TRP_Translation_Render{
325
  if($this->full_trim($row->outertext)!="" && $row->parent()->tag!="script" && $row->parent()->tag!="style" && !is_numeric($this->full_trim($row->outertext)) && !preg_match('/^\d+%$/',$this->full_trim($row->outertext))
326
  && !$this->has_ancestor_attribute( $row, $no_translate_attribute ) && $row->parent()->tag != 'title' && strpos($row->outertext,'[vc_') === false ){
327
  array_push( $translateable_strings, $this->full_trim( $row->outertext ) );
328
- array_push($nodes, array('node' => $row, 'type' => 'text'));
 
 
 
 
329
  }
330
  }
331
 
@@ -389,6 +393,10 @@ class TRP_Translation_Render{
389
  'placeholder' => array(
390
  'accessor' => 'placeholder',
391
  'attribute' => true
 
 
 
 
392
  )
393
  ));
394
 
@@ -422,7 +430,7 @@ class TRP_Translation_Render{
422
  }
423
 
424
  if ( $preview_mode ) {
425
- if ( $accessor == 'outertext' ) {
426
  $outertext_details = '<translate-press data-trp-translate-id="' . $translated_string_ids[$translateable_strings[$i]]->id . '" data-trp-node-type="' . $this->get_node_type_category( $nodes[$i]['type'] ) . '"';
427
  if ( $this->get_node_description( $nodes[$i] ) ) {
428
  $outertext_details .= ' data-trp-node-description="' . $this->get_node_description($nodes[$i] ) . '"';
@@ -430,6 +438,9 @@ class TRP_Translation_Render{
430
  $outertext_details .= '>' . $nodes[$i]['node']->outertext . '</translate-press>';
431
  $nodes[$i]['node']->outertext = $outertext_details;
432
  } else {
 
 
 
433
  $nodes[$i]['node']->setAttribute('data-trp-translate-id', $translated_string_ids[ $translateable_strings[$i] ]->id );
434
  $nodes[$i]['node']->setAttribute('data-trp-node-type', $this->get_node_type_category( $nodes[$i]['type'] ) );
435
 
287
  foreach ($all_attributes as $attr_name => $attr_value) {
288
  if (strpos($attr_value, 'trp-gettext ') !== false) {
289
  // convert to a node
290
+ $node_from_value = trp_str_get_html(html_entity_decode(htmlspecialchars_decode($attr_value, ENT_QUOTES)));
291
+ foreach ($node_from_value->find('trp-gettext') as $nfv_row) {
292
+ $nfv_row->outertext = $nfv_row->innertext();
293
+ $row->setAttribute($attr_name, $node_from_value->save() );
294
  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
295
  $row->setAttribute('data-no-translation', '');
296
  // we are in the editor
325
  if($this->full_trim($row->outertext)!="" && $row->parent()->tag!="script" && $row->parent()->tag!="style" && !is_numeric($this->full_trim($row->outertext)) && !preg_match('/^\d+%$/',$this->full_trim($row->outertext))
326
  && !$this->has_ancestor_attribute( $row, $no_translate_attribute ) && $row->parent()->tag != 'title' && strpos($row->outertext,'[vc_') === false ){
327
  array_push( $translateable_strings, $this->full_trim( $row->outertext ) );
328
+ if( $row->parent()->tag == 'button') {
329
+ array_push($nodes, array('node' => $row, 'type' => 'button'));
330
+ }else{
331
+ array_push($nodes, array('node' => $row, 'type' => 'text'));
332
+ }
333
  }
334
  }
335
 
393
  'placeholder' => array(
394
  'accessor' => 'placeholder',
395
  'attribute' => true
396
+ ),
397
+ 'button' => array(
398
+ 'accessor' => 'outertext',
399
+ 'attribute' => false
400
  )
401
  ));
402
 
430
  }
431
 
432
  if ( $preview_mode ) {
433
+ if ( $accessor == 'outertext' && $nodes[$i]['type'] != 'button' ) {
434
  $outertext_details = '<translate-press data-trp-translate-id="' . $translated_string_ids[$translateable_strings[$i]]->id . '" data-trp-node-type="' . $this->get_node_type_category( $nodes[$i]['type'] ) . '"';
435
  if ( $this->get_node_description( $nodes[$i] ) ) {
436
  $outertext_details .= ' data-trp-node-description="' . $this->get_node_description($nodes[$i] ) . '"';
438
  $outertext_details .= '>' . $nodes[$i]['node']->outertext . '</translate-press>';
439
  $nodes[$i]['node']->outertext = $outertext_details;
440
  } else {
441
+ if( $nodes[$i]['type'] == 'button' ){
442
+ $nodes[$i]['node'] = $nodes[$i]['node']->parent();
443
+ }
444
  $nodes[$i]['node']->setAttribute('data-trp-translate-id', $translated_string_ids[ $translateable_strings[$i] ]->id );
445
  $nodes[$i]['node']->setAttribute('data-trp-node-type', $this->get_node_type_category( $nodes[$i]['type'] ) );
446
 
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.0.3
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.0.4
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.8.2
7
- Stable tag: 1.0.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -106,6 +106,11 @@ For more information please check out [TranslatePress documentation](https://tra
106
 
107
  == Changelog ==
108
 
 
 
 
 
 
109
  = 1.0.3 =
110
  * Added a conditional language shortcode: [trp_language language="en_US"] English only content [/trp_language]
111
  * Create link to test out Google API key.
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.8.2
7
+ Stable tag: 1.0.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
106
 
107
  == Changelog ==
108
 
109
+ = 1.0.4 =
110
+ * Fixed issues with the pencil select icon in the translation editor not showing up in certain cases on the button element
111
+ * Fixed issues with the pencil select icon in the translation editor not showing up in certain cases because of overflow hidden
112
+ * Fixed a issue that was sometimes causing javascript errors with certain plugins
113
+
114
  = 1.0.3 =
115
  * Added a conditional language shortcode: [trp_language language="en_US"] English only content [/trp_language]
116
  * Create link to test out Google API key.