Lingotek Translation - Version 1.0.9

Version Description

(2015-08-19) =

  • Fixed error with YouTube videos not displaying in translations
  • Fixed a minor bug which prevented real-time translation status updates
  • Fixed custom fields settings page error
Download this release

Release Info

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

Code changes from version 1.0.8 to 1.0.9

admin/admin.php CHANGED
@@ -49,28 +49,30 @@ class Lingotek_Admin {
49
  foreach($object_ids as $object_id) {
50
  $id = $object_id;
51
  $document = $lgtm->get_group($taxonomy, $object_id);
52
- if($document->source !== $object_id){
53
- $document = $lgtm->get_group($taxonomy, $document->source);
54
- }
55
- $source_id = $document->source !== null ? $document->source : $object_id;
56
- $source_language = $terms ? pll_get_term_language($document->source, 'locale')
57
- : pll_get_post_language($document->source, 'locale');
58
- $existing_translations = $pllm->get_translations($taxonomy, $source_id);
59
- $content_metadata[$id]['existing_trans'] = false;
60
- if(count($existing_translations) > 1){
61
- $content_metadata[$id]['existing_trans'] = true;
62
- }
63
- $content_metadata[$id]['source'] = $source_language;
64
- $content_metadata[$id]['doc_id'] = $document->document_id;
65
- $content_metadata[$id]['source_id'] = $document->source;
66
- $content_metadata[$id]['source_status'] = $document->status;
67
- $target_status = $document->status == 'edited' || $document->status == null ? 'edited' : 'current';
68
- $content_metadata[$id][$source_language]['status'] = $document->source == $object_id ? $document->status : $target_status;
69
- if(is_array($document->translations)){
70
- foreach($document->translations as $locale => $translation_status){
71
- $content_metadata[$id][$locale]['status'] = $translation_status;
72
- $workbench_link = Lingotek_Actions::workbench_link($document->document_id, $locale);
73
- $content_metadata[$id][$locale]['workbench_link'] = $workbench_link;
 
 
74
  }
75
  }
76
  }
49
  foreach($object_ids as $object_id) {
50
  $id = $object_id;
51
  $document = $lgtm->get_group($taxonomy, $object_id);
52
+ if ($document) {
53
+ if($document->source !== $object_id){
54
+ $document = $lgtm->get_group($taxonomy, $document->source);
55
+ }
56
+ $source_id = $document->source !== null ? $document->source : $object_id;
57
+ $source_language = $terms ? pll_get_term_language($document->source, 'locale')
58
+ : pll_get_post_language($document->source, 'locale');
59
+ $existing_translations = $pllm->get_translations($taxonomy, $source_id);
60
+ $content_metadata[$id]['existing_trans'] = false;
61
+ if(count($existing_translations) > 1){
62
+ $content_metadata[$id]['existing_trans'] = true;
63
+ }
64
+ $content_metadata[$id]['source'] = $source_language;
65
+ $content_metadata[$id]['doc_id'] = $document->document_id;
66
+ $content_metadata[$id]['source_id'] = $document->source;
67
+ $content_metadata[$id]['source_status'] = $document->status;
68
+ $target_status = $document->status == 'edited' || $document->status == null ? 'edited' : 'current';
69
+ $content_metadata[$id][$source_language]['status'] = $document->source == $object_id ? $document->status : $target_status;
70
+ if(is_array($document->translations)){
71
+ foreach($document->translations as $locale => $translation_status) {
72
+ $content_metadata[$id][$locale]['status'] = $translation_status;
73
+ $workbench_link = Lingotek_Actions::workbench_link($document->document_id, $locale);
74
+ $content_metadata[$id][$locale]['workbench_link'] = $workbench_link;
75
+ }
76
  }
77
  }
78
  }
admin/custom-fields-table.php CHANGED
@@ -94,7 +94,6 @@ class Lingotek_Custom_Fields_Table extends WP_List_Table {
94
  * @param array $data
95
  */
96
  function prepare_items($data = array()) {
97
- $per_page = $this->get_items_per_page('lingotek_custom_fields_per_page');
98
  $this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
99
 
100
  function usort_reorder($a, $b){
@@ -105,13 +104,6 @@ class Lingotek_Custom_Fields_Table extends WP_List_Table {
105
  if (!empty($_REQUEST['orderby'])) // no sort by default
106
  usort($data, 'usort_reorder');
107
 
108
- $total_items = count($data);
109
- $this->items = array_slice($data, ($this->get_pagenum() - 1) * $per_page, $per_page);
110
-
111
- $this->set_pagination_args(array(
112
- 'total_items' => $total_items,
113
- 'per_page' => $per_page,
114
- 'total_pages' => ceil($total_items/$per_page)
115
- ));
116
  }
117
  }
94
  * @param array $data
95
  */
96
  function prepare_items($data = array()) {
 
97
  $this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
98
 
99
  function usort_reorder($a, $b){
104
  if (!empty($_REQUEST['orderby'])) // no sort by default
105
  usort($data, 'usort_reorder');
106
 
107
+ $this->items = $data;
 
 
 
 
 
 
 
108
  }
109
  }
admin/settings/view-custom-fields.php CHANGED
@@ -6,10 +6,8 @@ $items = array();
6
 
7
  if (!empty($_POST)) {
8
  check_admin_referer('lingotek-custom-fields', '_wpnonce_lingotek-custom-fields');
9
-
10
- if (!empty($_POST['settings'])) {
11
- update_option('lingotek_custom_fields', $_POST['settings']);
12
- }
13
 
14
  if (!empty($_POST['refresh'])) {
15
  $items = Lingotek_Group_Post::get_updated_meta_values();
6
 
7
  if (!empty($_POST)) {
8
  check_admin_referer('lingotek-custom-fields', '_wpnonce_lingotek-custom-fields');
9
+ $arr = empty($_POST['settings']) ? array() : $_POST['settings'];
10
+ update_option('lingotek_custom_fields', $arr);
 
 
11
 
12
  if (!empty($_POST['refresh'])) {
13
  $items = Lingotek_Group_Post::get_updated_meta_values();
include/group-post.php CHANGED
@@ -207,13 +207,14 @@ class Lingotek_Group_Post extends Lingotek_Group {
207
  $custom_fields_from_lingotek = get_option('lingotek_custom_fields', array());
208
  $items = array();
209
 
210
- foreach ($custom_fields_from_lingotek as $key => $setting) {
211
- $arr = array(
212
- 'meta_key' => $key,
213
- 'setting' => $setting,
214
- );
215
-
216
- $items [] = $arr;
 
217
  }
218
  return $items;
219
  }
@@ -281,6 +282,10 @@ class Lingotek_Group_Post extends Lingotek_Group {
281
  * @param string $locale
282
  */
283
  public function create_translation($locale) {
 
 
 
 
284
  $client = new Lingotek_API();
285
 
286
  if (false === ($translation = $client->get_translation($this->document_id, $locale)))
@@ -298,6 +303,25 @@ class Lingotek_Group_Post extends Lingotek_Group {
298
  // update existing translation
299
  if ($tr_id = $this->pllm->get_post($this->source, $locale)) {
300
  $tr_post['ID'] = $tr_id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  wp_update_post($tr_post);
302
 
303
  $this->safe_translation_status_update($locale, 'current');
@@ -352,6 +376,10 @@ class Lingotek_Group_Post extends Lingotek_Group {
352
  }
353
 
354
  self::$creating_translation = false;
 
 
 
 
355
  }
356
 
357
  /*
207
  $custom_fields_from_lingotek = get_option('lingotek_custom_fields', array());
208
  $items = array();
209
 
210
+ if (is_array($custom_fields_from_lingotek)) {
211
+ foreach ($custom_fields_from_lingotek as $key => $setting) {
212
+ $arr = array(
213
+ 'meta_key' => $key,
214
+ 'setting' => $setting,
215
+ );
216
+ $items [] = $arr;
217
+ }
218
  }
219
  return $items;
220
  }
282
  * @param string $locale
283
  */
284
  public function create_translation($locale) {
285
+ // Removes content sanitization so YouTube videos, links, etc don't get removed when inserting translations
286
+ remove_filter('content_save_pre', 'wp_filter_post_kses');
287
+ remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
288
+
289
  $client = new Lingotek_API();
290
 
291
  if (false === ($translation = $client->get_translation($this->document_id, $locale)))
303
  // update existing translation
304
  if ($tr_id = $this->pllm->get_post($this->source, $locale)) {
305
  $tr_post['ID'] = $tr_id;
306
+
307
+ // copy or ignore metas
308
+ $custom_fields = get_option('lingotek_custom_fields', array());
309
+ foreach ($custom_fields as $key => $setting) {
310
+ if ('copy' === $setting) {
311
+ $source_meta = current(get_post_meta($post->ID, $key)) ;
312
+ update_post_meta($tr_id, $key, $source_meta);
313
+ }
314
+ elseif ('ignore' === $setting) {
315
+ delete_post_meta($tr_id, $key);
316
+ }
317
+ }
318
+
319
+ // translate metas
320
+ if (!empty($translation['metas'])) {
321
+ foreach ($translation['metas'] as $key => $meta)
322
+ update_post_meta($tr_id, $key, $meta);
323
+ }
324
+
325
  wp_update_post($tr_post);
326
 
327
  $this->safe_translation_status_update($locale, 'current');
376
  }
377
 
378
  self::$creating_translation = false;
379
+
380
+ // Adds content sanitization back in after Lingotek saves the translation
381
+ add_filter('content_save_pre', 'wp_filter_post_kses');
382
+ add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
383
  }
384
 
385
  /*
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.0.8
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/wp-lingotek
15
  if (!function_exists('add_action'))
16
  exit();
17
 
18
- define('LINGOTEK_VERSION', '1.0.8'); // plugin version (should match above meta)
19
  define('LINGOTEK_MIN_PLL_VERSION', '1.7.4.2');
20
  define('LINGOTEK_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
21
  define('LINGOTEK_PLUGIN_SLUG', 'wp-lingotek');// 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.0.9
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.0.9'); // plugin version (should match above meta)
19
  define('LINGOTEK_MIN_PLL_VERSION', '1.7.4.2');
20
  define('LINGOTEK_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
21
  define('LINGOTEK_PLUGIN_SLUG', 'wp-lingotek');// plugin slug (should match above meta: Text Domain)
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: chouby, smithworx, erichie
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: 4.2
7
- Stable tag: 1.0.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -115,6 +115,12 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
115
 
116
  == Changelog ==
117
 
 
 
 
 
 
 
118
  = 1.0.8 (2015-08-19) =
119
 
120
  * Fixed custom fields error upon saving or updating posts
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: 4.3
7
+ Stable tag: 1.0.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
115
 
116
  == Changelog ==
117
 
118
+ = 1.0.9 (2015-08-19) =
119
+
120
+ * Fixed error with YouTube videos not displaying in translations
121
+ * Fixed a minor bug which prevented real-time translation status updates
122
+ * Fixed custom fields settings page error
123
+
124
  = 1.0.8 (2015-08-19) =
125
 
126
  * Fixed custom fields error upon saving or updating posts