Lingotek Translation - Version 1.2.1

Version Description

(2016-5-26) =

  • Added support for the Share Slugs feature in Polylang Pro
  • Minor fix for status icons
Download this release

Release Info

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

Code changes from version 1.2 to 1.2.1

admin/filters-term.php CHANGED
@@ -114,7 +114,7 @@ class Lingotek_Filters_Term extends PLL_Admin_Filters_Term {
114
  $term_ids = array_map('intval', $_REQUEST['delete_tags']);
115
 
116
  $term_ids[] = $term_id;
117
- return array_diff($this->model->get_translations('term', $term_id), $term_ids);
118
  }
119
 
120
  /*
114
  $term_ids = array_map('intval', $_REQUEST['delete_tags']);
115
 
116
  $term_ids[] = $term_id;
117
+ return array_diff(PLL()->model->term->get_translations($term_id), $term_ids);
118
  }
119
 
120
  /*
include/group-post.php CHANGED
@@ -324,7 +324,10 @@ class Lingotek_Group_Post extends Lingotek_Group {
324
 
325
  // create new translation
326
  else if ($this->translations[$locale] == 'ready' || $automatic) {
327
- unset($post->post_name); // forces the creation of a new default slug if not translated by Lingotek
 
 
 
328
  $tr_post = array_merge((array) $post , $tr_post); // copy all untranslated fields from the original post
329
  $tr_post['ID'] = null; // will force the creation of a new post
330
 
@@ -359,6 +362,10 @@ class Lingotek_Group_Post extends Lingotek_Group {
359
  if (isset($translation['metas'])) {
360
  self::copy_translated_metas($translation['metas'], $tr_id);
361
  }
 
 
 
 
362
  }
363
  }
364
 
324
 
325
  // create new translation
326
  else if ($this->translations[$locale] == 'ready' || $automatic) {
327
+ $content_type_options = get_option('lingotek_content_type');
328
+ if (!isset($content_type_options[$post->post_type]['fields']['post_name'])) {
329
+ unset($post->post_name); // forces the creation of a new default slug if not translated by Lingotek
330
+ }
331
  $tr_post = array_merge((array) $post , $tr_post); // copy all untranslated fields from the original post
332
  $tr_post['ID'] = null; // will force the creation of a new post
333
 
362
  if (isset($translation['metas'])) {
363
  self::copy_translated_metas($translation['metas'], $tr_id);
364
  }
365
+
366
+ if (class_exists('PLL_Share_Post_Slug', true) && isset($content_type_options[$post->post_type]['fields']['post_name'])) {
367
+ wp_update_post(array('ID' => $tr_id ,'post_name' => $post->post_name));
368
+ }
369
  }
370
  }
371
 
include/group-term.php CHANGED
@@ -120,15 +120,32 @@ class Lingotek_Group_Term extends Lingotek_Group {
120
 
121
  // create new translation
122
  else {
 
123
  $tr_lang = $this->pllm->get_language($locale);
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'])) {
131
- $args['slug'] .= '-' . $tr_lang->slug;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  }
133
 
134
  $tr = wp_insert_term($translation['name'], $this->type, $args);
120
 
121
  // create new translation
122
  else {
123
+ $content_type_options = get_option('lingotek_content_type');
124
  $tr_lang = $this->pllm->get_language($locale);
125
 
126
  // translate parent
127
  $term = get_term($this->source, $this->type);
128
  $args['parent'] = ($term->parent && $tr_parent = PLL()->model->term->get_translation($term->parent, $locale)) ? $tr_parent : 0;
129
 
130
+ if (class_exists('PLL_Share_Term_Slug', true) && isset($content_type_options[$this->type]['fields']['args']['slug'])) {
131
+ remove_action( 'create_term', array( PLL()->filters_term, 'save_term' ), 999, 3 );
132
+ remove_action( 'edit_term', array( PLL()->filters_term, 'save_term' ), 999, 3 );
133
+ remove_action( 'pre_post_update', array( PLL()->filters_term, 'pre_post_update' ));
134
+ remove_filter( 'pre_term_name', array( PLL()->filters_term, 'pre_term_name' ));
135
+ remove_filter( 'pre_term_slug', array( PLL()->filters_term, 'pre_term_slug' ), 10, 2);
136
+ add_action( 'pre_post_update', array( PLL()->share_term_slug, 'pre_post_update' ) );
137
+ add_filter( 'pre_term_name', array( PLL()->share_term_slug, 'pre_term_name' ) );
138
+ add_filter( 'pre_term_slug', array( PLL()->share_term_slug, 'pre_term_slug' ), 10, 2 );
139
+ add_action( 'create_term', array( PLL()->share_term_slug, 'save_term' ), 1, 3 );
140
+ add_action( 'edit_term', array( PLL()->share_term_slug, 'save_term' ), 1, 3 );
141
+ $_POST['term_lang_choice'] = $tr_lang->slug;
142
+ $args['slug'] = $term->slug;
143
+ }
144
+ else {
145
+ // attempt to get a unique slug in case it already exists in another language
146
+ if (isset($args['slug']) && term_exists($args['slug'])) {
147
+ $args['slug'] .= '-' . $tr_lang->slug;
148
+ }
149
  }
150
 
151
  $tr = wp_insert_term($translation['name'], $this->type, $args);
include/model.php CHANGED
@@ -218,6 +218,7 @@ class Lingotek_Model {
218
  $cp_lang = $this->pllm->get_language($target);
219
  $cp_post = (array) $post;
220
  $cp_post['post_status'] = ($prefs['download_post_status'] === 'SAME_AS_SOURCE')? $post->post_status : $prefs['download_post_status']; // status
 
221
  unset($cp_post['ID']);
222
  unset($cp_post['post_name']);
223
  if (!isset($document->desc_array[$target])) {
@@ -230,6 +231,9 @@ class Lingotek_Model {
230
  Lingotek_Group_Post::copy_or_ignore_metas($post->ID, $new_post_id);
231
  $document->desc_array[$target] = $new_post_id;
232
  $document->save();
 
 
 
233
  }
234
  }
235
  self::$copying_post = false;
@@ -242,9 +246,25 @@ class Lingotek_Model {
242
  $cp_term = (array) $term;
243
  //unset($cp_term['term_id']);
244
 
245
- if (isset($cp_term['slug']) && term_exists($cp_term['slug'])) {
246
- $cp_term['slug'] .= '-' . $cp_lang->slug;
 
 
 
 
 
 
 
 
 
 
247
  }
 
 
 
 
 
 
248
  $new_term = wp_insert_term($cp_term['name'], $taxonomy, $cp_term);
249
 
250
  if (!is_wp_error($new_term)) {
218
  $cp_lang = $this->pllm->get_language($target);
219
  $cp_post = (array) $post;
220
  $cp_post['post_status'] = ($prefs['download_post_status'] === 'SAME_AS_SOURCE')? $post->post_status : $prefs['download_post_status']; // status
221
+ $slug = $cp_post['post_name'];
222
  unset($cp_post['ID']);
223
  unset($cp_post['post_name']);
224
  if (!isset($document->desc_array[$target])) {
231
  Lingotek_Group_Post::copy_or_ignore_metas($post->ID, $new_post_id);
232
  $document->desc_array[$target] = $new_post_id;
233
  $document->save();
234
+ if (class_exists('PLL_Share_Post_Slug', true)) {
235
+ wp_update_post(array('ID' => $new_post_id ,'post_name' => $slug));
236
+ }
237
  }
238
  }
239
  self::$copying_post = false;
246
  $cp_term = (array) $term;
247
  //unset($cp_term['term_id']);
248
 
249
+ if (class_exists('PLL_Share_Term_Slug', true)) {
250
+ remove_action( 'create_term', array( PLL()->filters_term, 'save_term' ), 999, 3 );
251
+ remove_action( 'edit_term', array( PLL()->filters_term, 'save_term' ), 999, 3 );
252
+ remove_action( 'pre_post_update', array( PLL()->filters_term, 'pre_post_update' ));
253
+ remove_filter( 'pre_term_name', array( PLL()->filters_term, 'pre_term_name' ));
254
+ remove_filter( 'pre_term_slug', array( PLL()->filters_term, 'pre_term_slug' ), 10, 2);
255
+ add_action( 'pre_post_update', array( PLL()->share_term_slug, 'pre_post_update' ) );
256
+ add_filter( 'pre_term_name', array( PLL()->share_term_slug, 'pre_term_name' ) );
257
+ add_filter( 'pre_term_slug', array( PLL()->share_term_slug, 'pre_term_slug' ), 10, 2 );
258
+ add_action( 'create_term', array( PLL()->share_term_slug, 'save_term' ), 1, 3 );
259
+ add_action( 'edit_term', array( PLL()->share_term_slug, 'save_term' ), 1, 3 );
260
+ $_POST['term_lang_choice'] = $cp_lang->slug;
261
  }
262
+ else {
263
+ if (isset($cp_term['slug']) && term_exists($cp_term['slug'])) {
264
+ $cp_term['slug'] .= '-' . $cp_lang->slug;
265
+ }
266
+ }
267
+
268
  $new_term = wp_insert_term($cp_term['name'], $taxonomy, $cp_term);
269
 
270
  if (!is_wp_error($new_term)) {
js/updater.js CHANGED
@@ -120,6 +120,7 @@ jQuery(document).ready(function($) {
120
  }
121
  else {
122
  $(td).find('.pll_icon_add').remove();
 
123
  $(td).find('.pll_icon_edit').remove();
124
  $(td).find('.lingotek-color').remove();
125
  var indicator = $('<div></div>').addClass('lingotek-color dashicons dashicons-no');
120
  }
121
  else {
122
  $(td).find('.pll_icon_add').remove();
123
+ $(td).find('.pll_icon_tick').remove();
124
  $(td).find('.pll_icon_edit').remove();
125
  $(td).find('.lingotek-color').remove();
126
  var indicator = $('<div></div>').addClass('lingotek-color dashicons dashicons-no');
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.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/lingotek-translation
15
  if (!function_exists('add_action'))
16
  exit();
17
 
18
- define('LINGOTEK_VERSION', '1.2'); // 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.2.1
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.2.1'); // 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.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -122,6 +122,11 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
122
 
123
  == Changelog ==
124
 
 
 
 
 
 
125
  = 1.2 (2016-3-29) =
126
 
127
  * Fixed a bug that prevented the language of translated taxonomies to be set
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.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
122
 
123
  == Changelog ==
124
 
125
+ = 1.2.1 (2016-5-26) =
126
+
127
+ * Added support for the Share Slugs feature in Polylang Pro
128
+ * Minor fix for status icons
129
+
130
  = 1.2 (2016-3-29) =
131
 
132
  * Fixed a bug that prevented the language of translated taxonomies to be set