Tidio Live Chat - Version 4.4.0

Version Description

  • Add french, spanish and polish translations
  • Display an error message when invalid credentials have been provided
Download this release

Release Info

Developer kkopaczyktidio
Plugin Icon 128x128 Tidio Live Chat
Version 4.4.0
Comparing to
See all releases

Code changes from version 4.3.0 to 4.4.0

TidioDotEnv.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TidioDotEnv
4
+ {
5
+ const ENV_FILENAME = '.env';
6
+
7
+ /**
8
+ * @var string
9
+ */
10
+ private $envDirectoryPath;
11
+
12
+ public function __construct($envDirectoryPath)
13
+ {
14
+ if (!is_dir($envDirectoryPath)) {
15
+ throw new \RuntimeException('Path must point an env directory');
16
+ }
17
+
18
+ $this->envDirectoryPath = $envDirectoryPath;
19
+ }
20
+
21
+ /**
22
+ * @return void
23
+ */
24
+ public function load()
25
+ {
26
+ $file = sprintf('%s/%s', $this->envDirectoryPath, self::ENV_FILENAME);
27
+ if (!file_exists($file)) {
28
+ return;
29
+ }
30
+
31
+ if (!is_file($file) || !is_readable($file)) {
32
+ throw new \RuntimeException(sprintf('%s file is not readable', self::ENV_FILENAME));
33
+ }
34
+
35
+ $envs = $this->parseEnvFile($file);
36
+ $this->setEnvs($envs);
37
+ }
38
+
39
+ /**
40
+ * @param string $file
41
+ * @return array
42
+ */
43
+ private function parseEnvFile($file)
44
+ {
45
+ $envs = [];
46
+ $lines = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
47
+ foreach ($lines as $line) {
48
+ if (strpos(trim($line), '#') === 0) {
49
+ continue;
50
+ }
51
+
52
+ list($name, $value) = explode('=', $line, 2);
53
+ $envs[trim($name)] = trim($value);
54
+ }
55
+
56
+ return $envs;
57
+ }
58
+
59
+ /**
60
+ * @param array $envs
61
+ * @return void
62
+ */
63
+ private function setEnvs($envs)
64
+ {
65
+ foreach ($envs as $envName => $envValue) {
66
+ putenv(sprintf('%s=%s', $envName, $envValue));
67
+ }
68
+ }
69
+ }
config.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once __DIR__ . '/TidioDotEnv.php';
4
+
5
+ (new TidioDotEnv(__DIR__))->load();
6
+
7
+ return [
8
+ 'tidio_api_url' => getenv('TIDIO_API_URL') ?: 'https://api-v2.tidio.co',
9
+ 'tidio_panel_url' => getenv('TIDIO_PANEL_URL') ?: 'https://www.tidio.com',
10
+ 'tidio_widget_url' => getenv('TIDIO_WIDGET_URL') ?: '//code.tidio.co',
11
+ ];
languages/.gitkeep ADDED
File without changes
languages/js/.gitkeep ADDED
File without changes
languages/js/tidio-live-chat-es_ES-tidio-chat-admin.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "domain": "tidio-live-chat",
3
+ "locale_data": {
4
+ "tidio-live-chat": {
5
+ "": {
6
+ "domain": "tidio-live-chat",
7
+ "plural_forms": "nplurals=2; plural=(n != 1);",
8
+ "lang": "es"
9
+ },
10
+ "Loading...": [
11
+ "Cargando..."
12
+ ],
13
+ "Can’t be empty!": [
14
+ "¡No puede dejarse en blanco!"
15
+ ],
16
+ "Email can’t be empty!": [
17
+ "¡El email no puede dejarse en blanco!"
18
+ ],
19
+ "Email is invalid!": [
20
+ "¡El email no es válido!"
21
+ ],
22
+ "Start using Tidio": [
23
+ "Comienza a usar Tidio"
24
+ ],
25
+ "Something went wrong.": [
26
+ "Algo ha salido mal."
27
+ ],
28
+ "You have been blocked for too many attempts. Please try again in an hour.": [
29
+ "Como ha habido demasiados intentos, se te ha bloqueado. Vuelve a intentarlo en una hora."
30
+ ],
31
+ "Password can’t be empty!": [
32
+ "¡La contraseña no puede dejarse en blanco!"
33
+ ],
34
+ "Wrong email or password": [
35
+ "Email o contraseña no válidos"
36
+ ],
37
+ "Go to Tidio panel": [
38
+ "Ir al panel de Tidio"
39
+ ],
40
+ "Error occured while creating, please try again!": [
41
+ "Se ha producido un error durante la creación, ¡vuelve a intentarlo!"
42
+ ]
43
+ }
44
+ }
45
+ }
languages/js/tidio-live-chat-es_MX-tidio-chat-admin.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "domain": "tidio-live-chat",
3
+ "locale_data": {
4
+ "tidio-live-chat": {
5
+ "": {
6
+ "domain": "tidio-live-chat",
7
+ "plural_forms": "nplurals=2; plural=(n != 1);",
8
+ "lang": "es_MX"
9
+ },
10
+ "Loading...": [
11
+ "Cargando..."
12
+ ],
13
+ "Can’t be empty!": [
14
+ "No puede quedar en blanco."
15
+ ],
16
+ "Email can’t be empty!": [
17
+ "El email no puede quedar en blanco."
18
+ ],
19
+ "Email is invalid!": [
20
+ "El email no es válido."
21
+ ],
22
+ "Start using Tidio": [
23
+ "Comienza a usar Tidio"
24
+ ],
25
+ "Something went wrong.": [
26
+ "Algo salió mal."
27
+ ],
28
+ "You have been blocked for too many attempts. Please try again in an hour.": [
29
+ "Como hubo demasiados intentos, fuiste bloqueado. Vuelve a intentar en una hora."
30
+ ],
31
+ "Password can’t be empty!": [
32
+ "La contraseña no puede quedar en blanco."
33
+ ],
34
+ "Wrong email or password": [
35
+ "Email o contraseña no válidos"
36
+ ],
37
+ "Go to Tidio panel": [
38
+ "Ir al panel de Tidio"
39
+ ],
40
+ "Error occured while creating, please try again!": [
41
+ "Ocurrió un error durante la creación, ¡vuelve a intentarlo!"
42
+ ]
43
+ }
44
+ }
45
+ }
languages/js/tidio-live-chat-fr_BE-tidio-chat-admin.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "domain": "tidio-live-chat",
3
+ "locale_data": {
4
+ "tidio-live-chat": {
5
+ "": {
6
+ "domain": "tidio-live-chat",
7
+ "plural_forms": "nplurals=2; plural=(n > 1);",
8
+ "lang": "fr"
9
+ },
10
+ "Loading...": [
11
+ "Chargement..."
12
+ ],
13
+ "Can’t be empty!": [
14
+ "Ce champ ne peut pas être vide !"
15
+ ],
16
+ "Email can’t be empty!": [
17
+ "L'e-mail ne peut pas être vide !"
18
+ ],
19
+ "Email is invalid!": [
20
+ "L'adresse e-mail est invalide !"
21
+ ],
22
+ "Start using Tidio": [
23
+ "Commencez à utiliser Tidio"
24
+ ],
25
+ "Something went wrong.": [
26
+ "Une erreur s'est produite."
27
+ ],
28
+ "You have been blocked for too many attempts. Please try again in an hour.": [
29
+ "Vous avez été bloqué en raison d'un nombre trop élevé de tentatives. Veuillez réessayer dans une heure"
30
+ ],
31
+ "Password can’t be empty!": [
32
+ "Le mot de passe ne peut pas être vide !"
33
+ ],
34
+ "Wrong email or password": [
35
+ "Adresse e-mail ou mot de passe erroné"
36
+ ],
37
+ "Go to Tidio panel": [
38
+ "Accéder au panneau Tidio"
39
+ ],
40
+ "Error occured while creating, please try again!": [
41
+ "Une erreur s'est produite lors de la création, veuillez réessayer !"
42
+ ]
43
+ }
44
+ }
45
+ }
languages/js/tidio-live-chat-fr_CA-tidio-chat-admin.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "domain": "tidio-live-chat",
3
+ "locale_data": {
4
+ "tidio-live-chat": {
5
+ "": {
6
+ "domain": "tidio-live-chat",
7
+ "plural_forms": "nplurals=2; plural=(n > 1);",
8
+ "lang": "fr"
9
+ },
10
+ "Loading...": [
11
+ "Chargement..."
12
+ ],
13
+ "Can’t be empty!": [
14
+ "Ce champ ne peut pas être vide !"
15
+ ],
16
+ "Email can’t be empty!": [
17
+ "L'e-mail ne peut pas être vide !"
18
+ ],
19
+ "Email is invalid!": [
20
+ "L'adresse e-mail est invalide !"
21
+ ],
22
+ "Start using Tidio": [
23
+ "Commencez à utiliser Tidio"
24
+ ],
25
+ "Something went wrong.": [
26
+ "Une erreur s'est produite."
27
+ ],
28
+ "You have been blocked for too many attempts. Please try again in an hour.": [
29
+ "Vous avez été bloqué en raison d'un nombre trop élevé de tentatives. Veuillez réessayer dans une heure."
30
+ ],
31
+ "Password can’t be empty!": [
32
+ "Le mot de passe ne peut pas être vide !"
33
+ ],
34
+ "Wrong email or password": [
35
+ "Adresse e-mail ou mot de passe erroné"
36
+ ],
37
+ "Go to Tidio panel": [
38
+ "Accéder au panneau Tidio"
39
+ ],
40
+ "Error occured while creating, please try again!": [
41
+ "Une erreur s'est produite lors de la création, veuillez réessayer !"
42
+ ]
43
+ }
44
+ }
45
+ }
languages/js/tidio-live-chat-fr_FR-tidio-chat-admin.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "domain": "tidio-live-chat",
3
+ "locale_data": {
4
+ "tidio-live-chat": {
5
+ "": {
6
+ "domain": "tidio-live-chat",
7
+ "plural_forms": "nplurals=2; plural=(n > 1);",
8
+ "lang": "fr"
9
+ },
10
+ "Loading...": [
11
+ "Chargement..."
12
+ ],
13
+ "Can’t be empty!": [
14
+ "Ce champ ne peut pas être vide !"
15
+ ],
16
+ "Email can’t be empty!": [
17
+ "L'e-mail ne peut pas être vide !"
18
+ ],
19
+ "Email is invalid!": [
20
+ "L'adresse e-mail est invalide !"
21
+ ],
22
+ "Start using Tidio": [
23
+ "Commencez à utiliser Tidio"
24
+ ],
25
+ "Something went wrong.": [
26
+ "Une erreur s'est produite."
27
+ ],
28
+ "You have been blocked for too many attempts. Please try again in an hour.": [
29
+ "Vous avez été bloqué en raison d'un nombre trop élevé de tentatives. Veuillez réessayer dans une heure."
30
+ ],
31
+ "Password can’t be empty!": [
32
+ "Le mot de passe ne peut pas être vide !"
33
+ ],
34
+ "Wrong email or password": [
35
+ "Adresse e-mail ou mot de passe erroné"
36
+ ],
37
+ "Go to Tidio panel": [
38
+ "Accéder au panneau Tidio"
39
+ ],
40
+ "Error occured while creating, please try again!": [
41
+ "Une erreur s'est produite lors de la création, veuillez réessayer !"
42
+ ]
43
+ }
44
+ }
45
+ }
languages/js/tidio-live-chat-pl_PL-tidio-chat-admin.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "domain": "tidio-live-chat",
3
+ "locale_data": {
4
+ "tidio-live-chat": {
5
+ "": {
6
+ "domain": "tidio-live-chat",
7
+ "plural_forms": "nplurals=2; plural=(n != 1);",
8
+ "lang": "es_MX"
9
+ },
10
+ "Loading...": [
11
+ "Ładowanie..."
12
+ ],
13
+ "Can’t be empty!": [
14
+ "Nie może być puste."
15
+ ],
16
+ "Email can’t be empty!": [
17
+ "E-mail musi zostać podany."
18
+ ],
19
+ "Email is invalid!": [
20
+ "Podany e-mail jest nieprawidłowy."
21
+ ],
22
+ "Start using Tidio": [
23
+ "Rozpocznij korzystanie z Tidio"
24
+ ],
25
+ "Something went wrong.": [
26
+ "Coś poszło nie tak."
27
+ ],
28
+ "You have been blocked for too many attempts. Please try again in an hour.": [
29
+ "Zostałeś zablokowany z powodu zbyt wielu prób. Spróbuj ponownie za 1 godzinę."
30
+ ],
31
+ "Password can’t be empty!": [
32
+ "Hasło nie może być puste!"
33
+ ],
34
+ "Wrong email or password": [
35
+ "Nieprawidłowy email lub hasło"
36
+ ],
37
+ "Go to Tidio panel": [
38
+ "Przejdź do panelu Tidio"
39
+ ],
40
+ "Error occured while creating, please try again!": [
41
+ "Wystąpił błąd podczas tworzenia, proszę spróbować ponownie!"
42
+ ]
43
+ }
44
+ }
45
+ }
languages/tidio-live-chat-es_ES.mo ADDED
Binary file
languages/tidio-live-chat-es_MX.mo ADDED
Binary file
languages/tidio-live-chat-fr_BE.mo ADDED
Binary file
languages/tidio-live-chat-fr_CA.mo ADDED
Binary file
languages/tidio-live-chat-fr_FR.mo ADDED
Binary file
languages/tidio-live-chat-pl_PL.mo ADDED
Binary file
media/js/options.js CHANGED
@@ -1,10 +1,13 @@
1
  /* global jQuery */
