Version Description
Download this release
Release Info
Developer | npaudyal |
Plugin | Lingotek Translation |
Version | 1.5.8 |
Comparing to | |
See all releases |
Code changes from version 1.5.7 to 1.5.8
- CHANGELOG.md +3 -0
- include/api.php +8 -5
- include/callback.php +4 -1
- include/group-post.php +24 -17
- lingotek.php +2 -2
- readme.txt +4 -1
CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1 |
# Changelog
|
|
|
|
|
|
|
2 |
## [1.4.16] - 2021-07-22
|
3 |
- Merging hotfix 1.4.16 branch
|
1 |
# Changelog
|
2 |
+
## [1.4.16] - 2022-06-23
|
3 |
+
- Merging hotfix 1.5.8 branch
|
4 |
+
|
5 |
## [1.4.16] - 2021-07-22
|
6 |
- Merging hotfix 1.4.16 branch
|
include/api.php
CHANGED
@@ -494,15 +494,16 @@ class Lingotek_API extends Lingotek_HTTP {
|
|
494 |
*
|
495 |
* @param string $doc_id document id
|
496 |
* @param string $locale locale
|
497 |
-
* @return
|
498 |
*/
|
499 |
public function get_translation_status( $doc_id, $locale ) {
|
500 |
$locale = Lingotek::map_to_lingotek_locale( $locale );
|
501 |
-
$status =
|
502 |
$response = $this->get( $this->api_url . "/document/$doc_id/translation/$locale" );
|
503 |
if ( ! is_wp_error( $response ) && 200 == wp_remote_retrieve_response_code( $response ) ) {
|
504 |
-
$b
|
505 |
-
$
|
|
|
506 |
}
|
507 |
|
508 |
$this->log_error_on_response_failure(
|
@@ -531,10 +532,12 @@ class Lingotek_API extends Lingotek_HTTP {
|
|
531 |
foreach ( $b->entities as $e ) {
|
532 |
if ( $e->properties->status != 'CANCELLED' ) {
|
533 |
// cancelled is in a completed state, but it does not mean the translation is 100% complete
|
|
|
|
|
534 |
$translations[ $e->properties->locale_code ] = array(
|
535 |
'progress' => $e->properties->status,
|
536 |
'percent_complete' => $e->properties->percent_complete,
|
537 |
-
'ready_to_download' => $
|
538 |
|
539 |
);
|
540 |
}
|
494 |
*
|
495 |
* @param string $doc_id document id
|
496 |
* @param string $locale locale
|
497 |
+
* @return bool
|
498 |
*/
|
499 |
public function get_translation_status( $doc_id, $locale ) {
|
500 |
$locale = Lingotek::map_to_lingotek_locale( $locale );
|
501 |
+
$status = false;
|
502 |
$response = $this->get( $this->api_url . "/document/$doc_id/translation/$locale" );
|
503 |
if ( ! is_wp_error( $response ) && 200 == wp_remote_retrieve_response_code( $response ) ) {
|
504 |
+
$b = json_decode( wp_remote_retrieve_body( $response ) );
|
505 |
+
$ready_to_download = $b->properties->ready_to_download;
|
506 |
+
$status = is_string( $ready_to_download ) ? filter_var( $ready_to_download, FILTER_VALIDATE_BOOLEAN ) : (bool) $ready_to_download;
|
507 |
}
|
508 |
|
509 |
$this->log_error_on_response_failure(
|
532 |
foreach ( $b->entities as $e ) {
|
533 |
if ( $e->properties->status != 'CANCELLED' ) {
|
534 |
// cancelled is in a completed state, but it does not mean the translation is 100% complete
|
535 |
+
$ready_to_download = $e->properties->ready_to_download;
|
536 |
+
$ready_to_download = is_string( $ready_to_download ) ? filter_var( $ready_to_download, FILTER_VALIDATE_BOOLEAN ) : (bool) $ready_to_download;
|
537 |
$translations[ $e->properties->locale_code ] = array(
|
538 |
'progress' => $e->properties->status,
|
539 |
'percent_complete' => $e->properties->percent_complete,
|
540 |
+
'ready_to_download' => $ready_to_download,
|
541 |
|
542 |
);
|
543 |
}
|
include/callback.php
CHANGED
@@ -121,6 +121,7 @@ class Lingotek_Callback {
|
|
121 |
'Complete' => isset( $_GET['complete'] ) ? $_GET['complete'] : null,
|
122 |
'Type' => isset( $_GET['type'] ) ? $_GET['type'] : null,
|
123 |
'Document Status' => isset( $_GET['doc_status'] ) ? $_GET['doc_status'] : null,
|
|
|
124 |
);
|
125 |
Lingotek_Logger::info( 'Callback received', array( 'Callback Parameters' => $callback_parameters ) );
|
126 |
// We will need access to PLL_Admin_Sync::copy_post_metas
|
@@ -128,9 +129,11 @@ class Lingotek_Callback {
|
|
128 |
$polylang->sync = new PLL_Admin_Sync( $polylang );
|
129 |
// Map to WordPress locale.
|
130 |
$locale = Lingotek::map_to_wp_locale( $_GET['locale'] );
|
|
|
|
|
131 |
if ( $type == 'download_interim_translation' ) {
|
132 |
$document->is_automatic_download( $locale ) ? $document->create_translation( $locale, true, $type ) : $document->translation_ready_interim( $locale );
|
133 |
-
} else {
|
134 |
$document->is_automatic_download( $locale ) ? $document->create_translation( $locale, true, $type ) : $document->translation_ready( $locale );
|
135 |
}
|
136 |
}//end if
|
121 |
'Complete' => isset( $_GET['complete'] ) ? $_GET['complete'] : null,
|
122 |
'Type' => isset( $_GET['type'] ) ? $_GET['type'] : null,
|
123 |
'Document Status' => isset( $_GET['doc_status'] ) ? $_GET['doc_status'] : null,
|
124 |
+
'Ready To Download' => isset( $_GET['ready_to_download'] ) ? $_GET['ready_to_download'] : null,
|
125 |
);
|
126 |
Lingotek_Logger::info( 'Callback received', array( 'Callback Parameters' => $callback_parameters ) );
|
127 |
// We will need access to PLL_Admin_Sync::copy_post_metas
|
129 |
$polylang->sync = new PLL_Admin_Sync( $polylang );
|
130 |
// Map to WordPress locale.
|
131 |
$locale = Lingotek::map_to_wp_locale( $_GET['locale'] );
|
132 |
+
$ready_to_download = isset( $_GET['ready_to_download'] ) ? $_GET['ready_to_download'] : false;
|
133 |
+
$ready_to_download = is_string( $ready_to_download ) ? filter_var( $ready_to_download, FILTER_VALIDATE_BOOLEAN ) : (bool) $ready_to_download;
|
134 |
if ( $type == 'download_interim_translation' ) {
|
135 |
$document->is_automatic_download( $locale ) ? $document->create_translation( $locale, true, $type ) : $document->translation_ready_interim( $locale );
|
136 |
+
} else if ( $ready_to_download ){
|
137 |
$document->is_automatic_download( $locale ) ? $document->create_translation( $locale, true, $type ) : $document->translation_ready( $locale );
|
138 |
}
|
139 |
}//end if
|
include/group-post.php
CHANGED
@@ -14,9 +14,9 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
14 |
*
|
15 |
* @since 0.2
|
16 |
*
|
17 |
-
* @param int $object_id post id
|
18 |
* @param object $language
|
19 |
-
* @param string $document_id translation term name (Lingotek document id)
|
20 |
*/
|
21 |
public static function create( $object_id, $language, $document_id ) {
|
22 |
$data = array(
|
@@ -69,7 +69,7 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
69 |
if ( is_array( $custom_fields ) && ! empty( $custom_fields ) ) {
|
70 |
foreach ( $custom_fields as $cf => $setting ) {
|
71 |
if ( 'translate' == $setting ) {
|
72 |
-
if (
|
73 |
$arr['metas'][ Lingotek_Metadata_Elementor::$elementor_data ] = Lingotek_Metadata_Elementor::$elementor_data;
|
74 |
} else {
|
75 |
$arr['metas'][ $cf ] = $cf;
|
@@ -87,8 +87,6 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
87 |
* returns custom fields from the wpml-config.xml file
|
88 |
*
|
89 |
* @since 0.2
|
90 |
-
*
|
91 |
-
* @param string $post_type
|
92 |
* @return array
|
93 |
*/
|
94 |
public static function get_custom_fields_from_wpml() {
|
@@ -210,7 +208,7 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
210 |
* @since 1.5.3
|
211 |
*
|
212 |
* @param array $metas The array of meta keys that users can translate.
|
213 |
-
* @param array $elementor_field_group The array of elementor metadata found in the posts
|
214 |
*/
|
215 |
public static function group_elementor_fields( &$metas, $elementor_field_group ) {
|
216 |
// Create Lingotek elementor meta field if posts exist with elementor content
|
@@ -226,8 +224,6 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
226 |
* updates meta (custom) fields values in the lingotek_custom_fields option
|
227 |
*
|
228 |
* @since 0.2
|
229 |
-
*
|
230 |
-
* @return array
|
231 |
*/
|
232 |
public static function get_updated_meta_values( $post_ID = null ) {
|
233 |
$custom_fields_from_wpml = self::get_custom_fields_from_wpml();
|
@@ -278,21 +274,20 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
278 |
*
|
279 |
* @return array
|
280 |
*/
|
281 |
-
|
282 |
-
public static function get_cached_meta_values($search = "") {
|
283 |
$custom_fields_from_lingotek = get_option( 'lingotek_custom_fields', array() );
|
284 |
$items = array();
|
285 |
|
286 |
if ( is_array( $custom_fields_from_lingotek ) ) {
|
287 |
foreach ( $custom_fields_from_lingotek as $key => $setting ) {
|
288 |
-
if (
|
289 |
continue;
|
290 |
}
|
291 |
-
$arr
|
292 |
'meta_key' => $key,
|
293 |
'setting' => $setting,
|
294 |
);
|
295 |
-
if (empty($search) || stripos($key, $search) !== false) {
|
296 |
$items[] = $arr;
|
297 |
}
|
298 |
}
|
@@ -389,9 +384,21 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
389 |
remove_filter( 'content_save_pre', 'wp_filter_post_kses' );
|
390 |
remove_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' );
|
391 |
$client = new Lingotek_API();
|
392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
|
394 |
-
if ( $ready_to_download
|
395 |
return;
|
396 |
}
|
397 |
|
@@ -430,7 +437,7 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
430 |
self::copy_or_ignore_metas( $post->ID, $tr_id );
|
431 |
|
432 |
wp_update_post( $tr_post );
|
433 |
-
if (
|
434 |
$this->safe_translation_status_update( $locale, 'interim' );
|
435 |
} else {
|
436 |
$this->safe_translation_status_update( $language->locale, 'current' );
|
@@ -464,7 +471,7 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
464 |
$tr_lang = $this->pllm->get_language( $locale );
|
465 |
PLL()->model->post->set_language( $tr_id, $tr_lang );
|
466 |
$this->safe_translation_status_update( $locale, 'current', array( $tr_lang->slug => $tr_id ) );
|
467 |
-
if (
|
468 |
$this->safe_translation_status_update( $locale, 'interim' );
|
469 |
}
|
470 |
wp_set_object_terms( $tr_id, $this->term_id, 'post_translations' );
|
14 |
*
|
15 |
* @since 0.2
|
16 |
*
|
17 |
+
* @param int $object_id post id.
|
18 |
* @param object $language
|
19 |
+
* @param string $document_id translation term name (Lingotek document id).
|
20 |
*/
|
21 |
public static function create( $object_id, $language, $document_id ) {
|
22 |
$data = array(
|
69 |
if ( is_array( $custom_fields ) && ! empty( $custom_fields ) ) {
|
70 |
foreach ( $custom_fields as $cf => $setting ) {
|
71 |
if ( 'translate' == $setting ) {
|
72 |
+
if ( Lingotek_Metadata_Elementor::$elementor_content === $cf ) {
|
73 |
$arr['metas'][ Lingotek_Metadata_Elementor::$elementor_data ] = Lingotek_Metadata_Elementor::$elementor_data;
|
74 |
} else {
|
75 |
$arr['metas'][ $cf ] = $cf;
|
87 |
* returns custom fields from the wpml-config.xml file
|
88 |
*
|
89 |
* @since 0.2
|
|
|
|
|
90 |
* @return array
|
91 |
*/
|
92 |
public static function get_custom_fields_from_wpml() {
|
208 |
* @since 1.5.3
|
209 |
*
|
210 |
* @param array $metas The array of meta keys that users can translate.
|
211 |
+
* @param array $elementor_field_group The array of elementor metadata found in the posts.
|
212 |
*/
|
213 |
public static function group_elementor_fields( &$metas, $elementor_field_group ) {
|
214 |
// Create Lingotek elementor meta field if posts exist with elementor content
|
224 |
* updates meta (custom) fields values in the lingotek_custom_fields option
|
225 |
*
|
226 |
* @since 0.2
|
|
|
|
|
227 |
*/
|
228 |
public static function get_updated_meta_values( $post_ID = null ) {
|
229 |
$custom_fields_from_wpml = self::get_custom_fields_from_wpml();
|
274 |
*
|
275 |
* @return array
|
276 |
*/
|
277 |
+
public static function get_cached_meta_values( $search = '' ) {
|
|
|
278 |
$custom_fields_from_lingotek = get_option( 'lingotek_custom_fields', array() );
|
279 |
$items = array();
|
280 |
|
281 |
if ( is_array( $custom_fields_from_lingotek ) ) {
|
282 |
foreach ( $custom_fields_from_lingotek as $key => $setting ) {
|
283 |
+
if ( 'hide-copy' === $setting ) {
|
284 |
continue;
|
285 |
}
|
286 |
+
$arr = array(
|
287 |
'meta_key' => $key,
|
288 |
'setting' => $setting,
|
289 |
);
|
290 |
+
if ( empty( $search ) || stripos( $key, $search ) !== false ) {
|
291 |
$items[] = $arr;
|
292 |
}
|
293 |
}
|
384 |
remove_filter( 'content_save_pre', 'wp_filter_post_kses' );
|
385 |
remove_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' );
|
386 |
$client = new Lingotek_API();
|
387 |
+
if ( $callback_type === 'target') {
|
388 |
+
$interim_download = false;
|
389 |
+
// already checked in callback handler
|
390 |
+
$ready_to_download = true;
|
391 |
+
} else if ($callback_type === 'download_interim_translation') {
|
392 |
+
$interim_download = true;
|
393 |
+
$ready_to_download = true;
|
394 |
+
} else {
|
395 |
+
// Check if the locale status is `ready-interim` or `interim`.
|
396 |
+
$interim_download = isset($this->translations[$locale]) && ($this->translations[$locale] === 'ready-interim' || $this->translations[$locale] === 'interim') ? true : false;
|
397 |
+
// If translation not an interim status, check translation status.
|
398 |
+
$ready_to_download = $interim_download ? true : $client->get_translation_status( $this->document_id, $locale );
|
399 |
+
}
|
400 |
|
401 |
+
if ( ! $ready_to_download ) {
|
402 |
return;
|
403 |
}
|
404 |
|
437 |
self::copy_or_ignore_metas( $post->ID, $tr_id );
|
438 |
|
439 |
wp_update_post( $tr_post );
|
440 |
+
if ( $interim_download ) {
|
441 |
$this->safe_translation_status_update( $locale, 'interim' );
|
442 |
} else {
|
443 |
$this->safe_translation_status_update( $language->locale, 'current' );
|
471 |
$tr_lang = $this->pllm->get_language( $locale );
|
472 |
PLL()->model->post->set_language( $tr_id, $tr_lang );
|
473 |
$this->safe_translation_status_update( $locale, 'current', array( $tr_lang->slug => $tr_id ) );
|
474 |
+
if ( $interim_download ) {
|
475 |
$this->safe_translation_status_update( $locale, 'interim' );
|
476 |
}
|
477 |
wp_set_object_terms( $tr_id, $this->term_id, 'post_translations' );
|
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.
|
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.
|
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.8
|
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.8' );
|
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.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -124,6 +124,9 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
|
|
124 |
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.
|
125 |
|
126 |
== Changelog ==
|
|
|
|
|
|
|
127 |
= 1.5.7 (2022-06-06) =
|
128 |
- Fixed handling of undefined Polylang constants
|
129 |
|
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.8
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
124 |
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.
|
125 |
|
126 |
== Changelog ==
|
127 |
+
1.5.8 (2022-06-23) =
|
128 |
+
- Fixed issue with properly downloading interim translations
|
129 |
+
|
130 |
= 1.5.7 (2022-06-06) =
|
131 |
- Fixed handling of undefined Polylang constants
|
132 |
|