Tidio Live Chat - Version 4.1.0

Version Description

  • Simplify login flow for users with only one project
  • Set widget as installed immediately after user connected project
Download this release

Release Info

Developer lucastidio
Plugin Icon 128x128 Tidio Live Chat
Version 4.1.0
Comparing to
See all releases

Code changes from version 4.0.1 to 4.1.0

Files changed (5) hide show
  1. media/css/options.css +6 -6
  2. media/js/options.js +20 -11
  3. options.php +3 -3
  4. readme.txt +5 -1
  5. tidio-elements.php +15 -4
media/css/options.css CHANGED
@@ -56,7 +56,7 @@
56
  max-width: 360px;
57
  }
58
 
59
- .tidio-box-advert {
60
  text-align: center;
61
  position: relative;
62
  padding-bottom: 324px;
@@ -74,7 +74,7 @@
74
  background-repeat: no-repeat;
75
  }
76
 
77
- .tidio-box-advert h2, .tidio-box-actions h1 {
78
  font-size: 24px;
79
  line-height: 34px;
80
  font-weight: bold;
@@ -96,7 +96,7 @@
96
  margin: 0;
97
  }
98
 
99
- .tidio-box-advert-image {
100
  position: absolute;
101
  left: 0;
102
  right: 0;
@@ -209,7 +209,7 @@
209
  margin-top: 44px;
210
  }
211
 
212
- .tidio-box-advert h2 {
213
  margin-top: 24px;
214
  }
215
  }
@@ -228,7 +228,7 @@
228
  background-position: top left;
229
  }
230
 
231
- .tidio-box-advert h2 {
232
  margin-top: 32px;
233
  }
234
 
@@ -236,7 +236,7 @@
236
  align-items: flex-start;
237
  }
238
 
239
- .tidio-box-advert {
240
  flex-basis: 680px;
241
  }
242
  }
56
  max-width: 360px;
57
  }
58
 
59
+ .tidio-box-george {
60
  text-align: center;
61
  position: relative;
62
  padding-bottom: 324px;
74
  background-repeat: no-repeat;
75
  }
76
 
77
+ .tidio-box-george h2, .tidio-box-actions h1 {
78
  font-size: 24px;
79
  line-height: 34px;
80
  font-weight: bold;
96
  margin: 0;
97
  }
98
 
99
+ .tidio-box-george-image {
100
  position: absolute;
101
  left: 0;
102
  right: 0;
209
  margin-top: 44px;
210
  }
211
 
212
+ .tidio-box-george h2 {
213
  margin-top: 24px;
214
  }
215
  }
228
  background-position: top left;
229
  }
230
 
231
+ .tidio-box-george h2 {
232
  margin-top: 32px;
233
  }
234
 
236
  align-items: flex-start;
237
  }
238
 
239
+ .tidio-box-george {
240
  flex-basis: 680px;
241
  }
242
  }
