Lingotek Translation - Version 1.1.3

Version Description

(2015-10-2) =

  • Greatly improved API error reporting
  • Fixed a bug that caused existing profiles to be overwritten
  • Fixed a bug that prevented users from being notified that existing translations would be overwritten
  • Fixed a bug that caused blank posts being created upon download of translations
Download this release

Release Info

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

Code changes from version 1.1.2 to 1.1.3

admin/actions.php CHANGED
@@ -95,11 +95,10 @@ abstract class Lingotek_Actions {
95
  'icon' => 'edit'
96
  ),
97
 
98
- // Removed error reporting for release 1.1.2
99
- // 'error' => array(
100
- // 'title' => __('There was an error contacting Lingotek', 'wp-lingotek'),
101
- // 'icon' => 'warning'
102
- // ),
103
  );
104
 
105
  $this->type = $type;
@@ -187,19 +186,18 @@ abstract class Lingotek_Actions {
187
  self::$icons[$name]['icon'], self::$icons[$name]['title'], esc_url($link), $additional);
188
  }
189
 
190
- // Removed error reporting for release 1.1.2
191
- // /*
192
- // * outputs an API error icon
193
- // *
194
- // * @since 0.2
195
- // *
196
- // * @param string $name
197
- // * @param string $additional parameters to add (js, target)
198
- // */
199
- // public static function display_error_icon($name, $api_error, $additional = '') {
200
- // return sprintf('<span class="lingotek-error dashicons dashicons-%s" title="%s"></span>',
201
- // self::$icons[$name]['icon'], self::$icons[$name]['title'] . "\n" . $api_error, $additional);
202
- // }
203
 
204
  /*
205
  * outputs an upload icon
@@ -242,6 +240,9 @@ abstract class Lingotek_Actions {
242
  $link = wp_nonce_url(add_query_arg(array('document_id' => $document->document_id, 'locale' => $language->locale, 'action' => 'lingotek-download', 'noheader' => true)), 'lingotek-download');
243
  return self::display_icon($document->translations[$language->locale], $link);
244
  }
 
 
 
245
  else {
246
  $link = self::workbench_link($document->document_id, $language->lingotek_locale);
247
  return self::display_icon($document->translations[$language->locale], $link, ' target="_blank"');
@@ -297,7 +298,19 @@ abstract class Lingotek_Actions {
297
  }
298
 
299
  if ($this->lgtm->can_upload($this->type, $id) || (isset($document->source) && 'string' != $this->type && $this->lgtm->can_upload($this->type, $document->source))) {
300
- $actions['lingotek-upload'] = $this->get_action_link(array($this->type => $id, 'action' => 'upload'));
 
 
 
 
 
 
 
 
 
 
 
 
301
  }
302
 
303
  elseif (isset($document->translations)) {
@@ -491,4 +504,34 @@ abstract class Lingotek_Actions {
491
  }
492
  die();
493
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
494
  }
95
  'icon' => 'edit'
96
  ),
97
 
98
+ 'error' => array(
99
+ 'title' => __('There was an error contacting Lingotek', 'wp-lingotek'),
100
+ 'icon' => 'warning'
101
+ ),
 
102
  );
103
 
104
  $this->type = $type;
186
  self::$icons[$name]['icon'], self::$icons[$name]['title'], esc_url($link), $additional);
187
  }
188
 
189
+ /*
190
+ * outputs an API error icon
191
+ *
192
+ * @since 1.2
193
+ *
194
+ * @param string $name
195
+ * @param string $additional parameters to add (js, target)
196
+ */
197
+ public static function display_error_icon($name, $api_error, $additional = '') {
198
+ return sprintf('<span class="lingotek-error dashicons dashicons-%s" title="%s"></span>',
199
+ self::$icons[$name]['icon'], self::$icons[$name]['title'] . "\n" . $api_error, $additional);
200
+ }
 
201
 
202
  /*
203
  * outputs an upload icon
240
  $link = wp_nonce_url(add_query_arg(array('document_id' => $document->document_id, 'locale' => $language->locale, 'action' => 'lingotek-download', 'noheader' => true)), 'lingotek-download');
241
  return self::display_icon($document->translations[$language->locale], $link);
242
  }
243
+ else if ('not-current' == $document->translations[$language->locale]) {
244
+ return '<div class="lingotek-color dashicons dashicons-no"></div>';
245
+ }
246
  else {
247
  $link = self::workbench_link($document->document_id, $language->lingotek_locale);
248
  return self::display_icon($document->translations[$language->locale], $link, ' target="_blank"');
298
  }
299
 
300
  if ($this->lgtm->can_upload($this->type, $id) || (isset($document->source) && 'string' != $this->type && $this->lgtm->can_upload($this->type, $document->source))) {
301
+ if ($document) {
302
+ $desc_array = $document->desc_array;
303
+ unset($desc_array['lingotek']);
304
+ if (count($desc_array) >= 2) {
305
+ $actions['lingotek-upload'] = $this->get_action_link(array($this->type => $id, 'action' => 'upload'), true);
306
+ }
307
+ else {
308
+ $actions['lingotek-upload'] = $this->get_action_link(array($this->type => $id, 'action' => 'upload'));
309
+ }
310
+ }
311
+ else {
312
+ $actions['lingotek-upload'] = $this->get_action_link(array($this->type => $id, 'action' => 'upload'));
313
+ }
314
  }
315
 
316
  elseif (isset($document->translations)) {
504
  }
505
  die();
506
  }
507
+
508
+ /*
509
+ * collects and returns all API errors
510
+ *
511
+ * @since 1.1
512
+ *
513
+ * @param string errors
514
+ */
515
+ public static function retrieve_api_error($errors) {
516
+ $api_error = "\n";
517
+
518
+ foreach($errors as $error => $error_message) {
519
+
520
+ if ($error === 'request_translation') {
521
+ foreach($errors['request_translation'] as $locale => $message) {
522
+ $api_error = $api_error . $message . "\n";
523
+ }
524
+ }
525
+ else if ($error === 'get_translation') {
526
+ foreach($errors['get_translation'] as $locale => $message) {
527
+ $api_error = $api_error . $message . "\n";
528
+ }
529
+ }
530
+ else {
531
+ $api_error = $api_error . $error_message . "\n";
532
+ }
533
+ }
534
+
535
+ return $api_error;
536
+ }
537
  }
admin/admin.php CHANGED
@@ -64,6 +64,9 @@ class Lingotek_Admin {
64
  );
65
 
66
  $document = $lgtm->get_group($type, $object_id);
 
 
 
