Lingotek Translation - Version 1.5.6

Version Description

(2022-05-19) = - WordPress Elementor: Widget Typography should not be translated - WordPress - completed translations cannot be downloaded, source and translation status is not updated

Download this release

Release Info

Developer lopez93
Plugin Icon 128x128 Lingotek Translation
Version 1.5.6
Comparing to
See all releases

Code changes from version 1.5.5 to 1.5.6

here DELETED
File without changes
include/api.php CHANGED
@@ -958,9 +958,9 @@ class Lingotek_API extends Lingotek_HTTP {
958
  $response_error_message = 403 == wp_remote_retrieve_response_code( $response ) && $this->get_error_message_from_response( $response ) !== false ?
959
  $this->get_error_message_from_response( $response ) : false;
960
  if ( $response_error_message ) {
961
- $error_message = $response_error_message;
 
962
  }
963
- $lingotek_log_errors['disassociate_document_error'] = $error_message;
964
  update_option( 'lingotek_log_errors', $lingotek_log_errors, false );
965
 
966
  return $is_success;
958
  $response_error_message = 403 == wp_remote_retrieve_response_code( $response ) && $this->get_error_message_from_response( $response ) !== false ?
959
  $this->get_error_message_from_response( $response ) : false;
960
  if ( $response_error_message ) {
961
+ $error_message = $response_error_message;
962
+ $lingotek_log_errors['disassociate_document_error'] = $error_message;
963
  }
 
964
  update_option( 'lingotek_log_errors', $lingotek_log_errors, false );
965
 
966
  return $is_success;
include/group-post.php CHANGED
@@ -397,7 +397,7 @@ class Lingotek_Group_Post extends Lingotek_Group {
397
 
398
  $translation = $client->get_translation( $this->document_id, $locale, $this->source );
399
  // If the request failed.
400
- if ( ! $translation || $this->translation_not_ready( json_decode( $translation, true ) ) ) {
401
  return;
402
  }
403
  // wp_insert_post expects array
@@ -501,20 +501,6 @@ class Lingotek_Group_Post extends Lingotek_Group {
501
  add_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' );
502
  }
503
 
504
- /**
505
- * TMS will return an associative array with empty fields if the translation is not ready.
506
- *
507
- * @param array $translation the array returned from TMS.
508
- */
509
- private function translation_not_ready( $translation ) {
510
- $trimmed_title = trim( $translation['post']['post_title'] );
511
- $trimmed_content = trim( $translation['post']['post_content'] );
512
- $trimmed_excerpt = trim( $translation['post']['post_excerpt'] );
513
- return empty( $trimmed_title ) &&
514
- empty( $trimmed_content ) &&
515
- empty( $trimmed_excerpt );
516
- }
517
-
518
  /**
519
  * copies source meta strings to translations or deletes meta if set to ignore
520
  *
397
 
398
  $translation = $client->get_translation( $this->document_id, $locale, $this->source );
399
  // If the request failed.
400
+ if ( ! $translation ) {
401
  return;
402
  }
403
  // wp_insert_post expects array
501
  add_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' );
502
  }
503
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  /**
505
  * copies source meta strings to translations or deletes meta if set to ignore
506
  *
include/metadata-elementor.php CHANGED
@@ -32,22 +32,62 @@ class Lingotek_Metadata_Elementor {
32
  * @var array
33
  */
34
  protected static $text_widgets = array(
35
- 'text-editor',
36
- 'heading',
37
- 'button',
38
- 'call-to-action',
39
- 'form',
40
- 'text-path',
41
- 'blockquote',
42
- 'forms',
43
- 'animated-headline',
44
- 'price-list',
45
- 'price-table',
46
- 'table-of-contents',
47
- 'lottie',
48
- 'theme-site-title',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  );
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  /**
52
  * Widgets that embedded content that need to be handled differently, i.e. images
53
  * The values are the translatable fields in the settings of each widget type.
@@ -148,11 +188,22 @@ class Lingotek_Metadata_Elementor {
148
  $element_widget_type = isset( $element['widgetType'] ) ? $element['widgetType'] : false;
149
 
150
  // Check if element has already been stored, and if the widget has translatable text.
151
- $widget_editor_type = in_array( $element_widget_type, self::$text_widgets, true );
152
  $embedded_widget = isset( self::$embedded_widgets[ $element_widget_type ] ) ? true : false;
153
  if ( ! $element_in_array && $widget_editor_type && $element_settings ) {
154
- $content_list[ $element['id'] ] = $element_settings;
155
- } elseif ( ! $element_in_array && $embedded_widget && $element_settings ) {
 
 
 
 
 
 
 
 
 
 
 
156
  $translatable_fields = isset( self::$embedded_widgets[ $element_widget_type ] ) ? self::$embedded_widgets[ $element_widget_type ] : array();
157
  $content_list[ $element['id'] ] = self::get_translatable_fields( $translatable_fields, $element_settings );
158
  }
@@ -161,7 +212,7 @@ class Lingotek_Metadata_Elementor {
161
  // Check embedded elements for more translatable content.
162
  self::get_elements( $sub_elements, $content_list );
163
  }
164
- }
165
  }
166
 
167
  /**
@@ -177,11 +228,22 @@ class Lingotek_Metadata_Elementor {
177
  $translated_element = isset( $element['id'], $translation_list[ $element['id'] ] ) ? $translation_list[ $element['id'] ] : false;
178
  $element_settings = isset( $element['settings'] ) && ! empty( $element['settings'] ) ? $element['settings'] : false;
179
  $element_widget_type = isset( $element['widgetType'] ) ? $element['widgetType'] : false;
180
- $widget_editor_type = in_array( $element_widget_type, self::$text_widgets, true );
181
  $embedded_widget = isset( self::$embedded_widgets[ $element_widget_type ] ) ? true : false;
182
  // Check that element translation exists, has a valid editor type, and has a settings key.
183
  if ( $translated_element && $widget_editor_type && $element_settings ) {
184
- $element['settings'] = $translated_element;
 
 
 
 
 
 
 
 
 
 
 
185
  } elseif ( $translated_element && $element_settings && $embedded_widget ) {
186
  $translatable_fields = isset( self::$embedded_widgets[ $element_widget_type ] ) ? self::$embedded_widgets[ $element_widget_type ] : array();
187
  $element['settings'] = self::set_translatable_fields( $translatable_fields, $element_settings, $translated_element );
@@ -236,7 +298,7 @@ class Lingotek_Metadata_Elementor {
236
  } else {
237
  $temp_value[ '_' . $value_key ] = $value_settings;
238
  }
239
- } else {
240
  // Else we check each item in the array for translatable fields.
241
  $temp_value[ $value_key ] = self::get_translatable_fields( $translatable_fields, $value_settings );
242
  }
@@ -285,6 +347,42 @@ class Lingotek_Metadata_Elementor {
285
  return $settings;
286
  }
287
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  /**
289
  * Returns true if the array has all string keys, else returns false
290
  *
32
  * @var array
33
  */
34
  protected static $text_widgets = array(
35
+ 'text-editor' => array(
36
+ 'editor',
37
+ ),
38
+ 'heading' => array(
39
+ 'title',
40
+ ),
41
+ 'button' => array(),
42
+ 'call-to-action' => array(
43
+ 'title',
44
+ 'description',
45
+ 'button',
46
+ ),
47
+ 'form' => array(
48
+ 'form_name',
49
+ 'form_fields',
50
+ 'step_next_label',
51
+ 'step_previous_label',
52
+ 'button_text',
53
+ 'success_message',
54
+ 'error_message',
55
+ 'required_field_message',
56
+ 'invalid_message',
57
+ ),
58
+ 'text-path' => array(),
59
+ 'blockquote' => array(),
60
+ 'forms' => array(),
61
+ 'animated-headline' => array(),
62
+ 'price-list' => array(),
63
+ 'price-table' => array(),
64
+ 'table-of-contents' => array(),
65
+ 'lottie' => array(),
66
+ 'theme-site-title' => array(),
67
+ 'icon-list' => array(),
68
+ 'icon-box' => array(
69
+ 'title_text',
70
+ 'description_text',
71
+ ),
72
  );
73
 
74
+ /**
75
+ * Settings to translate in field forms
76
+ *
77
+ * @var array
78
+ */
79
+ public static $translatable_form_fields = array(
80
+ 'field_label',
81
+ 'placeholder',
82
+ 'previous_button',
83
+ 'next_button',
84
+ 'acceptance_text',
85
+ 'field_value',
86
+ 'field_options',
87
+ 'field_html',
88
+ );
89
+
90
+
91
  /**
92
  * Widgets that embedded content that need to be handled differently, i.e. images
93
  * The values are the translatable fields in the settings of each widget type.
188
  $element_widget_type = isset( $element['widgetType'] ) ? $element['widgetType'] : false;
189
 
190
  // Check if element has already been stored, and if the widget has translatable text.
191
+ $widget_editor_type = $element_widget_type && array_key_exists( $element_widget_type, self::$text_widgets ) ? true : false;
192
  $embedded_widget = isset( self::$embedded_widgets[ $element_widget_type ] ) ? true : false;
193
  if ( ! $element_in_array && $widget_editor_type && $element_settings ) {
194
+ $translatable_fields = self::$text_widgets[ $element_widget_type ];
195
+ if ( ! empty( $translatable_fields ) ) {
196
+ foreach ( $translatable_fields as $field ) {
197
+ if ( 'form_fields' === $field ) {
198
+ $content_list[ $element['id'] ][ $field ] = self::get_form_fields( $element_settings[ $field ] );
199
+ } else {
200
+ $content_list[ $element['id'] ][ $field ] = $element_settings[ $field ];
201
+ }
202
+ }
203
+ } else {
204
+ $content_list[ $element['id'] ] = $element_settings;
205
+ }
206
+ } elseif ( ! $element_in_array && $embedded_widget && $element_settings && is_array( $element_settings ) ) {
207
  $translatable_fields = isset( self::$embedded_widgets[ $element_widget_type ] ) ? self::$embedded_widgets[ $element_widget_type ] : array();
208
  $content_list[ $element['id'] ] = self::get_translatable_fields( $translatable_fields, $element_settings );
209
  }
212
  // Check embedded elements for more translatable content.
213
  self::get_elements( $sub_elements, $content_list );
214
  }
215
+ }//end foreach
216
  }
217
 
218
  /**
228
  $translated_element = isset( $element['id'], $translation_list[ $element['id'] ] ) ? $translation_list[ $element['id'] ] : false;
229
  $element_settings = isset( $element['settings'] ) && ! empty( $element['settings'] ) ? $element['settings'] : false;
230
  $element_widget_type = isset( $element['widgetType'] ) ? $element['widgetType'] : false;
231
+ $widget_editor_type = $element_widget_type && array_key_exists( $element_widget_type, self::$text_widgets ) ? true : false;
232
  $embedded_widget = isset( self::$embedded_widgets[ $element_widget_type ] ) ? true : false;
233
  // Check that element translation exists, has a valid editor type, and has a settings key.
234
  if ( $translated_element && $widget_editor_type && $element_settings ) {
235
+ $translatable_fields = self::$text_widgets[ $element_widget_type ];
236
+ if ( ! empty( $translatable_fields ) ) {
237
+ foreach ( $translatable_fields as $field ) {
238
+ if ( 'form_fields' === $field ) {
239
+ $element['settings'][ $field ] = self::set_form_fields( $element['settings'][ $field ], $translated_element[ $field ] );
240
+ } else {
241
+ $element['settings'][ $field ] = $translated_element[ $field ];
242
+ }
243
+ }
244
+ } else {
245
+ $element['settings'] = $translated_element;
246
+ }
247
  } elseif ( $translated_element && $element_settings && $embedded_widget ) {
248
  $translatable_fields = isset( self::$embedded_widgets[ $element_widget_type ] ) ? self::$embedded_widgets[ $element_widget_type ] : array();
249
  $element['settings'] = self::set_translatable_fields( $translatable_fields, $element_settings, $translated_element );
298
  } else {
299
  $temp_value[ '_' . $value_key ] = $value_settings;
300
  }
301
+ } elseif ( is_array( $value_settings ) ) {
302
  // Else we check each item in the array for translatable fields.
303
  $temp_value[ $value_key ] = self::get_translatable_fields( $translatable_fields, $value_settings );
304
  }
347
  return $settings;
348
  }
349
 
350
+ /**
351
+ * Gets the form_field settings for translation
352
+ *
353
+ * @since 1.5.6
354
+ * @param array $form_fields List of fields found in the form widget.
355
+ * @return array
356
+ */
357
+ public static function get_form_fields( array $form_fields ) {
358
+ $element_form_fields = array();
359
+ foreach ( $form_fields as $key => $form_field_settings ) {
360
+ $translatable_form_field_settings = array();
361
+ foreach ( self::$translatable_form_fields as $translatable_field ) {
362
+ $translatable_form_field_settings[ $translatable_field ] = $form_field_settings[ $translatable_field ];
363
+ }
364
+ $element_form_fields[ $key ] = $translatable_form_field_settings;
365
+ }
366
+ return $element_form_fields;
367
+ }
368
+
369
+ /**
370
+ * Sets the translated from_field settings
371
+ *
372
+ * @since 1.5.6
373
+ * @param array $form_fields List of fields found in forms.
374
+ * @param array $translated_form_fields List of localized fields.
375
+ * @return array
376
+ */
377
+ public static function set_form_fields( array $form_fields, array $translated_form_fields ) {
378
+ foreach ( $form_fields as $key => $form_field_settings ) {
379
+ $form_field_settings['placeholder'] = $translated_form_fields[ $key ]['placeholder'];
380
+ $form_field_settings['field_label'] = $translated_form_fields[ $key ]['field_label'];
381
+ $form_fields[ $key ] = $form_field_settings;
382
+ }
383
+ return $form_fields;
384
+ }
385
+
386
  /**
387
  * Returns true if the array has all string keys, else returns false
388
  *
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.5.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.
@@ -19,7 +19,7 @@ if ( ! function_exists( 'add_action' ) ) {
19
  }
20
 
21
  // Plugin version (should match above meta).
22
- define( 'LINGOTEK_VERSION', '1.5.5' );
23
  define( 'LINGOTEK_MIN_PLL_VERSION', '1.8' );
24
  // Plugin name as known by WordPress.
25
  define( 'LINGOTEK_BASENAME', plugin_basename( __FILE__ ) );
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.5.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.
19
  }
20
 
21
  // Plugin version (should match above meta).
22
+ define( 'LINGOTEK_VERSION', '1.5.6' );
23
  define( 'LINGOTEK_MIN_PLL_VERSION', '1.8' );
24
  // Plugin name as known by WordPress.
25
  define( 'LINGOTEK_BASENAME', plugin_basename( __FILE__ ) );
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: 5.8
7
- Stable tag: 1.5.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -123,6 +123,10 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
123
  5. The Lingotek Translation plugin provides the ability to Copy, Translate, and Ignore each specific custom field. Our plugin supports Wordpress custom fields and advanced custom fields.
124
 
125
  == Changelog ==
 
 
 
 
126
  = 1.5.5 (2022-04-20) =
127
  - WordPress: Paginate the custom field type page.
128
 
4
  Tags: automation, bilingual, international, language, Lingotek, localization, multilanguage, multilingual, translate, translation
5
  Requires at least: 3.8
6
  Tested up to: 5.8
7
+ Stable tag: 1.5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
123
  5. The Lingotek Translation plugin provides the ability to Copy, Translate, and Ignore each specific custom field. Our plugin supports Wordpress custom fields and advanced custom fields.
124
 
125
  == Changelog ==
126
+ = 1.5.6 (2022-05-19) =
127
+ - WordPress Elementor: Widget Typography should not be translated
128
+ - WordPress - completed translations cannot be downloaded, source and translation status is not updated
129
+
130
  = 1.5.5 (2022-04-20) =
131
  - WordPress: Paginate the custom field type page.
132