Lingotek Translation - Version 1.4.9

Version Description

(2021-2-05) = * Fixed major bug that prevented users from authenticating with Lingotek

Download this release

Release Info

Developer elliothanna
Plugin Icon 128x128 Lingotek Translation
Version 1.4.9
Comparing to
See all releases

Code changes from version 1.4.8 to 1.4.9

admin/admin.php CHANGED
@@ -36,6 +36,12 @@ class Lingotek_Admin {
36
  add_action( 'wp_ajax_get_current_status', array( $this, 'ajax_get_current_status' ) );
37
  // Network admin menu.
38
  add_action( 'network_admin_menu', array( $this, 'add_network_admin_menu' ) );
 
 
 
 
 
 
39
  }
40
 
41
  /**
@@ -277,7 +283,8 @@ class Lingotek_Admin {
277
  }
278
 
279
  // connect Lingotek account.
280
- $access_token = filter_input( INPUT_COOKIE, 'lingotek_access_token' );
 
281
  if ( ! empty( $access_token ) && empty( $delete_access_token ) ) {
282
  // set and get token details.
283
  $client = new Lingotek_API();
36
  add_action( 'wp_ajax_get_current_status', array( $this, 'ajax_get_current_status' ) );
37
  // Network admin menu.
38
  add_action( 'network_admin_menu', array( $this, 'add_network_admin_menu' ) );
39
+ add_action('wp_ajax_lingotek_authorization_action', array($this,'lingotek_authorization_action'));
40
+ }
41
+
42
+ public function lingotek_authorization_action() {
43
+ $access_token = $_SERVER['HTTP_TOKEN'];
44
+ update_option( 'lingotek_token', array( 'access_token' => $access_token ));
45
  }
46
 
47
  /**
283
  }
284
 
285
  // connect Lingotek account.
286
+ $database_token_details = get_option('lingotek_token', []);
287
+ $access_token = isset($database_token_details['access_token']) ? $database_token_details['access_token'] : null;
288
  if ( ! empty( $access_token ) && empty( $delete_access_token ) ) {
289
  // set and get token details.
290
  $client = new Lingotek_API();
admin/filters-columns.php CHANGED
@@ -112,9 +112,7 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
112
  $get_action = filter_input( INPUT_GET, 'action' );
113
  $inline_lang_choice = filter_input( INPUT_POST, 'inline_lang_choice' );
114
  $inline = defined( 'DOING_AJAX' ) && $get_action === $action && ! empty( $inline_lang_choice );
115
- $lang = $inline ?
116
- $this->model->get_language( $inline_lang_choice ) :
117
- 'post' === $type ? PLL()->model->post->get_language( $object_id ) : PLL()->model->term->get_language( $object_id );
118
 
119
  if ( false === strpos( $column, 'language_' ) || ! $lang ) {
120
  if ( $custom_data ) {
@@ -134,9 +132,9 @@ class Lingotek_Filters_Columns extends PLL_Admin_Filters_Columns {
134
  printf( '<div class="hidden" id="lang_%d">%s</div>', esc_attr( $object_id ), esc_html( $lang->slug ) );
135
  }
136
 
137
- $id = ($inline && $lang->slug !== $this->model->get_language( filter_input( INPUT_POST, 'old_lang' ) )->slug) ?
138
  ($language->slug === $lang->slug ? $object_id : 0) :
139
- 'post' === $type ? PLL()->model->post->get( $object_id, $language ) : PLL()->model->term->get( $object_id, $language );
140
 
141
  $document = $this->lgtm->get_group( $type, $object_id );
142
  if ( isset( $document->source ) ) {
112
  $get_action = filter_input( INPUT_GET, 'action' );
113
  $inline_lang_choice = filter_input( INPUT_POST, 'inline_lang_choice' );
114
  $inline = defined( 'DOING_AJAX' ) && $get_action === $action && ! empty( $inline_lang_choice );
115
+ $lang = $inline ? $this->model->get_language( $inline_lang_choice ) : ('post' === $type ? PLL()->model->post->get_language( $object_id ) : PLL()->model->term->get_language( $object_id ));
 
 
116
 
117
  if ( false === strpos( $column, 'language_' ) || ! $lang ) {
118
  if ( $custom_data ) {
132
  printf( '<div class="hidden" id="lang_%d">%s</div>', esc_attr( $object_id ), esc_html( $lang->slug ) );
133
  }
134
 
135
+ $id = (($inline && $lang->slug !== $this->model->get_language( filter_input( INPUT_POST, 'old_lang' ) )->slug) ?
136
  ($language->slug === $lang->slug ? $object_id : 0) :
137
+ 'post' === $type) ? PLL()->model->post->get( $object_id, $language ) : PLL()->model->term->get( $object_id, $language );
138
 
139
  $document = $this->lgtm->get_group( $type, $object_id );
140
  if ( isset( $document->source ) ) {
admin/settings/connect-account.php CHANGED
@@ -1,20 +1,42 @@
1
  <!-- Redirect Access Token -->
2
  <script>
 
3
  var hash = window.location.hash;
4
  if (hash.length && hash.indexOf("access_token") !== -1) {
 
5
  var regex = /^access_token=(\w{8}-\w{4}-\w{4}-\w{4}-\w{12})/;
6
  var access_token = regex.exec(hash.substr(1));
 
7
  if (access_token && access_token[1]) {
8
- document.cookie = 'lingotek_access_token=' + access_token[1] + ';path=/';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
10
- window.location.href = window.location.origin + window.location.pathname + window.location.search;
11
- }
12
- else if (window.location.search.indexOf("connect") != -1) {
13
- window.location.href = "<?php echo esc_url_raw( $connect_url ) ?>";
14
  }
 
15
  </script>
16
  <!-- Connect Your Account Button -->
17
- <div class="wrap">
 
18
  <h2><?php esc_html_e( 'Connect Your Account', 'lingotek-translation' ) ?></h2>
19
  <div>
20
  <p class="description">
@@ -40,3 +62,20 @@
40
  </p>
41
  </div>
42
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <!-- Redirect Access Token -->
2
  <script>
3
+ jQuery(document).ready(function ($){
4
  var hash = window.location.hash;
5
  if (hash.length && hash.indexOf("access_token") !== -1) {
6
+ $('.content').toggle();
7
  var regex = /^access_token=(\w{8}-\w{4}-\w{4}-\w{4}-\w{12})/;
8
  var access_token = regex.exec(hash.substr(1));
9
+ var redirect_url = window.location.origin + window.location.pathname + window.location.search;
10
  if (access_token && access_token[1]) {
11
+ var request_data = {
12
+ 'action': 'lingotek_authorization_action',
13
+ }
14
+ jQuery.ajax({
15
+ type: 'POST',
16
+ url: ajaxurl,
17
+ data: request_data,
18
+ headers: {
19
+ 'Token': access_token[1],
20
+ },
21
+ success: function (response) {
22
+ console.log('success')
23
+ }
24
+ ,
25
+ error: function (xhr, status, error) {
26
+ console.log('failed', status, error)
27
+ }
28
+ }).then( function (data) {
29
+ window.location.href = redirect_url;
30
+ })
31
  }
32
+ } else if (window.location.search.includes("connect")) {
33
+ window.location.href = "<?php echo esc_url_raw( $connect_url ) ?>";
 
 
34
  }
35
+ });
36
  </script>
37
  <!-- Connect Your Account Button -->
38
+ <div class="loader content" hidden></div>
39
+ <div class="wrap content">
40
  <h2><?php esc_html_e( 'Connect Your Account', 'lingotek-translation' ) ?></h2>
41
  <div>
42
  <p class="description">
62
  </p>
63
  </div>
64
  </div>
65
+ <style>
66
+ .loader {
67
+ border: 16px solid #dedede;
68
+ border-top: 16px solid #3498db;
69
+ border-radius: 50%;
70
+ width: 100px;
71
+ height: 100px;
72
+ animation: spin 1.5s linear infinite;
73
+ animation-direction: reverse;
74
+ margin: 7em;
75
+ }
76
+
77
+ @keyframes spin {
78
+ 0% { transform: rotate(0deg); }
79
+ 100% { transform: rotate(360deg); }
80
+ }
81
+ </style>
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.4.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.
@@ -16,7 +16,7 @@ if ( ! function_exists( 'add_action' ) ) {
16
  exit();
17
  }
18
 
19
- define( 'LINGOTEK_VERSION', '1.4.8' ); // plugin version (should match above meta).
20
  define( 'LINGOTEK_MIN_PLL_VERSION', '1.8' );
21
  define( 'LINGOTEK_BASENAME', plugin_basename( __FILE__ ) ); // plugin name as known by WP.
22
  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.4.9
6
  Author: Lingotek and Frédéric Demarle
7
  Author uri: http://lingotek.com
8
  Description: Lingotek offers convenient cloud-based localization and translation.
16
  exit();
17
  }
18
 
19
+ define( 'LINGOTEK_VERSION', '1.4.9' ); // plugin version (should match above meta).
20
  define( 'LINGOTEK_MIN_PLL_VERSION', '1.8' );
21
  define( 'LINGOTEK_BASENAME', plugin_basename( __FILE__ ) ); // plugin name as known by WP.
22
  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: 5.6
7
- Stable tag: 1.4.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -123,6 +123,9 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
123
 
124
  == Changelog ==
125
 
 
 
 
126
  = 1.4.8 (2021-1-29) =
127
  * Updated patching logic to reference the translation profile
128
  * Changed access token to be sent with bearer
4
  Tags: automation, bilingual, international, language, Lingotek, localization, multilanguage, multilingual, translate, translation
5
  Requires at least: 3.8
6
  Tested up to: 5.6
7
+ Stable tag: 1.4.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
123
 
124
  == Changelog ==
125
 
126
+ = 1.4.9 (2021-2-05) =
127
+ * Fixed major bug that prevented users from authenticating with Lingotek
128
+
129
  = 1.4.8 (2021-1-29) =
130
  * Updated patching logic to reference the translation profile
131
  * Changed access token to be sent with bearer