Lingotek Translation - Version 1.4.6

Version Description

(2020-1-28) = * Fixed issue that caused duplicate uploads to Lingotek TMS * Enabled in-context translation for WordPress using the new Workbench

Download this release

Release Info

Developer elliothanna
Plugin Icon 128x128 Lingotek Translation
Version 1.4.6
Comparing to
See all releases

Code changes from version 1.4.5 to 1.4.6

admin/filters-columns.php CHANGED
@@ -173,7 +173,8 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
173
  return 'post' === $type ? parent::post_column( $column, $object_id ) : parent::term_column( '', $column, $object_id );
174
  } // source post is uploaded.
175
  elseif ( isset( $document->source ) && $document->source === $id ) {
176
- // source ready for upload.
 
177
  if ( $this->lgtm->can_upload( $type, $id ) ) {
178
  return $actions->upload_icon( $id );
179
  }
173
  return 'post' === $type ? parent::post_column( $column, $object_id ) : parent::term_column( '', $column, $object_id );
174
  } // source post is uploaded.
175
  elseif ( isset( $document->source ) && $document->source === $id ) {
176
+ // source ready for upload.
177
+ delete_option( $document->source );
178
  if ( $this->lgtm->can_upload( $type, $id ) ) {
179
  return $actions->upload_icon( $id );
180
  }
admin/settings/view-utilities.php CHANGED
@@ -66,7 +66,7 @@ if ( ! empty( $_POST ) ) {
66
  printf(
67
  '<p><input type="checkbox" name="%1$s" id="%1$s"/><label for="%1$s">%2$s</label></p>',
68
  'utility_disassociate',
69
- esc_html( __( 'Delete all the content from your Lingotek community.', 'lingotek-translation' ) ) . " <b>This is NOT recommended. Please cancel instead.</b>"
70
  );
71
 
72
  $confirm_delete = __( 'You are about to delete all your content from your Lingotek community. Are you sure ?', 'lingotek-translation' );
66
  printf(
67
  '<p><input type="checkbox" name="%1$s" id="%1$s"/><label for="%1$s">%2$s</label></p>',
68
  'utility_disassociate',
69
+ esc_html( __( 'Delete all unfinished documents from WordPress and cancel corresponding documents from your Lingotek Community.', 'lingotek-translation' ) ) . " <b>Use with caution.</b>"
70
  );
71
 
72
  $confirm_delete = __( 'You are about to delete all your content from your Lingotek community. Are you sure ?', 'lingotek-translation' );
include/model.php CHANGED
@@ -287,34 +287,32 @@ class Lingotek_Model {
287
  public function upload_post($post_id) {
288
  $post = get_post($post_id);
289
  $language = PLL()->model->post->get_language($post_id);
290
- if (empty($post) || empty($language))
291
- return;
292
-
293
  $profile = self::get_profile($post->post_type, $language, $post_id);
 
 
 
294
 
295
  /**
296
  * Customized workflows have the option to do any sort of pre-processing before a document is uploaded to lingotek.
297
  */
298
  $document = $this->get_group('post', $post_id);
 
299
  if ($document) {
300
  $document->pre_upload_to_lingotek($post_id, $post->post_type, $language, 'post');
301
  }
302
 
303
- if ('disabled' == $profile['profile'])
304
- return;
305
-
306
  $client = new Lingotek_API();
307
- $external_url = add_query_arg(array('lingotek' => 1, 'document_id' => '{document_id}', 'locale' => '{locale}', 'type' => 'get'), site_url());
308
  $content = Lingotek_Group_Post::get_content($post);
309
- $params = $this->build_params($post->post_title, $post->post_type, $content, $language, $profile, $post_id, $wp_target_locales);
310
  $filter_ids = $this->get_filter_ids($post->post_type, $language, $post_id);
311
  $params = array_merge($params, $filter_ids);
312
 
313
- if (($document = $this->get_group('post', $post_id)) && 'edited' == $document->status) {
314
  $document->patch($post->post_title, $post, $external_url, $filter_ids);
315
- }
316
 
317
- elseif (!Lingotek_Group::$creating_translation && !self::$copying_post) {
318
  $document_id = $client->upload_document($params, $post->ID);
319
 
320
  if ($document_id) {
@@ -364,7 +362,7 @@ class Lingotek_Model {
364
 
365
  $client = new Lingotek_API();
366
  $content = Lingotek_Group_Term::get_content($term);
367
- $params = $this->build_params($term->name, $taxonomy, $content, $language, $profile, $term_id, $wp_target_locales);
368
  $filter_ids = $this->get_filter_ids($taxonomy, $language, $term_id);
369
  $params = array_merge($params, $filter_ids);
370
 
@@ -420,7 +418,7 @@ class Lingotek_Model {
420
 
421
  $client = new Lingotek_API();
422
  $content = Lingotek_Group_String::get_content($group);
423
- $params = $this->build_params($group, $type, $content, $language, $profile, null);
424
  $filter_ids = $this->get_filter_ids($type, $language, null);
425
  $params = array_merge($params, $filter_ids);
426
 
@@ -793,7 +791,7 @@ class Lingotek_Model {
793
  return $r[$taxonomy] = compact('sources', 'targets', 'total');
794
  }
795
 
796
- private function build_params($title, $type, $content, $language, $profile, $wp_id, &$wp_target_locales = array()) {
797
 
798
  $translation_workflow_id = self::get_profile_option('workflow_id', $type, $language, false, $wp_id);
799
  if ($translation_workflow_id === 'project-default' || $translation_workflow_id === false) {
@@ -805,13 +803,9 @@ class Lingotek_Model {
805
  'content' => $content,
806
  'locale_code' => $language->lingotek_locale,
807
  'project_id' => self::get_profile_option('project_id', $type, $language, false, $wp_id),
 
808
  );
809
 
810
- if ($wp_id) {
811
- $external_url = add_query_arg(array('lingotek' => 1, 'document_id' => '{document_id}', 'locale' => '{locale}', 'type' => 'get'), site_url());
812
- $params['external_url'] = $external_url;
813
- }
814
-
815
  $lingotek_metadata_keys = array('author_email',
816
  'author_name',
817
  'division',
287
  public function upload_post($post_id) {
288
  $post = get_post($post_id);
289
  $language = PLL()->model->post->get_language($post_id);
 
 
 
290
  $profile = self::get_profile($post->post_type, $language, $post_id);
291
+ if ('disabled' == $profile['profile'] || empty($post) || empty($language) || get_option( $post_id, false )) {
292
+ return;
293
+ }
294
 
295
  /**
296
  * Customized workflows have the option to do any sort of pre-processing before a document is uploaded to lingotek.
297
  */
298
  $document = $this->get_group('post', $post_id);
299
+
300
  if ($document) {
301
  $document->pre_upload_to_lingotek($post_id, $post->post_type, $language, 'post');
302
  }
303
 
 
 
 
304
  $client = new Lingotek_API();
305
+ $external_url = get_page_link($post_id);
306
  $content = Lingotek_Group_Post::get_content($post);
307
+ $params = $this->build_params($external_url, $post->post_title, $post->post_type, $content, $language, $profile, $post_id, $wp_target_locales);
308
  $filter_ids = $this->get_filter_ids($post->post_type, $language, $post_id);
309
  $params = array_merge($params, $filter_ids);
310
 
311
+ if ($document && 'edited' == $document->status) {
312
  $document->patch($post->post_title, $post, $external_url, $filter_ids);
313
+ } elseif (!Lingotek_Group::$creating_translation && !self::$copying_post && !$document) {
314
 
315
+ update_option($post_id, true);
316
  $document_id = $client->upload_document($params, $post->ID);
317
 
318
  if ($document_id) {
362
 
363
  $client = new Lingotek_API();
364
  $content = Lingotek_Group_Term::get_content($term);
365
+ $params = $this->build_params(get_term_link( $term_id, $taxonomy ), $term->name, $taxonomy, $content, $language, $profile, $term_id, $wp_target_locales);
366
  $filter_ids = $this->get_filter_ids($taxonomy, $language, $term_id);
367
  $params = array_merge($params, $filter_ids);
368
 
418
 
419
  $client = new Lingotek_API();
420
  $content = Lingotek_Group_String::get_content($group);
421
+ $params = $this->build_params('', $group, $type, $content, $language, $profile, null);
422
  $filter_ids = $this->get_filter_ids($type, $language, null);
423
  $params = array_merge($params, $filter_ids);
424
 
791
  return $r[$taxonomy] = compact('sources', 'targets', 'total');
792
  }
793
 
794
+ private function build_params($external_url, $title, $type, $content, $language, $profile, $wp_id, &$wp_target_locales = array()) {
795
 
796
  $translation_workflow_id = self::get_profile_option('workflow_id', $type, $language, false, $wp_id);
797
  if ($translation_workflow_id === 'project-default' || $translation_workflow_id === false) {
803
  'content' => $content,
804
  'locale_code' => $language->lingotek_locale,
805
  'project_id' => self::get_profile_option('project_id', $type, $language, false, $wp_id),
806
+ 'external_url' => $external_url
807
  );
808
 
 
 
 
 
 
809
  $lingotek_metadata_keys = array('author_email',
810
  'author_name',
811
  'division',
lingotek.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  Plugin name: Lingotek Translation
4
  Plugin URI: http://lingotek.com/wordpress#utm_source=wpadmin&utm_medium=plugin&utm_campaign=wplingotektranslationplugin
5
- Version: 1.4.5
6
  Author: Lingotek and Frédéric Demarle
7
  Author uri: http://lingotek.com
8
  Description: Lingotek offers convenient cloud-based localization and translation.
@@ -16,7 +16,7 @@ if ( ! function_exists( 'add_action' ) ) {
16
  exit();
17
  }
18
 
19
- define( 'LINGOTEK_VERSION', '1.4.5' ); // plugin version (should match above meta).
20
  define( 'LINGOTEK_MIN_PLL_VERSION', '1.8' );
21
  define( 'LINGOTEK_BASENAME', plugin_basename( __FILE__ ) ); // plugin name as known by WP.
22
  define( 'LINGOTEK_PLUGIN_SLUG', 'lingotek-translation' );// plugin slug (should match above meta: Text Domain).
2
  /**
3
  Plugin name: Lingotek Translation
4
  Plugin URI: http://lingotek.com/wordpress#utm_source=wpadmin&utm_medium=plugin&utm_campaign=wplingotektranslationplugin
5
+ Version: 1.4.6
6
  Author: Lingotek and Frédéric Demarle
7
  Author uri: http://lingotek.com
8
  Description: Lingotek offers convenient cloud-based localization and translation.
16
  exit();
17
  }
18
 
19
+ define( 'LINGOTEK_VERSION', '1.4.6' ); // plugin version (should match above meta).
20
  define( 'LINGOTEK_MIN_PLL_VERSION', '1.8' );
21
  define( 'LINGOTEK_BASENAME', plugin_basename( __FILE__ ) ); // plugin name as known by WP.
22
  define( 'LINGOTEK_PLUGIN_SLUG', 'lingotek-translation' );// plugin slug (should match above meta: Text Domain).
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: chouby, smithworx, erichie, robertdhanna, ipoulsen, elliothanna, l
3
  Donate link: http://lingotek.com/
4
  Tags: automation, bilingual, international, language, Lingotek, localization, multilanguage, multilingual, translate, translation
5
  Requires at least: 3.8
6
- Tested up to: 5.3
7
- Stable tag: 1.4.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -123,6 +123,10 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
123
 
124
  == Changelog ==
125
 
 
 
 
 
126
  = 1.4.5 (2019-12-3) =
127
  * Removed Translation Modal
128
  * Changed API to be compatible with new Lingotek Update Document
3
  Donate link: http://lingotek.com/
4
  Tags: automation, bilingual, international, language, Lingotek, localization, multilanguage, multilingual, translate, translation
5
  Requires at least: 3.8
6
+ Tested up to: 5.3.2
7
+ Stable tag: 1.4.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
123
 
124
  == Changelog ==
125
 
126
+ = 1.4.6 (2020-1-28) =
127
+ * Fixed issue that caused duplicate uploads to Lingotek TMS
128
+ * Enabled in-context translation for WordPress using the new Workbench
129
+
130
  = 1.4.5 (2019-12-3) =
131
  * Removed Translation Modal
132
  * Changed API to be compatible with new Lingotek Update Document