Lingotek Translation - Version 1.1.11

Version Description

(2016-2-16) =

  • Improved the copy source feature by allowing manual copying when using a manual Translation Profile
  • Fixed a bug that prevented synchronization of translation taxonomies
Download this release

Release Info

Developer erichie
Plugin Icon 128x128 Lingotek Translation
Version 1.1.11
Comparing to
See all releases

Code changes from version 1.1.10 to 1.1.11

admin/actions.php CHANGED
@@ -99,6 +99,11 @@ abstract class Lingotek_Actions {
99
  'title' => __('There was an error contacting Lingotek', 'lingotek-translation'),
100
  'icon' => 'warning'
101
  ),
 
 
 
 
 
102
  );
103
 
104
  $this->type = $type;
@@ -213,6 +218,20 @@ abstract class Lingotek_Actions {
213
  return self::display_icon('upload', $link, $confirm ? self::$confirm_message : '');
214
  }
215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  /*
217
  * outputs an importing icon
218
  *
@@ -530,4 +549,4 @@ abstract class Lingotek_Actions {
530
 
531
  return $api_error;
532
  }
533
- }
99
  'title' => __('There was an error contacting Lingotek', 'lingotek-translation'),
100
  'icon' => 'warning'
101
  ),
102
+
103
+ 'copy' => array(
104
+ 'title' => __('Copy source language', 'lingotek-translation'),
105
+ 'icon' => 'welcome-add-page'
106
+ ),
107
  );
108
 
109
  $this->type = $type;
218
  return self::display_icon('upload', $link, $confirm ? self::$confirm_message : '');
219
  }
220
 
221
+ /*
222
+ * outputs a copy icon
223
+ *
224
+ *
225
+ * @param int|string $object_id
226
+ * @param string $target
227
+ * @param bool $warning
228
+ */
229
+ public function copy_icon($object_id, $target, $confirm = false) {
230
+ $args = array($this->type => $object_id, 'target' => $target, 'action' => 'lingotek-copy', 'noheader' => true);
231
+ $link = wp_nonce_url(defined('DOING_AJAX') && DOING_AJAX ? add_query_arg($args, wp_get_referer()) : add_query_arg($args), 'lingotek-copy');
232
+ return self::display_icon('copy', $link, $confirm ? self::$confirm_message : '');
233
+ }
234
+
235
  /*
236
  * outputs an importing icon
237
  *
549
 
550
  return $api_error;
551
  }
552
+ }
admin/filters-columns.php CHANGED
@@ -97,6 +97,7 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
97
  $document = $this->lgtm->get_group($type, $object_id);
98
  if (isset($document->source)) {
99
  $source_language = $type == 'post' ? PLL()->model->post->get_language($document->source) : PLL()->model->term->get_language($document->source);
 
100
  }
101
  else {
102
  $source_language = $lang;
@@ -106,7 +107,6 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
106
  $actions = 'post' == $type ? $GLOBALS['wp_lingotek']->post_actions : $GLOBALS['wp_lingotek']->term_actions;
107
 
108
  $profile = Lingotek_Model::get_profile($this->content_type, $language, $object_id);
109
- $source_profile = Lingotek_Model::get_profile($this->content_type, $lang, $id);
110
  $disabled = 'disabled' == $profile['profile'];
111
 
112
  // post ready for upload
@@ -115,6 +115,21 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
115
  : ($document && (count($document->desc_array) >= 3) ? $actions->upload_icon($object_id, true) : $actions->upload_icon($object_id));
116
  }
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  // translation disabled
119
  elseif (isset($document->source) && $document->is_disabled_target($source_language, $language) && !isset($document->translations[$language->locale])) {
120
  return 'post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id);
97
  $document = $this->lgtm->get_group($type, $object_id);
98
  if (isset($document->source)) {
99
  $source_language = $type == 'post' ? PLL()->model->post->get_language($document->source) : PLL()->model->term->get_language($document->source);
100
+ $source_profile = Lingotek_Model::get_profile($this->content_type, $source_language, $document->source);
101
  }
102
  else {
103
  $source_language = $lang;
107
  $actions = 'post' == $type ? $GLOBALS['wp_lingotek']->post_actions : $GLOBALS['wp_lingotek']->term_actions;
108
 
109
  $profile = Lingotek_Model::get_profile($this->content_type, $language, $object_id);
 
110
  $disabled = 'disabled' == $profile['profile'];
111
 
112
  // post ready for upload
115
  : ($document && (count($document->desc_array) >= 3) ? $actions->upload_icon($object_id, true) : $actions->upload_icon($object_id));
116
  }
117
 
118
+ // if language is set to copy and profile is manual
119
+ elseif ((isset($source_profile['targets'][$language->slug]) && $source_profile['targets'][$language->slug] == 'copy') || (isset($profile['targets'][$language->slug]) && $profile['targets'][$language->slug] == 'copy') && isset($document->source)) {
120
+ if (isset($document->desc_array[$language->slug])) {
121
+ return 'post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id);
122
+ }
123
+ else {
124
+ if ($document) {
125
+ return $actions->copy_icon($document->source, $language->slug);
126
+ }
127
+ else {
128
+ return $actions->copy_icon($object_id, $language->slug);
129
+ }
130
+ }
131
+ }
132
+
133
  // translation disabled
134
  elseif (isset($document->source) && $document->is_disabled_target($source_language, $language) && !isset($document->translations[$language->locale])) {
135
  return 'post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id);
admin/post-actions.php CHANGED
@@ -131,7 +131,7 @@ class Lingotek_Post_actions extends Lingotek_Actions {
131
  // the document is already translated so will be overwritten
132
  elseif(($document = $this->lgtm->get_group('post', $post_id)) && empty($document->source)) {
133
  // take care to upload only one post in a translation group
134
- $intersect = array_intersect($post_ids, $this->pllm->get_translations('post', $post_id));
135
  if (empty($intersect)) {
136
  $post_ids[] = $post_id;
137
  $redirect = add_query_arg('lingotek_warning', 1, $redirect);
@@ -142,7 +142,7 @@ class Lingotek_Post_actions extends Lingotek_Actions {
142
  // check if translation is disabled
143
  if (!empty($post_ids)) {
144
  foreach ($post_ids as $key => $post_id) {
145
- $language = $this->pllm->get_post_language($post_id);
146
  $profile = Lingotek_Model::get_profile($post_type, $language);
147
  if ('disabled' == $profile['profile'])
148
  unset($post_ids[$key]);
@@ -173,6 +173,13 @@ class Lingotek_Post_actions extends Lingotek_Actions {
173
  $this->lgtm->upload_post((int) $_GET['post']);
174
  break;
175
 
 
 
 
 
 
 
 
176
  default:
177
  if (!$this->_manage_actions($action))
178
  return; // do not redirect if this is not one of our actions
131
  // the document is already translated so will be overwritten
132
  elseif(($document = $this->lgtm->get_group('post', $post_id)) && empty($document->source)) {
133
  // take care to upload only one post in a translation group
134
+ $intersect = array_intersect($post_ids, PLL()->model->post->get_translations($post_id));
135
  if (empty($intersect)) {
136
  $post_ids[] = $post_id;
137
  $redirect = add_query_arg('lingotek_warning', 1, $redirect);
142
  // check if translation is disabled
143
  if (!empty($post_ids)) {
144
  foreach ($post_ids as $key => $post_id) {
145
+ $language = PLL()->model->post->get_language($post_id);
146
  $profile = Lingotek_Model::get_profile($post_type, $language);
147
  if ('disabled' == $profile['profile'])
148
  unset($post_ids[$key]);
173
  $this->lgtm->upload_post((int) $_GET['post']);
174
  break;
175
 
176
+ case 'lingotek-copy':
177
+ check_admin_referer('lingotek-copy');
178
+ $post = get_post((int) $_GET['post']);
179
+ $target = $_GET['target'];
180
+ $this->lgtm->copy_post($post, $target);
181
+ break;
182
+
183
  default:
184
  if (!$this->_manage_actions($action))
185
  return; // do not redirect if this is not one of our actions
admin/term-actions.php CHANGED
@@ -119,7 +119,7 @@ class Lingotek_Term_actions extends Lingotek_Actions {
119
  // the document is already translated so will be overwritten
120
  elseif(($document = $this->lgtm->get_group('term', $term_id)) && empty($document->source)) {
121
  // take care to upload only one post in a translation group
122
- $intersect = array_intersect($term_ids, $this->pllm->get_translations('term', $term_id));
123
  if (empty($intersect)) {
124
  $term_ids[] = $term_id;
125
  $redirect = add_query_arg('lingotek_warning', 1, $redirect);
@@ -130,7 +130,7 @@ class Lingotek_Term_actions extends Lingotek_Actions {
130
  // check if translation is disabled
131
  if (!empty($term_ids)) {
132
  foreach ($term_ids as $key => $term_id) {
133
- $language = $this->pllm->get_term_language($term_id);
134
  $profile = Lingotek_Model::get_profile($taxnow, $language);
135
  if ('disabled' == $profile['profile'])
136
  unset($term_ids[$key]);
119
  // the document is already translated so will be overwritten
120
  elseif(($document = $this->lgtm->get_group('term', $term_id)) && empty($document->source)) {
121
  // take care to upload only one post in a translation group
122
+ $intersect = array_intersect($term_ids, PLL()->model->term->get_translations($term_id));
123
  if (empty($intersect)) {
124
  $term_ids[] = $term_id;
125
  $redirect = add_query_arg('lingotek_warning', 1, $redirect);
130
  // check if translation is disabled
131
  if (!empty($term_ids)) {
132
  foreach ($term_ids as $key => $term_id) {
133
+ $language = PLL()->model->term->get_language($term_id);
134
  $profile = Lingotek_Model::get_profile($taxnow, $language);
135
  if ('disabled' == $profile['profile'])
136
  unset($term_ids[$key]);
include/group-post.php CHANGED
@@ -345,6 +345,9 @@ class Lingotek_Group_Post extends Lingotek_Group {
345
  $this->safe_translation_status_update($locale, 'current', array($tr_lang->slug => $tr_id));
346
  wp_set_object_terms($tr_id, $this->term_id, 'post_translations');
347
 
 
 
 
348
  // assign terms and metas
349
  $GLOBALS['polylang']->sync->copy_post_metas($this->source, $tr_id, $tr_lang->slug);
350
 
@@ -416,7 +419,7 @@ class Lingotek_Group_Post extends Lingotek_Group {
416
  * @return object
417
  */
