Lingotek Translation - Version 1.0.6

Version Description

(2015-07-30) =

  • Enhanced String Groups functionality and removed unecessary statuses
  • Fixed incorrect counting and extra term_taxonomy creation when importing content
Download this release

Release Info

Developer smithworx
Plugin Icon 128x128 Lingotek Translation
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

admin/actions.php CHANGED
@@ -272,7 +272,7 @@ abstract class Lingotek_Actions {
272
  return $actions;
273
 
274
  $document = $this->lgtm->get_group($this->type, $id);
275
- if (isset($document->desc_array['lingotek']['source'])) {
276
  $id = $document->desc_array['lingotek']['source'];
277
  }
278
 
272
  return $actions;
273
 
274
  $document = $this->lgtm->get_group($this->type, $id);
275
+ if ($this->type != 'string' && isset($document->desc_array['lingotek']['source'])) {
276
  $id = $document->desc_array['lingotek']['source'];
277
  }
278
 
admin/wp-import.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Fires before WordPress Importer to remove Lingotek metadata so Lingotek can track posts correctly
5
+ *
6
+ * @since 1.0.6
7
+ */
8
+ class Lingotek_WP_Import extends PLL_WP_Import {
9
+
10
+ /*
11
+ * Removes post_translations metadata if no translations exist so it doesn't get put in the database by WP_Import
12
+ *
13
+ * @since 1.0.6
14
+ */
15
+ public function process_posts() {
16
+ if (empty($this->post_translations)) {
17
+ foreach ($this->posts as &$post) {
18
+ foreach ($post['terms'] as $key => &$term) {
19
+ if (!empty($post['terms'])) {
20
+ if (in_array('post_translations', $term)) {
21
+ unset($post['terms'][$key]);
22
+ }
23
+ }
24
+ }
25
+ }
26
+ }
27
+ parent::process_posts();
28
+ }
29
+ }
30
+
31
+ ?>
include/dashboard.php CHANGED
@@ -85,7 +85,16 @@ class Lingotek_Dashboard {
85
  $default_category = pll_get_term(get_option('default_category'), $lang->slug);
86
  $polylang->model->delete_language((int) $lang->term_id);
87
  wp_delete_term( $default_category, 'category' ); // delete the default category after the language
88
-
 
 
 
 
 
 
 
 
 
89
  $response = array (
90
  'request' => sprintf('DELETE: remove language from CMS and project (%s)', $code),
91
  'code' => $code,
85
  $default_category = pll_get_term(get_option('default_category'), $lang->slug);
86
  $polylang->model->delete_language((int) $lang->term_id);
87
  wp_delete_term( $default_category, 'category' ); // delete the default category after the language
88
+
89
+ // Deletes the translation status so when re-adding a language the string groups translations won't display as current
90
+ $lingotek_model = new Lingotek_Model();
91
+ $strings = $lingotek_model->get_strings();
92
+ foreach ($strings as $string) {
93
+ $group = $lingotek_model->get_group('string', $string['context']);
94
+ unset($group->translations[$lang->locale]);
95
+ $group->save();
96
+ }
97
+
98
  $response = array (
99
  'request' => sprintf('DELETE: remove language from CMS and project (%s)', $code),
100
  'code' => $code,
include/group-string.php CHANGED
@@ -97,8 +97,8 @@ class Lingotek_Group_String extends Lingotek_Group {
97
  $content = $this->get_content($group);
98
 
99
  $params = array(
100
- 'title' => $title,
101
- 'content' => $this->get_content($content),
102
  'external_url' => $external_url,
103
  );
104
  $params = array_merge($params, $filters);
97
  $content = $this->get_content($group);
98
 
99
  $params = array(
100
+ 'title' => $group,
101
+ 'content' => $content,
102
  'external_url' => $external_url,
103
  );
104
  $params = array_merge($params, $filters);
include/group.php CHANGED
@@ -180,7 +180,8 @@ abstract class Lingotek_Group {
180
  $workflow = Lingotek_Model::get_profile_option('workflow_id', $this->type, $this->get_source_language(), $language);
181
  $args = $workflow ? array('workflow_id' => $workflow) : array();
182
 
183
- if (!$this->is_disabled_target($language) && empty($this->translations[$language->locale]) && $client->request_translation($this->document_id, $language->locale, $args)) {
 
184
  $this->status = 'current';
185
  $this->translations[$language->locale] = 'pending';
186
  $this->save();
180
  $workflow = Lingotek_Model::get_profile_option('workflow_id', $this->type, $this->get_source_language(), $language);
181
  $args = $workflow ? array('workflow_id' => $workflow) : array();
182
 
183
+ if (!$this->is_disabled_target($language) && empty($this->translations[$language->locale])) {
184
+ $client->request_translation($this->document_id, $language->locale, $args);
185
  $this->status = 'current';
186
  $this->translations[$language->locale] = 'pending';
187
  $this->save();
include/plugins-compat.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * manages compatibility with 3rd party plugins (and themes)
5
+ * this class is available as soon as the plugin is loaded
6
+ * code borrowed from Polylang
7
+ *
8
+ * @since 1.0.6
9
+ */
10
+ class Lingotek_Plugins_Compat {
11
+ static protected $instance;
12
+
13
+ protected function __construct() {
14
+ // WordPress Importer
15
+ add_action('init', array(&$this, 'lingotek_maybe_wordpress_importer'));
16
+ }
17
+
18
+ static public function instance() {
19
+ if (empty(self::$instance))
20
+ self::$instance = new self();
21
+
22
+ return self::$instance;
23
+ }
24
+
25
+ function lingotek_maybe_wordpress_importer() {
26
+ if (defined('WP_LOAD_IMPORTERS') && class_exists('WP_Import')) {
27
+ remove_action('admin_init', 'lingotek_wordpress_importer_init');
28
+ add_action('admin_init', array(&$this, 'lingotek_wordpress_importer_init'));
29
+ }
30
+ }
31
+
32
+ function lingotek_wordpress_importer_init() {
33
+ $class = new ReflectionClass('WP_Import');
34
+ load_plugin_textdomain( 'wordpress-importer', false, basename(dirname( $class->getFileName() )) . '/languages' );
35
+
36
+ $GLOBALS['wp_import'] = new Lingotek_WP_Import();
37
+ register_importer( 'wordpress', 'WordPress', __('Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file.', 'wordpress-importer'), array( $GLOBALS['wp_import'], 'dispatch' ) );
38
+ }
39
+ }
40
+ ?>
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.5
6
  Author: Lingotek and Frédéric Demarle
7
  Author uri: http://lingotek.com
8
  Description: Lingotek offers convenient cloud-based localization and translation.
@@ -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.5'); // 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)
@@ -114,6 +114,11 @@ class Lingotek {
114
  if (!get_option('lingotek_token')) {
115
  add_action('init', array(&$this, 'lingotek_activation_pointer'));
116
  }
 
 
 
 
 
117
  }
118
 
119
  /**
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.6
6
  Author: Lingotek and Frédéric Demarle
7
  Author uri: http://lingotek.com
8
  Description: Lingotek offers convenient cloud-based localization and translation.
15
  if (!function_exists('add_action'))
16
  exit();
17
 
18
+ define('LINGOTEK_VERSION', '1.0.6'); // 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)
114
  if (!get_option('lingotek_token')) {
115
  add_action('init', array(&$this, 'lingotek_activation_pointer'));
116
  }
117
+
118
+ // adds extra plugin compatibility - borrowed from Polylang
119
+ if (!defined('LINGOTEK_PLUGINS_COMPAT') || LINGOTEK_PLUGINS_COMPAT) {
120
+ Lingotek_Plugins_Compat::instance();
121
+ }
122
  }
123
 
124
  /**
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.2
7
- Stable tag: 1.0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -115,6 +115,10 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
115
 
116
  == Changelog ==
117
 
 
 
 
 
118
 
119
  = 1.0.5 (2015-07-23) =
120
 
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.6
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.6 (2015-07-30) =
119
+
120
+ * Enhanced String Groups functionality and removed unecessary statuses
121
+ * Fixed incorrect counting and extra term_taxonomy creation when importing content
122
 
123
  = 1.0.5 (2015-07-23) =
124