TranslatePress – Translate Multilingual sites - Version 1.7.7

Version Description

  • Added option to enable translation of numerals
  • Added capability to translate special URLs like tel, callto or mailto
  • Added support for translating oembed response data
  • Fixed some CSS issues on Safari
Download this release

Release Info

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

Code changes from version 1.7.6 to 1.7.7

assets/css/trp-editor.css CHANGED
@@ -1076,7 +1076,7 @@ a:hover {
1076
  }
1077
 
1078
  .trp-help-toggle {
1079
- padding: 13px 7px 13px 7px;
1080
  width: 20px;
1081
  height: 20px;
1082
  cursor: pointer;
@@ -1184,10 +1184,9 @@ a.trp-link-button.trp-link-button-disabled {
1184
  */
1185
 
1186
  .trp-ajax-loader {
1187
- margin-bottom: -16px;
1188
- margin-left: 20px;
1189
- margin-right: 3px;
1190
  display: inline-block;
 
 
1191
  z-index: 50;
1192
  -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=1, StartColorStr='#E57EB149', EndColorStr='#E57EB149')";
1193
  filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr="#E57EB149", EndColorStr="#E57EB149");
1076
  }
1077
 
1078
  .trp-help-toggle {
1079
+ padding: 14px 22px 18px 4px;
1080
  width: 20px;
1081
  height: 20px;
1082
  cursor: pointer;
1184
  */
1185
 
1186
  .trp-ajax-loader {
 
 
 
1187
  display: inline-block;
1188
+ float: left;
1189
+ margin: 12px 3px -16px 20px;
1190
  z-index: 50;
1191
  -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=1, StartColorStr='#E57EB149', EndColorStr='#E57EB149')";
1192
  filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr="#E57EB149", EndColorStr="#E57EB149");