2
  jQuery(function ($) {
 
 
3
  var TidioChatWP = {
4
- apiUrl: 'https://api-v2.tidio.co',
5
- chatUrl: 'https://www.tidio.com',
6
  token: null,
7
  email: '',
 
8
  init: function () {
9
  this.error = $('.error');
10
  this.form = $('#tidio-start');
@@ -17,16 +20,16 @@ jQuery(function ($) {
17
  var emailField = this.form.find('#email');
18
  var submitButton = this.form.find('button');
19
  if (emailField.val() === '') {
20
- this.showError('Can’t be empty!');
21
  return false;
22
  }
23
  if (emailField.is(':invalid')) {
24
- this.showError('Email is invalid!');
25
  return false;
26
  }
27
  this.hideError();
28
  this.email = emailField.val();
29
- submitButton.prop('disabled', true).text('Loading...');
30
 
31
  $.get(TidioChatWP.apiUrl + '/access/checkIfEmailIsRegistered', {
32
  email: emailField.val(),
@@ -34,17 +37,17 @@ jQuery(function ($) {
34
  if (data.status === true && data.value &&
35
  data.value.registered === true) {
36
  this.form.hide();
37
- submitButton.prop('disabled', false).text('Start using Tidio');
38
  this.showLoginForm(emailField.val());
39
  } else {
40
  this.redirectToPanel();
41
  }
42
  }.bind(this)).fail((function(error) {
43
- submitButton.prop('disabled', false).text('Start using Tidio');
44
  if (error && error.status === 429) {
45
- this.showError('You have been blocked for too many failed attempts. Please try again in an hour.');
46
  } else {
47
- this.showError('Something went wrong.');
48
  }
49
 
50
  }).bind(this));
@@ -71,36 +74,46 @@ jQuery(function ($) {
71
  var passwordField = this.form.find('#password');
72
  var submitButton = this.form.find('button');
73
  if (emailField.val() === '') {
74
- this.showError('Email can’t be empty!');
75
  return false;
76
  }
77
  if (emailField.is(':invalid')) {
78
- this.showError('Email is invalid!');
79
  return false;
80
  }
81
  if (passwordField.val() === '') {
82
- this.showError('Password can’t be empty!');
83
  return false;
84
  }
85
  this.hideError();
86
- submitButton.prop('disabled', true).text('Loading...');
87
 
88
  var email = emailField.val();
89
  var password = document.querySelector(
90
  '#tidio-login #password').value;
 
91
  $.get(TidioChatWP.apiUrl + '/access/getUserToken', {
92
  email: email,
93
  password: password,
94
- }, (function (data) {
95
- if (data.status === true && data.value !==
96
- 'ERR_DATA_INVALID') {
97
  TidioChatWP.token = data.value;
98
  this.getProjects(TidioChatWP.token);
99
- } else {
100
- this.showError('Wrong email or password');
101
- }
102
- submitButton.prop('disabled', false).text('Go to Tidio panel');
103
- }).bind(this), 'json');
 
 
 
 
 
 
 
 
 
 
104
  return false;
105
  },
106
  addEmailToRedirectLink: function(url) {
@@ -302,7 +315,7 @@ jQuery(function ($) {
302
  '&platform=wordpress';
303
  $.getJSON(xhr_url, {}, function (r) {
304
  if (!r || !r.value) {
305
- alert('Error occured while creating, please try again!');
306
  return false;
307
  }
308
  _func(TidioChatWP.chatUrl + '/access?privateKey=' +
@@ -317,7 +330,7 @@ jQuery(function ($) {
317
  '_wpnonce': nonce,
318
  });
319
  }).fail(function () {
320
- alert('Error occured while creating, please try again!');
321
  });
322
 
323
  },
1
  /* global jQuery */
2
  jQuery(function ($) {
3
+ const { __ } = wp.i18n;
4
+
5
  var TidioChatWP = {
6
+ apiUrl: tidioApiUrl,
7
+ chatUrl: tidioPanelUrl,
8
  token: null,
9
  email: '',
10
+ translate: message => __(message, 'tidio-live-chat'),
11
  init: function () {
12
  this.error = $('.error');
13
  this.form = $('#tidio-start');
20
  var emailField = this.form.find('#email');
21
  var submitButton = this.form.find('button');
22
  if (emailField.val() === '') {
23
+ this.showError(this.translate('Can’t be empty!'));
24
  return false;
25
  }
26
  if (emailField.is(':invalid')) {
27
+ this.showError(this.translate('Email is invalid!'));
28
  return false;
29
  }
30
  this.hideError();
31
  this.email = emailField.val();
32
+ submitButton.prop('disabled', true).text(this.translate('Loading...'));
33
 
34
  $.get(TidioChatWP.apiUrl + '/access/checkIfEmailIsRegistered', {
35
  email: emailField.val(),
37
  if (data.status === true && data.value &&
38
  data.value.registered === true) {
39
  this.form.hide();
40
+ submitButton.prop('disabled', false).text(this.translate('Start using Tidio'));
41
  this.showLoginForm(emailField.val());
42
  } else {
43
  this.redirectToPanel();
44
  }
45
  }.bind(this)).fail((function(error) {
46
+ submitButton.prop('disabled', false).text(this.translate('Start using Tidio'));
47
  if (error && error.status === 429) {
48
+ this.showError(this.translate('You have been blocked for too many attempts. Please try again in an hour.'));
49
  } else {
50
+ this.showError(this.translate('Something went wrong.'));
51
  }
52
 
53
  }).bind(this));
74
  var passwordField = this.form.find('#password');
75
  var submitButton = this.form.find('button');
76
  if (emailField.val() === '') {
77
+ this.showError(this.translate('Email can’t be empty!'));
78
  return false;
79
  }
80
  if (emailField.is(':invalid')) {
81
+ this.showError(this.translate('Email is invalid!'));
82
  return false;
83
  }
84
  if (passwordField.val() === '') {
85
+ this.showError(this.translate('Password can’t be empty!'));
86
  return false;
87
  }
88
  this.hideError();
89
+ submitButton.prop('disabled', true).text(this.translate('Loading...'));
90
 
91
  var email = emailField.val();
92
  var password = document.querySelector(
93
  '#tidio-login #password').value;
94
+
95
  $.get(TidioChatWP.apiUrl + '/access/getUserToken', {
96
  email: email,
97
  password: password,
98
+ })
99
+ .done(function (data) {
 
100
  TidioChatWP.token = data.value;
101
  this.getProjects(TidioChatWP.token);
102
+ }.bind(this))
103
+ .fail(function (error) {
104
+ const statusCode = error?.status;
105
+ if (statusCode === 401) {
106
+ this.showError(this.translate('Wrong email or password'));
107
+ } else if (statusCode === 429) {
108
+ this.showError(this.translate('You have been blocked for too many attempts. Please try again in an hour.'));
109
+ } else {
110
+ this.showError(this.translate('Something went wrong.'));
111
+ }
112
+ }.bind(this))
113
+ .always(function() {
114
+ submitButton.prop('disabled', false).text(this.translate('Go to Tidio panel'));
115
+ }.bind(this));
116
+
117
  return false;
118
  },
119
  addEmailToRedirectLink: function(url) {
315
  '&platform=wordpress';
316
  $.getJSON(xhr_url, {}, function (r) {
317
  if (!r || !r.value) {
318
+ alert(this.translate('Error occured while creating, please try again!'));
319
  return false;
320
  }
321
  _func(TidioChatWP.chatUrl + '/access?privateKey=' +
330
  '_wpnonce': nonce,
331
  });
332
  }).fail(function () {
333
+ alert(this.translate('Error occured while creating, please try again!'));
334
  });
335
 
336
  },
options.php CHANGED
@@ -1,5 +1,7 @@
1
  <script>
2
  var nonce = '<?php echo wp_create_nonce(TidioLiveChat::TIDIO_XHR_NONCE_NAME); ?>';
 
 
3
  </script>
4
  <div id="tidio-wrapper">
5
  <div class="tidio-box-wrapper">
@@ -9,55 +11,55 @@
9
  <div class="logo wp-logo"></div>
10
  </div>
11
  <form novalidate id="tidio-start">
12
- <h1>Start using Tidio</h1>
13
  <label>
14
- Email Address
15
  <input type="email" id="email" placeholder="e.g. tidius@tidio.com" required/>
16
  </label>
17
 
18
  <div class="error"></div>
19
- <button>Let’s go</button>
20
  </form>
21
  <form novalidate id="tidio-login">
22
- <h1>Log into your account</h1>
23
  <label>
24
- Email Address
25
  <input type="email" id="email" placeholder="e.g. tidius@tidio.com" required/>
26
  </label>
27
 
28
  <label>
29
- Password
30
- <input type="password" id="password" placeholder="Type your password&hellip;" required/>
31
  </label>
32
 
33
  <div class="error"></div>
34
- <button>Go to Tidio panel</button>
35
- <a class="button btn-link" href="https://www.tidio.com/panel/forgot-password" target="_blank">Forgot password?</a>
36
  </form>
37
  <form novalidate id="tidio-project">
38
- <h1>Choose your project</h1>
39
  <label>
40
- Choose your project
41
  <div class="custom-select">
42
  <select name="select-tidio-project" id="select-tidio-project">
43
- <option selected="selected" disabled>Pick one from the list&hellip;</option>
44
  </select>
45
  </div>
46
  </label>
47
 
48
  <div class="error"></div>
49
- <button>Go to Tidio panel</button>
50
- <button type="button" id="start-over" class="btn-link">Start all over again</button>
51
  </form>
52
  <form id="after-install-text">
53
- <h1>Your site is already integrated with Tidio Chat</h1>
54
- <p>All you need to do now is select the “Tidio Chat” tab on the left - that will take you to your Tidio panel. You can also open the panel by using the link below.</p>
55
- <a href="#" id="open-panel-link" class="button" target="_blank">Go to Panel</a>
56
  </form>
57
  </div>
58
  <div class="tidio-box tidio-box-george">
59
- <h2>Join 300 000+ websites using Tidio - Live Chat boosted with Bots</h2>
60
- <p>Increase sales by skyrocketing communication with customers.</p>
61
  <div class="tidio-box-george-image"></div>
62
  </div>
63
  </div>
1
  <script>
2
  var nonce = '<?php echo wp_create_nonce(TidioLiveChat::TIDIO_XHR_NONCE_NAME); ?>';
3
+ var tidioApiUrl = '<?php echo TidioLiveChatConfig::getApiUrl(); ?>';
4
+ var tidioPanelUrl = '<?php echo TidioLiveChatConfig::getPanelUrl(); ?>';
5
  </script>
6
  <div id="tidio-wrapper">
7
  <div class="tidio-box-wrapper">
11
  <div class="logo wp-logo"></div>
12
  </div>
13
  <form novalidate id="tidio-start">
14
+ <h1><?php i18n::_e('Start using Tidio');?></h1>
15
  <label>
16
+ <?php i18n::_e('Email Address');?>
17
  <input type="email" id="email" placeholder="e.g. tidius@tidio.com" required/>
18
  </label>
19
 
20
  <div class="error"></div>
21
+ <button><?php i18n::_e('Let’s go');?></button>
22
  </form>
23
  <form novalidate id="tidio-login">
24
+ <h1><?php i18n::_e('Log into your account');?></h1>
25
  <label>
26
+ <?php i18n::_e('Email Address');?>
27
  <input type="email" id="email" placeholder="e.g. tidius@tidio.com" required/>
28
  </label>
29
 
30
  <label>
31
+ <?php i18n::_e('Password');?>
32
+ <input type="password" id="password" placeholder="<?php i18n::_e('Type your password');?>&hellip;" required/>
33
  </label>
34
 
35
  <div class="error"></div>
36
+ <button><?php i18n::_e('Go to Tidio panel');?></button>
37
+ <a class="button btn-link" href="https://www.tidio.com/panel/forgot-password" target="_blank"><?php i18n::_e('Forgot password?');?></a>
38
  </form>
39
  <form novalidate id="tidio-project">
40
+ <h1><?php i18n::_e('Choose your project');?></h1>
41
  <label>
42
+ <?php i18n::_e('Choose your project');?>
43
  <div class="custom-select">
44
  <select name="select-tidio-project" id="select-tidio-project">
45
+ <option selected="selected" disabled><?php i18n::_e('Pick one from the list');?>&hellip;</option>
46
  </select>
47
  </div>
48
  </label>
49
 
50
  <div class="error"></div>
51
+ <button><?php i18n::_e('Go to Tidio panel');?></button>
52
+ <button type="button" id="start-over" class="btn-link"><?php i18n::_e('Start all over again');?></button>
53
  </form>
54
  <form id="after-install-text">
55
+ <h1><?php i18n::_e('Your site is already integrated with Tidio Chat');?></h1>
56
+ <p><?php i18n::_e('All you need to do now is select the “Tidio Chat” tab on the left - that will take you to your Tidio panel. You can also open the panel by using the link below.');?></p>
57
+ <a href="#" id="open-panel-link" class="button" target="_blank"><?php i18n::_e('Go to Panel');?></a>
58
  </form>
59
  </div>
60
  <div class="tidio-box tidio-box-george">
61
+ <h2><?php i18n::_e('Join 300 000+ websites using Tidio - Live Chat boosted with Bots');?></h2>
62
+ <p><?php i18n::_e('Increase sales by skyrocketing communication with customers.');?></p>
63
  <div class="tidio-box-george-image"></div>
64
  </div>
65
  </div>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: tytus-tytus, lucastidio, marcingwizdala, kkopaczyktidio
3
  Tags: free live chat, live chat, chat, chatbot, livechat, tidio, widget, zendesk, mailchimp, messenger
4
  Requires at least: 3.0
5
  Tested up to: 5.8
6
- Stable tag: 4.3.0
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -189,6 +189,11 @@ Currently, Tidio is available in English and French. Other languages are in deve
189
 
190
  == Changelog ==
191
 
 
 
 
 
 
192
  = 4.3.0 =
193
 
194
  - Add preconnect hint
3
  Tags: free live chat, live chat, chat, chatbot, livechat, tidio, widget, zendesk, mailchimp, messenger
4
  Requires at least: 3.0
5
  Tested up to: 5.8
6
+ Stable tag: 4.4.0
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
189
 
190
  == Changelog ==
191
 
192
+ = 4.4.0 =
193
+
194
+ - Add french, spanish and polish translations
195
+ - Display an error message when invalid credentials have been provided
196
+
197
  = 4.3.0 =
198
 
199
  - Add preconnect hint
tidio-elements.php CHANGED
@@ -4,19 +4,18 @@
4
  * Plugin Name: Tidio Chat
5
  * Plugin URI: http://www.tidio.com
6
  * Description: Tidio Live Chat - live chat boosted with chatbots for your online business. Integrates with your website in less than 20 seconds.
7
- * Version: 4.3.0
8
  * Author: Tidio Ltd.
9
  * Author URI: http://www.tidio.com
 
 
10
  * License: GPL2
11
  */
12
- define('TIDIOCHAT_VERSION', '4.3.0');
13
  define('AFFILIATE_CONFIG_FILE_PATH', get_template_directory().'/tidio_affiliate_ref_id.txt');
14
 
15
  class TidioLiveChat
16
  {
17
- const SCRIPT_URL = '//code.tidio.co/';
18
- const API_URL = 'https://api-v2.tidio.co';
19
- const CHAT_URL = 'https://www.tidio.com';
20
  const PUBLIC_KEY_OPTION = 'tidio-one-public-key';
21
  const PRIVATE_KEY_OPTION = 'tidio-one-private-key';
22
  const ASYNC_LOAD_OPTION = 'tidio-async-load';
@@ -33,6 +32,10 @@ class TidioLiveChat
33
  exit;
34
  }
35
 
 
 
 
 
36
  /* Before add link to menu - check is user trying to unninstal */
37
  if (is_admin() && current_user_can('activate_plugins') && !empty($_GET['tidio_one_clear_cache'])) {
38
  delete_option(TidioLiveChat::PUBLIC_KEY_OPTION);
@@ -53,6 +56,7 @@ class TidioLiveChat
53
  } else if (current_user_can('activate_plugins')) {
54
  add_action('admin_menu', array($this, 'addAdminMenuLink'));
55
  add_action('admin_enqueue_scripts', array($this, 'enqueueAdminScripts'));
 
56
 
57
  add_action('wp_ajax_tidio_chat_save_keys', array($this, 'ajaxTidioChatSaveKeys'));
58
  add_action('wp_ajax_set_project_keys', array($this, 'ajaxSetProjectKeys'));
@@ -65,6 +69,16 @@ class TidioLiveChat
65
  }
66
  }
67
 
 
 
 
 
 
 
 
 
 
 
68
  public static function activate()
69
  {
70
  update_option(TidioLiveChat::ASYNC_LOAD_OPTION, true);
@@ -178,12 +192,12 @@ class TidioLiveChat
178
  $parameters['ref_id'] = $refIdFromFile;
179
  }
180
  $accessUrlParameters = http_build_query($parameters);
181
- return TidioLiveChat::API_URL . '/access/external/create?'.$accessUrlParameters;
182
  }
183
 
184
  public static function getRedirectUrl($privateKey)
185
  {
186
- return TidioLiveChat::CHAT_URL . '/panel/external-access?' . http_build_query(
187
  array(
188
  'privateKey' => $privateKey,
189
  'utm_source' => 'platform',
@@ -202,12 +216,11 @@ class TidioLiveChat
202
  '_wpnonce' => wp_create_nonce(TidioLiveChat::CLEAR_ACCOUNT_DATA_ACTION),
203
  )
204
  );
205
- $links[] = '<a href="' . admin_url('admin-post.php') . '?' . $queryString . '">' . esc_html__('Clear Account Data',
206
- TidioLiveChat::TIDIO_PLUGIN_NAME) . '</a>';
207
 
208
  if (get_option(TidioLiveChat::ASYNC_LOAD_OPTION)) {
209
  $toggleAsyncLabel = '✓';
210
- $onclickPart = 'onclick="return confirm(\'Disabling asynchronous loading of the chat widget may affect the page loading time of your website. Are you sure you want to disable the asynchronous loading?\');"';
211
  } else {
212
  $toggleAsyncLabel = '✘';
213
  $onclickPart = '';
@@ -218,8 +231,7 @@ class TidioLiveChat
218
  '_wpnonce' => wp_create_nonce(TidioLiveChat::TOGGLE_ASYNC_ACTION),
219
  )
220
  );
221
- $links[] = '<a href="' . admin_url('admin-post.php') . '?' . $queryString . '" ' . $onclickPart . '>' . esc_html__($toggleAsyncLabel . ' Asynchronous loading',
222
- TidioLiveChat::TIDIO_PLUGIN_NAME) . '</a>';
223
  }
224
  }
225
 
@@ -252,7 +264,7 @@ class TidioLiveChat
252
  $options = array('http' => array('method' => 'POST'));
253
 
254
  $context = stream_context_create($options);
255
- @file_get_contents(TidioLiveChat::API_URL . '/access/connectWordpress?' . $query, false, $context);
256
 
257
  echo TidioLiveChat::getRedirectUrl($_POST['private_key']);
258
  exit();
@@ -284,7 +296,7 @@ class TidioLiveChat
284
  public function enqueueScriptsAsync()
285
  {
286
  $publicKey = TidioLiveChat::getPublicKey();
287
- $widgetUrl = TidioLiveChat::SCRIPT_URL . $publicKey . '.js';
288
  $asyncScript = <<<SRC
289
  <script type='text/javascript'>
290
  document.tidioChatCode = "$publicKey";
@@ -322,16 +334,23 @@ SRC;
322
 
323
  public function enqueueScriptsSync()
324
  {
325
- wp_enqueue_script('tidio-chat', TidioLiveChat::SCRIPT_URL . TidioLiveChat::getPublicKey() . '.js', array(),
326
  TIDIOCHAT_VERSION,
327
  true);
328
  wp_add_inline_script('tidio-chat', 'document.tidioChatCode = "' . TidioLiveChat::getPublicKey() . '";',
329
  'before');
330
  }
331
 
 
 
 
 
 
 
 
332
  public function enqueueAdminScripts()
333
  {
334
- wp_enqueue_script('tidio-chat-admin', plugins_url('media/js/options.js', __FILE__), array(), TIDIOCHAT_VERSION,
335
  true);
336
  wp_enqueue_style('tidio-chat-admin-style', plugins_url('media/css/options.css', __FILE__), array(),
337
  TIDIOCHAT_VERSION);
@@ -384,6 +403,50 @@ SRC;
384
  }
385
  }
386
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  add_action('init', 'initialize_tidio');
388
 
389
  function initialize_tidio()
@@ -392,3 +455,22 @@ function initialize_tidio()
392
  }
393
 
394
  register_activation_hook(__FILE__, array('TidioLiveChat', 'activate'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  * Plugin Name: Tidio Chat
5
  * Plugin URI: http://www.tidio.com
6
  * Description: Tidio Live Chat - live chat boosted with chatbots for your online business. Integrates with your website in less than 20 seconds.
7
+ * Version: 4.4.0
8
  * Author: Tidio Ltd.
9
  * Author URI: http://www.tidio.com
10
+ * Text Domain: tidio-live-chat
11
+ * Domain Path: /languages/
12
  * License: GPL2
13
  */
14
+ define('TIDIOCHAT_VERSION', '4.4.0');
15
  define('AFFILIATE_CONFIG_FILE_PATH', get_template_directory().'/tidio_affiliate_ref_id.txt');
16
 
17
  class TidioLiveChat
18
  {
 
 
 
19
  const PUBLIC_KEY_OPTION = 'tidio-one-public-key';
20
  const PRIVATE_KEY_OPTION = 'tidio-one-private-key';
21
  const ASYNC_LOAD_OPTION = 'tidio-async-load';
32
  exit;
33
  }
34
 
35
+ /* load plugin translations*/
36
+ add_filter('load_textdomain_mofile', [$this, 'loadTextDomain'], 10, 2);
37
+ load_plugin_textdomain(self::TIDIO_PLUGIN_NAME);
38
+
39
  /* Before add link to menu - check is user trying to unninstal */
40
  if (is_admin() && current_user_can('activate_plugins') && !empty($_GET['tidio_one_clear_cache'])) {
41
  delete_option(TidioLiveChat::PUBLIC_KEY_OPTION);
56
  } else if (current_user_can('activate_plugins')) {
57
  add_action('admin_menu', array($this, 'addAdminMenuLink'));
58
  add_action('admin_enqueue_scripts', array($this, 'enqueueAdminScripts'));
59
+ add_action('admin_enqueue_scripts', [$this, 'enqueueAdminScriptTranslation']);
60
 
61
  add_action('wp_ajax_tidio_chat_save_keys', array($this, 'ajaxTidioChatSaveKeys'));
62
  add_action('wp_ajax_set_project_keys', array($this, 'ajaxSetProjectKeys'));
69
  }
70
  }
71
 
72
+ public function loadTextDomain($mofile, $domain)
73
+ {
74
+ if ('tidio-live-chat' === $domain && false !== strpos($mofile, WP_LANG_DIR . '/plugins/')) {
75
+ $locale = apply_filters('plugin_locale', determine_locale(), $domain);
76
+ $mofile = WP_PLUGIN_DIR . '/' . dirname(plugin_basename(__FILE__)) . '/languages/' . $domain . '-' . $locale . '.mo';
77
+ }
78
+
79
+ return $mofile;
80
+ }
81
+
82
  public static function activate()
83
  {
84
  update_option(TidioLiveChat::ASYNC_LOAD_OPTION, true);
192
  $parameters['ref_id'] = $refIdFromFile;
193
  }
194
  $accessUrlParameters = http_build_query($parameters);
195
+ return TidioLiveChatConfig::getApiUrl() . '/access/external/create?'.$accessUrlParameters;
196
  }
197
 
198
  public static function getRedirectUrl($privateKey)
199
  {
200
+ return TidioLiveChatConfig::getPanelUrl() . '/panel/external-access?' . http_build_query(
201
  array(
202
  'privateKey' => $privateKey,
203
  'utm_source' => 'platform',
216
  '_wpnonce' => wp_create_nonce(TidioLiveChat::CLEAR_ACCOUNT_DATA_ACTION),
217
  )
218
  );
219
+ $links[] = '<a href="' . admin_url('admin-post.php') . '?' . $queryString . '">' . esc_html(i18n::_t('Clear Account Data')) . '</a>';
 
220
 
221
  if (get_option(TidioLiveChat::ASYNC_LOAD_OPTION)) {
222
  $toggleAsyncLabel = '✓';
223
+ $onclickPart = 'onclick="return confirm(\''.i18n::_t('Disabling asynchronous loading of the chat widget may affect the page loading time of your website. Are you sure you want to disable the asynchronous loading?').'\');"';
224
  } else {
225
  $toggleAsyncLabel = '✘';
226
  $onclickPart = '';
231
  '_wpnonce' => wp_create_nonce(TidioLiveChat::TOGGLE_ASYNC_ACTION),
232
  )
233
  );
234
+ $links[] = '<a href="' . admin_url('admin-post.php') . '?' . $queryString . '" ' . $onclickPart . '>' . esc_html($toggleAsyncLabel . ' ' . i18n::_t('Asynchronous loading')) . '</a>';
 
235
  }
236
  }
237
 
264
  $options = array('http' => array('method' => 'POST'));
265
 
266
  $context = stream_context_create($options);
267
+ @file_get_contents(TidioLiveChatConfig::getApiUrl() . '/access/connectWordpress?' . $query, false, $context);
268
 
269
  echo TidioLiveChat::getRedirectUrl($_POST['private_key']);
270
  exit();
296
  public function enqueueScriptsAsync()
297
  {
298
  $publicKey = TidioLiveChat::getPublicKey();
299
+ $widgetUrl = TidioLiveChatConfig::getWidgetUrl() . '/' . $publicKey . '.js';
300
  $asyncScript = <<<SRC
301
  <script type='text/javascript'>
302
  document.tidioChatCode = "$publicKey";
334
 
335
  public function enqueueScriptsSync()
336
  {
337
+ wp_enqueue_script('tidio-chat', TidioLiveChatConfig::getWidgetUrl() . '/' . TidioLiveChat::getPublicKey() . '.js', array(),
338
  TIDIOCHAT_VERSION,
339
  true);
340
  wp_add_inline_script('tidio-chat', 'document.tidioChatCode = "' . TidioLiveChat::getPublicKey() . '";',
341
  'before');
342
  }
343
 
344
+ public function enqueueAdminScriptTranslation()
345
+ {
346
+ $langDir = plugin_dir_path(__FILE__) . 'languages/js/';
347
+
348
+ wp_set_script_translations('tidio-chat-admin', 'tidio-live-chat', $langDir);
349
+ }
350
+
351
  public function enqueueAdminScripts()
352
  {
353
+ wp_enqueue_script('tidio-chat-admin', plugins_url('media/js/options.js', __FILE__), ['wp-i18n'], TIDIOCHAT_VERSION,
354
  true);
355
  wp_enqueue_style('tidio-chat-admin-style', plugins_url('media/css/options.css', __FILE__), array(),
356
  TIDIOCHAT_VERSION);
403
  }
404
  }
405
 
406
+ final class TidioLiveChatConfig
407
+ {
408
+ /**
409
+ * @var array|null
410
+ */
411
+ private static $config = null;
412
+
413
+ /**
414
+ * @return string
415
+ */
416
+ public static function getApiUrl()
417
+ {
418
+ return self::getConfig()['tidio_api_url'];
419
+ }
420
+
421
+ /**
422
+ * @return string
423
+ */
424
+ public static function getPanelUrl()
425
+ {
426
+ return self::getConfig()['tidio_panel_url'];
427
+ }
428
+
429
+ /**
430
+ * @return string
431
+ */
432
+ public static function getWidgetUrl()
433
+ {
434
+ return self::getConfig()['tidio_widget_url'];
435
+ }
436
+
437
+ /**
438
+ * @return array
439
+ */
440
+ private static function getConfig()
441
+ {
442
+ if (self::$config === null) {
443
+ self::$config = require __DIR__ . '/config.php';
444
+ }
445
+
446
+ return self::$config;
447
+ }
448
+ }
449
+
450
  add_action('init', 'initialize_tidio');
451
 
452
  function initialize_tidio()
455
  }
456
 
457
  register_activation_hook(__FILE__, array('TidioLiveChat', 'activate'));
458
+
459
+ class i18n
460
+ {
461
+ /**
462
+ * echo translation
463
+ */
464
+ public static function _e($message)
465
+ {
466
+ _e($message, TidioLiveChat::TIDIO_PLUGIN_NAME);
467
+ }
468
+
469
+ /**
470
+ * returns translation
471
+ */
472
+ public static function _t($message)
473
+ {
474
+ return __($message, TidioLiveChat::TIDIO_PLUGIN_NAME);
475
+ }
476
+ }