media/js/options.js CHANGED
@@ -74,8 +74,8 @@ jQuery(function ($) {
74
  this.showError('Email is invalid!');
75
  return false;
76
  }
77
- if (passwordField.is(':invalid')) {
78
- this.showError('Password must be at least 6 characters long!');
79
  return false;
80
  }
81
  this.hideError();
@@ -130,6 +130,10 @@ jQuery(function ($) {
130
  var defaultOption = select_project.children()[0];
131
  select_project.children().remove();
132
  select_project.append(defaultOption);
 
 
 
 
133
  for (var i in data.value) {
134
  var project = data.value[i];
135
  var value = {
@@ -139,7 +143,7 @@ jQuery(function ($) {
139
  };
140
 
141
  var option = $(
142
- '<option value="' + project.id + '">' + project.name +
143
  '</option>');
144
  option.data('value', value);
145
  select_project.append(option);
@@ -151,19 +155,24 @@ jQuery(function ($) {
151
  $.get(TidioChatWP.apiUrl + '/project', {
152
  api_token: token,
153
  }, (function (response) {
154
- this.form.hide();
155
- this.form = $('#tidio-project');
156
- this.form.show();
157
- this.renderProjects(response);
158
- this.form.off().submit(this.onProjectSubmit.bind(this));
159
- var startOver = $('#start-over');
160
- startOver.click(this.startOver.bind(this));
 
 
 
 
 
161
  }).bind(this), 'json');
162
  },
163
  onProjectSubmit: function () {
164
  var details = $('#select-tidio-project option:selected').
165
  data('value');
166
- $.extend(details, { 'action': 'get_project_keys' });
167
  $.post(ajaxurl, details, (function (response) {
168
  window.open(response, '_blank');
169
  TidioChatWP.setRedirectLink(response);
74
  this.showError('Email is invalid!');
75
  return false;
76
  }
77
+ if (passwordField.val() === '') {
78
+ this.showError('Password can’t be empty!');
79
  return false;
80
  }
81
  this.hideError();
130
  var defaultOption = select_project.children()[0];
131
  select_project.children().remove();
132
  select_project.append(defaultOption);
133
+ var selected = false;
134
+ if (data.value.length === 1) {
135
+ selected = true;
136
+ }
137
  for (var i in data.value) {
138
  var project = data.value[i];
139
  var value = {
143
  };
144
 
145
  var option = $(
146
+ '<option value="' + project.id + '" ' + (selected ? 'selected="selected"' : '') + '>' + project.name +
147
  '</option>');
148
  option.data('value', value);
149
  select_project.append(option);
155
  $.get(TidioChatWP.apiUrl + '/project', {
156
  api_token: token,
157
  }, (function (response) {
158
+ if (response.value.length === 1) {
159
+ this.renderProjects(response);
160
+ this.onProjectSubmit();
161
+ } else {
162
+ this.form.hide();
163
+ this.form = $('#tidio-project');
164
+ this.form.show();
165
+ this.renderProjects(response);
166
+ this.form.off().submit(this.onProjectSubmit.bind(this));
167
+ var startOver = $('#start-over');
168
+ startOver.click(this.startOver.bind(this));
169
+ }
170
  }).bind(this), 'json');
171
  },
172
  onProjectSubmit: function () {
173
  var details = $('#select-tidio-project option:selected').
174
  data('value');
175
+ $.extend(details, { 'action': 'set_project_keys', 'api_token': TidioChatWP.token });
176
  $.post(ajaxurl, details, (function (response) {
177
  window.open(response, '_blank');
178
  TidioChatWP.setRedirectLink(response);
options.php CHANGED
@@ -24,7 +24,7 @@
24
 
25
  <label>
26
  Password
27
- <input type="password" id="password" minlength="6" required placeholder="Type your password&hellip;"/>
28
  </label>
29
 
30
  <div class="error"></div>
@@ -52,10 +52,10 @@
52
  <a href="#" id="open-panel-link" class="button" target="_blank">Go to Panel</a>
53
  </form>
54
  </div>
55
- <div class="tidio-box tidio-box-advert">
56
  <h2>Join 300 000+ websites using Tidio - Live Chat boosted with Bots</h2>
57
  <p>Increase sales by skyrocketing communication with customers.</p>
58
- <div class="tidio-box-advert-image"></div>
59
  </div>
60
  </div>
61
  </div>
24
 
25
  <label>
26
  Password
27
+ <input type="password" id="password" placeholder="Type your password&hellip;" required/>
28
  </label>
29
 
30
  <div class="error"></div>
52
  <a href="#" id="open-panel-link" class="button" target="_blank">Go to Panel</a>
53
  </form>
54
  </div>
55
+ <div class="tidio-box tidio-box-george">
56
  <h2>Join 300 000+ websites using Tidio - Live Chat boosted with Bots</h2>
57
  <p>Increase sales by skyrocketing communication with customers.</p>
58
+ <div class="tidio-box-george-image"></div>
59
  </div>
60
  </div>
61
  </div>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: tytus-tytus, lucastidio, marcingwizdala
3
  Tags: free live chat, plugin, facebook, admin, live chat, chat, livechat, post, tidio, widget, post, posts, twitter, zendesk, mailchimp
4
  Requires at least: 3.0
5
  Tested up to: 5.2
6
- Stable tag: trunk
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -121,6 +121,10 @@ Yes, simply go to your chat panel and switch the “Display” option to off.
121
 
122
  == Changelog ==
123
 
 
 
 
 
124
  = 4.0.1 =
125
  * Fix saving project data after creating new project
126
 
3
  Tags: free live chat, plugin, facebook, admin, live chat, chat, livechat, post, tidio, widget, post, posts, twitter, zendesk, mailchimp
4
  Requires at least: 3.0
5
  Tested up to: 5.2
6
+ Stable tag: 4.1.0
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
121
 
122
  == Changelog ==
123
 
124
+ = 4.1.0 =
125
+ * Simplify login flow for users with only one project
126
+ * Set widget as installed immediately after user connected project
127
+
128
  = 4.0.1 =
129
  * Fix saving project data after creating new project
130
 
tidio-elements.php CHANGED
@@ -4,12 +4,12 @@
4
  * Plugin Name: Tidio Chat
5
  * Plugin URI: http://www.tidiochat.com
6
  * Description: Tidio Live Chat - Live chat for your website. No logging in, no signing up - integrates with your website in less than 20 seconds.
7
- * Version: 4.0.1
8
  * Author: Tidio Ltd.
9
  * Author URI: http://www.tidiochat.com
10
  * License: GPL2
11
  */
12
- define('TIDIOCHAT_VERSION', '4.0.1');
13
  define('AFFILIATE_CONFIG_FILE_PATH', get_template_directory().'/tidio_affiliate_ref_id.txt');
14
 
15
  class TidioLiveChat
@@ -52,7 +52,7 @@ class TidioLiveChat
52
  add_action('admin_enqueue_scripts', array($this, 'enqueueAdminScripts'));
53
 
54
  add_action('wp_ajax_tidio_chat_save_keys', array($this, 'ajaxTidioChatSaveKeys'));
55
- add_action('wp_ajax_get_project_keys', array($this, 'ajaxGetProjectKeys'));
56
  add_action('wp_ajax_get_private_key', array($this, 'ajaxGetPrivateKey'));
57
 
58
  add_action('admin_post_' . TidioLiveChat::CLEAR_ACCOUNT_DATA_ACTION . '', array($this, 'uninstall'));
@@ -216,10 +216,21 @@ class TidioLiveChat
216
  die();
217
  }
218
 
219
- public function ajaxGetProjectKeys()
220
  {
221
  update_option(TidioLiveChat::PUBLIC_KEY_OPTION, $_POST['public_key']);
222
  update_option(TidioLiveChat::PRIVATE_KEY_OPTION, $_POST['private_key']);
 
 
 
 
 
 
 
 
 
 
 
223
  echo TidioLiveChat::getRedirectUrl($_POST['private_key']);
224
  exit();
225
  }
4
  * Plugin Name: Tidio Chat
5
  * Plugin URI: http://www.tidiochat.com
6
  * Description: Tidio Live Chat - Live chat for your website. No logging in, no signing up - integrates with your website in less than 20 seconds.
7
+ * Version: 4.1.0
8
  * Author: Tidio Ltd.
9
  * Author URI: http://www.tidiochat.com
10
  * License: GPL2
11
  */
12
+ define('TIDIOCHAT_VERSION', '4.1.0');
13
  define('AFFILIATE_CONFIG_FILE_PATH', get_template_directory().'/tidio_affiliate_ref_id.txt');
14
 
15
  class TidioLiveChat
52
  add_action('admin_enqueue_scripts', array($this, 'enqueueAdminScripts'));
53
 
54
  add_action('wp_ajax_tidio_chat_save_keys', array($this, 'ajaxTidioChatSaveKeys'));
55
+ add_action('wp_ajax_set_project_keys', array($this, 'ajaxSetProjectKeys'));
56
  add_action('wp_ajax_get_private_key', array($this, 'ajaxGetPrivateKey'));
57
 
58
  add_action('admin_post_' . TidioLiveChat::CLEAR_ACCOUNT_DATA_ACTION . '', array($this, 'uninstall'));
216
  die();
217
  }
218
 
219
+ public function ajaxSetProjectKeys()
220
  {
221
  update_option(TidioLiveChat::PUBLIC_KEY_OPTION, $_POST['public_key']);
222
  update_option(TidioLiveChat::PRIVATE_KEY_OPTION, $_POST['private_key']);
223
+
224
+ $query = http_build_query(array(
225
+ 'api_token' => $_POST['api_token'],
226
+ 'project_public_key' => $_POST['public_key']
227
+ ));
228
+
229
+ $options = array('http' => array('method' => 'POST'));
230
+
231
+ $context = stream_context_create($options);
232
+ @file_get_contents(TidioLiveChat::API_URL . '/access/connectWordpress?' . $query, false, $context);
233
+
234
  echo TidioLiveChat::getRedirectUrl($_POST['private_key']);
235
  exit();
236
  }