WP Live Chat Support - Version 9.0.22

Version Description

  • 2020-09-10 =
  • Fix dashboard online visitors / agents update.
  • Fix agent's status report.
  • Fix bug in 3CX Hosted Chat socket channel.
Download this release

Release Info

Developer wpdev3cx
Plugin Icon 128x128 WP Live Chat Support
Version 9.0.22
Comparing to
See all releases

Code changes from version 9.0.21 to 9.0.22

ajax/agent.php CHANGED
@@ -13,6 +13,7 @@ add_action( 'wp_ajax_wplc_admin_send_msg', 'wplc_admin_send_msg' );
13
  add_action( 'wp_ajax_wplc_admin_upload_file', 'wplc_admin_upload_file' );
14
  add_action( 'wp_ajax_wplc_admin_close_chat', 'wplc_admin_close_chat' );
15
  add_action( 'wp_ajax_wplc_choose_accepting', 'wplc_set_agent_accepting' );
 
16
 
17
 
18
  function wplc_get_chat_info() {
@@ -514,3 +515,13 @@ function wplc_set_agent_accepting() {
514
  die( TCXChatAjaxResponse::success_ajax_respose( $result ) );
515
  }
516
 
 
 
 
 
 
 
 
 
 
 
13
  add_action( 'wp_ajax_wplc_admin_upload_file', 'wplc_admin_upload_file' );
14
  add_action( 'wp_ajax_wplc_admin_close_chat', 'wplc_admin_close_chat' );
15
  add_action( 'wp_ajax_wplc_choose_accepting', 'wplc_set_agent_accepting' );
16
+ add_action('wp_ajax_wplc_keep_alive','wplc_keep_alive');
17
 
18
 
19
  function wplc_get_chat_info() {
515
  die( TCXChatAjaxResponse::success_ajax_respose( $result ) );
516
  }
517
 
518
+ function wplc_keep_alive(){
519
+ $agent_id = wplc_validate_agent_call();
520
+ if ( $agent_id>=0 ) {
521
+ TCXAgentsHelper::update_agent_time($agent_id);
522
+ die( TCXChatAjaxResponse::success_ajax_respose( $agent_id ) );
523
+ }else{
524
+ die( TCXChatAjaxResponse::error_ajax_respose( "Not an agent." ) );
525
+ }
526
+ }
527
+
changelog.txt CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  = 9.0.21 - 2020-09-09 =
2
  * Added chat pop out functionality.
3
  * UI optimization for mobile devices.
1
+ = 9.0.22 - 2020-09-10 =
2
+ * Fix dashboard online visitors / agents update.
3
+ * Fix agent's status report.
4
+ * Fix bug in 3CX Hosted Chat socket channel.
5
+
6
  = 9.0.21 - 2020-09-09 =
7
  * Added chat pop out functionality.
8
  * UI optimization for mobile devices.
config.php CHANGED
@@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
9
 
10
  define('WPLC_MIN_WP_VERSION', "5.3");
11
  define('WPLC_MIN_PHP_VERSION', "5.4");
12
- define('WPLC_PLUGIN_VERSION', "9.0.21");
13
  define('WPLC_PLUGIN_DIR', dirname(__FILE__));
14
  define('WPLC_PLUGIN_URL', wplc_plugins_url( '/', __FILE__ ) );
15
  define('WPLC_PLUGIN', plugin_basename( __FILE__ ) );
9
 
10
  define('WPLC_MIN_WP_VERSION', "5.3");
11
  define('WPLC_MIN_PHP_VERSION', "5.4");
12
+ define('WPLC_PLUGIN_VERSION', "9.0.22");
13
  define('WPLC_PLUGIN_DIR', dirname(__FILE__));
14
  define('WPLC_PLUGIN_URL', wplc_plugins_url( '/', __FILE__ ) );
15
  define('WPLC_PLUGIN', plugin_basename( __FILE__ ) );
css/vendor/bootstrap/{wplc_bootstrap_9_0_21.css → wplc_bootstrap_9_0_22.css} RENAMED
File without changes
includes/wplc_activator.php CHANGED
@@ -35,6 +35,7 @@ function wplc_activate( $plugin_file ) {
35
  */
36
  function wplc_choose_deactivate() {
37
  TCXAgentsHelper::set_agent_accepting( get_current_user_id(), false );
 
38
  wplc_cron_job_delete();
39
  }
40
 
35
  */
36
  function wplc_choose_deactivate() {
37
  TCXAgentsHelper::set_agent_accepting( get_current_user_id(), false );
38
+ wplc_check_guid( true,true );
39
  wplc_cron_job_delete();
40
  }
41
 
includes/wplc_crons.php CHANGED
@@ -55,15 +55,10 @@ function wplc_schedule_get_mcu_data() {
55
  function wplc_cron_update_chats() {
56
  global $wpdb;
57
  $chats = TCXChatData::get_incomplete_chats( $wpdb, - 1, array(
58
- ChatStatus::MISSED,
59
  ChatStatus::OLD_ENDED,
60
  ChatStatus::PENDING_AGENT,
61
  ChatStatus::ACTIVE,
62
  ChatStatus::NOT_STARTED,
63
- ChatStatus::ENDED_BY_AGENT,
64
- ChatStatus::ENDED_BY_CLIENT,
65
- ChatStatus::ENDED_DUE_AGENT_INACTIVITY,
66
- ChatStatus::ENDED_DUE_CLIENT_INACTIVITY
67
  ) );
68
  TCXChatHelper::update_chat_statuses( $chats, false );
69
  }
55
  function wplc_cron_update_chats() {
56
  global $wpdb;
57
  $chats = TCXChatData::get_incomplete_chats( $wpdb, - 1, array(
 
58
  ChatStatus::OLD_ENDED,
59
  ChatStatus::PENDING_AGENT,
60
  ChatStatus::ACTIVE,
61
  ChatStatus::NOT_STARTED,
 
 
 
 
62
  ) );
63
  TCXChatHelper::update_chat_statuses( $chats, false );
64
  }
js/wplc_initiate.js CHANGED
@@ -3,6 +3,7 @@ var current_locale = admin_localization_data.locale;
3
  jQuery(document).ready(function () {
4
  wplc_showLoader('windowload');
5
  wplc_init_heartbeat();
 
6
  wplc_setup_checkboxes();
7
  wplc_setup_agent_online_switch();
8
 
@@ -102,6 +103,13 @@ function wplc_init_heartbeat() {
102
  });
103
  }
104
 
 
 
 
 
 
 
 
105
  function wplc_desktop_notification() {
106
  if (typeof Notification !== 'undefined') {
107
  if (!Notification) {
@@ -183,6 +191,18 @@ function wplc_set_agent_accepting_call(is_online) {
183
  });
184
  }
185
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  function wplc_update_topbar_agent_list(agents) {
187
  jQuery("#wplc_ma_online_agents_count").text(agents.length);
188
  var agents_drop_down_element = jQuery('#wp-admin-bar-wplc_ma_online_agents-default');
3
  jQuery(document).ready(function () {
4
  wplc_showLoader('windowload');
5
  wplc_init_heartbeat();
6
+ wplc_init_keep_alive();
7
  wplc_setup_checkboxes();
8
  wplc_setup_agent_online_switch();
9
 
103
  });
104
  }
105
 
106
+ function wplc_init_keep_alive(){
107
+ setInterval(()=>{
108
+ console.log("Keep me alive");
109
+ wplc_keep_alive_call();
110
+ },5*60*1000)//
111
+ }
112
+
113
  function wplc_desktop_notification() {
114
  if (typeof Notification !== 'undefined') {
115
  if (!Notification) {
191
  });
192
  }
193
 
194
+ function wplc_keep_alive_call() {
195
+ var data = {
196
+ action: 'wplc_keep_alive',
197
+ security: admin_localization_data.nonce
198
+ };
199
+ return jQuery.ajax({
200
+ url: admin_localization_data.wplc_ajaxurl,
201
+ data: data,
202
+ type: "POST"
203
+ });
204
+ }
205
+
206
  function wplc_update_topbar_agent_list(agents) {
207
  jQuery("#wplc_ma_online_agents_count").text(agents.length);
208
  var agents_drop_down_element = jQuery('#wp-admin-bar-wplc_ma_online_agents-default');
modules/agent_chat/js/mcu_websocket.js CHANGED
@@ -2,9 +2,10 @@ var socket;
2
  var clientId;
3
  var sessionId;
4
  var socketTimeout;
 
5
 
6
  jQuery(function () {
7
-
8
  jQuery("body").on('mcu-setup-socket', function (e) {
9
  wplc_setupSocket();
10
  });
@@ -66,14 +67,22 @@ function wplc_socketEventsSetup() {
66
  }
67
 
68
  socket.onerror = function (error) {
69
- if (socketTimeout === null || typeof socketTimeout === 'undefined') {
70
  socketTimeout = setTimeout(wplc_setupSocket, 5000);
 
 
 
 
71
  }
72
  }
73
 
74
  socket.onclose = function (event) {
75
- if (event.code != 1000 && (socketTimeout === null || typeof socketTimeout === 'undefined')) {
76
  socketTimeout = setTimeout(wplc_setupSocket, 5000);
 
 
 
 
77
  }
78
  };
79
 
@@ -145,13 +154,7 @@ function wplc_socketEventsSetup() {
145
 
146
  }
147
  } else if (data.notification == 'InvalidLogin' && localization_data.wplc_is_chat_page) {
148
- var url = window.location.href;
149
- if (url.indexOf('?') > -1){
150
- url += '&wplc_action=invalid_login'
151
- }else{
152
- url += '?wplc_action=invalid_login'
153
- }
154
- window.location.href = url;
155
  } else if (data.notification == 'AgentAlreadyJoined')
156
  {
157
  alert("Another agent already joined this chat session.")
@@ -285,6 +288,16 @@ function wplc_closeConnection() {
285
  }
286
  }
287
 
 
 
 
 
 
 
 
 
 
 
288
  var IdGenerator = (function () {
289
  var currentID = -1;
290
 
2
  var clientId;
3
  var sessionId;
4
  var socketTimeout;
5
+ var connectionTriesCount;
6
 
7
  jQuery(function () {
8
+ connectionTriesCount = 0;
9
  jQuery("body").on('mcu-setup-socket', function (e) {
10
  wplc_setupSocket();
11
  });
67
  }
68
 
69
  socket.onerror = function (error) {
70
+ if (connectionTriesCount<5 && (socketTimeout === null || typeof socketTimeout === 'undefined')) {
71
  socketTimeout = setTimeout(wplc_setupSocket, 5000);
72
+ connectionTriesCount++;
73
+ }else if(connectionTriesCount>=5)
74
+ {
75
+ wplc_force_reload_mcu_data();
76
  }
77
  }
78
 
79
  socket.onclose = function (event) {
80
+ if (connectionTriesCount<5 && event.code != 1000 && (socketTimeout === null || typeof socketTimeout === 'undefined')) {
81
  socketTimeout = setTimeout(wplc_setupSocket, 5000);
82
+ connectionTriesCount++;
83
+ }else if(connectionTriesCount>=5)
84
+ {
85
+ wplc_force_reload_mcu_data();
86
  }
87
  };
88
 
154
 
155
  }
156
  } else if (data.notification == 'InvalidLogin' && localization_data.wplc_is_chat_page) {
157
+ wplc_force_reload_mcu_data();
 
 
 
 
 
 
158
  } else if (data.notification == 'AgentAlreadyJoined')
159
  {
160
  alert("Another agent already joined this chat session.")
288
  }
289
  }
290
 
291
+ function wplc_force_reload_mcu_data() {
292
+ var url = window.location.href;
293
+ if (url.indexOf('?') > -1) {
294
+ url += '&wplc_action=invalid_login'
295
+ } else {
296
+ url += '?wplc_action=invalid_login'
297
+ }
298
+ window.location.href = url;
299
+ }
300
+
301
  var IdGenerator = (function () {
302
  var currentID = -1;
303
 
modules/dashboard/dashboard_view.php CHANGED
@@ -15,7 +15,7 @@
15
  <i class="fas fa-users"></i>
16
  </div>
17
  <div class="wplc_dashboard_activity_current_data">
18
- <span><?= $online_visitors ?></span><br/>
19
  ACTIVE USERS
20
  </div>
21
  <i class="fa fa-caret-down"></i>
@@ -25,7 +25,7 @@
25
  <img src="<?= wplc_protocol_agnostic_url( WPLC_PLUGIN_URL . '/images/svgs/new_agent_ic.svg' ); ?>">
26
  </div>
27
  <div class="wplc_dashboard_activity_current_data">
28
- <span><?= $online_users ?></span><br/>
29
  ACTIVE AGENTS
30
  </div>
31
  <i class="fa fa-caret-up"></i>
15
  <i class="fas fa-users"></i>
16
  </div>
17
  <div class="wplc_dashboard_activity_current_data">
18
+ <span id ="wplc_online_visitors" ><?= $online_visitors ?></span><br/>
19
  ACTIVE USERS
20
  </div>
21
  <i class="fa fa-caret-down"></i>
25
  <img src="<?= wplc_protocol_agnostic_url( WPLC_PLUGIN_URL . '/images/svgs/new_agent_ic.svg' ); ?>">
26
  </div>
27
  <div class="wplc_dashboard_activity_current_data">
28
+ <span id="wplc_online_agents"><?= $online_users ?></span><br/>
29
  ACTIVE AGENTS
30
  </div>
31
  <i class="fa fa-caret-up"></i>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: live chat, live support, chat plugin, live help, wordpress live chat, chat
4
  Requires at least: 5.3
5
  Tested up to: 5.5
6
  Requires PHP: 5.4
7
- Stable tag: 9.0.21
8
  License: GPLv2
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
  Text Domain: wp-live-chat-support
@@ -159,6 +159,11 @@ If the live chat box still does not appear on your website, please go through th
159
  Huge update with over 300 changes that include: Bugfixes, Vulnerability Fixes & Plugin Security, Plugin Optimization & Rebranding Updates. We suggest you remove any existing installations of this plugin and install 8.1.x fresh.
160
 
161
  == Changelog ==
 
 
 
 
 
162
  = 9.0.21 - 2020-09-09 =
163
  * Added chat pop out to new window functionality.
164
  * UI optimization for mobile devices.
4
  Requires at least: 5.3
5
  Tested up to: 5.5
6
  Requires PHP: 5.4
7
+ Stable tag: 9.0.22
8
  License: GPLv2
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
  Text Domain: wp-live-chat-support
159
  Huge update with over 300 changes that include: Bugfixes, Vulnerability Fixes & Plugin Security, Plugin Optimization & Rebranding Updates. We suggest you remove any existing installations of this plugin and install 8.1.x fresh.
160
 
161
  == Changelog ==
162
+ = 9.0.22 - 2020-09-10 =
163
+ * Fix dashboard online visitors / agents update.
164
+ * Fix agent's status report.
165
+ * Fix bug in 3CX Hosted Chat socket channel.
166
+
167
  = 9.0.21 - 2020-09-09 =
168
  * Added chat pop out to new window functionality.
169
  * UI optimization for mobile devices.
wp-live-chat-support.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-Live Chat by 3CX
4
  Plugin URI: https://www.3cx.com/wp-live-chat/
5
  Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP-Live Chat by 3CX.
6
- Version: 9.0.21
7
  Author: 3CX
8
  Author URI: https://www.3cx.com/wp-live-chat/
9
  Domain Path: /languages
@@ -76,13 +76,13 @@ register_uninstall_hook( __FILE__, 'wplc_uninstall' );
76
  function wplc_check_compatibility() {
77
  global $wplc_error;
78
  $compatible = wplc_check_version_compatibility();
79
- if ( ! $compatible->php || ! $compatible->wp || !$compatible->ie ) {
80
  wp_register_style( "wplc-bootstrap", admin_url( '/admin.php?wplc_action=loadbootstrap', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
81
  wp_enqueue_style( "wplc-bootstrap" );
82
  $wplc_error = new stdClass();
83
  $wplc_error->Title = __( "Incompatible Environment", "wp-live-chat-support" );
84
  $wplc_error->Message = ! $compatible->php ? __( "Your PHP version is lower than required.", "wp-live-chat-support" ) . "<br/>" : "";
85
- $wplc_error->Message = $wplc_error->Message . ( ! $compatible->wp ? __( "Your Wordpress version is lower than required.", "wp-live-chat-support" ) . "<br/>" : "");
86
  $wplc_error->Message = $wplc_error->Message . ( ! $compatible->ie ? __( "Internet Explorer is not compatible with WP-Live Chat by 3CX plugin.", "wp-live-chat-support" ) : "" );
87
  $wplc_error->HtmlContent = "";
88
  }
@@ -105,6 +105,7 @@ function wplc_uninstall() {
105
 
106
  $wplc_settings = TCXSettings::getSettings();
107
  wplc_cron_job_delete();
 
108
  if ( $wplc_settings->wplc_delete_db_on_uninstall ) {
109
  $options = array(
110
  'WPLC_ACBC_SETTINGS',
@@ -203,7 +204,7 @@ function wplc_uninstall() {
203
  delete_user_meta( $user->ID, 'wplc_user_department' );
204
  delete_user_meta( $user->ID, 'wplc_ma_agent' );
205
  delete_user_meta( $user->ID, 'wplc_user_tagline' );
206
- $user->remove_cap('wplc_ma_agent');
207
  if ( ! in_array( 'administrator', (array) $user->roles ) ) {
208
  $user->remove_cap( 'wplc_cap_show_history' );
209
  $user->remove_cap( 'wplc_cap_show_offline' );
@@ -256,7 +257,7 @@ function wplc_parameter_bool( $settings, $name ) {
256
  return $param;
257
  }
258
 
259
- function wplc_check_guid( $force_update = false ) {
260
  $guid = get_option( 'WPLC_GUID' );
261
  $guid_fqdn = get_option( 'WPLC_GUID_URL' );
262
  $guid_lastcheck = intval( get_option( 'WPLC_GUID_CHECK' ) );
@@ -284,11 +285,12 @@ function wplc_check_guid( $force_update = false ) {
284
  $data_array = array(
285
  'method' => 'POST',
286
  'body' => array(
287
- 'method' => 'get_guid',
288
- 'url' => get_option( 'siteurl' ),
289
- 'server' => $server,
290
- 'gdpr' => $gdpr,
291
- 'version' => WPLC_PLUGIN_VERSION
 
292
  )
293
  );
294
  $response = wp_remote_post( WPLC_ACTIVATION_SERVER . '/api/v1', $data_array );
@@ -360,7 +362,7 @@ function wplc_check_version_compatibility() {
360
  $result->php = false;
361
  }
362
 
363
- if(array_key_exists('HTTP_USER_AGENT',$_SERVER)) {
364
  $ua = htmlentities( $_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, 'UTF-8' );
365
  if ( preg_match( '~MSIE|Internet Explorer~i', $ua ) || ( strpos( $ua, 'Trident/7.0' ) !== false && strpos( $ua, 'rv:11.0' ) !== false ) ) {
366
  $result->ie = false;
3
  Plugin Name: WP-Live Chat by 3CX
4
  Plugin URI: https://www.3cx.com/wp-live-chat/
5
  Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP-Live Chat by 3CX.
6
+ Version: 9.0.22
7
  Author: 3CX
8
  Author URI: https://www.3cx.com/wp-live-chat/
9
  Domain Path: /languages
76
  function wplc_check_compatibility() {
77
  global $wplc_error;
78
  $compatible = wplc_check_version_compatibility();
79
+ if ( ! $compatible->php || ! $compatible->wp || ! $compatible->ie ) {
80
  wp_register_style( "wplc-bootstrap", admin_url( '/admin.php?wplc_action=loadbootstrap', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
81
  wp_enqueue_style( "wplc-bootstrap" );
82
  $wplc_error = new stdClass();
83
  $wplc_error->Title = __( "Incompatible Environment", "wp-live-chat-support" );
84
  $wplc_error->Message = ! $compatible->php ? __( "Your PHP version is lower than required.", "wp-live-chat-support" ) . "<br/>" : "";
85
+ $wplc_error->Message = $wplc_error->Message . ( ! $compatible->wp ? __( "Your Wordpress version is lower than required.", "wp-live-chat-support" ) . "<br/>" : "" );
86
  $wplc_error->Message = $wplc_error->Message . ( ! $compatible->ie ? __( "Internet Explorer is not compatible with WP-Live Chat by 3CX plugin.", "wp-live-chat-support" ) : "" );
87
  $wplc_error->HtmlContent = "";
88
  }
105
 
106
  $wplc_settings = TCXSettings::getSettings();
107
  wplc_cron_job_delete();
108
+ wplc_check_guid( true, true );
109
  if ( $wplc_settings->wplc_delete_db_on_uninstall ) {
110
  $options = array(
111
  'WPLC_ACBC_SETTINGS',
204
  delete_user_meta( $user->ID, 'wplc_user_department' );
205
  delete_user_meta( $user->ID, 'wplc_ma_agent' );
206
  delete_user_meta( $user->ID, 'wplc_user_tagline' );
207
+ $user->remove_cap( 'wplc_ma_agent' );
208
  if ( ! in_array( 'administrator', (array) $user->roles ) ) {
209
  $user->remove_cap( 'wplc_cap_show_history' );
210
  $user->remove_cap( 'wplc_cap_show_offline' );
257
  return $param;
258
  }
259
 
260
+ function wplc_check_guid( $force_update = false, $uninstall = false ) {
261
  $guid = get_option( 'WPLC_GUID' );
262
  $guid_fqdn = get_option( 'WPLC_GUID_URL' );
263
  $guid_lastcheck = intval( get_option( 'WPLC_GUID_CHECK' ) );
285
  $data_array = array(
286
  'method' => 'POST',
287
  'body' => array(
288
+ 'method' => 'get_guid',
289
+ 'url' => get_option( 'siteurl' ),
290
+ 'server' => $server,
291
+ 'gdpr' => $gdpr,
292
+ 'version' => WPLC_PLUGIN_VERSION,
293
+ 'uninstall' => $uninstall ? 1 : 0
294
  )
295
  );
296
  $response = wp_remote_post( WPLC_ACTIVATION_SERVER . '/api/v1', $data_array );
362
  $result->php = false;
363
  }
364
 
365
+ if ( array_key_exists( 'HTTP_USER_AGENT', $_SERVER ) ) {
366
  $ua = htmlentities( $_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, 'UTF-8' );
367
  if ( preg_match( '~MSIE|Internet Explorer~i', $ua ) || ( strpos( $ua, 'Trident/7.0' ) !== false && strpos( $ua, 'rv:11.0' ) !== false ) ) {
368
  $result->ie = false;