67
  if ($document && isset($document->source) && isset($document->document_id) && isset($document->status) && isset($document->translations)) {
68
  if($document->source !== (int) $object_id){
69
  $document = $lgtm->get_group($type, $document->source);
@@ -389,24 +392,18 @@ class Lingotek_Admin {
389
 
390
  $api_data = $client->get_projects($community_id);
391
  $projects = array();
392
- if (empty($api_data)) {
393
- add_settings_error('lingotek_community_resources', 'error', __('Your Community currently has no projects.', 'wp-lingotek'), 'error');
394
- }
395
- else if ($api_data !== FALSE) {
396
- foreach ($api_data->entities as $project) {
397
- $projects[$project->properties->id] = $project->properties->title;
398
- }
399
- if ($api_data->properties->total == 1) {
400
- if (!$project->properties->callback_url) {
401
- $client->update_callback_url($project->properties->id);
402
- }
403
- }
404
- natcasesort($projects); //order by title (case-insensitive)
405
- $refresh_success['projects'] = TRUE;
406
- }
407
- else {
408
- add_settings_error('lingotek_community_resources', 'error', __('Projects could not be refreshed', 'wp-lingotek'), 'error');
409
- }
410
 
411
  $api_data = $client->get_workflows($community_id);
412
  $default_workflows = array(
@@ -430,13 +427,10 @@ class Lingotek_Admin {
430
  natcasesort($workflows); //order by title (case-insensitive)
431
  $refresh_success['workflows'] = TRUE;
432
  }
433
- else {
434
- add_settings_error('lingotek_community_resources', 'error', __('Workflows could not be refreshed', 'wp-lingotek'), 'error');
435
- }
436
 
437
  $api_data = $client->get_filters();
438
  $filters = array();
439
- if ($api_data->properties->total > 0) {
440
  foreach ($api_data->entities as $filter) {
441
  if (!$filter->properties->is_public) {
442
  $filters[$filter->properties->id] = $filter->properties->title;
64
  );
65
 
66
  $document = $lgtm->get_group($type, $object_id);
67
+ if($document && !isset($document->source) && count($document->desc_array >= 3)) {
68
+ $content_metadata[$id]['existing_trans'] = true;
69
+ }
70
  if ($document && isset($document->source) && isset($document->document_id) && isset($document->status) && isset($document->translations)) {
71
  if($document->source !== (int) $object_id){
72
  $document = $lgtm->get_group($type, $document->source);
392
 
393
  $api_data = $client->get_projects($community_id);
394
  $projects = array();
395
+ if ($api_data !== FALSE) {
396
+ foreach ($api_data->entities as $project) {
397
+ $projects[$project->properties->id] = $project->properties->title;
398
+ }
399
+ if ($api_data->properties->total == 1) {
400
+ if (!$project->properties->callback_url) {
401
+ $client->update_callback_url($project->properties->id);
402
+ }
403
+ }
404
+ natcasesort($projects); //order by title (case-insensitive)
405
+ $refresh_success['projects'] = TRUE;
406
+ }
 
 
 
 
 
 
407
 
408
  $api_data = $client->get_workflows($community_id);
409
  $default_workflows = array(
427
  natcasesort($workflows); //order by title (case-insensitive)
428
  $refresh_success['workflows'] = TRUE;
429
  }
 
 
 
430
 
431
  $api_data = $client->get_filters();
432
  $filters = array();
433
+ if ($api_data && $api_data->properties->total > 0) {
434
  foreach ($api_data->entities as $filter) {
435
  if (!$filter->properties->is_public) {
436
  $filters[$filter->properties->id] = $filter->properties->title;
admin/filters-columns.php CHANGED
@@ -78,7 +78,7 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
78
  else {
79
  return '';
80
  }
81
- }
82
 
83
  $language = $this->model->get_language(substr($column, 9));
84
 
@@ -88,7 +88,7 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
88
  // hidden field containing the post language for quick edit (used to filter categories since Polylang 1.7)
89
  if ($column == $this->get_first_language_column() /*&& !$this->model->get_translation_id('post', $post_id)*/) {
90
  printf('<div class="hidden" id="lang_%d">%s</div>', esc_attr($object_id), esc_html($lang->slug));
91
- }
92
 
93
  $id = ($inline && $lang->slug != $this->model->get_language($_POST['old_lang'])->slug) ?
94
  ($language->slug == $lang->slug ? $object_id : 0) :
@@ -111,28 +111,26 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
111
 
112
  // post ready for upload
113
  if ($this->lgtm->can_upload($type, $object_id) && $object_id == $id) {
114
- return $disabled ?
115
- ('post' == $type ? parent::post_column($column, $object_id)
116
- : parent::term_column('', $column, $object_id))
117
- : $actions->upload_icon($object_id);
118
- }
119
 
120
  // translation disabled
121
  elseif (isset($document->source) && $document->is_disabled_target($source_language, $language) && !isset($document->translations[$language->locale])) {
122
  return 'post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id);
123
- }
124
 
125
  // source post is uploaded
126
  elseif (isset($document->source) && $document->source == $id) {
127
  // source ready for upload
128
  if ($this->lgtm->can_upload($type, $id)) {
129
  return $actions->upload_icon($id);
130
- }
131
 
132
  // importing source
133
  if ($id == $object_id && 'importing' == $document->status) {
134
  return Lingotek_Actions::importing_icon($document);
135
- }
136
 
137
  // uploaded
138
  return 'post' == $type ? Lingotek_Post_actions::uploaded_icon($id) : Lingotek_Term_actions::uploaded_icon($id);
@@ -145,19 +143,17 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
145
  // translations
146
  elseif (isset($document->translations[$language->locale]) || (isset($document->source) && 'current' == $document->status)){
147
  return Lingotek_Actions::translation_icon($document, $language);
148
- }
149
 
150
  // translations exist but are not managed by Lingotek TMS
151
  elseif (empty($document->source)) {
152
- return $object_id == $id && !$disabled ? $actions->upload_icon($object_id, true)
153
- : ('post' == $type ? parent::post_column($column, $object_id)
154
- : parent::term_column('', $column, $object_id));
155
- }
156
 
157
  // no translation
158
  else {
159
  return '<div class="lingotek-color dashicons dashicons-no"></div>';
160
- }
161
  }
162
 
163
  /*
@@ -174,26 +170,15 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
174
 
175
  echo $this->_column('post', $column, $post_id);
176
 
177
- // Removed error reporting for release 1.1.2
178
  // checking for api errors
179
- // $column_language_only = substr($column, 0, 11);
180
- // $group = $this->lgtm->get_group('post', $post_id);
181
-
182
- // if ($group) {
183
- // $source = $group->desc_array['lingotek']['source'];
184
- // // remove the remnants of previous API errors if there aren't any current errors
185
- // if (isset($group->desc_array['lingotek']['api_errors'])) {
186
- // $api_errors = $group->desc_array['lingotek']['api_errors'];
187
- // if (empty($api_errors)) {
188
- // unset($group->desc_array['lingotek']['api_errors']);
189
- // $group->save();
190
- // }
191
- // }
192
- // if ($column_language_only == $this->get_first_language_column() && $post_id === $source && isset($group->desc_array['lingotek']['api_errors'])) {
193
- // $error = $this->retrieve_api_error($group);
194
- // echo Lingotek_Actions::display_error_icon('error', $error);
195
- // }
196
- // }
197
  }
198
 
199
  /*
@@ -209,60 +194,34 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
209
  public function term_column($custom_data, $column, $term_id) {
210
  $this->content_type = $GLOBALS['taxonomy'];
211
  if (!$custom_data) {
212
- return $this->_column('term', $column, $term_id);
213
  }
214
  else {
215
- return $this->_column('term', $column, $term_id, $custom_data);
216
  }
 
 
217
  }
218
 
219
- // Removed error reporting for release 1.1.2
220
- // /*
221
- // * collects and returns all API errors in the group object
222
- // *
223
- // * @since 1.1
224
- // *
225
- // * @param string $group
226
- // */
227
- // protected function retrieve_api_error($group) {
228
- // $api_error = "\n";
229
-
230
- // if (isset($group->desc_array['lingotek']['api_errors']['source_status'])){
231
- // $source_status = $group->desc_array['lingotek']['api_errors']['source_status'];
232
- // $api_error = $api_error . $source_status . "\n";
233
- // }
234
- // if (isset($group->desc_array['lingotek']['api_errors']['translations_status'])){
235
- // $translations_status = $group->desc_array['lingotek']['api_errors']['translations_status'];
236
- // $api_error = $api_error . $translations_status . "\n";
237
- // }
238
- // if (isset($group->desc_array['lingotek']['api_errors']['request_translation'])){
239
- // $request_translation = $group->desc_array['lingotek']['api_errors']['request_translation'];
240
- // $api_error = $api_error . $request_translation . "\n";
241
- // }
242
- // if (isset($group->desc_array['lingotek']['api_errors']['_request_translations'])) {
243
- // $request_translations = $group->desc_array['lingotek']['api_errors']['_request_translations'];
244
- // foreach ($request_translations as $lang => $error) {
245
- // $api_error = $api_error . $error . "\n";
246
- // }
247
- // }
248
- // if (isset($group->desc_array['lingotek']['api_errors']['create_translation'])) {
249
- // $create_translation = $group->desc_array['lingotek']['api_errors']['create_translation'];
250
- // foreach ($create_translation as $locale => $error) {
251
- // $api_error = $api_error . $error . "\n";
252
- // }
253
- // }
254
- // if (isset($group->desc_array['lingotek']['api_errors']['disassociate'])) {
255
- // $disassociate = $group->desc_array['lingotek']['api_errors']['disassociate'];
256
- // $api_error = $api_error . $disassociate . "\n";
257
- // }
258
- // if (isset($group->desc_array['lingotek']['api_errors']['patch'])) {
259
- // $patch = $group->desc_array['lingotek']['api_errors']['patch'];
260
- // $api_error = $api_error . $patch . "\n";
261
- // }
262
- // if (isset($group->desc_array['lingotek']['api_errors']['upload'])) {
263
- // $upload = $group->desc_array['lingotek']['api_errors']['upload'];
264
- // $api_error = $api_error . $upload . "\n";
265
- // }
266
- // return $api_error;
267
- // }
268
  }
78
  else {
79
  return '';
80
  }
81
+ }
82
 
83
  $language = $this->model->get_language(substr($column, 9));
84
 
88
  // hidden field containing the post language for quick edit (used to filter categories since Polylang 1.7)
89
  if ($column == $this->get_first_language_column() /*&& !$this->model->get_translation_id('post', $post_id)*/) {
90
  printf('<div class="hidden" id="lang_%d">%s</div>', esc_attr($object_id), esc_html($lang->slug));
91
+ }
92
 
93
  $id = ($inline && $lang->slug != $this->model->get_language($_POST['old_lang'])->slug) ?
94
  ($language->slug == $lang->slug ? $object_id : 0) :
111
 
112
  // post ready for upload
113
  if ($this->lgtm->can_upload($type, $object_id) && $object_id == $id) {
114
+ return $disabled ? ('post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id))
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);
121
+ }
122
 
123
  // source post is uploaded
124
  elseif (isset($document->source) && $document->source == $id) {
125
  // source ready for upload
126
  if ($this->lgtm->can_upload($type, $id)) {
127
  return $actions->upload_icon($id);
128
+ }
129
 
130
  // importing source
131
  if ($id == $object_id && 'importing' == $document->status) {
132
  return Lingotek_Actions::importing_icon($document);
133
+ }
134
 
135
  // uploaded
136
  return 'post' == $type ? Lingotek_Post_actions::uploaded_icon($id) : Lingotek_Term_actions::uploaded_icon($id);
143
  // translations
144
  elseif (isset($document->translations[$language->locale]) || (isset($document->source) && 'current' == $document->status)){
145
  return Lingotek_Actions::translation_icon($document, $language);
146
+ }
147
 
148
  // translations exist but are not managed by Lingotek TMS
149
  elseif (empty($document->source)) {
150
+ return $object_id == $id && !$disabled ? $actions->upload_icon($object_id, true) : ('post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id));
151
+ }
 
 
152
 
153
  // no translation
154
  else {
155
  return '<div class="lingotek-color dashicons dashicons-no"></div>';
156
+ }
157
  }
158
 
159
  /*
170
 
171
  echo $this->_column('post', $column, $post_id);
172
 
 
173
  // checking for api errors
174
+ $document = $this->lgtm->get_group('post', $post_id);
175
+ if (isset($document->source)) {
176
+ $source_language = $this->model->get_post_language($document->source);
177
+ $this->error_icon_html($column, $post_id, $source_language->locale);
178
+ }
179
+ else {
180
+ $this->error_icon_html($column, $post_id);
181
+ }
 
 
 
 
 
 
 
 
 
 
182
  }
183
 
184
  /*
194
  public function term_column($custom_data, $column, $term_id) {
195
  $this->content_type = $GLOBALS['taxonomy'];
196
  if (!$custom_data) {
197
+ echo $this->_column('term', $column, $term_id);
198
  }
199
  else {
200
+ echo $this->_column('term', $column, $term_id, $custom_data);
201
  }
202
+ // checking for api errors
203
+ $this->error_icon_html($column, $term_id);
204
  }
205
 
206
+ /*
207
+ * checks for errors in the lingotek_log_errors option and displays an icon
208
+ *
209
+ * @since 1.2
210
+ *
211
+ * @param string $column
212
+ * @param string $object_id
213
+ */
214
+ protected function error_icon_html($column, $object_id, $source_locale = null) {
215
+ // checking for api errors
216
+ $source_column = substr($column, 9);
217
+ $column_language_only = substr($column, 0, 11);
218
+ $errors = get_option('lingotek_log_errors');
219
+
220
+ if ($source_column == $source_locale) {
221
+ if (isset($errors[$object_id])) {
222
+ $api_error = Lingotek_Actions::retrieve_api_error($errors[$object_id]);
223
+ echo Lingotek_Actions::display_error_icon('error', $api_error);
224
+ }
225
+ }
226
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  }
admin/manage/view-profiles.php CHANGED
@@ -28,17 +28,17 @@ if (!empty($_POST)) {
28
  add_settings_error('lingotek_profile', 'default', __('You must provide a name for your translation profile.', 'wp-lingotek'), 'error');
29
  }
30
  else {
31
- $profile = sanitize_title(empty($_POST['profile']) ? $_POST['name'] : $_POST['profile']);
32
- $profiles[$profile]['profile'] = $profile;
33
  if (!empty($_POST['name']))
34
- $profiles[$profile]['name'] = strip_tags($_POST['name']);
35
 
36
  foreach (array('upload', 'download', 'project_id', 'workflow_id') as $key) {
37
  if (isset($_POST[$key]) && in_array($_POST[$key], array_keys($settings[$key]['options'])))
38
- $profiles[$profile][$key] = $_POST[$key];
39
 
40
  if (empty($_POST[$key]) || 'default' == $_POST[$key])
41
- unset($profiles[$profile][$key]);
42
  }
43
 
44
  foreach ($this->pllm->get_languages_list() as $language) {
@@ -46,21 +46,21 @@ if (!empty($_POST)) {
46
  case 'custom':
47
  foreach (array('download', 'project_id', 'workflow_id') as $key) {
48
  if (isset($_POST['custom'][$key][$language->slug]) && in_array($_POST['custom'][$key][$language->slug], array_keys($settings[$key]['options']))) {
49
- $profiles[$profile]['custom'][$key][$language->slug] = $_POST['custom'][$key][$language->slug];
50
  }
51
 
52
  if (empty($_POST['custom'][$key][$language->slug]) || 'default' == $_POST['custom'][$key][$language->slug]) {
53
- unset($profiles[$profile]['custom'][$key][$language->slug]);
54
  }
55
  }
56
 
57
  case 'disabled':
58
  case 'copy':
59
- $profiles[$profile]['targets'][$language->slug] = $_POST['targets'][$language->slug];
60
  break;
61
 
62
  case 'default':
63
- unset($profiles[$profile]['targets'][$language->slug]);
64
  }
65
  }
66
 
@@ -73,7 +73,7 @@ if (!empty($_POST)) {
73
  add_settings_error('lingotek_profile', 'default', __('Your translation profile was sucessfully saved.', 'wp-lingotek'), 'updated');
74
 
75
  if (isset($_POST['update_callback'])) {
76
- $project_id = isset($profiles[$profile]['project_id']) ? $profiles[$profile]['project_id'] : $defaults['project_id'];
77
  $client = new Lingotek_API();
78
  if ($client->update_callback_url($project_id))
79
  add_settings_error('lingotek_profile', 'default', __('Your callback url was successfully updated.', 'wp-lingotek'), 'updated');
28
  add_settings_error('lingotek_profile', 'default', __('You must provide a name for your translation profile.', 'wp-lingotek'), 'error');
29
  }
30
  else {
31
+ $profile_id = isset($_POST['profile']) ? $_POST['profile'] : uniqid(rand());
32
+ $profiles[$profile_id]['profile'] = $profile_id;
33
  if (!empty($_POST['name']))
34
+ $profiles[$profile_id]['name'] = strip_tags($_POST['name']);
35
 
36
  foreach (array('upload', 'download', 'project_id', 'workflow_id') as $key) {
37
  if (isset($_POST[$key]) && in_array($_POST[$key], array_keys($settings[$key]['options'])))
38
+ $profiles[$profile_id][$key] = $_POST[$key];
39
 
40
  if (empty($_POST[$key]) || 'default' == $_POST[$key])
41
+ unset($profiles[$profile_id][$key]);
42
  }
43
 
44
  foreach ($this->pllm->get_languages_list() as $language) {
46
  case 'custom':
47
  foreach (array('download', 'project_id', 'workflow_id') as $key) {
48
  if (isset($_POST['custom'][$key][$language->slug]) && in_array($_POST['custom'][$key][$language->slug], array_keys($settings[$key]['options']))) {
49
+ $profiles[$profile_id]['custom'][$key][$language->slug] = $_POST['custom'][$key][$language->slug];
50
  }
51
 
52
  if (empty($_POST['custom'][$key][$language->slug]) || 'default' == $_POST['custom'][$key][$language->slug]) {
53
+ unset($profiles[$profile_id]['custom'][$key][$language->slug]);
54
  }
55
  }
56
 
57
  case 'disabled':
58
  case 'copy':
59
+ $profiles[$profile_id]['targets'][$language->slug] = $_POST['targets'][$language->slug];
60
  break;
61
 
62
  case 'default':
63
+ unset($profiles[$profile_id]['targets'][$language->slug]);
64
  }
65
  }
66
 
73
  add_settings_error('lingotek_profile', 'default', __('Your translation profile was sucessfully saved.', 'wp-lingotek'), 'updated');
74
 
75
  if (isset($_POST['update_callback'])) {
76
+ $project_id = isset($profiles[$profile_id]['project_id']) ? $profiles[$profile_id]['project_id'] : $defaults['project_id'];
77
  $client = new Lingotek_API();
78
  if ($client->update_callback_url($project_id))
79
  add_settings_error('lingotek_profile', 'default', __('Your callback url was successfully updated.', 'wp-lingotek'), 'updated');
admin/settings/view-account.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
  if (!$community_id) {
3
  $ltk_client = new Lingotek_API();
4
  $ltk_communities = $ltk_client->get_communities();
@@ -90,25 +96,25 @@ if (!$community_id) {
90
  <?php
91
  $default_community_id = $community_id;
92
 
93
- $client = new Lingotek_API();
94
-
95
  // Community
96
- $api_communities = $client->get_communities();
97
  $communities = array();
98
- foreach ($api_communities->entities as $community) {
99
- $communities[$community->properties->id] = $community->properties->title; // . ' (' . $community->properties->id . ')';
100
- }
 
101
 
102
- $num_communities = count($communities);
103
- if($num_communities == 1 && !$community_id){
104
- update_option('lingotek_community', current(array_keys($communities)));
105
- }
106
- if(!$community_id && $num_communities > 1) {
107
- echo "\n\t" . '<option value="">'.__('Select', 'wp-lingotek').'...</option>';
108
- }
109
- foreach ($communities as $community_id_option => $community_title) {
110
- $selected = ($default_community_id == $community_id_option) ? 'selected="selected"' : '';
111
- echo "\n\t" . '<option value="' . esc_attr($community_id_option) . '" '.$selected.'>' . $community_title . '</option>';
 
112
  }
113
  ?>
114
  </select>
@@ -117,4 +123,4 @@ if (!$community_id) {
117
  </table>
118
 
119
  <?php submit_button(__('Save Changes', 'wp-lingotek'), 'primary', 'submit', false); ?>
120
- </form>
1
  <?php
2
+ $client = new Lingotek_API();
3
+ $api_communities = $client->get_communities();
4
+ if (!isset($api_communities->entities)) {
5
+ add_settings_error('lingotek_community_resources', 'error', __('The Lingotek TMS is currently unavailable. Please try again later. If the problem persists, contact Lingotek Support.', 'wp-lingotek'), 'error');
6
+ settings_errors();
7
+ }
8
  if (!$community_id) {
9
  $ltk_client = new Lingotek_API();
10
  $ltk_communities = $ltk_client->get_communities();
96
  <?php
97
  $default_community_id = $community_id;
98
 
 
 
99
  // Community
100
+
101
  $communities = array();
102
+ if (isset($api_communities->entities)) {
103
+ foreach ($api_communities->entities as $community) {
104
+ $communities[$community->properties->id] = $community->properties->title; // . ' (' . $community->properties->id . ')';
105
+ }
106
 
107
+ $num_communities = count($communities);
108
+ if($num_communities == 1 && !$community_id){
109
+ update_option('lingotek_community', current(array_keys($communities)));
110
+ }
111
+ if(!$community_id && $num_communities > 1) {
112
+ echo "\n\t" . '<option value="">'.__('Select', 'wp-lingotek').'...</option>';
113
+ }
114
+ foreach ($communities as $community_id_option => $community_title) {
115
+ $selected = ($default_community_id == $community_id_option) ? 'selected="selected"' : '';
116
+ echo "\n\t" . '<option value="' . esc_attr($community_id_option) . '" '.$selected.'>' . $community_title . '</option>';
117
+ }
118
  }
119
  ?>
120
  </select>
123
  </table>
124
 
125
  <?php submit_button(__('Save Changes', 'wp-lingotek'), 'primary', 'submit', false); ?>
126
+ </form>
admin/settings/view-defaults.php CHANGED
@@ -6,7 +6,6 @@ wp_enqueue_script('defaults', LINGOTEK_URL . '/js/defaults.js');
6
 
7
  if (!empty($_POST)) {
8
  check_admin_referer($page_key, '_wpnonce_' . $page_key);
9
-
10
  if (array_key_exists('refresh', $_POST)) {
11
  $refresh_success = $this->set_community_resources($community_id);
12
  if ($refresh_success['projects'] == TRUE && $refresh_success['workflows'] == TRUE) {
@@ -18,6 +17,9 @@ if (!empty($_POST)) {
18
  else if ($refresh_success['workflows'] == TRUE) {
19
  add_settings_error('lingotek_community_resources', 'error', __('Resources from Lingotek were successfully updated for workflows.', 'wp-lingotek'), 'updated');
20
  }
 
 
 
21
  }
22
  else {
23
  $options = array();
6
 
7
  if (!empty($_POST)) {
8
  check_admin_referer($page_key, '_wpnonce_' . $page_key);
 
9
  if (array_key_exists('refresh', $_POST)) {
10
  $refresh_success = $this->set_community_resources($community_id);
11
  if ($refresh_success['projects'] == TRUE && $refresh_success['workflows'] == TRUE) {
17
  else if ($refresh_success['workflows'] == TRUE) {
18
  add_settings_error('lingotek_community_resources', 'error', __('Resources from Lingotek were successfully updated for workflows.', 'wp-lingotek'), 'updated');
19
  }
20
+ else if ($refresh_success['workflows'] == FALSE || $refresh_success['projects'] == FALSE) {
21
+ add_settings_error('lingotek_community_resources', 'error', __('The Lingotek TMS is currently unavailable. Please try again later. If the problem persists, contact Lingotek Support.', 'wp-lingotek'), 'error');
22
+ }
23
  }
24
  else {
25
  $options = array();
admin/strings-table.php CHANGED
@@ -59,6 +59,15 @@ class Lingotek_Strings_Table extends WP_List_Table {
59
  // no translation
60
  else
61
  echo '<div class="lingotek-color dashicons dashicons-no"></div>';
 
 
 
 
 
 
 
 
 
62
  }
63
 
64
  /*
@@ -167,4 +176,19 @@ class Lingotek_Strings_Table extends WP_List_Table {
167
  $arr['bulk-lingotek-' . $action] = $strings['action'];
168
  return $arr;
169
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  }
59
  // no translation
60
  else
61
  echo '<div class="lingotek-color dashicons dashicons-no"></div>';
62
+
63
+ $language_only = 'language_' . $language->slug;
64
+ $errors = get_option('lingotek_log_errors');
65
+ if ($language_only == $this->get_first_language_column()) {
66
+ if (isset($errors[$item['context']])) {
67
+ $api_error = Lingotek_Actions::retrieve_api_error($errors[$item['context']]);
68
+ echo Lingotek_Actions::display_error_icon('error', $api_error);
69
+ }
70
+ }
71
  }
72
 
73
  /*
176
  $arr['bulk-lingotek-' . $action] = $strings['action'];
177
  return $arr;
178
  }
179
+
180
+ /*
181
+ * returns the first language column
182
+ *
183
+ * @since 1.2
184
+ *
185
+ * @return string first language column name
186
+ */
187
+ protected function get_first_language_column() {
188
+ foreach ($this->pllm->get_languages_list() as $language) {
189
+ $columns[] = 'language_'.$language->slug;
190
+ }
191
+
192
+ return empty($columns) ? '' : reset($columns);
193
+ }
194
  }
include/api.php CHANGED
@@ -72,23 +72,23 @@ class Lingotek_API extends Lingotek_HTTP {
72
  *
73
  * @param string $title
74
  */
75
- public function create_project($title, $community_id) {
76
- $args = array(
77
- 'title' => $title,
78
- 'community_id' => $community_id,
79
- 'workflow_id' => $this->defaults['workflow_id'],
80
- 'callback_url' => add_query_arg('lingotek', 1, site_url()),
81
- );
82
-
83
- $response = $this->post($this->api_url . '/project', $args);
84
- if(!is_wp_error($response) && 201 == wp_remote_retrieve_response_code($response)) {
85
- $new_id = json_decode(wp_remote_retrieve_body($response));
86
- return $new_id->properties->id;
87
- }
88
- else {
89
- return false;
90
- }
91
- }
92
 
93
  /*
94
  * uploads a document
@@ -98,12 +98,26 @@ class Lingotek_API extends Lingotek_HTTP {
98
  * @param array $args expects array with title, content and locale_code
99
  * @returns bool|string document_id, false if something got wrong
100
  */
101
- public function upload_document($args) {
102
  $args = wp_parse_args($args, array('format' => 'JSON', 'project_id' => $this->defaults['project_id'], 'workflow_id' => $this->defaults['workflow_id']));
103
-
104
  $this->format_as_multipart($args);
105
  $response = $this->post($this->api_url . '/document', $args);
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  if (!is_wp_error($response) && 202 == wp_remote_retrieve_response_code($response)) {
108
  $b = json_decode(wp_remote_retrieve_body($response));
109
  return $b->properties->id;
@@ -120,10 +134,26 @@ class Lingotek_API extends Lingotek_HTTP {
120
  * @param array $args expects array with content
121
  * @return bool false if something got wrong
122
  */
123
- public function patch_document($id, $args) {
124
  $args = wp_parse_args($args, array('format' => 'JSON'));
125
  $this->format_as_multipart($args);
126
  $response = $this->patch($this->api_url . '/document/' . $id, $args);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  return !is_wp_error($response) && 202 == wp_remote_retrieve_response_code($response);
128
  }
129
 
@@ -134,8 +164,15 @@ class Lingotek_API extends Lingotek_HTTP {
134
  *
135
  * @param string $id document id
136
  */
137
- public function delete_document($id) {
138
  $response = $this->delete($this->api_url . '/document/' . $id);
 
 
 
 
 
 
 
139
  return !is_wp_error($response) && 204 == wp_remote_retrieve_response_code($response);
140
  }
141
 
@@ -166,8 +203,24 @@ class Lingotek_API extends Lingotek_HTTP {
166
  * @param string $id document id
167
  * @return bool
168
  */
169
- public function document_exists($id) {
170
- $response = $this->get($this->api_url . '/document/' . $id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  return !is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response);
172
  }
173
 
@@ -179,20 +232,29 @@ class Lingotek_API extends Lingotek_HTTP {
179
  * @param string $id document id
180
  * @return array with locale as key and status as value
181
  */
182
- public function get_translations_status($id) {
183
- $response = $this->get($this->api_url . '/document/' . $id . '/translation');
184
  if (!is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response)) {
185
  $b = json_decode(wp_remote_retrieve_body($response));
186
  foreach ($b->entities as $e) {
187
  $translations[$e->properties->locale_code] = $e->properties->percent_complete;
188
  }
189
  }
190
- // Removed error reporting for release 1.1.2
191
- // else {
192
- // if (empty(wp_remote_retrieve_response_code($response))) {
193
- // return false;
194
- // }
195
- // }
 
 
 
 
 
 
 
 
 
196
 
197
  return empty($translations) ? array() : $translations;
198
  }
@@ -207,10 +269,30 @@ class Lingotek_API extends Lingotek_HTTP {
207
  * @param array $args optional arguments (only workflow_id at the moment)
208
  * @return bool true if the request succeeded
209
  */
210
- public function request_translation($id, $locale, $args = array()) {
211
  $args = wp_parse_args($args, array('workflow_id' => $this->defaults['workflow_id']));
212
  $args = array_merge(array('locale_code' => $locale), $args);
213
  $response = $this->post($this->api_url . '/document/' . $id . '/translation', $args);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  return !is_wp_error($response) && 201 == wp_remote_retrieve_response_code($response);
215
  }
216
 
@@ -223,8 +305,28 @@ class Lingotek_API extends Lingotek_HTTP {
223
  * @param string $locale Lingotek locale
224
  * @return string|bool the translation, false if there is none
225
  */
226
- public function get_translation($id, $locale) {
227
- $response = $this->get(add_query_arg(array('locale_code' => $locale, 'auto_format' => 'true') , $this->api_url . '/document/' . $id . '/content'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  return !is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response) ? wp_remote_retrieve_body($response) : false;
229
  }
230
 
@@ -236,8 +338,28 @@ class Lingotek_API extends Lingotek_HTTP {
236
  * @param string $id document id
237
  * @param string $locale Lingotek locale
238
  */
239
- public function delete_translation($id, $locale) {
240
  $response = $this->delete($this->api_url . '/document/' . $id . '/translation/' . $locale);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  // FIXME send a response
242
  }
243
 
72
  *
73
  * @param string $title
74
  */
75
+ public function create_project($title, $community_id) {
76
+ $args = array(
77
+ 'title' => $title,
78
+ 'community_id' => $community_id,
79
+ 'workflow_id' => $this->defaults['workflow_id'],
80
+ 'callback_url' => add_query_arg('lingotek', 1, site_url()),
81
+ );
82
+
83
+ $response = $this->post($this->api_url . '/project', $args);
84
+ if(!is_wp_error($response) && 201 == wp_remote_retrieve_response_code($response)) {
85
+ $new_id = json_decode(wp_remote_retrieve_body($response));
86
+ return $new_id->properties->id;
87
+ }
88
+ else {
89
+ return false;
90
+ }
91
+ }
92
 
93
  /*
94
  * uploads a document
98
  * @param array $args expects array with title, content and locale_code
99
  * @returns bool|string document_id, false if something got wrong
100
  */
101
+ public function upload_document($args, $wp_id = null) {
102
  $args = wp_parse_args($args, array('format' => 'JSON', 'project_id' => $this->defaults['project_id'], 'workflow_id' => $this->defaults['workflow_id']));
 
103
  $this->format_as_multipart($args);
104
  $response = $this->post($this->api_url . '/document', $args);
105
 
106
+ if ($wp_id){
107
+ $arr = get_option('lingotek_log_errors');
108
+
109
+ if (202 == wp_remote_retrieve_response_code($response)) {
110
+ unset($arr[$wp_id]);
111
+ }
112
+ else if (is_wp_error($response)) {
113
+ $arr[$wp_id]['wp_error'] = __('Make sure you have internet connectivity');
114
+ }
115
+ else if (400 == wp_remote_retrieve_response_code($response)) {
116
+ $arr[$wp_id]['upload_document'] = __('There was an error uploading WordPress item ') . $wp_id;
117
+ }
118
+ update_option('lingotek_log_errors', $arr);
119
+ }
120
+
121
  if (!is_wp_error($response) && 202 == wp_remote_retrieve_response_code($response)) {
122
  $b = json_decode(wp_remote_retrieve_body($response));
123
  return $b->properties->id;
134
  * @param array $args expects array with content
135
  * @return bool false if something got wrong
136
  */
137
+ public function patch_document($id, $args, $wp_id = null) {
138
  $args = wp_parse_args($args, array('format' => 'JSON'));
139
  $this->format_as_multipart($args);
140
  $response = $this->patch($this->api_url . '/document/' . $id, $args);
141
+
142
+ if ($wp_id) {
143
+ $arr = get_option('lingotek_log_errors');
144
+
145
+ if (202 == wp_remote_retrieve_response_code($response)) {
146
+ unset($arr[$wp_id]);
147
+ }
148
+ else if (is_wp_error($response)) {
149
+ $arr[$wp_id]['wp_error'] = __('Make sure you have internet connectivity');
150
+ }
151
+ else if (400 == wp_remote_retrieve_response_code($response) || 404 == wp_remote_retrieve_response_code($response)) {
152
+ $arr[$wp_id]['patch_document'] = __('There was an error updating WordPress item ') . $wp_id;
153
+ }
154
+ update_option('lingotek_log_errors', $arr);
155
+ }
156
+
157
  return !is_wp_error($response) && 202 == wp_remote_retrieve_response_code($response);
158
  }
159
 
164
  *
165
  * @param string $id document id
166
  */
167
+ public function delete_document($id, $wp_id = null) {
168
  $response = $this->delete($this->api_url . '/document/' . $id);
169
+
170
+ if ($wp_id) {
171
+ $arr = get_option('lingotek_log_errors');
172
+ unset($arr[$wp_id]);
173
+ update_option('lingotek_log_errors', $arr);
174
+ }
175
+
176
  return !is_wp_error($response) && 204 == wp_remote_retrieve_response_code($response);
177
  }
178
 
203
  * @param string $id document id
204
  * @return bool
205
  */
206
+ public function document_exists($doc_id, $wp_id = null) {
207
+ $response = $this->get($this->api_url . '/document/' . $doc_id);
208
+
209
+ if ($wp_id) {
210
+ $arr = get_option('lingotek_log_errors');
211
+
212
+ if (200 == wp_remote_retrieve_response_code($response)) {
213
+ unset($arr[$wp_id] );
214
+ }
215
+ else if (is_wp_error($response)) {
216
+ $arr[$wp_id]['wp_error'] = __('Make sure you have internet connectivity');
217
+ }
218
+ else if (400 == wp_remote_retrieve_response_code($response)) {
219
+ $arr[$wp_id]['document_exists'] = __('There was an error updating the translations status for WordPress item ') . $wp_id;
220
+ }
221
+ update_option('lingotek_log_errors', $arr);
222
+ }
223
+
224
  return !is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response);
225
  }
226
 
232
  * @param string $id document id
233
  * @return array with locale as key and status as value
234
  */
235
+ public function get_translations_status($doc_id, $wp_id = null) {
236
+ $response = $this->get($this->api_url . '/document/' . $doc_id . '/translation');
237
  if (!is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response)) {
238
  $b = json_decode(wp_remote_retrieve_body($response));
239
  foreach ($b->entities as $e) {
240
  $translations[$e->properties->locale_code] = $e->properties->percent_complete;
241
  }
242
  }
243
+
244
+ if($wp_id) {
245
+ $arr = get_option('lingotek_log_errors');
246
+
247
+ if (200 == wp_remote_retrieve_response_code($response)) {
248
+ unset($arr[$wp_id]);
249
+ }
250
+ else if (is_wp_error($response)) {
251
+ $arr[$wp_id]['wp_error'] = __('Make sure you have internet connectivity');
252
+ }
253
+ else if (400 == wp_remote_retrieve_response_code($response)) {
254
+ $arr[$wp_id]['get_translations_status'] = __('There was an error updating the translations status for WordPress item ') . $wp_id;
255
+ }
256
+ update_option('lingotek_log_errors', $arr);
257
+ }
258
 
259
  return empty($translations) ? array() : $translations;
260
  }
269
  * @param array $args optional arguments (only workflow_id at the moment)
270
  * @return bool true if the request succeeded
271
  */
272
+ public function request_translation($id, $locale, $args = array(), $wp_id = null) {
273
  $args = wp_parse_args($args, array('workflow_id' => $this->defaults['workflow_id']));
274
  $args = array_merge(array('locale_code' => $locale), $args);
275
  $response = $this->post($this->api_url . '/document/' . $id . '/translation', $args);
276
+
277
+ if ($wp_id) {
278
+ $arr = get_option('lingotek_log_errors');
279
+
280
+ if (201 == wp_remote_retrieve_response_code($response)) {
281
+ unset($arr[$wp_id]['wp_error']);
282
+ unset($arr[$wp_id]['request_translation'][$locale]);
283
+ if (empty($arr[$wp_id])){
284
+ unset($arr[$wp_id]);
285
+ }
286
+ }
287
+ else if (is_wp_error($response)) {
288
+ $arr[$wp_id]['wp_error'] = __('Make sure you have internet connectivity');
289
+ }
290
+ else if (400 == wp_remote_retrieve_response_code($response) || 404 == wp_remote_retrieve_response_code($response)) {
291
+ $arr[$wp_id]['request_translation'][$locale] = __('There was an error requesting translation ') . $locale . __(' for WordPress item ') . $wp_id;
292
+ }
293
+ update_option('lingotek_log_errors', $arr);
294
+ }
295
+
296
  return !is_wp_error($response) && 201 == wp_remote_retrieve_response_code($response);
297
  }
298
 
305
  * @param string $locale Lingotek locale
306
  * @return string|bool the translation, false if there is none
307
  */
308
+ public function get_translation($doc_id, $locale, $wp_id = null) {
309
+ $response = $this->get(add_query_arg(array('locale_code' => $locale, 'auto_format' => 'true') , $this->api_url . '/document/' . $doc_id . '/content'));
310
+
311
+ if ($wp_id) {
312
+ $arr = get_option('lingotek_log_errors');
313
+
314
+ if (200 == wp_remote_retrieve_response_code($response)) {
315
+ unset($arr[$wp_id]['wp_error']);
316
+ unset($arr[$wp_id]['get_translation'][$locale]);
317
+ if (empty($arr[$wp_id])) {
318
+ unset($arr[$wp_id]);
319
+ }
320
+ }
321
+ else if (is_wp_error($response)) {
322
+ $arr[$wp_id]['wp_error'] = __('Make sure you have internet connectivity');
323
+ }
324
+ else if (400 == wp_remote_retrieve_response_code($response) || 404 == wp_remote_retrieve_response_code($response)) {
325
+ $arr[$wp_id]['get_translation'][$locale] = __('There was an error downloading translation ') . $locale . __(' for WordPress item ') . $wp_id;
326
+ }
327
+ update_option('lingotek_log_errors', $arr);
328
+ }
329
+
330
  return !is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response) ? wp_remote_retrieve_body($response) : false;
331
  }
332
 
338
  * @param string $id document id
339
  * @param string $locale Lingotek locale
340
  */
341
+ public function delete_translation($id, $locale, $wp_id = null) {
342
  $response = $this->delete($this->api_url . '/document/' . $id . '/translation/' . $locale);
343
+
344
+ if ($wp_id) {
345
+ $arr = get_option('lingotek_log_errors');
346
+
347
+ if (204 == wp_remote_retrieve_response_code($response)) {
348
+ unset($arr[$wp_id]['wp_error']);
349
+ unset($arr[$wp_id]['delete_translation'][$locale]);
350
+ if (empty($arr[$wp_id])) {
351
+ unset($arr[$wp_id]);
352
+ }
353
+ }
354
+ else if (is_wp_error($response)) {
355
+ $arr[$wp_id]['wp_error'] = __('Make sure you have internet connectivity');
356
+ }
357
+ else if (400 == wp_remote_retrieve_response_code($response) || 404 == wp_remote_retrieve_response_code($response)) {
358
+ $arr[$wp_id]['delete_translation'][$locale] = __('There was an error deleting translation ') . $locale . __(' for WordPress item ') . $wp_id;
359
+ }
360
+ update_option('lingotek_log_errors', $arr);
361
+ }
362
+
363
  // FIXME send a response
364
  }
365
 
include/callback.php CHANGED
@@ -36,7 +36,7 @@ class Lingotek_Callback {
36
  // url for in context review
37
  if (isset($_GET['locale']) && 'get' == $_GET['type']) {
38
  $locale = Lingotek::map_to_wp_locale($_GET['locale']); // map to WP locale
39
-
40
  // posts
41
  if (post_type_exists($document->type)) {
42
  if ($id = $document->pllm->get_post($document->source, $locale)) {
@@ -72,9 +72,9 @@ class Lingotek_Callback {
72
  $polylang->sync = new PLL_Admin_Sync($polylang);
73
 
74
  $locale = Lingotek::map_to_wp_locale($_GET['locale']); // map to WP locale
75
- $document->is_automatic_download($locale) ? $document->create_translation($locale) : $document->translation_ready($locale);
76
  }
77
-
78
  status_header(200); // useless as it the default value
79
  die();
80
  }
36
  // url for in context review
37
  if (isset($_GET['locale']) && 'get' == $_GET['type']) {
38
  $locale = Lingotek::map_to_wp_locale($_GET['locale']); // map to WP locale
39
+
40
  // posts
41
  if (post_type_exists($document->type)) {
42
  if ($id = $document->pllm->get_post($document->source, $locale)) {
72
  $polylang->sync = new PLL_Admin_Sync($polylang);
73
 
74
  $locale = Lingotek::map_to_wp_locale($_GET['locale']); // map to WP locale
75
+ $document->is_automatic_download($locale) ? $document->create_translation($locale, true) : $document->translation_ready($locale);
76
  }
77
+
78
  status_header(200); // useless as it the default value
79
  die();
80
  }
include/group-post.php CHANGED
@@ -285,26 +285,16 @@ class Lingotek_Group_Post extends Lingotek_Group {
285
  *
286
  * @param string $locale
287
  */
288
- public function create_translation($locale) {
289
  // Removes content sanitization so YouTube videos, links, etc don't get removed when inserting translations
290
  remove_filter('content_save_pre', 'wp_filter_post_kses');
291
  remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
292
 
293
  $client = new Lingotek_API();
294
 
295
- if (false === ($translation = $client->get_translation($this->document_id, $locale))) {
296
- // Error reporting removed for release 1.1.2
297
- // $this->desc_array['lingotek']['api_errors']['create_translation'][$locale] = __('Error downloading ', 'wp-lingotek') . $locale . __(' translation for post ', 'wp-lingotek') . $this->source;
298
- // $this->save();
299
  return;
300
  }
301
- //else {
302
- // unset($this->desc_array['lingotek']['api_errors']['create_translation'][$locale]);
303
- // if (empty($this->desc_array['lingotek']['api_errors']['create_translation'])) {
304
- // unset($this->desc_array['lingotek']['api_errors']['create_translation']);
305
- // }
306
- // $this->save();
307
- //}
308
 
309
  self::$creating_translation = true;
310
  $prefs = Lingotek_Model::get_prefs(); // need an array by default
@@ -332,7 +322,7 @@ class Lingotek_Group_Post extends Lingotek_Group {
332
  }
333
 
334
  // create new translation
335
- else {
336
  unset($post->post_name); // forces the creation of a new default slug if not translated by Lingotek
337
  $tr_post = array_merge((array) $post , $tr_post); // copy all untranslated fields from the original post
338
  $tr_post['ID'] = null; // will force the creation of a new post
285
  *
286
  * @param string $locale
287
  */
288
+ public function create_translation($locale, $automatic = false) {
289
  // Removes content sanitization so YouTube videos, links, etc don't get removed when inserting translations
290
  remove_filter('content_save_pre', 'wp_filter_post_kses');
291
  remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
292
 
293
  $client = new Lingotek_API();
294
 
295
+ if (false === ($translation = $client->get_translation($this->document_id, $locale, $this->source))) {
 
 
 
296
  return;
297
  }
 
 
 
 
 
 
 
298
 
299
  self::$creating_translation = true;
300
  $prefs = Lingotek_Model::get_prefs(); // need an array by default
322
  }
323
 
324
  // create new translation
325
+ else if ($this->translations[$locale] == 'ready' || $automatic) {
326
  unset($post->post_name); // forces the creation of a new default slug if not translated by Lingotek
327
  $tr_post = array_merge((array) $post , $tr_post); // copy all untranslated fields from the original post
328
  $tr_post['ID'] = null; // will force the creation of a new post
include/group-string.php CHANGED
@@ -76,7 +76,7 @@ class Lingotek_Group_String extends Lingotek_Group {
76
  $prefs = Lingotek_Model::get_prefs();
77
 
78
  if ($prefs['delete_document_from_tms']) {
79
- $client->delete_document($this->document_id);
80
  wp_delete_term($this->term_id, 'post_translations');
81
  }
82
  else {
@@ -103,7 +103,7 @@ class Lingotek_Group_String extends Lingotek_Group {
103
  );
104
  $params = array_merge($params, $filters);
105
 
106
- $res = $client->patch_document($this->document_id, $params);
107
 
108
  if ($res) {
109
  $this->md5 = md5($content);
@@ -150,7 +150,7 @@ class Lingotek_Group_String extends Lingotek_Group {
150
  public function create_translation($locale) {
151
  $client = new Lingotek_API();
152
 
153
- if (false === ($translation = $client->get_translation($this->document_id, $locale)))
154
  return;
155
 
156
  $strings = wp_list_pluck(PLL_Admin_Strings::get_strings(), 'name', 'string'); // get the strings name for the filter
76
  $prefs = Lingotek_Model::get_prefs();
77
 
78
  if ($prefs['delete_document_from_tms']) {
79
+ $client->delete_document($this->document_id, $this->name);
80
  wp_delete_term($this->term_id, 'post_translations');
81
  }
82
  else {
103
  );
104
  $params = array_merge($params, $filters);
105
 
106
+ $res = $client->patch_document($this->document_id, $params, $group);
107
 
108
  if ($res) {
109
  $this->md5 = md5($content);
150
  public function create_translation($locale) {
151
  $client = new Lingotek_API();
152
 
153
+ if (false === ($translation = $client->get_translation($this->document_id, $locale, $this->name)))
154
  return;
155
 
156
  $strings = wp_list_pluck(PLL_Admin_Strings::get_strings(), 'name', 'string'); // get the strings name for the filter
include/group-term.php CHANGED
@@ -102,7 +102,7 @@ class Lingotek_Group_Term extends Lingotek_Group {
102
  public function create_translation($locale) {
103
  $client = new Lingotek_API();
104
 
105
- if (false === ($translation = $client->get_translation($this->document_id, $locale)))
106
  return;
107
 
108
  self::$creating_translation = true;
102
  public function create_translation($locale) {
103
  $client = new Lingotek_API();
104
 
105
+ if (false === ($translation = $client->get_translation($this->document_id, $locale, $this->source)))
106
  return;
107
 
108
  self::$creating_translation = true;
include/group.php CHANGED
@@ -106,7 +106,7 @@ abstract class Lingotek_Group {
106
  $prefs = Lingotek_Model::get_prefs();
107
 
108
  if ($prefs['delete_document_from_tms']) {
109
- $client->delete_document($this->document_id);
110
  unset($this->desc_array['lingotek']);
111
  $this->save();
112
  }
@@ -114,6 +114,7 @@ abstract class Lingotek_Group {
114
  unset($this->desc_array['lingotek']);
115
  $this->save();
116
  }
 
117
  }
118
 
119
  /*
@@ -134,18 +135,12 @@ abstract class Lingotek_Group {
134
  );
135
  $params = array_merge($params, $filters);
136
 
137
- $res = $client->patch_document($this->document_id, $params);
138
 
139
  if ($res) {
140
  $this->status = 'importing';
141
  $this->translations = array_fill_keys(array_keys($this->translations), 'pending');
142
- // Removed error reporting for release 1.1.2
143
- // unset($this->desc_array['lingotek']['api_errors']['patch']);
144
- // $this->save();
145
- // }
146
- // else {
147
- // $this->desc_array['lingotek']['api_errors']['patch'] = __('Error uploading updated post ', 'wp-lingotek') . $this->source;
148
- $this->save();
149
  }
150
  }
151
 
@@ -157,25 +152,10 @@ abstract class Lingotek_Group {
157
  public function source_status() {
158
  $client = new Lingotek_API();
159
 
160
- if ('importing' == $this->status && $client->document_exists($this->document_id)) {
161
  $this->status = 'current';
162
  $this->save();
163
  }
164
-
165
- // Removed error reporting for release 1.1.2
166
- // $response = $client->document_exists($this->document_id);
167
-
168
- // if (!is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response)) {
169
- // unset($this->desc_array['lingotek']['api_errors']['source_status']);
170
- // if ('importing' == $this->status) {
171
- // $this->status = 'current';
172
- // }
173
- // }
174
- // elseif (400 == wp_remote_retrieve_response_code($response) || empty(wp_remote_retrieve_response_code($response))) {
175
- // $this->desc_array['lingotek']['api_errors']['source_status'] = __('Error updating source status of post ', 'wp-lingotek') . $this->source;
176
- // }
177
-
178
- // $this->save();
179
  }
180
 
181
  /*
@@ -202,19 +182,11 @@ abstract class Lingotek_Group {
202
  $args = $workflow ? array('workflow_id' => $workflow) : array();
203
 
204
  if (!$this->is_disabled_target($language) && empty($this->translations[$language->locale])) {
205
- $client->request_translation($this->document_id, $language->locale, $args);
206
- $this->status = 'current';
207
- $this->translations[$language->locale] = 'pending';
208
- // Removed error reporting for release 1.1.2
209
- // if ($client->request_translation($this->document_id, $language->locale, $args)) {
210
- // $this->status = 'current';
211
- // $this->translations[$language->locale] = 'pending';
212
- // unset($this->desc_array['lingotek']['api_errors']['request_translation']);
213
- // unset($this->desc_array['lingotek']['api_errors']['_request_translations']);
214
- // }
215
- // else {
216
- // $this->desc_array['lingotek']['api_errors']['request_translation'] = __('Error requesting translation for ' . $language->name . ' for post ', 'wp-lingotek') . $this->source;
217
- // }
218
 
219
  $this->save();
220
  }
@@ -228,30 +200,25 @@ abstract class Lingotek_Group {
228
  * @param object $source_language language of the source
229
  */
230
  protected function _request_translations($source_language) {
 
231
  $client = new Lingotek_API();
232
 
233
  foreach ($this->pllm->get_languages_list() as $lang) {
234
  if ($source_language->slug != $lang->slug && !$this->is_disabled_target($source_language, $lang) && empty($this->translations[$lang->locale])) {
235
  $workflow = Lingotek_Model::get_profile_option('workflow_id', $this->type, $source_language, $lang, $this->source);
236
  $args = $workflow ? array('workflow_id' => $workflow) : array();
237
- $client->request_translation($this->document_id, $lang->lingotek_locale, $args);
238
- $this->status = 'current';
239
- $this->translations[$lang->locale] = 'pending';
240
- // Removed error reporting for release 1.1.2
241
- // if ($client->request_translation($this->document_id, $lang->lingotek_locale, $args)) {
242
- // $this->status = 'current';
243
- // $this->translations[$lang->locale] = 'pending';
244
- // unset($this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name]);
245
- // unset($this->desc_array['lingotek']['api_errors']['request_translation']);
246
- // if (empty($this->desc_array['lingotek']['api_errors']['_request_translations'])) {
247
- // unset($this->desc_array['lingotek']['api_errors']['_request_translations']);
248
- // }
249
- // }
250
- // else {
251
- // if (!isset($this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name])) {
252
- // $this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name] = __('Error requesting translation for ', 'wp-lingotek') . $lang->name . __(' for post ', 'wp-lingotek') . $this->source;
253
- // }
254
- // }
255
  }
256
  }
257
 
@@ -265,25 +232,11 @@ abstract class Lingotek_Group {
265
  */
266
  public function translations_status() {
267
  $client = new Lingotek_API();
268
- $translations = $client->get_translations_status($this->document_id); // key are Lingotek locales
269
  foreach($this->translations as $locale => $status) {
270
  $lingotek_locale = $this->pllm->get_language($locale)->lingotek_locale;
271
  if ('current' != $status && isset($translations[$lingotek_locale]) && 100 == $translations[$lingotek_locale])
272
  $this->translations[$locale] = 'ready';
273
- // Removed error reporting for release 1.1.2
274
- // if ($translations !== false) {
275
- // foreach($this->translations as $locale => $status) {
276
- // $lingotek_locale = $this->pllm->get_language($locale)->lingotek_locale;
277
- // if ('current' != $status && isset($translations[$lingotek_locale]) && 100 == $translations[$lingotek_locale])
278
- // $this->translations[$locale] = 'ready';
279
- // }
280
- // unset($this->desc_array['lingotek']['api_errors']['translations_status']);
281
- // $this->save();
282
- // }
283
- // // take note of api errors
284
- // else {
285
- // $this->desc_array['lingotek']['api_errors']['translations_status'] = __('Error checking translations status of post ', 'wp-lingotek') . $this->source;
286
- // $this->save();
287
  }
288
  $this->save();
289
  }
106
  $prefs = Lingotek_Model::get_prefs();
107
 
108
  if ($prefs['delete_document_from_tms']) {
109
+ $client->delete_document($this->document_id, $this->source);
110
  unset($this->desc_array['lingotek']);
111
  $this->save();
112
  }
114
  unset($this->desc_array['lingotek']);
115
  $this->save();
116
  }
117
+
118
  }
119
 
120
  /*
135
  );
136
  $params = array_merge($params, $filters);
137
 
138
+ $res = $client->patch_document($this->document_id, $params, $this->source);
139
 
140
  if ($res) {
141
  $this->status = 'importing';
142
  $this->translations = array_fill_keys(array_keys($this->translations), 'pending');
143
+ $this->save();
 
 
 
 
 
 
144
  }
145
  }
146
 
152
  public function source_status() {
153
  $client = new Lingotek_API();
154
 
155
+ if ('importing' == $this->status && $client->document_exists($this->document_id, $this->source)){
156
  $this->status = 'current';
157
  $this->save();
158
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  }
160
 
161
  /*
182
  $args = $workflow ? array('workflow_id' => $workflow) : array();
183
 
184
  if (!$this->is_disabled_target($language) && empty($this->translations[$language->locale])) {
185
+ // don't change translations to pending if the api call failed
186
+ if ($client->request_translation($this->document_id, $language->locale, $args, $this->source)) {
187
+ $this->status = 'current';
188
+ $this->translations[$language->locale] = 'pending';
189
+ }
 
 
 
 
 
 
 
 
190
 
191
  $this->save();
192
  }
200
  * @param object $source_language language of the source
201
  */
202
  protected function _request_translations($source_language) {
203
+ $type_id;
204
  $client = new Lingotek_API();
205
 
206
  foreach ($this->pllm->get_languages_list() as $lang) {
207
  if ($source_language->slug != $lang->slug && !$this->is_disabled_target($source_language, $lang) && empty($this->translations[$lang->locale])) {
208
  $workflow = Lingotek_Model::get_profile_option('workflow_id', $this->type, $source_language, $lang, $this->source);
209
  $args = $workflow ? array('workflow_id' => $workflow) : array();
210
+
211
+ if ($this->type == 'string') {
212
+ $type_id = $this->name;
213
+ }
214
+ else {
215
+ $type_id = $this->source;
216
+ }
217
+ // don't change translations to pending if the api call failed
218
+ if ($client->request_translation($this->document_id, $lang->locale, $args, $type_id)) {
219
+ $this->status = 'current';
220
+ $this->translations[$lang->locale] = 'pending';
221
+ }
 
 
 
 
 
 
222
  }
223
  }
224
 
232
  */
233
  public function translations_status() {
234
  $client = new Lingotek_API();
235
+ $translations = $client->get_translations_status($this->document_id, $this->source); // key are Lingotek locales
236
  foreach($this->translations as $locale => $status) {
237
  $lingotek_locale = $this->pllm->get_language($locale)->lingotek_locale;
238
  if ('current' != $status && isset($translations[$lingotek_locale]) && 100 == $translations[$lingotek_locale])
239
  $this->translations[$locale] = 'ready';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  }
241
  $this->save();
242
  }
include/model.php CHANGED
@@ -297,7 +297,7 @@ class Lingotek_Model {
297
  }
298
 
299
  elseif (!Lingotek_Group::$creating_translation && !self::$copying_post) {
300
- $document_id = $client->upload_document($params);
301
 
302
  if ($document_id) {
303
  Lingotek_Group_Post::create($post->ID , $language, $document_id);
@@ -309,16 +309,7 @@ class Lingotek_Model {
309
  $this->copy_post($post, $target);
310
  }
311
  }
312
- // Error reporting commented out for release 1.1.2
313
- // $group = $this->get_group('post', $post_id);
314
- // unset($group->desc_array['lingotek']['api_errors']['upload']);
315
- // $group->save();
316
  }
317
- // else {
318
- // $group = $this->get_group('post', $post_id);
319
- // $group->desc_array['lingotek']['api_errors']['upload'] = __('Error uploading post ', 'wp-lingotek') . $group->source;
320
- // $group->save();
321
- // }
322
  }
323
  }
324
 
@@ -364,7 +355,7 @@ class Lingotek_Model {
364
  }
365
 
366
  elseif (!Lingotek_Group::$creating_translation && !self::$copying_term) {
367
- $document_id = $client->upload_document($params);
368
 
369
  if ($document_id) {
370
  Lingotek_Group_Term::create($term_id, $taxonomy , $language, $document_id);
@@ -426,7 +417,7 @@ class Lingotek_Model {
426
  $document->patch($group);
427
  }
428
  else {
429
- $document_id = $client->upload_document($params);
430
 
431
  if ($document_id) {
432
  Lingotek_Group_String::create($group, $language, $document_id);
@@ -489,12 +480,12 @@ class Lingotek_Model {
489
  $client = new Lingotek_API();
490
 
491
  if ($document->source == $object_id) {
492
- $client->delete_document($document->document_id);
493
  }
494
  else {
495
  $this->pllm->delete_translation('post', $object_id);
496
  $lang = $this->pllm->get_post_language($object_id);
497
- $client->delete_translation($document->document_id, $lang->lingotek_locale);
498
  }
499
  }
500
  }
@@ -511,13 +502,13 @@ class Lingotek_Model {
511
  $client = new Lingotek_API();
512
 
513
  if ($document->source == $object_id) {
514
- $client->delete_document($document->document_id);
515
  }
516
  else {
517
  $lang = $this->pllm->get_term_language($object_id);
518
  $this->pllm->delete_term_language($object_id);
519
  $this->pllm->delete_translation('term', $object_id);
520
- $client->delete_translation($document->document_id, $lang->lingotek_locale);
521
  }
522
  }
523
  }
297
  }
298
 
299
  elseif (!Lingotek_Group::$creating_translation && !self::$copying_post) {
300
+ $document_id = $client->upload_document($params, $post->ID);
301
 
302
  if ($document_id) {
303
  Lingotek_Group_Post::create($post->ID , $language, $document_id);
309
  $this->copy_post($post, $target);
310
  }
311
  }
 
 
 
 
312
  }
 
 
 
 
 
313
  }
314
  }
315
 
355
  }
356
 
357
  elseif (!Lingotek_Group::$creating_translation && !self::$copying_term) {
358
+ $document_id = $client->upload_document($params, $term_id);
359
 
360
  if ($document_id) {
361
  Lingotek_Group_Term::create($term_id, $taxonomy , $language, $document_id);
417
  $document->patch($group);
418
  }
419
  else {
420
+ $document_id = $client->upload_document($params, $group);
421
 
422
  if ($document_id) {
423
  Lingotek_Group_String::create($group, $language, $document_id);
480
  $client = new Lingotek_API();
481
 
482
  if ($document->source == $object_id) {
483
+ $client->delete_document($document->document_id, $object_id);
484
  }
485
  else {
486
  $this->pllm->delete_translation('post', $object_id);
487
  $lang = $this->pllm->get_post_language($object_id);
488
+ $client->delete_translation($document->document_id, $lang->lingotek_locale, $object_id);
489
  }
490
  }
491
  }
502
  $client = new Lingotek_API();
503
 
504
  if ($document->source == $object_id) {
505
+ $client->delete_document($document->document_id, $object_id);
506
  }
507
  else {
508
  $lang = $this->pllm->get_term_language($object_id);
509
  $this->pllm->delete_term_language($object_id);
510
  $this->pllm->delete_translation('term', $object_id);
511
+ $client->delete_translation($document->document_id, $lang->lingotek_locale, $object_id);
512
  }
513
  }
514
  }
js/updater.js CHANGED
@@ -86,9 +86,6 @@ jQuery(document).ready(function($) {
86
  updateGenericBulkLink(tr, data, key, 'status' , 'Update translations status of this item in Lingotek TMS', 'Update translations status ');
87
  updateIndicator(td, data, key, locale, 'status', 'Importing Source', 'clock');
88
  break;
89
- case 'not-current' :
90
- updateWorkbenchIcon(td, data, key, locale, 'The target translation is no longer current as the source content has been updated', 'edit');
91
- break;
92
  case 'edited':
93
  $(td).find('.pll_icon_edit').remove();
94
  updateUploadBulkLink(tr, data, source_id, 'upload' , 'Upload this item to Lingotek TMS', 'Upload to Lingotek');
@@ -164,6 +161,7 @@ jQuery(document).ready(function($) {
164
  function updateUploadBulkLink(tr, data, key, action, title, text){
165
  var row_actions = $(tr).find('.row-actions');
166
  if($(row_actions).find('.lingotek-' + action).length === 0){
 
167
  var status_update_link = $('<span class="lingotek-'+ action +'"><a class="lingotek-color"'
168
  + ' title="' + title + '" '
169
  + 'href="?'
@@ -172,7 +170,7 @@ jQuery(document).ready(function($) {
172
  + '&action=lingotek-' + action
173
  + '&noheader=1'
174
  + '&_wpnonce=' + data[action + '_nonce']
175
- + '">' + text + '</a> | </span>');
176
  var disassociate = $(row_actions).find('.lingotek-delete');
177
  if($(disassociate).length > 0){
178
  $(disassociate).before(status_update_link);
86
  updateGenericBulkLink(tr, data, key, 'status' , 'Update translations status of this item in Lingotek TMS', 'Update translations status ');
87
  updateIndicator(td, data, key, locale, 'status', 'Importing Source', 'clock');
88
  break;
 
 
 
89
  case 'edited':
90
  $(td).find('.pll_icon_edit').remove();
91
  updateUploadBulkLink(tr, data, source_id, 'upload' , 'Upload this item to Lingotek TMS', 'Upload to Lingotek');
161
  function updateUploadBulkLink(tr, data, key, action, title, text){
162
  var row_actions = $(tr).find('.row-actions');
163
  if($(row_actions).find('.lingotek-' + action).length === 0){
164
+ var pipe_separator = data[key].doc_id == null ? '">' + text + '</a> </span>' : '">' + text + '</a> | </span>';
165
  var status_update_link = $('<span class="lingotek-'+ action +'"><a class="lingotek-color"'
166
  + ' title="' + title + '" '
167
  + 'href="?'
170
  + '&action=lingotek-' + action
171
  + '&noheader=1'
172
  + '&_wpnonce=' + data[action + '_nonce']
173
+ + pipe_separator);
174
  var disassociate = $(row_actions).find('.lingotek-delete');
175
  if($(disassociate).length > 0){
176
  $(disassociate).before(status_update_link);
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.2
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.1.2'); // 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)
@@ -382,9 +382,21 @@ class Lingotek {
382
  * @since 0.1
383
  */
384
  public function pll_inactive_notice() {
 
 
 
 
 
 
 
 
 
 
 
 
385
  printf(
386
- '<div class="error"><p>%s</p></div>',
387
- __('Lingotek Translation requires Polylang to work. Please install Polylang.', 'wp-lingotek')
388
  );
389
  }
390
 
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.3
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.3'); // 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)
382
  * @since 0.1
383
  */
384
  public function pll_inactive_notice() {
385
+ $action = 'install-plugin';
386
+ $slug = 'polylang';
387
+ $url = wp_nonce_url(
388
+ add_query_arg(
389
+ array(
390
+ 'action' => $action,
391
+ 'plugin' => $slug
392
+ ),
393
+ admin_url( 'update.php' )
394
+ ),
395
+ $action.'_'.$slug
396
+ );
397
  printf(
398
+ '<div class="error" style="height:55px"><p style="font-size:1.5em">%s<a href="%s">%s</a></p></div>',
399
+ __('Lingotek Translation requires Polylang to work. ', 'wp-lingotek'), $url, __('Install Polylang', 'wp-lingotek')
400
  );
401
  }
402
 
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.3
7
- Stable tag: 1.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -118,6 +118,13 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
118
 
119
  == Changelog ==
120
 
 
 
 
 
 
 
 
121
  = 1.1.2 (2015-09-18) =
122
 
123
  * Fix for copy feature
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.1.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
118
 
119
  == Changelog ==
120
 
121
+ = 1.1.3 (2015-10-2) =
122
+
123
+ * Greatly improved API error reporting
124
+ * Fixed a bug that caused existing profiles to be overwritten
125
+ * Fixed a bug that prevented users from being notified that existing translations would be overwritten
126
+ * Fixed a bug that caused blank posts being created upon download of translations
127
+
128
  = 1.1.2 (2015-09-18) =
129
 
130
  * Fix for copy feature
uninstall.php CHANGED
@@ -41,6 +41,8 @@ class Lingotek_Uninstall {
41
  delete_option('lingotek_profiles');
42
  delete_option('lingotek_token');
43
  delete_option('lingotek_community_resources');
 
 
44
  }
45
  }
46
 
41
  delete_option('lingotek_profiles');
42
  delete_option('lingotek_token');
43
  delete_option('lingotek_community_resources');
44
+ delete_option('lingotek_custom_fields');
45
+ delete_option('lingotek_log_errors');
46
  }
47
  }
48