Lingotek Translation - Version 1.0.7

Version Description

(2015-08-18) =

  • Enhanced custom field support including compatibility with user created custom fields, the Advanced Custom Fields (ACF) plugin, and the use of language configuration files (i.e., wpml-config.xml) for default settings.
  • Fixed issue with sub-category translation
Download this release

Release Info

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

Code changes from version 1.0.6 to 1.0.7

admin/content-table.php CHANGED
@@ -112,6 +112,9 @@ class Lingotek_Content_Table extends WP_List_Table {
112
  protected function display_fields($labels, $values, $name) {
113
  foreach ($labels as $key => $str) {
114
  if (is_array($str)) {
 
 
 
115
  $this->display_fields($str, isset($values[$key]) ? $values[$key] : array(), $name . "[$key]");
116
  }
117
  else {
112
  protected function display_fields($labels, $values, $name) {
113
  foreach ($labels as $key => $str) {
114
  if (is_array($str)) {
115
+ if ($key === 'metas') {
116
+ continue;
117
+ }
118
  $this->display_fields($str, isset($values[$key]) ? $values[$key] : array(), $name . "[$key]");
119
  }
120
  else {
admin/custom-fields-table.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!class_exists('WP_List_Table')){
4
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
5
+ }
6
+
7
+ class Lingotek_Custom_Fields_Table extends WP_List_Table {
8
+ protected $profiles, $content_types;
9
+
10
+ /*
11
+ * constructor
12
+ *
13
+ * @since 0.2
14
+ */
15
+ function __construct() {
16
+ parent::__construct(array(
17
+ 'plural' => 'lingotek-custom-fields', // do not translate (used for css class)
18
+ 'ajax' => false
19
+ ));
20
+ }
21
+
22
+ /*
23
+ * displays the item's meta_key
24
+ *
25
+ * @since 0.2
26
+ *
27
+ * @param array $item
28
+ * @return string
29
+ */
30
+ function column_meta_key($item) {
31
+ return isset($item['meta_key']) ? esc_html($item['meta_key']) : '';
32
+ }
33
+
34
+ /*
35
+ * displays the item setting
36
+ *
37
+ * @since 0.2
38
+ *
39
+ * @param array $item
40
+ * @param string $column_name
41
+ * @return string
42
+ */
43
+ function column_setting($item) {
44
+ $settings = array('translate', 'copy', 'ignore');
45
+ $custom_field_choices = get_option('lingotek_custom_fields', array());
46
+
47
+ printf('<select class="custom-field-setting" name="%1$s" id="%1$s">', 'settings' . '[' . $item['meta_key'] . ']');
48
+
49
+ // select the option from the lingotek_custom_fields option
50
+ foreach ($settings as $setting) {
51
+ if ($setting === $custom_field_choices[$item['meta_key']]) {
52
+ $selected = 'selected="selected"';
53
+ }
54
+ else {
55
+ $selected = '';
56
+ }
57
+ echo "\n\t<option value='" . esc_attr($setting) . "' $selected>" . esc_attr(ucwords($setting)) . '</option>';
58
+ }
59
+ echo '</select>';
60
+ }
61
+
62
+ /*
63
+ * gets the list of columns
64
+ *
65
+ * @since 0.2
66
+ *
67
+ * @return array the list of column titles
68
+ */
69
+ function get_columns() {
70
+ return array(
71
+ 'meta_key' => __('Custom Field Key', 'wp-lingotek'),
72
+ 'setting' => __('Action', 'wp-lingotek'),
73
+ );
74
+ }
75
+
76
+ /*
77
+ * gets the list of sortable columns
78
+ *
79
+ * @since 0.2
80
+ *
81
+ * @return array
82
+ */
83
+ function get_sortable_columns() {
84
+ return array(
85
+ 'meta_key' => array('meta_key', false),
86
+ );
87
+ }
88
+
89
+ /*
90
+ * prepares the list of items for displaying
91
+ *
92
+ * @since 0.2
93
+ *
94
+ * @param array $data
95
+ */
96
+ function prepare_items($data = array()) {
97
+ $per_page = $this->get_items_per_page('lingotek_custom_fields_per_page');
98
+ $this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
99
+
100
+ function usort_reorder($a, $b){
101
+ $result = strcmp($a[$_REQUEST['orderby']], $b[$_REQUEST['orderby']]); // determine sort order
102
+ return (empty($_REQUEST['order']) || $_REQUEST['order'] == 'asc') ? $result : -$result; // send final sort direction to usort
103
+ };
104
+
105
+ if (!empty($_REQUEST['orderby'])) // no sort by default
106
+ usort($data, 'usort_reorder');
107
+
108
+ $total_items = count($data);
109
+ $this->items = array_slice($data, ($this->get_pagenum() - 1) * $per_page, $per_page);
110
+
111
+ $this->set_pagination_args(array(
112
+ 'total_items' => $total_items,
113
+ 'per_page' => $per_page,
114
+ 'total_pages' => ceil($total_items/$per_page)
115
+ ));
116
+ }
117
+ }
admin/settings.php CHANGED
@@ -15,6 +15,7 @@
15
  'defaults' => __('Defaults', 'wp-lingotek'),
16
  'profiles' => __('Translation Profiles', 'wp-lingotek'),
17
  'content' => __('Content Type Configuration', 'wp-lingotek'),
 
18
  'preferences' => __('Preferences', 'wp-lingotek'),
19
  //'advanced' => __('Advanced', 'wp-lingotek'),
20
  //'logging' => __('Logging', 'wp-lingotek'),
15
  'defaults' => __('Defaults', 'wp-lingotek'),
16
  'profiles' => __('Translation Profiles', 'wp-lingotek'),
17
  'content' => __('Content Type Configuration', 'wp-lingotek'),
18
+ 'custom-fields' => __('Custom Fields', 'wp-lingotek'),
19
  'preferences' => __('Preferences', 'wp-lingotek'),
20
  //'advanced' => __('Advanced', 'wp-lingotek'),
21
  //'logging' => __('Logging', 'wp-lingotek'),
admin/settings/view-custom-fields.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ global $polylang;
4
+
5
+ $items = array();
6
+
7
+ if (!empty($_POST)) {
8
+ check_admin_referer('lingotek-custom-fields', '_wpnonce_lingotek-custom-fields');
9
+
10
+ if (!empty($_POST['settings'])) {
11
+ update_option('lingotek_custom_fields', $_POST['settings']);
12
+ }
13
+
14
+ if (!empty($_POST['refresh'])) {
15
+ $items = Lingotek_Group_Post::get_updated_meta_values();
16
+ }
17
+ }
18
+
19
+ $items = Lingotek_Group_Post::get_cached_meta_values();
20
+
21
+ ?>
22
+
23
+ <h3><?php _e('Custom Field Configuration', 'wp-lingotek'); ?></h3>
24
+ <p class="description"><?php _e('Custom Fields can be translated, copied, or ignored.', 'wp-lingotek'); ?></p>
25
+
26
+ <form id="lingotek-custom-fields" method="post" action="admin.php?page=wp-lingotek_settings&amp;sm=custom-fields" class="validate"><?php
27
+ wp_nonce_field('lingotek-custom-fields', '_wpnonce_lingotek-custom-fields');
28
+
29
+ $table = new Lingotek_Custom_Fields_Table();
30
+ $table->prepare_items($items);
31
+ $table->display();
32
+ ?>
33
+
34
+ <p>
35
+ <?php submit_button(__('Save Changes', 'wp-lingotek'), 'primary', 'submit', false); ?>
36
+ <?php submit_button(__( 'Refresh Custom Fields', 'wp-lingotek'), 'secondary', 'refresh', false ); ?>
37
+ </p>
38
+ </form>
admin/tutorial/credits.php CHANGED
@@ -41,6 +41,11 @@ $team = array(
41
  'title'=>'Developer',
42
  'image_url'=>'https://www.gravatar.com/avatar/53706ce5472909827db3e582bb4bccf2',
43
  'url'=>'https://profiles.wordpress.org/sethwhite'),
 
 
 
 
 
44
  );
45
 
46
  $contributors = array(
41
  'title'=>'Developer',
42
  'image_url'=>'https://www.gravatar.com/avatar/53706ce5472909827db3e582bb4bccf2',
43
  'url'=>'https://profiles.wordpress.org/sethwhite'),
44
+ 'joey'=>array(
45
+ 'name'=>'Joseph Hovik',
46
+ 'title'=>'Developer',
47
+ 'image_url'=>'https://www.gravatar.com/avatar/171f66a729d063bb6ee4e0e51135a120',
48
+ 'url'=>'https://profiles.wordpress.org/jbhovik'),
49
  );
50
 
51
  $contributors = array(
admin/tutorial/features.php CHANGED
@@ -31,10 +31,29 @@
31
  <p><?php _e( 'Content type profiles. Manually choosing which content to upload and download is rarely what a content administrator wants to do, and automating the upload of every change is not workable because there are various types of content. Each type of translatable content can be assigned to a customizable profile. For example, by default, we like to have Posts use an <i>Automatic</i> profile so that content will automatically be uploaded for translation and the resulting translations automatically be downloaded back into WordPress.', 'wp-lingotek'); ?></p>
32
  </div>
33
  <div class="last-feature">
34
- <!-- <img style="" class="lingotek-bordered" src="<?php echo LINGOTEK_URL . '/admin/tutorial/img/pro-translation.png'; ?>"> -->
35
  <img src="<?php echo LINGOTEK_URL . '/admin/tutorial/img/professional-translation.png'; ?>">
36
  <h3><?php _e( 'Request professional translation', 'wp-lingotek'); ?></h3>
37
  <p><?php _e( "Use your own translation agency or tap into Lingotek's network of more than 5,000+ in-country translators. Content transfer is fully automated between WordPress and Lingotek. You'll have full visibility into the translation process every step of the way. And once the translations are completed, they'll automatically download and publish to your website according to the preferences you've set.", 'wp-lingotek'); ?></p>
38
  <a href="http://www.lingotek.com/wordpress/request-professional-translation" class="button button-primary" target="_blank"><?php _e('Request Translation', 'wp-lingotek'); ?></a>
39
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  </div>
31
  <p><?php _e( 'Content type profiles. Manually choosing which content to upload and download is rarely what a content administrator wants to do, and automating the upload of every change is not workable because there are various types of content. Each type of translatable content can be assigned to a customizable profile. For example, by default, we like to have Posts use an <i>Automatic</i> profile so that content will automatically be uploaded for translation and the resulting translations automatically be downloaded back into WordPress.', 'wp-lingotek'); ?></p>
32
  </div>
33
  <div class="last-feature">
 
34
  <img src="<?php echo LINGOTEK_URL . '/admin/tutorial/img/professional-translation.png'; ?>">
35
  <h3><?php _e( 'Request professional translation', 'wp-lingotek'); ?></h3>
36
  <p><?php _e( "Use your own translation agency or tap into Lingotek's network of more than 5,000+ in-country translators. Content transfer is fully automated between WordPress and Lingotek. You'll have full visibility into the translation process every step of the way. And once the translations are completed, they'll automatically download and publish to your website according to the preferences you've set.", 'wp-lingotek'); ?></p>
37
  <a href="http://www.lingotek.com/wordpress/request-professional-translation" class="button button-primary" target="_blank"><?php _e('Request Translation', 'wp-lingotek'); ?></a>
38
  </div>
39
+ </div>
40
+
41
+
42
+ <div class="changelog feature-section three-col">
43
+ <div>
44
+ <a href="admin.php?page=wp-lingotek_settings&amp;sm=profiles"><img src="<?php echo LINGOTEK_URL . '/admin/tutorial/img/translation-services.png'; ?>"></a>
45
+ <h3><?php _e( 'Need Extra Services?', 'wp-lingotek'); ?></h3>
46
+ <p><?php _e( 'Start the process of getting extra services.', 'wp-lingotek'); ?></p>
47
+ <ul style="list-style-type: circle;">
48
+ <li><?php _e('Do you need someone to run your localization project?', 'wp-lingotek'); ?></li>
49
+ <li><?php _e('Do you need customized workflows?', 'wp-lingotek'); ?></li>
50
+ <li><?php _e('Do you you have existing Translation Memories you would like to use?', 'wp-lingotek'); ?></li>
51
+ <li><?php _e('Do you need help creating glossaries and terminologies?', 'wp-lingotek'); ?></li>
52
+ </ul>
53
+ <a href="http://www.lingotek.com/wordpress/extra_services" class="button button-primary" target="_blank"><?php _e('Request Services', 'wp-lingotek'); ?></a>
54
+ </div>
55
+ <div>
56
+ </div>
57
+ <div class="last-feature">
58
+ </div>
59
  </div>
admin/tutorial/img/translation-services.png ADDED
Binary file
css/admin.css CHANGED
@@ -61,7 +61,7 @@ a.dashicons {
61
  margin: 0;
62
  }
63
 
64
- .content-type-name, .content-type-profile {
65
  margin-bottom: 6px;
66
  }
67
 
61
  margin: 0;
62
  }
63
 
64
+ .content-type-name, .content-type-profile, .custom-field-setting {
65
  margin-bottom: 6px;
66
  }
67
 
include/group-post.php CHANGED
@@ -40,7 +40,7 @@ class Lingotek_Group_Post extends Lingotek_Group {
40
  * @param string $post_type
41
  * @return array
42
  */
43
- static public function get_content_type_fields($post_type) {
44
  $arr = 'attachment' == $post_type ?
45
  array(
46
  'post_title' => __('Title', 'wp-lingotek'),
@@ -55,20 +55,167 @@ class Lingotek_Group_Post extends Lingotek_Group {
55
  'post_excerpt' => __('Excerpt', 'wp-lingotek')
56
  );
57
 
58
- // add the custom fields from wpml-config.xml <custom-fields> sections
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  $wpml_config = PLL_WPML_Config::instance();
 
60
 
61
  if (isset($wpml_config->tags['custom-fields'])) {
62
  foreach ($wpml_config->tags['custom-fields'] as $context) {
63
  foreach ($context['custom-field'] as $cf) {
64
- if ('translate' == $cf['attributes']['action'])
65
- $arr['metas'][$cf['value']] = $cf['value'];
66
  }
67
  }
68
  }
69
 
70
  // allow plugins to modify the fields to translate
71
- return apply_filters('lingotek_post_content_type_fields', $arr, $post_type);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
 
74
  /*
@@ -80,13 +227,13 @@ class Lingotek_Group_Post extends Lingotek_Group {
80
  * @return string json encoded content to translate
81
  */
82
  public static function get_content($post) {
83
- $fields = self::get_content_type_fields($post->post_type);
84
  $content_types = get_option('lingotek_content_type');
85
-
86
  foreach (array_keys($fields) as $key) {
87
  if ('metas' == $key) {
88
  foreach (array_keys($fields['metas']) as $meta) {
89
- if (empty($content_types[$post->post_type]['fields']['metas'][$meta]) && $value = get_post_meta($post->ID, $meta, true))
 
90
  $arr['metas'][$meta] = $value;
91
  }
92
  }
@@ -102,7 +249,7 @@ class Lingotek_Group_Post extends Lingotek_Group {
102
  $arr['post'][$key] = $post->$key;
103
  }
104
  }
105
-
106
  return json_encode($arr);
107
  }
108
 
@@ -184,6 +331,18 @@ class Lingotek_Group_Post extends Lingotek_Group {
184
  // assign terms and metas
185
  $GLOBALS['polylang']->sync->copy_post_metas($this->source, $tr_id, $tr_lang->slug);
186
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  // translate metas
188
  if (!empty($translation['metas'])) {
189
  foreach ($translation['metas'] as $key => $meta)
40
  * @param string $post_type
41
  * @return array
42
  */
43
+ static public function get_content_type_fields($post_type, $post_ID = NULL) {
44
  $arr = 'attachment' == $post_type ?
45
  array(
46
  'post_title' => __('Title', 'wp-lingotek'),
55
  'post_excerpt' => __('Excerpt', 'wp-lingotek')
56
  );
57
 
58
+ // if the user hasn't visited the custom fields tab, and hasn't saved actions for custom
59
+ // fields, and uploaded a post, check the wpml file for settings
60
+ if ($post_ID) {
61
+ self::get_updated_meta_values($post_ID);
62
+ }
63
+ // add the custom fields from the lingotek_custom_fields option
64
+ $custom_fields = get_option('lingotek_custom_fields', array());
65
+
66
+ if (isset($custom_fields)) {
67
+ foreach ($custom_fields as $cf => $setting) {
68
+ if ('translate' == $setting)
69
+ $arr['metas'][$cf] = $cf;
70
+ }
71
+ }
72
+
73
+ // allow plugins to modify the fields to translate
74
+ return apply_filters('lingotek_post_content_type_fields', $arr, $post_type);
75
+ }
76
+
77
+ /*
78
+ * returns custom fields from the wpml-config.xml file
79
+ *
80
+ * @since 0.2
81
+ *
82
+ * @param string $post_type
83
+ * @return array
84
+ */
85
+ static public function get_custom_fields_from_wpml() {
86
  $wpml_config = PLL_WPML_Config::instance();
87
+ $arr = array();
88
 
89
  if (isset($wpml_config->tags['custom-fields'])) {
90
  foreach ($wpml_config->tags['custom-fields'] as $context) {
91
  foreach ($context['custom-field'] as $cf) {
92
+ $arr[$cf['value']] = $cf['attributes']['action'];
 
93
  }
94
  }
95
  }
96
 
97
  // allow plugins to modify the fields to translate
98
+ return apply_filters('lingotek_post_content_type_fields_from_wpml', $arr);
99
+ }
100
+
101
+ /*
102
+ * returns meta (custom) fields from the wp-postmeta database table
103
+ *
104
+ * @since 0.2
105
+ *
106
+ * @return array
107
+ */
108
+ static public function get_custom_fields_from_wp_postmeta($post_ID = NULL) {
109
+ $custom_fields = get_option('lingotek_custom_fields');
110
+ $arr = array();
111
+ $keys = array();
112
+
113
+ if ($post_ID) {
114
+ $p = get_post($post_ID);
115
+ $posts [] = $p;
116
+ }
117
+ else {
118
+ $posts = get_posts(array(
119
+ 'posts_per_page' => -1,
120
+ 'post_type' => 'post'
121
+ ));
122
+ $pages = get_posts(array(
123
+ 'posts_per_page' => -1,
124
+ 'post_type' => 'page'
125
+ ));
126
+ $posts = array_merge($posts, $pages);
127
+ }
128
+
129
+ foreach ($posts as $post) {
130
+ $metadata = has_meta($post->ID);
131
+ foreach ($metadata as $key => $value) {
132
+ if ($value['meta_key'] === '_encloseme' || $value['meta_key'] === '_edit_last' || $value['meta_key'] === '_edit_lock' || $value['meta_key'] === '_wp_trash_meta_status' || $value['meta_key'] === '_wp_trash_meta_time') {
133
+ unset($metadata[$key]);
134
+ }
135
+ if (in_array($value['meta_key'], $keys)) {
136
+ unset($metadata[$key]);
137
+ }
138
+ $keys [] = $value['meta_key'];
139
+ }
140
+ $arr = array_merge($arr, $metadata);
141
+ }
142
+ // allow plugins to modify the fields to translate
143
+ return apply_filters('lingotek_post_custom_fields', $arr);
144
+ }
145
+
146
+ /*
147
+ * updates meta (custom) fields values in the lingotek_custom_fields option
148
+ *
149
+ * @since 0.2
150
+ *
151
+ * @return array
152
+ */
153
+ public static function get_updated_meta_values($post_ID = NULL) {
154
+ $custom_fields_from_wpml = self::get_custom_fields_from_wpml();
155
+ $custom_fields_from_postmeta = self::get_custom_fields_from_wp_postmeta($post_ID);
156
+ $custom_fields_from_lingotek = get_option('lingotek_custom_fields');
157
+ $custom_fields = array();
158
+ $items = array();
159
+
160
+ foreach ($custom_fields_from_postmeta as $cf) {
161
+ // no lingotek setting
162
+ if (!array_key_exists($cf['meta_key'], $custom_fields_from_lingotek)) {
163
+ // no lingotek setting, but there's a wpml setting
164
+ if (array_key_exists($cf['meta_key'], $custom_fields_from_wpml)) {
165
+ $custom_fields[$cf['meta_key']] = $custom_fields_from_wpml[$cf['meta_key']];
166
+ $arr = array(
167
+ 'meta_key' => $cf['meta_key'],
168
+ 'setting' => $custom_fields_from_wpml[$cf['meta_key']],
169
+ );
170
+ }
171
+ // no lingotek setting, no wpml setting, so save default setting of ignore
172
+ else {
173
+ $custom_fields[$cf['meta_key']] = 'ignore';
174
+ $arr = array(
175
+ 'meta_key' => $cf['meta_key'],
176
+ 'setting' => 'ignore',
177
+ );
178
+ }
179
+ }
180
+ // lingotek already has this field setting saved
181
+ else {
182
+ $custom_fields[$cf['meta_key']] = $custom_fields_from_lingotek[$cf['meta_key']];
183
+ $arr = array(
184
+ 'meta_key' => $cf['meta_key'],
185
+ 'setting' => $custom_fields_from_lingotek[$cf['meta_key']],
186
+ );
187
+ }
188
+ $items [] = $arr;
189
+ }
190
+
191
+ if ($post_ID) {
192
+ $custom_fields = array_merge($custom_fields_from_lingotek, $custom_fields);
193
+ }
194
+ update_option('lingotek_custom_fields', $custom_fields);
195
+ return $items;
196
+ }
197
+
198
+ /*
199
+ * returns cached meta (custom) fields values in the lingotek_custom_fields option
200
+ *
201
+ * @since 0.2
202
+ *
203
+ * @return array
204
+ */
205
+
206
+ public static function get_cached_meta_values() {
207
+ $custom_fields_from_lingotek = get_option('lingotek_custom_fields', array());
208
+ $items = array();
209
+
210
+ foreach ($custom_fields_from_lingotek as $key => $setting) {
211
+ $arr = array(
212
+ 'meta_key' => $key,
213
+ 'setting' => $setting,
214
+ );
215
+
216
+ $items [] = $arr;
217
+ }
218
+ return $items;
219
  }
220
 
221
  /*
227
  * @return string json encoded content to translate
228
  */
229
  public static function get_content($post) {
230
+ $fields = self::get_content_type_fields($post->post_type, $post->ID);
231
  $content_types = get_option('lingotek_content_type');
 
232
  foreach (array_keys($fields) as $key) {
233
  if ('metas' == $key) {
234
  foreach (array_keys($fields['metas']) as $meta) {
235
+ $value = get_post_meta($post->ID, $meta, true);
236
+ if ($value)
237
  $arr['metas'][$meta] = $value;
238
  }
239
  }
249
  $arr['post'][$key] = $post->$key;
250
  }
251
  }
252
+
253
  return json_encode($arr);
254
  }
255
 
331
  // assign terms and metas
332
  $GLOBALS['polylang']->sync->copy_post_metas($this->source, $tr_id, $tr_lang->slug);
333
 
334
+ // copy or ignore metas
335
+ $custom_fields = get_option('lingotek_custom_fields');
336
+ foreach ($custom_fields as $key => $setting) {
337
+ if ('copy' === $setting) {
338
+ $source_meta = current(get_post_meta($post->ID, $key)) ;
339
+ update_post_meta($tr_id, $key, $source_meta);
340
+ }
341
+ elseif ('ignore' === $setting) {
342
+ delete_post_meta($tr_id, $key);
343
+ }
344
+ }
345
+
346
  // translate metas
347
  if (!empty($translation['metas'])) {
348
  foreach ($translation['metas'] as $key => $meta)
include/group-term.php CHANGED
@@ -124,7 +124,7 @@ class Lingotek_Group_Term extends Lingotek_Group {
124
 
125
  // translate parent
126
  $term = get_term($this->source, $this->type);
127
- $args['parent'] = ($term->parent && $tr_parent = $this->model->get_translation('term', $term->parent, $locale)) ? $tr_parent : 0;
128
 
129
  // attempt to get a unique slug in case it already exists in another language
130
  if (isset($args['slug']) && term_exists($args['slug'])) {
124
 
125
  // translate parent
126
  $term = get_term($this->source, $this->type);
127
+ $args['parent'] = ($term->parent && $tr_parent = $this->pllm->get_translation('term', $term->parent, $locale)) ? $tr_parent : 0;
128
 
129
  // attempt to get a unique slug in case it already exists in another language
130
  if (isset($args['slug']) && term_exists($args['slug'])) {
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.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,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.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)
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.7
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.7'); // plugin version (should match above meta)
19
  define('LINGOTEK_MIN_PLL_VERSION', '1.7.4.2');
20
  define('LINGOTEK_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
21
  define('LINGOTEK_PLUGIN_SLUG', 'wp-lingotek');// plugin slug (should match above meta: Text Domain)
readme.txt CHANGED
@@ -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.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -115,6 +115,11 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
115
 
116
  == Changelog ==
117
 
 
 
 
 
 
118
  = 1.0.6 (2015-07-30) =
119
 
120
  * Enhanced String Groups functionality and removed unecessary statuses
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.7
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.7 (2015-08-18) =
119
+
120
+ * Enhanced custom field support including compatibility with user created custom fields, the Advanced Custom Fields (ACF) plugin, and the use of language configuration files (i.e., wpml-config.xml) for default settings.
121
+ * Fixed issue with sub-category translation
122
+
123
  = 1.0.6 (2015-07-30) =
124
 
125
  * Enhanced String Groups functionality and removed unecessary statuses