418
  public function get_source_language() {
419
- return $this->pllm->get_post_language($this->source);
420
  }
421
 
422
  /*
345
  $this->safe_translation_status_update($locale, 'current', array($tr_lang->slug => $tr_id));
346
  wp_set_object_terms($tr_id, $this->term_id, 'post_translations');
347
 
348
+ // Copies categories and tags
349
+ $GLOBALS['polylang']->sync->copy_taxonomies($this->source, $tr_id, $tr_lang->slug);
350
+
351
  // assign terms and metas
352
  $GLOBALS['polylang']->sync->copy_post_metas($this->source, $tr_id, $tr_lang->slug);
353
 
419
  * @return object
420
  */
421
  public function get_source_language() {
422
+ return PLL()->model->post->get_language($this->source);
423
  }
424
 
425
  /*
include/group-term.php CHANGED
@@ -124,7 +124,7 @@ class Lingotek_Group_Term extends Lingotek_Group {
124
 
125
  // translate parent
126
  $term = get_term($this->source, $this->type);
127
- $args['parent'] = ($term->parent && $tr_parent = $this->pllm->get_translation('term', $term->parent, $locale)) ? $tr_parent : 0;
128
 
129
  // attempt to get a unique slug in case it already exists in another language
130
  if (isset($args['slug']) && term_exists($args['slug'])) {
124
 
125
  // translate parent
126
  $term = get_term($this->source, $this->type);
127
+ $args['parent'] = ($term->parent && $tr_parent = PLL()->model->term->get_translation($term->parent, $locale)) ? $tr_parent : 0;
128
 
129
  // attempt to get a unique slug in case it already exists in another language
130
  if (isset($args['slug']) && term_exists($args['slug'])) {
include/model.php CHANGED
@@ -223,8 +223,9 @@ class Lingotek_Model {
223
  if (!isset($document->desc_array[$target])) {
224
  $new_post_id = wp_insert_post($cp_post, true);
225
  if (!is_wp_error($new_post_id)) {
226
- $this->pllm->set_post_language($new_post_id, $cp_lang);
227
  wp_set_object_terms($new_post_id, $document->term_id, 'post_translations');
 
228
  $GLOBALS['polylang']->sync->copy_post_metas($document->source, $new_post_id, $cp_lang->slug);
229
  Lingotek_Group_Post::copy_or_ignore_metas($post->ID, $new_post_id);
230
  $document->desc_array[$target] = $new_post_id;
@@ -247,7 +248,7 @@ class Lingotek_Model {
247
  $new_term = wp_insert_term($cp_term['name'], $taxonomy, $cp_term);
248
 
249
  if (!is_wp_error($new_term)) {
250
- $this->pllm->set_term_language($new_term['term_id'], $cp_lang);
251
  wp_set_object_terms($new_term['term_id'], $document->term_id, 'term_translations');
252
  $document->desc_array[$target] = $new_term['term_id'];
253
  $document->save();
@@ -305,7 +306,8 @@ class Lingotek_Model {
305
 
306
  // If a translation profile has targets set to copy then copy them
307
  $targets_to_copy = $this->targets_to_be_copied($profile);
308
- if (!empty($targets_to_copy)) {
 
309
  foreach ($targets_to_copy as $target) {
310
  $this->copy_post($post, $target);
311
  }
223
  if (!isset($document->desc_array[$target])) {
224
  $new_post_id = wp_insert_post($cp_post, true);
225
  if (!is_wp_error($new_post_id)) {
226
+ PLL()->model->post->set_language($new_post_id, $cp_lang);
227
  wp_set_object_terms($new_post_id, $document->term_id, 'post_translations');
228
+ $GLOBALS['polylang']->sync->copy_taxonomies($document->source, $new_post_id, $cp_lang->slug);
229
  $GLOBALS['polylang']->sync->copy_post_metas($document->source, $new_post_id, $cp_lang->slug);
230
  Lingotek_Group_Post::copy_or_ignore_metas($post->ID, $new_post_id);
231
  $document->desc_array[$target] = $new_post_id;
248
  $new_term = wp_insert_term($cp_term['name'], $taxonomy, $cp_term);
249
 
250
  if (!is_wp_error($new_term)) {
251
+ PLL()->model->post->set_language($new_term['term_id'], $cp_lang);
252
  wp_set_object_terms($new_term['term_id'], $document->term_id, 'term_translations');
253
  $document->desc_array[$target] = $new_term['term_id'];
254
  $document->save();
306
 
307
  // If a translation profile has targets set to copy then copy them
308
  $targets_to_copy = $this->targets_to_be_copied($profile);
309
+ $upload = self::get_profile_option('upload', $post->post_type, $language, false, $post_id);
310
+ if (!empty($targets_to_copy) && $upload == 'automatic') {
311
  foreach ($targets_to_copy as $target) {
312
  $this->copy_post($post, $target);
313
  }
js/updater.js CHANGED
@@ -95,6 +95,8 @@ jQuery(document).ready(function($) {
95
  updateGenericBulkLink(tr, data, key, 'download' , 'Download translations of this item from Lingotek TMS', 'Download translations');
96
  updateIndicator(td, data, key, locale, 'download', 'Ready to download', 'download');
97
  break;
 
 
98
  default:
99
  var source = data[key]['source'];
100
  if(locale === data[key]['source']){
95
  updateGenericBulkLink(tr, data, key, 'download' , 'Download translations of this item from Lingotek TMS', 'Download translations');
96
  updateIndicator(td, data, key, locale, 'download', 'Ready to download', 'download');
97
  break;
98
+ case 'disabled':
99
+ break;
100
  default:
101
  var source = data[key]['source'];
102
  if(locale === data[key]['source']){
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.1.10
6
  Author: Lingotek and Frédéric Demarle
7
  Author uri: http://lingotek.com
8
  Description: Lingotek offers convenient cloud-based localization and translation.
@@ -15,7 +15,7 @@ GitHub Plugin URI: https://github.com/lingotek/lingotek-translation
15
  if (!function_exists('add_action'))
16
  exit();
17
 
18
- define('LINGOTEK_VERSION', '1.1.10'); // plugin version (should match above meta)
19
  define('LINGOTEK_MIN_PLL_VERSION', '1.8');
20
  define('LINGOTEK_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
21
  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.1.11
6
  Author: Lingotek and Frédéric Demarle
7
  Author uri: http://lingotek.com
8
  Description: Lingotek offers convenient cloud-based localization and translation.
15
  if (!function_exists('add_action'))
16
  exit();
17
 
18
+ define('LINGOTEK_VERSION', '1.1.11'); // plugin version (should match above meta)
19
  define('LINGOTEK_MIN_PLL_VERSION', '1.8');
20
  define('LINGOTEK_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
21
  define('LINGOTEK_PLUGIN_SLUG', 'lingotek-translation');// plugin slug (should match above meta: Text Domain)
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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: 4.4
7
- Stable tag: 1.1.10
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -28,7 +28,7 @@ WordPress administrators use Translation Profiles to categorize content by its r
28
 
29
  = Cloud-Based Translation Management System =
30
 
31
- Need access to a enterprise level Translation Management System designed to work directly with Wordpress and other content management systems allowing you can get complete transparent access with all your translation projects? The cloud-based Lingotek Translation Management Systems helps your business access new markets and customers. Contact sales@lingotek.com for more information and pricing of these features.
32
 
33
  = Benefits =
34
 
@@ -48,7 +48,7 @@ Lingotek works in conjuction with the [Polylang](https://wordpress.org/plugins/p
48
  * You can translate posts, pages, media, categories, post tags, menus, widgets...
49
  * Custom post types, custom taxonomies, sticky posts and post formats, RSS feeds and all default WordPress widgets are supported.
50
  * The language is either set by the content or by the language code in the url, or you can use one different subdomain or domain per language.
51
- * Categories, post tags as well as some other metas are automatically copied when adding a new post or page translation.
52
  * A customizable language switcher is provided as a widget or in the nav menu.
53
  * The admin interface is of course multilingual too and each user can set the WordPress admin language in its profile.
54
 
@@ -111,7 +111,7 @@ The *translation dashboard* not only shows how much of your content is translate
111
 
112
  When content is disassociated, the connection between WordPress and Lingotek is safely removed so that translations can be solely managed inside of WordPress.
113
 
114
- For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net/wiki/display/PDOC/WordPress)
115
 
116
  == Screenshots ==
117
 
@@ -122,6 +122,11 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
122
 
123
  == Changelog ==
124
 
 
 
 
 
 
125
  = 1.1.10 (2016-1-21) =
126
 
127
  * Fixed a bug that prevented images from being uploaded to the Media Library
4
  Tags: automation, bilingual, international, language, Lingotek, localization, multilanguage, multilingual, translate, translation
5
  Requires at least: 3.8
6
  Tested up to: 4.4
7
+ Stable tag: 1.1.11
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
28
 
29
  = Cloud-Based Translation Management System =
30
 
31
+ Need access to an enterprise level Translation Management System designed to work directly with Wordpress and other content management systems, allowing you complete transparent access with all your translation projects? The cloud-based Lingotek Translation Management Systems helps your business access new markets and customers. Contact sales@lingotek.com for more information and pricing of these features.
32
 
33
  = Benefits =
34
 
48
  * You can translate posts, pages, media, categories, post tags, menus, widgets...
49
  * Custom post types, custom taxonomies, sticky posts and post formats, RSS feeds and all default WordPress widgets are supported.
50
  * The language is either set by the content or by the language code in the url, or you can use one different subdomain or domain per language.
51
+ * Categories, post tags, and some other metas are automatically copied when adding a new post or page translation.
52
  * A customizable language switcher is provided as a widget or in the nav menu.
53
  * The admin interface is of course multilingual too and each user can set the WordPress admin language in its profile.
54
 
111
 
112
  When content is disassociated, the connection between WordPress and Lingotek is safely removed so that translations can be solely managed inside of WordPress.
113
 
114
+ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net/wiki/display/PDOC/WordPress).
115
 
116
  == Screenshots ==
117
 
122
 
123
  == Changelog ==
124
 
125
+ = 1.1.11 (2016-2-16) =
126
+
127
+ * Improved the copy source feature by allowing manual copying when using a manual Translation Profile
128
+ * Fixed a bug that prevented synchronization of translation taxonomies
129
+
130
  = 1.1.10 (2016-1-21) =
131
 
132
  * Fixed a bug that prevented images from being uploaded to the Media Library