assets/js/trp-translate-dom-changes.js CHANGED
@@ -16,7 +16,7 @@ function TRP_Translator(){
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;
19
- var except_characters = " \t\n\r  �.,/`~!@#$€£%^&*():;-_=+[]{}\\|?/<>1234567890'";
20
  var trim_characters = " \t\n\r  �\x0A\x0B" + "\302" + "\240";
21
  var already_detected = [];
22
  var duplicate_detections_allowed = parseInt( trp_data.duplicate_detections_allowed )
@@ -280,12 +280,12 @@ function TRP_Translator(){
280
  this.get_translateable_textcontent = function( node ){
281
  var string_originals = [];
282
  var nodesInfo = [];
283
- if ( node.textContent && _this.trim( node.textContent.trim(), except_characters ) != '' ) {
284
 
285
  var direct_string = get_string_from_node( node );
286
  if ( direct_string ) {
287
  // a text without HTML was added
288
- if ( _this.trim( direct_string.textContent, except_characters ) != '' ) {
289
  var extracted_original = _this.trim(direct_string.textContent, trim_characters);
290
  if ( ! _this.skip_string_original( extracted_original, false )) {
291
  nodesInfo.push({node: node, original: extracted_original, attribute: ''});
@@ -311,7 +311,7 @@ function TRP_Translator(){
311
  }
312
  var all_strings_length = all_strings.length;
313
  for (var j = 0; j < all_strings_length; j++ ) {
314
- if ( _this.trim( all_strings[j].textContent, except_characters ) != '' ) {
315
  if ( ! _this.skip_string_original( all_strings[j].textContent, false )) {
316
  nodesInfo.push({node: all_strings[j], original: all_strings[j].textContent, attribute: ''});
317
  string_originals.push(all_strings[j].textContent)
@@ -347,7 +347,7 @@ function TRP_Translator(){
347
  if ( _this.skip_string_original( attribute_content, attribute_selector_item.accessor )){
348
  continue;
349
  }
350
- if ( attribute_content && _this.trim( attribute_content.trim(), except_characters ) != '' ) {
351
  nodesInfo.push({node: all_nodes[j], original: attribute_content, attribute: attribute_selector_item.accessor });
352
  string_originals.push( attribute_content )
353
  if ( trp_data ['showdynamiccontentbeforetranslation'] == false && ( attribute_selector_item.accessor != 'src' ) ) {
@@ -429,6 +429,11 @@ function TRP_Translator(){
429
  current_language = trp_data.trp_current_language;
430
  original_language = trp_data.trp_original_language;
431
  language_to_query = trp_data.trp_language_to_query;
 
 
 
 
 
432
 
433
  // create an observer instance
434
  observer = new MutationObserver( _this.detect_new_strings_callback );
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;
19
+ this.except_characters = " \t\n\r  �.,/`~!@#$€£%^&*():;-_=+[]{}\\|?/<>1234567890'";
20
  var trim_characters = " \t\n\r  �\x0A\x0B" + "\302" + "\240";
21
  var already_detected = [];
22
  var duplicate_detections_allowed = parseInt( trp_data.duplicate_detections_allowed )
280
  this.get_translateable_textcontent = function( node ){
281
  var string_originals = [];
282
  var nodesInfo = [];
283
+ if ( node.textContent && _this.trim( node.textContent.trim(), _this.except_characters ) != '' ) {
284
 
285
  var direct_string = get_string_from_node( node );
286
  if ( direct_string ) {
287
  // a text without HTML was added
288
+ if ( _this.trim( direct_string.textContent, _this.except_characters ) != '' ) {
289
  var extracted_original = _this.trim(direct_string.textContent, trim_characters);
290
  if ( ! _this.skip_string_original( extracted_original, false )) {
291
  nodesInfo.push({node: node, original: extracted_original, attribute: ''});
311
  }
312
  var all_strings_length = all_strings.length;
313
  for (var j = 0; j < all_strings_length; j++ ) {
314
+ if ( _this.trim( all_strings[j].textContent, _this.except_characters ) != '' ) {
315
  if ( ! _this.skip_string_original( all_strings[j].textContent, false )) {
316
  nodesInfo.push({node: all_strings[j], original: all_strings[j].textContent, attribute: ''});
317
  string_originals.push(all_strings[j].textContent)
347
  if ( _this.skip_string_original( attribute_content, attribute_selector_item.accessor )){
348
  continue;
349
  }
350
+ if ( attribute_content && _this.trim( attribute_content.trim(), _this.except_characters ) != '' ) {
351
  nodesInfo.push({node: all_nodes[j], original: attribute_content, attribute: attribute_selector_item.accessor });
352
  string_originals.push( attribute_content )
353
  if ( trp_data ['showdynamiccontentbeforetranslation'] == false && ( attribute_selector_item.accessor != 'src' ) ) {
429
  current_language = trp_data.trp_current_language;
430
  original_language = trp_data.trp_original_language;
431
  language_to_query = trp_data.trp_language_to_query;
432
+ translate_numerals_opt = trp_data.trp_translate_numerals_opt;
433
+
434
+ if ( typeof translate_numerals_opt !== "undefined" && translate_numerals_opt !== '' && translate_numerals_opt === "yes") {
435
+ _this.except_characters = " \t\n\r  �.,/`~!@#$€£%^&*():;-_=+[]{}\\|?/<>'";
436
+ }
437
 
438
  // create an observer instance
439
  observer = new MutationObserver( _this.detect_new_strings_callback );
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.6' );
61
 
62
  wp_cache_add_non_persistent_groups(array('trp'));
63
 
@@ -280,6 +280,7 @@ class TRP_Translate_Press{
280
  $this->loader->add_action( "trp_set_translation_for_attribute", $this->translation_render, 'translate_image_srcset_attributes', 10, 3 );
281
  $this->loader->add_action( "trp_allow_machine_translation_for_string", $this->translation_render, 'allow_machine_translation_for_string', 10, 4 );
282
  $this->loader->add_action( "init", $this->translation_render, 'add_callbacks_for_translating_rest_api', 10, 4 );
 
283
 
284
  /* add custom containers for post content and pots title so we can identify string that are part of them */
285
  $this->loader->add_filter( "the_content", $this->translation_render, 'wrap_with_post_id', 1000 );
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.7' );
61
 
62
  wp_cache_add_non_persistent_groups(array('trp'));
63
 
280
  $this->loader->add_action( "trp_set_translation_for_attribute", $this->translation_render, 'translate_image_srcset_attributes', 10, 3 );
281
  $this->loader->add_action( "trp_allow_machine_translation_for_string", $this->translation_render, 'allow_machine_translation_for_string', 10, 4 );
282
  $this->loader->add_action( "init", $this->translation_render, 'add_callbacks_for_translating_rest_api', 10, 4 );
283
+ $this->loader->add_filter( "oembed_response_data", $this->translation_render, 'oembed_response_data', 10, 4 );
284
 
285
  /* add custom containers for post content and pots title so we can identify string that are part of them */
286
  $this->loader->add_filter( "the_content", $this->translation_render, 'wrap_with_post_id', 1000 );
includes/advanced-settings/enable-numerals-translation.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_filter('trp_register_advanced_settings', 'trp_register_enable_numerals_translation', 1081);
4
+ function trp_register_enable_numerals_translation($settings_array)
5
+ {
6
+ $settings_array[] = array(
7
+ 'name' => 'enable_numerals_translation',
8
+ 'type' => 'checkbox',
9
+ 'label' => esc_html__('Translate numbers and numerals', 'translatepress-multilingual'),
10
+ 'description' => esc_html__('Enable translation of numbers ( e.g. phone numbers)', 'translatepress-multilingual'),
11
+ );
12
+ return $settings_array;
13
+ }
includes/class-advanced-tab.php CHANGED
@@ -146,6 +146,7 @@ class TRP_Advanced_Tab {
146
  public function include_custom_codes(){
147
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/disable-dynamic-translation.php');
148
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/enable-auto-translate-slug.php');
 
149
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/exclude-dynamic-selectors.php');
150
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/exclude-gettext-strings.php');
151
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/exclude-selectors.php');
146
  public function include_custom_codes(){
147
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/disable-dynamic-translation.php');
148
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/enable-auto-translate-slug.php');
149
+ include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/enable-numerals-translation.php');
150
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/exclude-dynamic-selectors.php');
151
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/exclude-gettext-strings.php');
152
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/exclude-selectors.php');
includes/class-translation-manager.php CHANGED
@@ -71,7 +71,7 @@ class TRP_Translation_Manager {
71
  $localized_text = $this->string_groups();
72
 
73
  $merge_rules = array(
74
- 'top_parents' => array( 'p', 'div', 'li', 'ol', 'ul', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'body', 'footer', 'article', 'main', 'iframe', 'section', 'figure', 'figcaption', 'blockquote', 'cite' ),
75
  'self_object_type' => array( 'translate-press' ),
76
  'incompatible_siblings' => array( '[data-trpgettextoriginal]', '[data-trp-node-group="' . $localized_text['dynamicstrings'] . '"]' )
77
  );
71
  $localized_text = $this->string_groups();
72
 
73
  $merge_rules = array(
74
+ 'top_parents' => array( 'p', 'div', 'li', 'ol', 'ul', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'body', 'footer', 'article', 'main', 'iframe', 'section', 'figure', 'figcaption', 'blockquote', 'cite', 'tr', 'td', 'th', 'table', 'tbody', 'thead', 'tfoot', 'form' ),
75
  'self_object_type' => array( 'translate-press' ),
76
  'incompatible_siblings' => array( '[data-trpgettextoriginal]', '[data-trp-node-group="' . $localized_text['dynamicstrings'] . '"]' )
77
  );
includes/class-translation-render.php CHANGED
@@ -272,6 +272,32 @@ class TRP_Translation_Render{
272
  return null;
273
  }
274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  /**
276
  * Function that translates the content excerpt and post title in the REST API
277
  * @param $response
@@ -342,7 +368,7 @@ class TRP_Translation_Render{
342
  */
343
  global $wp_rewrite;
344
  if( is_object($wp_rewrite) ) {
345
- if( strpos( $this->url_converter->cur_page_url(), get_rest_url() ) !== false && strpos( current_filter(), 'rest_prepare_' ) !== 0){
346
  $trpremoved = $this->remove_trp_html_tags( $output );
347
  return $trpremoved;
348
  }
@@ -373,7 +399,7 @@ class TRP_Translation_Render{
373
  *
374
  * Removed is_ajax_on_frontend() check because we need to capture custom ajax events.
375
  * Decided that if $output is json decodable it's a good enough check to handle it this way.
376
- * We have necessary checks so that we don't get to this point when is_admin(), or when language is not default.
377
  */
378
  if( $json_array && $json_array != $output ) {
379
  /* if it's one of our own ajax calls don't do nothing */
@@ -590,14 +616,14 @@ class TRP_Translation_Render{
590
  }
591
  }
592
  foreach ( $html->find('.translation-block') as $row ){
593
- $trimmed_string = trp_full_trim($row->innertext);
594
  $parent = $row->parent();
595
  if( $trimmed_string!=""
596
  && $parent->tag!="script"
597
  && $parent->tag!="style"
598
  && $parent->tag != 'title'
599
  && strpos($row->outertext,'[vc_') === false
600
- && !is_numeric($trimmed_string)
601
  && !preg_match('/^\d+%$/',$trimmed_string)
602
  && !$this->has_ancestor_attribute( $row, $no_translate_attribute ) )
603
  {
@@ -612,13 +638,13 @@ class TRP_Translation_Render{
612
  foreach ( $html->find('trptext') as $row ){
613
  $outertext = $row->outertext;
614
  $parent = $row->parent();
615
- $trimmed_string = trp_full_trim($outertext);
616
  if( $trimmed_string!=""
617
  && $parent->tag!="script"
618
  && $parent->tag!="style"
619
  && $parent->tag != 'title'
620
  && strpos($outertext,'[vc_') === false
621
- && !is_numeric($trimmed_string)
622
  && !preg_match('/^\d+%$/',$trimmed_string)
623
  && !$this->has_ancestor_attribute( $row, $no_translate_attribute )
624
  && !$this->has_ancestor_class( $row, 'translation-block') )
@@ -648,15 +674,15 @@ class TRP_Translation_Render{
648
  if ( isset( $node_accessor['selector'] ) ){
649
  foreach ( $html->find( $node_accessor['selector'] ) as $k => $row ){
650
  $current_node_accessor_selector = $node_accessor['accessor'];
651
- $trimmed_string = trp_full_trim($row->$current_node_accessor_selector);
652
  if ( $current_node_accessor_selector === 'href' ) {
653
- $translate_href = ( $this->is_external_link( $trimmed_string, $home_url ) || $this->url_converter->url_is_file( $trimmed_string ) );
654
  $translate_href = apply_filters( 'trp_translate_this_href', $translate_href, $row, $TRP_LANGUAGE );
655
  $trimmed_string = ( $translate_href ) ? $trimmed_string : '';
656
  }
657
 
658
  if( $trimmed_string!=""
659
- && !is_numeric($trimmed_string)
660
  && !preg_match('/^\d+%$/',$trimmed_string)
661
  && !$this->has_ancestor_attribute( $row, $no_translate_attribute )
662
  && !$this->has_ancestor_attribute( $row, $no_translate_attribute . '-' . $current_node_accessor_selector )
@@ -1432,7 +1458,8 @@ class TRP_Translation_Render{
1432
  'showdynamiccontentbeforetranslation' => apply_filters( 'trp_show_dynamic_content_before_translation', false ),
1433
  'skip_strings_from_dynamic_translation' => apply_filters( 'trp_skip_strings_from_dynamic_translation', array() ),
1434
  'skip_strings_from_dynamic_translation_for_substrings' => apply_filters( 'trp_skip_strings_from_dynamic_translation_for_substrings', array( 'href' => array('amazon-adsystem', 'googleads', 'g.doubleclick') ) ),
1435
- 'duplicate_detections_allowed' => apply_filters( 'trp_duplicate_detections_allowed', 100 )
 
1436
  );
1437
  }
1438
 
@@ -1687,4 +1714,24 @@ class TRP_Translation_Render{
1687
 
1688
  return $content;
1689
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1690
  }
272
  return null;
273
  }
274
 
275
+ /**
276
+ * Function that translates the content post title, site title and post content in oembed response
277
+ *
278
+ * @param $data
279
+ * @param $post
280
+ * @param $width
281
+ * @param $height
282
+ *
283
+ * @return array
284
+ */
285
+ public function oembed_response_data($data, $post, $width, $height ){
286
+ if ( !empty( $data )) {
287
+ $translatable_items = apply_filters( 'trp_oembed_response_data_translatable_items', array('title', 'html', 'provider_name') );
288
+ foreach( $translatable_items as $item ){
289
+ if ( isset( $data[$item] ) ) {
290
+ $data[$item] = $this->translate_page( $data[$item] );
291
+ }
292
+ }
293
+ }
294
+
295
+ // Otherwise we incorrectly unescape the sequence to end CDATA from ']]&gt;' to ']]>' breaking the xml. It needs to stay escaped in oembed response data.
296
+ remove_filter( 'trp_before_translate_content', array( $this, 'handle_cdata'), 1000);
297
+
298
+ return $data;
299
+ }
300
+
301
  /**
302
  * Function that translates the content excerpt and post title in the REST API
303
  * @param $response
368
  */
369
  global $wp_rewrite;
370
  if( is_object($wp_rewrite) ) {
371
+ if( strpos( $this->url_converter->cur_page_url(), get_rest_url() ) !== false && strpos( current_filter(), 'rest_prepare_' ) !== 0 && current_filter() !== 'oembed_response_data' ){
372
  $trpremoved = $this->remove_trp_html_tags( $output );
373
  return $trpremoved;
374
  }
399
  *
400
  * Removed is_ajax_on_frontend() check because we need to capture custom ajax events.
401
  * Decided that if $output is json decodable it's a good enough check to handle it this way.
402
+ * We have necessary checks so that we don't get to this point when is_admin(), or when language is default.
403
  */
404
  if( $json_array && $json_array != $output ) {
405
  /* if it's one of our own ajax calls don't do nothing */
616
  }
617
  }
618
  foreach ( $html->find('.translation-block') as $row ){
619
+ $trimmed_string = trp_full_trim( $row->innertext );
620
  $parent = $row->parent();
621
  if( $trimmed_string!=""
622
  && $parent->tag!="script"
623
  && $parent->tag!="style"
624
  && $parent->tag != 'title'
625
  && strpos($row->outertext,'[vc_') === false
626
+ && !$this->trp_is_numeric($trimmed_string)
627
  && !preg_match('/^\d+%$/',$trimmed_string)
628
  && !$this->has_ancestor_attribute( $row, $no_translate_attribute ) )
629
  {
638
  foreach ( $html->find('trptext') as $row ){
639
  $outertext = $row->outertext;
640
  $parent = $row->parent();
641
+ $trimmed_string = trp_full_trim( $outertext );
642
  if( $trimmed_string!=""
643
  && $parent->tag!="script"
644
  && $parent->tag!="style"
645
  && $parent->tag != 'title'
646
  && strpos($outertext,'[vc_') === false
647
+ && !$this->trp_is_numeric($trimmed_string)
648
  && !preg_match('/^\d+%$/',$trimmed_string)
649
  && !$this->has_ancestor_attribute( $row, $no_translate_attribute )
650
  && !$this->has_ancestor_class( $row, 'translation-block') )
674
  if ( isset( $node_accessor['selector'] ) ){
675
  foreach ( $html->find( $node_accessor['selector'] ) as $k => $row ){
676
  $current_node_accessor_selector = $node_accessor['accessor'];
677
+ $trimmed_string = trp_full_trim( $row->$current_node_accessor_selector );
678
  if ( $current_node_accessor_selector === 'href' ) {
679
+ $translate_href = ( $this->is_external_link( $trimmed_string, $home_url ) || $this->url_converter->url_is_file( $trimmed_string ) || $this->url_converter->url_is_extra($trimmed_string) );
680
  $translate_href = apply_filters( 'trp_translate_this_href', $translate_href, $row, $TRP_LANGUAGE );
681
  $trimmed_string = ( $translate_href ) ? $trimmed_string : '';
682
  }
683
 
684
  if( $trimmed_string!=""
685
+ && !$this->trp_is_numeric($trimmed_string)
686
  && !preg_match('/^\d+%$/',$trimmed_string)
687
  && !$this->has_ancestor_attribute( $row, $no_translate_attribute )
688
  && !$this->has_ancestor_attribute( $row, $no_translate_attribute . '-' . $current_node_accessor_selector )
1458
  'showdynamiccontentbeforetranslation' => apply_filters( 'trp_show_dynamic_content_before_translation', false ),
1459
  'skip_strings_from_dynamic_translation' => apply_filters( 'trp_skip_strings_from_dynamic_translation', array() ),
1460
  'skip_strings_from_dynamic_translation_for_substrings' => apply_filters( 'trp_skip_strings_from_dynamic_translation_for_substrings', array( 'href' => array('amazon-adsystem', 'googleads', 'g.doubleclick') ) ),
1461
+ 'duplicate_detections_allowed' => apply_filters( 'trp_duplicate_detections_allowed', 100 ),
1462
+ 'trp_translate_numerals_opt' => isset ($this->settings["trp_advanced_settings"]["enable_numerals_translation"]) ? $this->settings["trp_advanced_settings"]["enable_numerals_translation"] : 'no'
1463
  );
1464
  }
1465
 
1714
 
1715
  return $content;
1716
  }
1717
+
1718
+ /**
1719
+ * Function that wraps around the PHP's is_numeric function and adds an additional check,
1720
+ * namely the option to translate numerals/numbers to be on.
1721
+ * @param $str
1722
+ * @return bool
1723
+ */
1724
+ function trp_is_numeric($str){
1725
+ if (is_numeric($str)){
1726
+ if (isset($this->settings["trp_advanced_settings"]["enable_numerals_translation"]) && $this->settings["trp_advanced_settings"]["enable_numerals_translation"] === 'yes') {
1727
+ return false;
1728
+ } else {
1729
+ return true;
1730
+ }
1731
+ }
1732
+ else {
1733
+ return false;
1734
+ }
1735
+ }
1736
+
1737
  }
includes/class-upgrade.php CHANGED
@@ -339,7 +339,7 @@ class TRP_Upgrade {
339
  return true;
340
  }
341
  foreach( $strings as $key => $string ){
342
- $strings[$key]['original'] = trp_full_trim( $strings[$key]['original'] );
343
  }
344
 
345
  // overwrite original only
339
  return true;
340
  }
341
  foreach( $strings as $key => $string ){
342
+ $strings[$key]['original'] = trp_full_trim( $strings[ $key ]['original'] );
343
  }
344
 
345
  // overwrite original only
includes/class-url-converter.php CHANGED
@@ -414,6 +414,24 @@ class TRP_Url_Converter {
414
  return is_file($path);
415
  }
416
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  /**
418
  * Get language code slug to use in url.
419
  *
414
  return is_file($path);
415
  }
416
 
417
+
418
+ /**
419
+ * Check for a spacial type of URL. Currently includes mailto, tel, callto URL types.
420
+ *
421
+ * @param string $url
422
+ * @return bool
423
+ */
424
+ public function url_is_extra( $url ){
425
+ $allowed = array( 'mailto', 'tel', 'callto' );
426
+ $parsed = parse_url($url);
427
+ if (is_array($parsed) && isset( $parsed['scheme'] )){
428
+ return in_array( $parsed['scheme'], $allowed );
429
+ } else {
430
+ return false;
431
+ }
432
+ }
433
+
434
+
435
  /**
436
  * Get language code slug to use in url.
437
  *
includes/external-functions.php CHANGED
@@ -1,12 +1,23 @@
1
  <?php
2
 
 
 
3
  /**
4
  * Trim strings.
5
  *
6
- * @param string $string Raw string.
 
7
  * @return string Trimmed string.
8
  */
9
  function trp_full_trim( $string ) {
 
 
 
 
 
 
 
 
10
  /* Make sure you update full_trim function from trp-ajax too*/
11
 
12
  /* 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,10 +42,15 @@ function trp_full_trim( $string ) {
31
  }
32
  }while( $string != $previous_iteration_string );
33
 
34
- if ( strip_tags( $string ) == "" || trim ($string, " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>1234567890'\"" ) == '' ){
35
- $string = '';
 
 
36
  }
37
 
 
 
 
38
  return $string;
39
  }
40
 
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
+ if (isset($opt["enable_numerals_translation"])){
17
+ $numerals_option = $opt["enable_numerals_translation"];
18
+ } else {
19
+ $numerals_option = "no";
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
42
  }
43
  }while( $string != $previous_iteration_string );
44
 
45
+ if ($numerals_option === "yes") {
46
+ $filter_string = " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>'\"";
47
+ } else {
48
+ $filter_string = " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>1234567890'\"";
49
  }
50
 
51
+ if ( strip_tags( $string ) === '' || trim ($string, $filter_string) === '' ){
52
+ $string = '';
53
+ }
54
  return $string;
55
  }
56
 
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.6
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.7
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
languages/translatepress-multilingual.catalog.php CHANGED
@@ -309,6 +309,8 @@
309
  <?php __("Generate automatic translations of slugs for posts, pages and Custom Post Types.<br/>Requires <a href=\"https://translatepress.com/docs/addons/seo-pack/\" title=\"TranslatePress Add-on SEO Pack documentation\" target=\"_blank\"> SEO Pack Add-on</a> to be installed and activated.", "translatepress-multilingual"); ?>
310
  <?php __("Enable the hreflang x-default tag for language:", "translatepress-multilingual"); ?>
311
  <?php __("Enables the hreflang=\"x-default\" for an entire language. See documentation for more details.", "translatepress-multilingual"); ?>
 
 
312
  <?php __("Selector", "translatepress-multilingual"); ?>
313
  <?php __("Exclude from dynamic translation", "translatepress-multilingual"); ?>
314
  <?php __("Do not dynamically translate strings that are found in html nodes matching these selectors.<br>Excludes all the children of HTML nodes matching these selectors from being translated using JavaScript.<br/>These strings will still be translated on the server side if possible.", "translatepress-multilingual"); ?>
309
  <?php __("Generate automatic translations of slugs for posts, pages and Custom Post Types.<br/>Requires <a href=\"https://translatepress.com/docs/addons/seo-pack/\" title=\"TranslatePress Add-on SEO Pack documentation\" target=\"_blank\"> SEO Pack Add-on</a> to be installed and activated.", "translatepress-multilingual"); ?>
310
  <?php __("Enable the hreflang x-default tag for language:", "translatepress-multilingual"); ?>
311
  <?php __("Enables the hreflang=\"x-default\" for an entire language. See documentation for more details.", "translatepress-multilingual"); ?>
312
+ <?php __("Translate numbers and numerals", "translatepress-multilingual"); ?>
313
+ <?php __("Enable translation of numbers ( e.g. phone numbers)", "translatepress-multilingual"); ?>
314
  <?php __("Selector", "translatepress-multilingual"); ?>
315
  <?php __("Exclude from dynamic translation", "translatepress-multilingual"); ?>
316
  <?php __("Do not dynamically translate strings that are found in html nodes matching these selectors.<br>Excludes all the children of HTML nodes matching these selectors from being translated using JavaScript.<br/>These strings will still be translated on the server side if possible.", "translatepress-multilingual"); ?>
languages/translatepress-multilingual.pot CHANGED
@@ -97,7 +97,7 @@ msgstr ""
97
  msgid "Are you sure you want to remove this language?"
98
  msgstr ""
99
 
100
- #: ../tp-add-on-extra-languages/partials/language-selector-pro.php:43, ../translatepress/includes/class-advanced-tab.php:422, ../translatepress/includes/class-advanced-tab.php:432, ../translatepress/partials/main-settings-language-selector.php:40
101
  msgid "Remove"
102
  msgstr ""
103
 
@@ -105,7 +105,7 @@ msgstr ""
105
  msgid "Choose..."
106
  msgstr ""
107
 
108
- #: ../tp-add-on-extra-languages/partials/language-selector-pro.php:58, ../translatepress/includes/class-advanced-tab.php:432, ../translatepress/partials/main-settings-language-selector.php:55
109
  msgid "Add"
110
  msgstr ""
111
 
@@ -121,11 +121,11 @@ msgstr ""
121
  msgid "Advanced"
122
  msgstr ""
123
 
124
- #: ../translatepress/includes/class-advanced-tab.php:241, ../translatepress/includes/class-error-manager.php:155, ../translatepress/partials/machine-translation-settings-page.php:13, ../translatepress/partials/machine-translation-settings-page.php:78, ../translatepress/partials/machine-translation-settings-page.php:111, ../translatepress/partials/main-settings-page.php:41, ../translatepress/partials/main-settings-page.php:54, ../translatepress/partials/main-settings-page.php:67
125
  msgid "Yes"
126
  msgstr ""
127
 
128
- #: ../translatepress/includes/class-advanced-tab.php:422, ../translatepress/includes/class-advanced-tab.php:432
129
  msgid "Are you sure you want to remove this item?"
130
  msgstr ""
131
 
@@ -1253,6 +1253,14 @@ msgstr ""
1253
  msgid "Enables the hreflang=\"x-default\" for an entire language. See documentation for more details."
1254
  msgstr ""
1255
 
 
 
 
 
 
 
 
 
1256
  #: ../translatepress/includes/advanced-settings/exclude-dynamic-selectors.php:9, ../translatepress/includes/advanced-settings/exclude-selectors.php:9
1257
  msgid "Selector"
1258
  msgstr ""
97
  msgid "Are you sure you want to remove this language?"
98
  msgstr ""
99
 
100
+ #: ../tp-add-on-extra-languages/partials/language-selector-pro.php:43, ../translatepress/includes/class-advanced-tab.php:423, ../translatepress/includes/class-advanced-tab.php:433, ../translatepress/partials/main-settings-language-selector.php:40
101
  msgid "Remove"
102
  msgstr ""
103
 
105
  msgid "Choose..."
106
  msgstr ""
107
 
108
+ #: ../tp-add-on-extra-languages/partials/language-selector-pro.php:58, ../translatepress/includes/class-advanced-tab.php:433, ../translatepress/partials/main-settings-language-selector.php:55
109
  msgid "Add"
110
  msgstr ""
111
 
121
  msgid "Advanced"
122
  msgstr ""
123
 
124
+ #: ../translatepress/includes/class-advanced-tab.php:242, ../translatepress/includes/class-error-manager.php:155, ../translatepress/partials/machine-translation-settings-page.php:13, ../translatepress/partials/machine-translation-settings-page.php:78, ../translatepress/partials/machine-translation-settings-page.php:111, ../translatepress/partials/main-settings-page.php:41, ../translatepress/partials/main-settings-page.php:54, ../translatepress/partials/main-settings-page.php:67
125
  msgid "Yes"
126
  msgstr ""
127
 
128
+ #: ../translatepress/includes/class-advanced-tab.php:423, ../translatepress/includes/class-advanced-tab.php:433
129
  msgid "Are you sure you want to remove this item?"
130
  msgstr ""
131
 
1253
  msgid "Enables the hreflang=\"x-default\" for an entire language. See documentation for more details."
1254
  msgstr ""
1255
 
1256
+ #: ../translatepress/includes/advanced-settings/enable-numerals-translation.php:9
1257
+ msgid "Translate numbers and numerals"
1258
+ msgstr ""
1259
+
1260
+ #: ../translatepress/includes/advanced-settings/enable-numerals-translation.php:10
1261
+ msgid "Enable translation of numbers ( e.g. phone numbers)"
1262
+ msgstr ""
1263
+
1264
  #: ../translatepress/includes/advanced-settings/exclude-dynamic-selectors.php:9, ../translatepress/includes/advanced-settings/exclude-selectors.php:9
1265
  msgid "Selector"
1266
  msgstr ""
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.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -138,6 +138,12 @@ For more information please check out our [documentation](https://translatepress
138
 
139
 
140
  == Changelog ==
 
 
 
 
 
 
141
  = 1.7.6 =
142
  * Added a help wizard for the Visual Editor
143
  * Added Puerto Rico flag
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.7
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.7 =
142
+ * Added option to enable translation of numerals
143
+ * Added capability to translate special URLs like tel, callto or mailto
144
+ * Added support for translating oembed response data
145
+ * Fixed some CSS issues on Safari
146
+
147
  = 1.7.6 =
148
  * Added a help wizard for the Visual Editor
149
  * Added Puerto Rico flag