TranslatePress – Translate Multilingual sites - Version 1.9.9

Version Description

  • Forcing a slash at the end of home url is now an optional Advanced setting
  • Better handling of WPEngine long query limiting
  • Fixed some cases of adding language slugs to file paths
  • Fixed unprefixed DOM library constant
  • Fixed a notice coming from the Do not translate paths option
Download this release

Release Info

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

Code changes from version 1.9.8 to 1.9.9

assets/lib/simplehtmldom/simple_html_dom.php CHANGED
@@ -60,7 +60,7 @@ defined('TRP_DEFAULT_TARGET_CHARSET') || define('TRP_DEFAULT_TARGET_CHARSET', 'U
60
  defined('TRP_DEFAULT_BR_TEXT') || define('TRP_DEFAULT_BR_TEXT', "\r\n");
61
  defined('TRP_DEFAULT_SPAN_TEXT') || define('TRP_DEFAULT_SPAN_TEXT', ' ');
62
  defined('TRP_MAX_FILE_SIZE') || define('TRP_MAX_FILE_SIZE', 100000000);
63
- define('HDOM_SMARTY_AS_TEXT', 1);
64
 
65
  function file_get_html(
66
  $url,
@@ -1552,7 +1552,7 @@ class simple_html_dom
1552
  // strip out server side scripts
1553
  $this->remove_noise("'(<\?)(.*?)(\?>)'s", true);
1554
 
1555
- if($options & HDOM_SMARTY_AS_TEXT) { // Strip Smarty scripts
1556
  $this->remove_noise("'(\{\w)(.*?)(\})'s", true);
1557
  }
1558
 
60
  defined('TRP_DEFAULT_BR_TEXT') || define('TRP_DEFAULT_BR_TEXT', "\r\n");
61
  defined('TRP_DEFAULT_SPAN_TEXT') || define('TRP_DEFAULT_SPAN_TEXT', ' ');
62
  defined('TRP_MAX_FILE_SIZE') || define('TRP_MAX_FILE_SIZE', 100000000);
63
+ define('TRP_HDOM_SMARTY_AS_TEXT', 1);
64
 
65
  function file_get_html(
66
  $url,
1552
  // strip out server side scripts
1553
  $this->remove_noise("'(<\?)(.*?)(\?>)'s", true);
1554
 
1555
+ if($options & TRP_HDOM_SMARTY_AS_TEXT) { // Strip Smarty scripts
1556
  $this->remove_noise("'(\{\w)(.*?)(\})'s", true);
1557
  }
1558
 
class-translate-press.php CHANGED
@@ -58,7 +58,7 @@ class TRP_Translate_Press{
58
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
59
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
60
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
61
- define( 'TRP_PLUGIN_VERSION', '1.9.8' );
62
 
63
  wp_cache_add_non_persistent_groups(array('trp'));
64
 
58
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
59
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
60
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
61
+ define( 'TRP_PLUGIN_VERSION', '1.9.9' );
62
 
63
  wp_cache_add_non_persistent_groups(array('trp'));
64
 
includes/advanced-settings/do-not-translate-certain-paths.php CHANGED
@@ -36,7 +36,7 @@ function trp_output_do_not_translate_certain_paths( $setting ){
36
  </label>
37
  </div>
38
 
39
- <textarea class="trp-adv-big-textarea" name="trp_advanced_settings[<?php echo $setting['name']; ?>][paths]"><?php echo $trp_settings['trp_advanced_settings'][$setting['name']]['paths']; ?></textarea>
40
 
41
  <p class="description"><?php echo $setting['description']; ?></p>
42
  </td>
36
  </label>
37
  </div>
38
 
39
+ <textarea class="trp-adv-big-textarea" name="trp_advanced_settings[<?php echo $setting['name']; ?>][paths]"><?php echo isset( $trp_settings['trp_advanced_settings'][$setting['name']]['paths'] ) ? $trp_settings['trp_advanced_settings'][$setting['name']]['paths'] : ''; ?></textarea>
40
 
41
  <p class="description"><?php echo $setting['description']; ?></p>
42
  </td>
includes/advanced-settings/enable-auto-translate-slug.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- add_filter( 'trp_register_advanced_settings', 'trp_register_enable_auto_translate_slug', 1080 );
4
  function trp_register_enable_auto_translate_slug( $settings_array ){
5
  $settings_array[] = array(
6
  'name' => 'enable_auto_translate_slug',
1
  <?php
2
 
3
+ add_filter( 'trp_register_advanced_settings', 'trp_register_enable_auto_translate_slug', 1070 );
4
  function trp_register_enable_auto_translate_slug( $settings_array ){
5
  $settings_array[] = array(
6
  'name' => 'enable_auto_translate_slug',
includes/advanced-settings/force-slash-at-end-of-links.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_filter('trp_register_advanced_settings', 'trp_register_force_slash_in_home_url', 1071);
4
+ function trp_register_force_slash_in_home_url($settings_array)
5
+ {
6
+ $settings_array[] = array(
7
+ 'name' => 'force_slash_at_end_of_links',
8
+ 'type' => 'checkbox',
9
+ 'label' => esc_html__('Force slash at end of home url:', 'translatepress-multilingual'),
10
+ 'description' => wp_kses(__('Ads a slash at the end of the home_url() function', 'translatepress-multilingual'), array('br' => array())),
11
+ );
12
+ return $settings_array;
13
+ }
includes/class-advanced-tab.php CHANGED
@@ -203,6 +203,7 @@ class TRP_Advanced_Tab {
203
  public function include_custom_codes(){
204
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/disable-dynamic-translation.php');
205
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/enable-auto-translate-slug.php');
 
206
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/enable-numerals-translation.php');
207
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/custom-date-format.php');
208
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/custom-language.php');
203
  public function include_custom_codes(){
204
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/disable-dynamic-translation.php');
205
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/enable-auto-translate-slug.php');
206
+ include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/force-slash-at-end-of-links.php');
207
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/enable-numerals-translation.php');
208
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/custom-date-format.php');
209
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/custom-language.php');
includes/class-translation-render.php CHANGED
@@ -667,6 +667,9 @@ class TRP_Translation_Render{
667
  //add data-trp-post-id attribute if needed
668
  $nodes = $this->maybe_add_post_id_in_node( $nodes, $row, $string_count );
669
  }
 
 
 
670
  }
671
  //set up general links variables
672
  $home_url = home_url();
@@ -853,6 +856,7 @@ class TRP_Translation_Render{
853
  ( $TRP_LANGUAGE != $this->settings['default-language'] || $this->settings['add-subdirectory-to-default-language'] == 'yes' ) &&
854
  $this->settings['force-language-to-custom-links'] == 'yes' &&
855
  !$is_external_link &&
 
856
  ( $this->url_converter->get_lang_from_url_string( $url ) == null || ( isset ($this->settings['add-subdirectory-to-default-language']) && $this->settings['add-subdirectory-to-default-language'] === 'yes' && $this->url_converter->get_lang_from_url_string( $url ) === $this->settings['default-language'] ) ) &&
857
  !$is_admin_link &&
858
  strpos($url, '#TRPLINKPROCESSED') === false &&
667
  //add data-trp-post-id attribute if needed
668
  $nodes = $this->maybe_add_post_id_in_node( $nodes, $row, $string_count );
669
  }
670
+
671
+ $row = apply_filters( 'trp_process_other_text_nodes', $row );
672
+
673
  }
674
  //set up general links variables
675
  $home_url = home_url();
856
  ( $TRP_LANGUAGE != $this->settings['default-language'] || $this->settings['add-subdirectory-to-default-language'] == 'yes' ) &&
857
  $this->settings['force-language-to-custom-links'] == 'yes' &&
858
  !$is_external_link &&
859
+ !$this->url_converter->url_is_file( $url ) &&
860
  ( $this->url_converter->get_lang_from_url_string( $url ) == null || ( isset ($this->settings['add-subdirectory-to-default-language']) && $this->settings['add-subdirectory-to-default-language'] === 'yes' && $this->url_converter->get_lang_from_url_string( $url ) === $this->settings['default-language'] ) ) &&
861
  !$is_admin_link &&
862
  strpos($url, '#TRPLINKPROCESSED') === false &&
includes/class-upgrade.php CHANGED
@@ -69,6 +69,9 @@ class TRP_Upgrade {
69
  $this->trp_query->check_original_table();
70
  $this->trp_query->check_original_meta_table();
71
  }
 
 
 
72
  }
73
 
74
  // don't update the db version unless they are different. Otherwise the query is run on every page load.
@@ -652,6 +655,22 @@ class TRP_Upgrade {
652
  }
653
  }
654
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
655
 
656
  public function trp_remove_duplicate_original_strings(){
657
  if ( ! $this->trp_query ) {
69
  $this->trp_query->check_original_table();
70
  $this->trp_query->check_original_meta_table();
71
  }
72
+ if ( version_compare($stored_database_version, '1.9.8', '<=')) {
73
+ $this->set_force_slash_at_end_of_links();
74
+ }
75
  }
76
 
77
  // don't update the db version unless they are different. Otherwise the query is run on every page load.
655
  }
656
  }
657
 
658
+ /**
659
+ *
660
+ */
661
+ private function set_force_slash_at_end_of_links(){
662
+ $trp = TRP_Translate_Press::get_trp_instance();
663
+ $trp_settings = $trp->get_component('settings' );
664
+ $settings = $trp_settings->get_settings();
665
+
666
+ if( !empty( $settings['trp_advanced_settings'] ) && !isset( $settings['trp_advanced_settings']['force_slash_at_end_of_links'] ) ){
667
+ $advanced_settings = $settings['trp_advanced_settings'];
668
+ $advanced_settings['force_slash_at_end_of_links'] = 'yes';
669
+ update_option('trp_advanced_settings', $advanced_settings );
670
+ }
671
+
672
+ }
673
+
674
 
675
  public function trp_remove_duplicate_original_strings(){
676
  if ( ! $this->trp_query ) {
includes/class-url-converter.php CHANGED
@@ -32,18 +32,35 @@ class TRP_Url_Converter {
32
  */
33
  public function add_language_to_home_url( $url, $path, $orig_scheme, $blog_id ){
34
  global $TRP_LANGUAGE;
 
 
 
 
 
35
  if ( isset( $this->settings['add-subdirectory-to-default-language'] ) && $this->settings['add-subdirectory-to-default-language'] == 'no' && $TRP_LANGUAGE == $this->settings['default-language'] ) {
36
  return $url;
37
  }
38
 
39
- if( is_customize_preview() || $this->is_admin_request() || $this->is_sitemap_path( $path ) )
40
  return $url;
41
 
42
  $url_slug = $this->get_url_slug( $TRP_LANGUAGE );
 
 
 
 
 
43
  $abs_home = $this->get_abs_home();
44
- $new_url = trailingslashit( trailingslashit( $abs_home ) . $url_slug );
 
 
 
 
 
 
 
45
  if ( ! empty( $path ) ){
46
- $new_url .= ltrim( $path, '/' );
47
  }
48
 
49
  return apply_filters( 'trp_home_url', $new_url, $abs_home, $TRP_LANGUAGE, $path, $url );
@@ -209,7 +226,7 @@ class TRP_Url_Converter {
209
 
210
  $hash = hash( 'md4', (string)$language . (string)$url . (string)$trp_link_is_processed . (string)$TRP_LANGUAGE );
211
  // set $new_url to false when debugging and developing new features
212
- $new_url = wp_cache_get('get_url_for_language_' . $hash, 'trp');
213
  if ( $new_url !== false ){
214
  return $new_url;
215
  }
@@ -219,13 +236,13 @@ class TRP_Url_Converter {
219
  $language = $TRP_LANGUAGE;
220
  }
221
 
222
- $url_obj = wp_cache_get('url_obj_' . hash('md4', $url), 'trp');
223
  if( $url_obj === false ){
224
  $url_obj = new \TranslatePress\Uri($url);
225
  wp_cache_set('url_obj_' . hash('md4', $url), $url_obj, 'trp' );
226
  }
227
 
228
- $abs_home_url_obj = wp_cache_get('url_obj_' . hash('md4', $this->get_abs_home() ), 'trp');
229
  if( $abs_home_url_obj === false ){
230
  $abs_home_url_obj = new \TranslatePress\Uri( $this->get_abs_home() );
231
  wp_cache_set('url_obj_' . hash('md4', $this->get_abs_home()), $abs_home_url_obj, 'trp' );
@@ -280,7 +297,7 @@ class TRP_Url_Converter {
280
  }
281
 
282
  // maybe find the post_id for the current URL
283
- $possible_post_id = wp_cache_get( 'possible_post_id_'. hash('md4', $url ), 'trp' );
284
  if ( $possible_post_id ){
285
  $post_id = $possible_post_id;
286
  trp_bulk_debug($debug, array('url' => $url, 'found post id' => $post_id, 'for language' => $TRP_LANGUAGE));
@@ -456,12 +473,18 @@ class TRP_Url_Converter {
456
  $translation_render = $trp->get_component("translation_render");
457
 
458
  if ( empty( $url ) || $translation_render->is_external_link($url) ){
459
- return false;
460
- }
 
 
 
 
461
 
462
- $path = trailingslashit(ABSPATH) . str_replace(untrailingslashit($this->get_abs_home()), '', $url);
 
 
463
 
464
- return is_file($path);
465
  }
466
 
467
 
@@ -508,7 +531,7 @@ class TRP_Url_Converter {
508
  * @return string
509
  */
510
  public function get_abs_home() {
511
- $this->absolute_home = wp_cache_get('get_abs_home', 'trp');
512
  if ( $this->absolute_home !== false ){
513
  return $this->absolute_home;
514
  }
@@ -563,18 +586,18 @@ class TRP_Url_Converter {
563
  $url = $this->cur_page_url();
564
  }
565
 
566
- $language = wp_cache_get('url_language_' . hash('md4', $url) , 'trp' );
567
  if ( $language !== false ){
568
  return $language;
569
  }
570
 
571
- $url_obj = wp_cache_get('url_obj_' . hash('md4', $url), 'trp');
572
  if( $url_obj === false ){
573
  $url_obj = new \TranslatePress\Uri($url);
574
  wp_cache_set('url_obj_' . hash('md4', $url), $url_obj, 'trp' );
575
  }
576
 
577
- $abs_home_url_obj = wp_cache_get('url_obj_' . hash('md4', $this->get_abs_home() ), 'trp');
578
  if( $abs_home_url_obj === false ){
579
  $abs_home_url_obj = new \TranslatePress\Uri( $this->get_abs_home() );
580
  wp_cache_set('url_obj_' . hash('md4', $this->get_abs_home()), $abs_home_url_obj, 'trp' );
@@ -617,7 +640,7 @@ class TRP_Url_Converter {
617
  */
618
  public function cur_page_url() {
619
 
620
- $req_uri = wp_cache_get('cur_page_url', 'trp');
621
  if ( $req_uri ){
622
  return $req_uri;
623
  }
32
  */
33
  public function add_language_to_home_url( $url, $path, $orig_scheme, $blog_id ){
34
  global $TRP_LANGUAGE;
35
+
36
+ //if this is not set then don't do anything as this is an exception/error and $TRP_LANGUAGE should always be set
37
+ if( empty( $TRP_LANGUAGE ) )
38
+ return $url;
39
+
40
  if ( isset( $this->settings['add-subdirectory-to-default-language'] ) && $this->settings['add-subdirectory-to-default-language'] == 'no' && $TRP_LANGUAGE == $this->settings['default-language'] ) {
41
  return $url;
42
  }
43
 
44
+ if( is_customize_preview() || $this->is_admin_request() || $this->is_sitemap_path( $path ) || $this->url_is_file( $path ) )
45
  return $url;
46
 
47
  $url_slug = $this->get_url_slug( $TRP_LANGUAGE );
48
+
49
+ //if this is not set then don't do anything as this is an exception/error if we don't have an $url_slug we don't need to do anything
50
+ if( empty( $url_slug ) )
51
+ return $url;
52
+
53
  $abs_home = $this->get_abs_home();
54
+
55
+ if ( trp_force_slash_at_end_of_link( $this->settings ) ) {
56
+ $new_url = trailingslashit( trailingslashit($abs_home) . $url_slug );
57
+ }
58
+ else {
59
+ $new_url = trailingslashit($abs_home) . $url_slug;
60
+ }
61
+
62
  if ( ! empty( $path ) ){
63
+ $new_url = trailingslashit($new_url) . ltrim( $path, '/' );
64
  }
65
 
66
  return apply_filters( 'trp_home_url', $new_url, $abs_home, $TRP_LANGUAGE, $path, $url );
226
 
227
  $hash = hash( 'md4', (string)$language . (string)$url . (string)$trp_link_is_processed . (string)$TRP_LANGUAGE );
228
  // set $new_url to false when debugging and developing new features
229
+ $new_url = trp_cache_get('get_url_for_language_' . $hash, 'trp');
230
  if ( $new_url !== false ){
231
  return $new_url;
232
  }
236
  $language = $TRP_LANGUAGE;
237
  }
238
 
239
+ $url_obj = trp_cache_get('url_obj_' . hash('md4', $url), 'trp');
240
  if( $url_obj === false ){
241
  $url_obj = new \TranslatePress\Uri($url);
242
  wp_cache_set('url_obj_' . hash('md4', $url), $url_obj, 'trp' );
243
  }
244
 
245
+ $abs_home_url_obj = trp_cache_get('url_obj_' . hash('md4', $this->get_abs_home() ), 'trp');
246
  if( $abs_home_url_obj === false ){
247
  $abs_home_url_obj = new \TranslatePress\Uri( $this->get_abs_home() );
248
  wp_cache_set('url_obj_' . hash('md4', $this->get_abs_home()), $abs_home_url_obj, 'trp' );
297
  }
298
 
299
  // maybe find the post_id for the current URL
300
+ $possible_post_id = trp_cache_get( 'possible_post_id_'. hash('md4', $url ), 'trp' );
301
  if ( $possible_post_id ){
302
  $post_id = $possible_post_id;
303
  trp_bulk_debug($debug, array('url' => $url, 'found post id' => $post_id, 'for language' => $TRP_LANGUAGE));
473
  $translation_render = $trp->get_component("translation_render");
474
 
475
  if ( empty( $url ) || $translation_render->is_external_link($url) ){
476
+ $return = false;
477
+ }else {
478
+ if ( strpos( $url, 'wp-content/uploads' ) !== false ) {
479
+ $return = true;
480
+ }else {
481
+ $path = trailingslashit( ABSPATH ) . str_replace( untrailingslashit( $this->get_abs_home() ), '', $url );
482
 
483
+ $return = is_file( $path );
484
+ }
485
+ }
486
 
487
+ return apply_filters( 'trp_url_is_file', $return, $url, $this->get_abs_home() );
488
  }
489
 
490
 
531
  * @return string
532
  */
533
  public function get_abs_home() {
534
+ $this->absolute_home = trp_cache_get('get_abs_home', 'trp');
535
  if ( $this->absolute_home !== false ){
536
  return $this->absolute_home;
537
  }
586
  $url = $this->cur_page_url();
587
  }
588
 
589
+ $language = trp_cache_get('url_language_' . hash('md4', $url) , 'trp' );
590
  if ( $language !== false ){
591
  return $language;
592
  }
593
 
594
+ $url_obj = trp_cache_get('url_obj_' . hash('md4', $url), 'trp');
595
  if( $url_obj === false ){
596
  $url_obj = new \TranslatePress\Uri($url);
597
  wp_cache_set('url_obj_' . hash('md4', $url), $url_obj, 'trp' );
598
  }
599
 
600
+ $abs_home_url_obj = trp_cache_get('url_obj_' . hash('md4', $this->get_abs_home() ), 'trp');
601
  if( $abs_home_url_obj === false ){
602
  $abs_home_url_obj = new \TranslatePress\Uri( $this->get_abs_home() );
603
  wp_cache_set('url_obj_' . hash('md4', $this->get_abs_home()), $abs_home_url_obj, 'trp' );
640
  */
641
  public function cur_page_url() {
642
 
643
+ $req_uri = trp_cache_get('cur_page_url', 'trp');
644
  if ( $req_uri ){
645
  return $req_uri;
646
  }
includes/compatibility-functions.php CHANGED
@@ -1476,3 +1476,23 @@ function trp_googlesitekit_compatibility_home_url( $url ) {
1476
  $url_converter = $trp->get_component('url_converter');
1477
  return $url_converter->get_abs_home();
1478
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1476
  $url_converter = $trp->get_component('url_converter');
1477
  return $url_converter->get_abs_home();
1478
  }
1479
+
1480
+
1481
+ /**
1482
+ * Compatibility with WPEngine hosting
1483
+ *
1484
+ * Detect and handle query length limiting feature of WPEngine. Without this check, the query returns no results as if
1485
+ * there were no translations found. This results in duplicate row inserting and unnecessary automatic translation
1486
+ * usage.
1487
+ */
1488
+ add_filter('trp_get_existing_translations', 'trp_wpengine_query_limit_check', 10, 3 );
1489
+ function trp_wpengine_query_limit_check($dictionary, $prepared_query, $strings_array){
1490
+ if ( function_exists('is_wpe') && ( !defined ('WPE_GOVERNOR') || ( defined ('WPE_GOVERNOR') && WPE_GOVERNOR != false ) ) && strlen($prepared_query) >= 16000 ){
1491
+ $trp = TRP_Translate_Press::get_trp_instance();
1492
+ $trp_query = $trp->get_component( 'query' );
1493
+ $trp_query->maybe_record_automatic_translation_error(array( 'details' => esc_html__("Detected long query limitation on WPEngine hosting. Some large pages may appear untranslated. You can remove limitation by adding the following to your site’s wp-config.php: define( 'WPE_GOVERNOR', false ); ", 'translatepress-multilingual')), true );
1494
+ return false;
1495
+ }else{
1496
+ return $dictionary;
1497
+ }
1498
+ }
includes/functions.php CHANGED
@@ -69,7 +69,7 @@ function trp_x( $text, $context, $domain, $language ){
69
 
70
  if( !empty( $path ) ) {
71
 
72
- $mo_file = wp_cache_get( 'trp_x_' . $domain .'_'. $language );
73
 
74
  if( false === $mo_file ){
75
  $mo_file = new MO();
@@ -563,3 +563,34 @@ function trp_get_languages($nodefault=null)
563
  }
564
  return ($published_lang_labels);
565
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  if( !empty( $path ) ) {
71
 
72
+ $mo_file = trp_cache_get( 'trp_x_' . $domain .'_'. $language );
73
 
74
  if( false === $mo_file ){
75
  $mo_file = new MO();
563
  }
564
  return ($published_lang_labels);
565
  }
566
+
567
+ /**
568
+ * Wrapper function for wp_cahce_get() that bypases cache if WP_DEBUG is on
569
+ * @param int|string $key The key under which the cache contents are stored.
570
+ * @param string $group Optional. Where the cache contents are grouped. Default empty.
571
+ * @param bool $force Optional. Whether to force an update of the local cache
572
+ * from the persistent cache. Default false.
573
+ * @param bool $found Optional. Whether the key was found in the cache (passed by reference).
574
+ * Disambiguates a return of false, a storable value. Default null.
575
+ * @return mixed|false The cache contents on success, false on failure to retrieve contents or false when WP_DEBUG is on
576
+ *
577
+ */
578
+ function trp_cache_get( $key, $group = '', $force = false, &$found = null ){
579
+ if( defined( 'WP_DEBUG' ) && WP_DEBUG == true )
580
+ return false;
581
+
582
+ $cache = wp_cache_get( $key, $group, $force, $found );
583
+ return $cache;
584
+ }
585
+
586
+ /**
587
+ * Determine if the setting in Advanced Options should make us add a slash at end of string
588
+ * @param $settings the TranslatePress settings object
589
+ * @return bool
590
+ */
591
+ function trp_force_slash_at_end_of_link( $settings ){
592
+ if ( !empty( $settings['trp_advanced_settings'] ) && isset( $settings['trp_advanced_settings']['force_slash_at_end_of_links'] ) && $settings['trp_advanced_settings']['force_slash_at_end_of_links'] === 'yes' )
593
+ return true;
594
+ else
595
+ return false;
596
+ }
index.php CHANGED
@@ -3,14 +3,14 @@
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.9.8
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
10
  Domain Path: /languages
11
  License: GPL2
12
  WC requires at least: 2.5.0
13
- WC tested up to: 5.1
14
 
15
  == Copyright ==
16
  Copyright 2017 Cozmoslabs (www.cozmoslabs.com)
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.9.9
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
10
  Domain Path: /languages
11
  License: GPL2
12
  WC requires at least: 2.5.0
13
+ WC tested up to: 5.2.2
14
 
15
  == Copyright ==
16
  Copyright 2017 Cozmoslabs (www.cozmoslabs.com)
languages/translatepress-multilingual.catalog.php CHANGED
@@ -211,6 +211,7 @@
211
  <?php __("click here", "translatepress-multilingual"); ?>
212
  <?php __("Recreated original strings table.", "translatepress-multilingual"); ?>
213
  <?php __("<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server.", "translatepress-multilingual"); ?>
 
214
  <?php __("Advanced Addons", "translatepress-multilingual"); ?>
215
  <?php __("These addons extend your translation plugin and are available in the Developer, Business and Personal plans.", "translatepress-multilingual"); ?>
216
  <?php __("SEO support for page slug, page title, description and facebook and twitter social graph information. </br> The HTML lang attribute is properly set.", "translatepress-multilingual"); ?>
@@ -364,6 +365,8 @@
364
  <?php __("General attempt to fix broken or missing HTML on translated pages.<br/><strong>Only try this if the \"Fix spaces between html attribute\" did not solve the issue.</strong>", "translatepress-multilingual"); ?>
365
  <?php __("Fix spaces between HTML attributes", "translatepress-multilingual"); ?>
366
  <?php __("Fixes attributes without spaces between them because they are not valid HTML.<br> May help fix missing or broken content from the HTML on translated pages.", "translatepress-multilingual"); ?>
 
 
367
  <?php __("Remove duplicate rows", "translatepress-multilingual"); ?>
368
  <?php __("Click <a href=\"%s\">here</a> to remove duplicate rows from the database.", "translatepress-multilingual"); ?>
369
  <?php __("Troubleshooting", "translatepress-multilingual"); ?>
211
  <?php __("click here", "translatepress-multilingual"); ?>
212
  <?php __("Recreated original strings table.", "translatepress-multilingual"); ?>
213
  <?php __("<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server.", "translatepress-multilingual"); ?>
214
+ <?php __("Detected long query limitation on WPEngine hosting. Some large pages may appear untranslated. You can remove limitation by adding the following to your site’s wp-config.php: define( 'WPE_GOVERNOR', false ); ", "translatepress-multilingual"); ?>
215
  <?php __("Advanced Addons", "translatepress-multilingual"); ?>
216
  <?php __("These addons extend your translation plugin and are available in the Developer, Business and Personal plans.", "translatepress-multilingual"); ?>
217
  <?php __("SEO support for page slug, page title, description and facebook and twitter social graph information. </br> The HTML lang attribute is properly set.", "translatepress-multilingual"); ?>
365
  <?php __("General attempt to fix broken or missing HTML on translated pages.<br/><strong>Only try this if the \"Fix spaces between html attribute\" did not solve the issue.</strong>", "translatepress-multilingual"); ?>
366
  <?php __("Fix spaces between HTML attributes", "translatepress-multilingual"); ?>
367
  <?php __("Fixes attributes without spaces between them because they are not valid HTML.<br> May help fix missing or broken content from the HTML on translated pages.", "translatepress-multilingual"); ?>
368
+ <?php __("Force slash at end of home url:", "translatepress-multilingual"); ?>
369
+ <?php __("Ads a slash at the end of the home_url() function", "translatepress-multilingual"); ?>
370
  <?php __("Remove duplicate rows", "translatepress-multilingual"); ?>
371
  <?php __("Click <a href=\"%s\">here</a> to remove duplicate rows from the database.", "translatepress-multilingual"); ?>
372
  <?php __("Troubleshooting", "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, includes/class-advanced-tab.php:502, includes/class-advanced-tab.php:513, includes/class-advanced-tab.php:601, includes/class-advanced-tab.php:632, 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, includes/class-advanced-tab.php:513, includes/class-advanced-tab.php:632, partials/main-settings-language-selector.php:55
109
  msgid "Add"
110
  msgstr ""
111
 
@@ -133,15 +133,15 @@ msgstr ""
133
  msgid "Advanced"
134
  msgstr ""
135
 
136
- #: includes/class-advanced-tab.php:305, includes/class-error-manager.php:155, partials/machine-translation-settings-page.php:13, partials/machine-translation-settings-page.php:88, partials/machine-translation-settings-page.php:121, partials/main-settings-page.php:41, partials/main-settings-page.php:54, partials/main-settings-page.php:67
137
  msgid "Yes"
138
  msgstr ""
139
 
140
- #: includes/class-advanced-tab.php:502, includes/class-advanced-tab.php:513, includes/class-advanced-tab.php:601, includes/class-advanced-tab.php:632
141
  msgid "Are you sure you want to remove this item?"
142
  msgstr ""
143
 
144
- #: includes/class-advanced-tab.php:585, includes/class-advanced-tab.php:619
145
  msgid "Select..."
146
  msgstr ""
147
 
@@ -757,103 +757,103 @@ msgstr ""
757
  msgid "Dublin Core Description"
758
  msgstr ""
759
 
760
- #: includes/class-upgrade.php:115
761
  msgid "Inserting original strings for language %s..."
762
  msgstr ""
763
 
764
- #: includes/class-upgrade.php:124
765
  msgid "Cleaning original strings table for language %s..."
766
  msgstr ""
767
 
768
- #: includes/class-upgrade.php:132
769
  msgid "Updating original string ids for language %s..."
770
  msgstr ""
771
 
772
- #: includes/class-upgrade.php:140
773
  msgid "Regenerating original meta table for language %s..."
774
  msgstr ""
775
 
776
- #: includes/class-upgrade.php:148
777
  msgid "Cleaning original meta table for language %s..."
778
  msgstr ""
779
 
780
- #: includes/class-upgrade.php:182
781
  msgid "TranslatePress data update"
782
  msgstr ""
783
 
784
- #: includes/class-upgrade.php:182
785
  msgid "We need to update your translations database to the latest version."
786
  msgstr ""
787
 
788
- #: includes/class-upgrade.php:183
789
  msgid "IMPORTANT: It is strongly recommended to first backup the database!\nAre you sure you want to continue?"
790
  msgstr ""
791
 
792
- #: includes/class-upgrade.php:183
793
  msgid "Run the updater"
794
  msgstr ""
795
 
796
- #: includes/class-upgrade.php:199
797
  msgid "Update aborted! Your user account doesn't have the capability to perform database updates."
798
  msgstr ""
799
 
800
- #: includes/class-upgrade.php:204
801
  msgid "Update aborted! Invalid nonce."
802
  msgstr ""
803
 
804
- #: includes/class-upgrade.php:243
805
  msgid "Update aborted! Incorrect action."
806
  msgstr ""
807
 
808
- #: includes/class-upgrade.php:246
809
  msgid "Update aborted! Incorrect language code."
810
  msgstr ""
811
 
812
- #: includes/class-upgrade.php:232
813
  msgid "Updating database to version %s+"
814
  msgstr ""
815
 
816
- #: includes/class-upgrade.php:236, includes/class-upgrade.php:296
817
  msgid "Processing table for language %s..."
818
  msgstr ""
819
 
820
- #: includes/class-upgrade.php:219, includes/class-upgrade.php:325, includes/class-upgrade.php:478, includes/class-upgrade.php:483
821
  msgid "Back to TranslatePress Settings"
822
  msgstr ""
823
 
824
- #: includes/class-upgrade.php:223
825
  msgid "Successfully updated database!"
826
  msgstr ""
827
 
828
- #: includes/class-upgrade.php:300, includes/class-upgrade.php:293
829
  msgid " done."
830
  msgstr ""
831
 
832
- #: includes/class-upgrade.php:478
833
  msgid "Done."
834
  msgstr ""
835
 
836
- #: includes/class-upgrade.php:483
837
  msgid "Invalid nonce."
838
  msgstr ""
839
 
840
- #: includes/class-upgrade.php:507
841
  msgid "Querying table <strong>%s</strong>"
842
  msgstr ""
843
 
844
- #: includes/class-upgrade.php:549
845
  msgid "%s duplicates removed"
846
  msgstr ""
847
 
848
- #: includes/class-upgrade.php:587, includes/class-upgrade.php:676
849
  msgid "If the page does not redirect automatically"
850
  msgstr ""
851
 
852
- #: includes/class-upgrade.php:587, includes/class-upgrade.php:676
853
  msgid "click here"
854
  msgstr ""
855
 
856
- #: includes/class-upgrade.php:665
857
  msgid "Recreated original strings table."
858
  msgstr ""
859
 
@@ -861,6 +861,10 @@ msgstr ""
861
  msgid "<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server."
862
  msgstr ""
863
 
 
 
 
 
864
  #: partials/addons-settings-page.php:12
865
  msgid "Advanced Addons"
866
  msgstr ""
@@ -1478,6 +1482,14 @@ msgstr ""
1478
  msgid "Fixes attributes without spaces between them because they are not valid HTML.<br> May help fix missing or broken content from the HTML on translated pages."
1479
  msgstr ""
1480
 
 
 
 
 
 
 
 
 
1481
  #: includes/advanced-settings/remove-duplicates-from-db.php:7
1482
  msgid "Remove duplicate rows"
1483
  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, includes/class-advanced-tab.php:503, includes/class-advanced-tab.php:514, includes/class-advanced-tab.php:602, includes/class-advanced-tab.php:633, 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, includes/class-advanced-tab.php:514, includes/class-advanced-tab.php:633, partials/main-settings-language-selector.php:55
109
  msgid "Add"
110
  msgstr ""
111
 
133
  msgid "Advanced"
134
  msgstr ""
135
 
136
+ #: includes/class-advanced-tab.php:306, includes/class-error-manager.php:155, partials/machine-translation-settings-page.php:13, partials/machine-translation-settings-page.php:88, partials/machine-translation-settings-page.php:121, partials/main-settings-page.php:41, partials/main-settings-page.php:54, partials/main-settings-page.php:67
137
  msgid "Yes"
138
  msgstr ""
139
 
140
+ #: includes/class-advanced-tab.php:503, includes/class-advanced-tab.php:514, includes/class-advanced-tab.php:602, includes/class-advanced-tab.php:633
141
  msgid "Are you sure you want to remove this item?"
142
  msgstr ""
143
 
144
+ #: includes/class-advanced-tab.php:586, includes/class-advanced-tab.php:620
145
  msgid "Select..."
146
  msgstr ""
147
 
757
  msgid "Dublin Core Description"
758
  msgstr ""
759
 
760
+ #: includes/class-upgrade.php:118
761
  msgid "Inserting original strings for language %s..."
762
  msgstr ""
763
 
764
+ #: includes/class-upgrade.php:127
765
  msgid "Cleaning original strings table for language %s..."
766
  msgstr ""
767
 
768
+ #: includes/class-upgrade.php:135
769
  msgid "Updating original string ids for language %s..."
770
  msgstr ""
771
 
772
+ #: includes/class-upgrade.php:143
773
  msgid "Regenerating original meta table for language %s..."
774
  msgstr ""
775
 
776
+ #: includes/class-upgrade.php:151
777
  msgid "Cleaning original meta table for language %s..."
778
  msgstr ""
779
 
780
+ #: includes/class-upgrade.php:185
781
  msgid "TranslatePress data update"
782
  msgstr ""
783
 
784
+ #: includes/class-upgrade.php:185
785
  msgid "We need to update your translations database to the latest version."
786
  msgstr ""
787
 
788
+ #: includes/class-upgrade.php:186
789
  msgid "IMPORTANT: It is strongly recommended to first backup the database!\nAre you sure you want to continue?"
790
  msgstr ""
791
 
792
+ #: includes/class-upgrade.php:186
793
  msgid "Run the updater"
794
  msgstr ""
795
 
796
+ #: includes/class-upgrade.php:202
797
  msgid "Update aborted! Your user account doesn't have the capability to perform database updates."
798
  msgstr ""
799
 
800
+ #: includes/class-upgrade.php:207
801
  msgid "Update aborted! Invalid nonce."
802
  msgstr ""
803
 
804
+ #: includes/class-upgrade.php:246
805
  msgid "Update aborted! Incorrect action."
806
  msgstr ""
807
 
808
+ #: includes/class-upgrade.php:249
809
  msgid "Update aborted! Incorrect language code."
810
  msgstr ""
811
 
812
+ #: includes/class-upgrade.php:235
813
  msgid "Updating database to version %s+"
814
  msgstr ""
815
 
816
+ #: includes/class-upgrade.php:239, includes/class-upgrade.php:299
817
  msgid "Processing table for language %s..."
818
  msgstr ""
819
 
820
+ #: includes/class-upgrade.php:222, includes/class-upgrade.php:328, includes/class-upgrade.php:481, includes/class-upgrade.php:486
821
  msgid "Back to TranslatePress Settings"
822
  msgstr ""
823
 
824
+ #: includes/class-upgrade.php:226
825
  msgid "Successfully updated database!"
826
  msgstr ""
827
 
828
+ #: includes/class-upgrade.php:303, includes/class-upgrade.php:296
829
  msgid " done."
830
  msgstr ""
831
 
832
+ #: includes/class-upgrade.php:481
833
  msgid "Done."
834
  msgstr ""
835
 
836
+ #: includes/class-upgrade.php:486
837
  msgid "Invalid nonce."
838
  msgstr ""
839
 
840
+ #: includes/class-upgrade.php:510
841
  msgid "Querying table <strong>%s</strong>"
842
  msgstr ""
843
 
844
+ #: includes/class-upgrade.php:552
845
  msgid "%s duplicates removed"
846
  msgstr ""
847
 
848
+ #: includes/class-upgrade.php:590, includes/class-upgrade.php:695
849
  msgid "If the page does not redirect automatically"
850
  msgstr ""
851
 
852
+ #: includes/class-upgrade.php:590, includes/class-upgrade.php:695
853
  msgid "click here"
854
  msgstr ""
855
 
856
+ #: includes/class-upgrade.php:684
857
  msgid "Recreated original strings table."
858
  msgstr ""
859
 
861
  msgid "<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server."
862
  msgstr ""
863
 
864
+ #: includes/compatibility-functions.php:1493
865
+ msgid "Detected long query limitation on WPEngine hosting. Some large pages may appear untranslated. You can remove limitation by adding the following to your site’s wp-config.php: define( 'WPE_GOVERNOR', false ); "
866
+ msgstr ""
867
+
868
  #: partials/addons-settings-page.php:12
869
  msgid "Advanced Addons"
870
  msgstr ""
1482
  msgid "Fixes attributes without spaces between them because they are not valid HTML.<br> May help fix missing or broken content from the HTML on translated pages."
1483
  msgstr ""
1484
 
1485
+ #: includes/advanced-settings/force-slash-at-end-of-links.php:9
1486
+ msgid "Force slash at end of home url:"
1487
+ msgstr ""
1488
+
1489
+ #: includes/advanced-settings/force-slash-at-end-of-links.php:10
1490
+ msgid "Ads a slash at the end of the home_url() function"
1491
+ msgstr ""
1492
+
1493
  #: includes/advanced-settings/remove-duplicates-from-db.php:7
1494
  msgid "Remove duplicate rows"
1495
  msgstr ""
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
- === TranslatePress - Translate Multilingual sites ===
2
  Contributors: cozmoslabs, razvan.mo, madalin.ungureanu, sareiodata, cristophor
3
  Donate link: https://www.translatepress.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: 5.7
7
  Requires PHP: 5.6.20
8
- Stable tag: 1.9.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -13,7 +13,7 @@ Translate your entire site directly from the front-end and go multilingual, with
13
 
14
  == Description ==
15
 
16
- **Experience a better way to translate your WordPress site and go multilingual, directly from the front-end using a friendly user interface.**
17
 
18
  TranslatePress is a [WordPress translation plugin](https://translatepress.com/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) that anyone can use.
19
 
@@ -37,6 +37,7 @@ https://www.youtube.com/watch?v=pUlYisvBm8g
37
  * Editorial control allowing you to publish your language only when all your translations are done
38
  * Conditional display content shortcode based on language [trp_language language="en_US"] English content only [/trp_language]
39
  * Possibility to [edit gettext strings](https://translatepress.com/edit-plugin-strings/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) from themes and plugins from English to English, without adding another language. Basically a string-replace functionality.
 
40
  * Translation Block feature in which you can translate multiple html elements together
41
  * Native **Gutenberg** support, so you can easily [translate Gutenberg blocks](https://translatepress.com/translate-gutenberg-blocks-in-wordpress/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree)
42
  * Out of the box [WooCommerce](https://translatepress.com/translate-woocommerce-products-translatepress/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) compatibility
@@ -138,6 +139,13 @@ For more information please check out our [documentation](https://translatepress
138
 
139
 
140
  == Changelog ==
 
 
 
 
 
 
 
141
  = 1.9.8 =
142
  * Added compatibility with Google Site Kit plugin
143
  * Added compatibility with Ivory Search plugin and possibly others
1
+ === Translate Multilingual sites - TranslatePress ===
2
  Contributors: cozmoslabs, razvan.mo, madalin.ungureanu, sareiodata, cristophor
3
  Donate link: https://www.translatepress.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: 5.7.1
7
  Requires PHP: 5.6.20
8
+ Stable tag: 1.9.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
13
 
14
  == Description ==
15
 
16
+ **Experience a better way to translate your WordPress site and go multilingual, directly from the front-end using a visual translation interface.**
17
 
18
  TranslatePress is a [WordPress translation plugin](https://translatepress.com/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) that anyone can use.
19
 
37
  * Editorial control allowing you to publish your language only when all your translations are done
38
  * Conditional display content shortcode based on language [trp_language language="en_US"] English content only [/trp_language]
39
  * Possibility to [edit gettext strings](https://translatepress.com/edit-plugin-strings/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) from themes and plugins from English to English, without adding another language. Basically a string-replace functionality.
40
+ * Translate only certain paths and [exclude content from being translated](https://translatepress.com/partially-translate-wordpress-exclude-posts-pages-products/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree)
41
  * Translation Block feature in which you can translate multiple html elements together
42
  * Native **Gutenberg** support, so you can easily [translate Gutenberg blocks](https://translatepress.com/translate-gutenberg-blocks-in-wordpress/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree)
43
  * Out of the box [WooCommerce](https://translatepress.com/translate-woocommerce-products-translatepress/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) compatibility
139
 
140
 
141
  == Changelog ==
142
+ = 1.9.9 =
143
+ * Forcing a slash at the end of home url is now an optional Advanced setting
144
+ * Better handling of WPEngine long query limiting
145
+ * Fixed some cases of adding language slugs to file paths
146
+ * Fixed unprefixed DOM library constant
147
+ * Fixed a notice coming from the Do not translate paths option
148
+
149
  = 1.9.8 =
150
  * Added compatibility with Google Site Kit plugin
151
  * Added compatibility with Ivory Search plugin and possibly others