WP Live Chat Support - Version 2.5

Version Description

  • Major performance improvements
  • Small UI improvements
Download this release

Release Info

Developer WP-LiveChat
Plugin Icon 128x128 WP Live Chat Support
Version 2.5
Comparing to
See all releases

Code changes from version 2.4 to 2.5

Files changed (6) hide show
  1. ajax.php +201 -0
  2. ding.mp3 +0 -0
  3. functions.php +467 -0
  4. js/wplc_u.js +7 -7
  5. readme.txt +9 -1
  6. wp-live-chat-support.php +74 -584
ajax.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ ini_set('html_errors', 0);
4
+ define('SHORTINIT', true);
5
+
6
+
7
+ $absolute_path = __FILE__;
8
+
9
+ $path_to_file = explode( 'wp-content', $absolute_path );
10
+
11
+ $path_to_wp = $path_to_file[0];
12
+
13
+
14
+
15
+ require_once( $path_to_wp.'/wp-load.php' );
16
+
17
+
18
+ require( ABSPATH . WPINC . '/l10n.php' );
19
+
20
+ require( ABSPATH . WPINC . '/link-template.php' );
21
+
22
+
23
+
24
+
25
+
26
+ global $wpdb;
27
+
28
+ global $wplc_tblname_chats;
29
+
30
+ global $wplc_tblname_msgs;
31
+
32
+ $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
33
+
34
+ $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
35
+
36
+
37
+
38
+ require_once("functions.php");
39
+
40
+
41
+
42
+ // stuff goes here
43
+
44
+
45
+
46
+ $check = 1;
47
+
48
+ if ($check == 1) {
49
+
50
+
51
+
52
+
53
+
54
+ // standard callbacks
55
+
56
+ if ($_POST['action'] == "wplc_start_chat") {
57
+
58
+ if ($_POST['cid']) {
59
+
60
+ if ($_POST['name'] && $_POST['email']) {
61
+
62
+ echo wplc_user_initiate_chat($_POST['name'],$_POST['email'],$_POST['cid']); // echo the chat session id
63
+
64
+ } else {
65
+
66
+ echo "error2";
67
+
68
+
69
+ }
70
+
71
+ } else {
72
+
73
+ if ($_POST['name'] && $_POST['email']) {
74
+
75
+ echo wplc_user_initiate_chat($_POST['name'],$_POST['email']); // echo the chat session id
76
+
77
+ } else {
78
+
79
+ echo "error2";
80
+
81
+ }
82
+
83
+ }
84
+
85
+ }
86
+
87
+ if ($_POST['action'] == "wplc_relay_stage") {
88
+
89
+
90
+
91
+ if ($_POST['stage'] == "1") { // chat window is displayed to user
92
+
93
+ echo wplc_log_user_on_page("user".time(),"no email set");
94
+
95
+ }
96
+
97
+ else if ($_POST['stage'] == "2") { // user still hasnt opened chat window but is now on another page
98
+
99
+ echo wplc_update_user_on_page($_POST['cid']);
100
+
101
+
102
+ }
103
+
104
+ }
105
+
106
+ if ($_POST['action'] == "wplc_update_admin_chat") {
107
+
108
+ wplc_list_chats();
109
+
110
+ }
111
+
112
+ if ($_POST['action'] == "wplc_update_admin_status") {
113
+
114
+ wplc_update_chat_statuses();
115
+
116
+ }
117
+
118
+ if ($_POST['action'] == "wplc_admin_accept_chat") {
119
+
120
+ wplc_admin_accept_chat($_POST['cid']);
121
+
122
+ }
123
+
124
+ if ($_POST['action'] == "wplc_update_admin_chat_boxes") {
125
+
126
+ echo wplc_return_admin_chat_messages($_POST['cid']);
127
+
128
+ wplc_mark_as_read_admin_chat_messages($_POST['cid']);
129
+
130
+ }
131
+
132
+ if ($_POST['action'] == "wplc_update_admin_return_chat_status") {
133
+
134
+ echo wplc_return_chat_status($_POST['cid']);
135
+
136
+ }
137
+
138
+
139
+
140
+ if ($_POST['action'] == "wplc_admin_send_msg") {
141
+
142
+ $chat_id = $_POST['cid'];
143
+
144
+ $chat_msg = $_POST['msg'];
145
+
146
+ $wplc_rec_msg = wplc_record_chat_msg("2",$chat_id,$chat_msg);
147
+
148
+ if ($wplc_rec_msg) {
149
+
150
+ echo 'sent';
151
+
152
+ } else {
153
+
154
+ echo "There was an error sending your chat message. Please contact support";
155
+
156
+ }
157
+
158
+ }
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+ // user
167
+
168
+
169
+ if ($_POST['action'] == "wplc_user_awaiting_chat") {
170
+ $chat_id = $_POST['id'];
171
+ echo wplc_return_chat_status($chat_id);
172
+ }
173
+ if ($_POST['action'] == "wplc_user_close_chat") {
174
+ $chat_id = $_POST['cid'];
175
+ wplc_change_chat_status($_POST['cid'],1);
176
+ }
177
+ if ($_POST['action'] == "wplc_user_send_msg") {
178
+ $chat_id = $_POST['cid'];
179
+ $chat_msg = $_POST['msg'];
180
+ $wplc_rec_msg = wplc_record_chat_msg("1",$chat_id,$chat_msg);
181
+ if ($wplc_rec_msg) {
182
+ echo 'sent';
183
+ } else {
184
+ echo "There was an error sending your chat message. Please contact support";
185
+ }
186
+ }
187
+
188
+ if ($_POST['action'] == "wplc_update_user_chat_boxes") {
189
+ echo wplc_return_user_chat_messages($_POST['cid']);
190
+ wplc_mark_as_read_user_chat_messages($_POST['cid']);
191
+ }
192
+ if ($_POST['action'] == "wplc_user_reactivate_chat") {
193
+ wplc_change_chat_status($_POST['cid'],3);
194
+ echo wplc_return_chat_messages($_POST['cid']);
195
+
196
+ }
197
+
198
+ }
199
+ function untrailingslashit($string) {
200
+ return rtrim($string, '/');
201
+ }
ding.mp3 ADDED
Binary file
functions.php ADDED
@@ -0,0 +1,467 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function wplc_log_user_on_page($name,$email) {
4
+ global $wpdb;
5
+ global $wplc_tblname_chats;
6
+
7
+ $ins_array = array(
8
+ 'status' => '5',
9
+ 'timestamp' => date("Y-m-d H:i:s"),
10
+ 'name' => $name,
11
+ 'email' => $email,
12
+ 'ip' => $_SERVER['REMOTE_ADDR'],
13
+ 'url' => $_SERVER['HTTP_REFERER'],
14
+ 'last_active_timestamp' => date("Y-m-d H:i:s")
15
+ );
16
+
17
+ $rows_affected = $wpdb->insert( $wplc_tblname_chats, $ins_array );
18
+
19
+ $lastid = $wpdb->insert_id;
20
+
21
+
22
+ return $lastid;
23
+
24
+ }
25
+ function wplc_update_user_on_page($cid) {
26
+ global $wpdb;
27
+ global $wplc_tblname_chats;
28
+
29
+ $query =
30
+ "
31
+ UPDATE $wplc_tblname_chats
32
+ SET
33
+ `url` = '".$_SERVER['HTTP_REFERER']."',
34
+ `last_active_timestamp` = '".date("Y-m-d H:i:s")."',
35
+ `ip` = '".$_SERVER['REMOTE_ADDR']."',
36
+ `status` = '5'
37
+
38
+ WHERE `id` = '$cid'
39
+ LIMIT 1
40
+ ";
41
+ $results = $wpdb->query($query);
42
+ return $query;
43
+
44
+
45
+
46
+ }
47
+
48
+
49
+
50
+ function wplc_record_chat_msg($from,$cid,$msg) {
51
+ global $wpdb;
52
+ global $wplc_tblname_msgs;
53
+
54
+ if ($from == "1") {
55
+ $fromname = wplc_return_chat_name($cid);
56
+ $orig = '2';
57
+ }
58
+ else {
59
+ $fromname = "admin";
60
+ $orig = '1';
61
+ }
62
+
63
+ $ins_array = array(
64
+ 'chat_sess_id' => $cid,
65
+ 'timestamp' => date("Y-m-d H:i:s"),
66
+ 'from' => $fromname,
67
+ 'msg' => $msg,
68
+ 'status' => 0,
69
+ 'originates' => $orig
70
+ );
71
+ $rows_affected = $wpdb->insert( $wplc_tblname_msgs, $ins_array );
72
+
73
+ wplc_update_active_timestamp($cid);
74
+ wplc_change_chat_status($cid,3);
75
+ return true;
76
+
77
+
78
+ }
79
+
80
+ function wplc_update_active_timestamp($cid) {
81
+ global $wpdb;
82
+ global $wplc_tblname_chats;
83
+ $results = $wpdb->get_results(
84
+ "
85
+ UPDATE $wplc_tblname_chats
86
+ SET `last_active_timestamp` = '".date("Y-m-d H:i:s")."'
87
+ WHERE `id` = '$cid'
88
+ LIMIT 1
89
+ "
90
+ );
91
+ wplc_change_chat_status($cid,3);
92
+ return true;
93
+
94
+ }
95
+
96
+ function wplc_return_chat_name($cid) {
97
+ global $wpdb;
98
+ global $wplc_tblname_chats;
99
+ $results = $wpdb->get_results(
100
+ "
101
+ SELECT *
102
+ FROM $wplc_tblname_chats
103
+ WHERE `id` = '$cid'
104
+ "
105
+ );
106
+ foreach ($results as $result) {
107
+ return $result->name;
108
+ }
109
+
110
+ }
111
+ function wplc_list_chats() {
112
+
113
+ global $wpdb;
114
+ global $wplc_tblname_chats;
115
+
116
+ $results = $wpdb->get_results(
117
+ "
118
+ SELECT *
119
+ FROM $wplc_tblname_chats
120
+ WHERE `status` = 3 OR `status` = 2
121
+ ORDER BY `timestamp` ASC
122
+
123
+ "
124
+ );
125
+ echo "
126
+
127
+
128
+ <table class=\"wp-list-table widefat fixed \" cellspacing=\"0\">
129
+ <thead>
130
+ <tr>
131
+ <th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>".__("IP","wplivechat")."</span></th>
132
+ <th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>".__("Name","wplivechat")."</span></th>
133
+ <th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">".__("Email","wplivechat")."</th>
134
+ <th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">".__("URL","wplivechat")."</th>
135
+ <th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">".__("Status","wplivechat")."</th>
136
+ <th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>".__("Action","wplivechat")."</span></th>
137
+ </tr>
138
+ </thead>
139
+ <tbody id=\"the-list\" class='list:wp_list_text_link'>
140
+ ";
141
+
142
+ if (!$results) {
143
+ echo "<tr><td></td><td>".__("No chat sessions available at the moment","wplivechat")."</td></tr>";
144
+ }
145
+ else {
146
+ foreach ($results as $result) {
147
+ unset($trstyle);
148
+ unset($actions);
149
+ $wplc_c++;
150
+
151
+ if ($result->status == 2) {
152
+ $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
153
+ $actions = "<a href=\"#\" onclick=\"window.open('$url', 'mywindow".$result->id."', 'location=no,status=1,scrollbars=1,width=500,height=650');return false;\">Accept Chat</a>";
154
+ $trstyle = "style='background-color:#FFFBE4; height:30px;'";
155
+ }
156
+ if ($result->status == 3) {
157
+ $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
158
+ $actions = "<a href=\"#\" onclick=\"window.open('$url', 'mywindow".$result->id."', 'location=no,status=1,scrollbars=1,width=500,height=650');return false;\">Open Chat Window</a>";
159
+ $trstyle = "style='background-color:#F7FCFE; height:30px;'";
160
+ }
161
+
162
+
163
+ echo "<tr id=\"record_".$result->id."\" $trstyle>";
164
+ echo "<td class='chat_id column-chat_d'>".$result->ip."</td>";
165
+ echo "<td class='chat_name column_chat_name' id='chat_name_".$result->id."'><img src=\"http://www.gravatar.com/avatar/".md5($result->email)."?s=40\" /> ".$result->name."</td>";
166
+ echo "<td class='chat_email column_chat_email' id='chat_email_".$result->id."'>".$result->email."</td>";
167
+ echo "<td class='chat_name column_chat_url' id='chat_url_".$result->id."'>".$result->url."</td>";
168
+ echo "<td class='chat_status column_chat_status' id='chat_status_".$result->id."'><strong>".wplc_return_status($result->status)."</strong></td>";if ($wplc_c>1) { $actions = wplc_get_msg(); }
169
+ echo "<td class='chat_action column-chat_action' id='chat_action_".$result->id."'>$actions</td>";
170
+ echo "</tr>";
171
+
172
+ }
173
+ }
174
+ echo "</table><br /><br />";
175
+
176
+
177
+ }
178
+
179
+
180
+
181
+
182
+ function wplc_return_user_chat_messages($cid) {
183
+ global $wpdb;
184
+ global $wplc_tblname_msgs;
185
+ $results = $wpdb->get_results(
186
+ "
187
+ SELECT *
188
+ FROM $wplc_tblname_msgs
189
+ WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '1'
190
+ ORDER BY `timestamp` ASC
191
+
192
+ "
193
+ );
194
+ $msg_hist = "";
195
+ foreach ($results as $result) {
196
+ $id = $result->id;
197
+ $from = $result->from;
198
+
199
+ $msg = stripslashes($result->msg);
200
+ //$timestamp = strtotime($result->timestamp);
201
+ //$timeshow = date("H:i",$timestamp);
202
+ $msg_hist .= "<strong>$from</strong>: $msg<br />";
203
+
204
+ }
205
+
206
+ return $msg_hist;
207
+
208
+
209
+ }
210
+
211
+
212
+ function wplc_change_chat_status($id,$status) {
213
+ global $wpdb;
214
+ global $wplc_tblname_chats;
215
+ $results = $wpdb->get_results(
216
+ "
217
+ UPDATE $wplc_tblname_chats
218
+ SET `status` = '$status'
219
+ WHERE `id` = '$id'
220
+ LIMIT 1
221
+ "
222
+ );
223
+ return true;
224
+
225
+ }
226
+
227
+
228
+ function wplc_return_chat_messages($cid) {
229
+ global $wpdb;
230
+ global $wplc_tblname_msgs;
231
+ $results = $wpdb->get_results(
232
+ "
233
+ SELECT *
234
+ FROM $wplc_tblname_msgs
235
+ WHERE `chat_sess_id` = '$cid'
236
+ ORDER BY `timestamp` ASC
237
+ LIMIT 0, 100
238
+ "
239
+ );
240
+ foreach ($results as $result) {
241
+ $from = $result->from;
242
+ $msg = $result->msg;
243
+ $timestamp = strtotime($result->timestamp);
244
+ $timeshow = date("H:i:s",$timestamp);
245
+ $msg_hist .= "<strong>$from</strong>: $msg<br />";
246
+
247
+ }
248
+ return $msg_hist;
249
+
250
+
251
+ }
252
+
253
+
254
+ function wplc_mark_as_read_user_chat_messages($cid) {
255
+ global $wpdb;
256
+ global $wplc_tblname_msgs;
257
+ $results = $wpdb->get_results(
258
+ "
259
+ SELECT *
260
+ FROM $wplc_tblname_msgs
261
+ WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '1'
262
+ ORDER BY `timestamp` DESC
263
+
264
+ "
265
+ );
266
+
267
+
268
+ foreach ($results as $result) {
269
+ $id = $result->id;
270
+ $check = $wpdb->query(
271
+ "
272
+ UPDATE $wplc_tblname_msgs
273
+ SET `status` = 1
274
+ WHERE `id` = '$id'
275
+ LIMIT 1
276
+
277
+ "
278
+ );
279
+ }
280
+ return "ok";
281
+
282
+
283
+ }
284
+
285
+ function wplc_return_admin_chat_messages($cid) {
286
+ global $wpdb;
287
+ global $wplc_tblname_msgs;
288
+ $results = $wpdb->get_results(
289
+ "
290
+ SELECT *
291
+ FROM $wplc_tblname_msgs
292
+ WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '2'
293
+ ORDER BY `timestamp` ASC
294
+
295
+ "
296
+ );
297
+ $msg_hist = "";
298
+ foreach ($results as $result) {
299
+ $id = $result->id;
300
+ $from = $result->from;
301
+
302
+ $msg = stripslashes($result->msg);
303
+ //$timestamp = strtotime($result->timestamp);
304
+ //$timeshow = date("H:i",$timestamp);
305
+ $msg_hist .= "<strong>$from</strong>: $msg<br />";
306
+
307
+ }
308
+
309
+ return $msg_hist;
310
+
311
+
312
+ }
313
+ function wplc_mark_as_read_admin_chat_messages($cid) {
314
+ global $wpdb;
315
+ global $wplc_tblname_msgs;
316
+ $results = $wpdb->get_results(
317
+ "
318
+ SELECT *
319
+ FROM $wplc_tblname_msgs
320
+ WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '2'
321
+ ORDER BY `timestamp` DESC
322
+
323
+ "
324
+ );
325
+
326
+
327
+ foreach ($results as $result) {
328
+ $id = $result->id;
329
+ $check = $wpdb->query(
330
+ "
331
+ UPDATE $wplc_tblname_msgs
332
+ SET `status` = 1
333
+ WHERE `id` = '$id'
334
+ LIMIT 1
335
+
336
+ "
337
+ );
338
+ }
339
+ return "ok";
340
+
341
+
342
+ }
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+ function wplc_return_chat_status($cid) {
351
+ global $wpdb;
352
+ global $wplc_tblname_chats;
353
+ $results = $wpdb->get_results(
354
+ "
355
+ SELECT *
356
+ FROM $wplc_tblname_chats
357
+ WHERE `id` = '$cid'
358
+ "
359
+ );
360
+ foreach ($results as $result) {
361
+ return $result->status;
362
+ }
363
+ }
364
+
365
+
366
+ function wplc_return_status($status) {
367
+ if ($status == 1) {
368
+ return "complete";
369
+ }
370
+ if ($status == 2) {
371
+ return "pending";
372
+ }
373
+ if ($status == 3) {
374
+ return "active";
375
+ }
376
+ if ($status == 4) {
377
+ return "deleted";
378
+ }
379
+ if ($status == 5) {
380
+ return "browsing";
381
+ }
382
+ if ($status == 6) {
383
+ return "requesting chat";
384
+ }
385
+ }
386
+
387
+
388
+ function wplc_user_initiate_chat($name,$email,$cid = null) {
389
+ global $wpdb;
390
+ global $wplc_tblname_chats;
391
+
392
+ if (function_exists("wplc_list_chats_pro")) { /* check if functions-pro is around */
393
+ wplc_pro_notify_via_email();
394
+ }
395
+
396
+ if ($cid != null) { /* change from a visitor to a chat */
397
+ $query =
398
+ "
399
+ UPDATE $wplc_tblname_chats
400
+ SET
401
+ `status` = '2',
402
+ `timestamp` = '".date("Y-m-d H:i:s")."',
403
+ `name` = '$name',
404
+ `email` = '$email',
405
+ `ip` = '".$_SERVER['REMOTE_ADDR']."',
406
+ `url` = '".$_SERVER['HTTP_REFERER']."',
407
+ `last_active_timestamp` = '".date("Y-m-d H:i:s")."'
408
+
409
+ WHERE `id` = '$cid'
410
+ LIMIT 1
411
+ ";
412
+ $results = $wpdb->query($query);
413
+ return $cid;
414
+ }
415
+ else { // create new ID for the chat
416
+ $ins_array = array(
417
+ 'status' => '2',
418
+ 'timestamp' => date("Y-m-d H:i:s"),
419
+ 'name' => $name,
420
+ 'email' => $email,
421
+ 'ip' => $_SERVER['REMOTE_ADDR'],
422
+ 'url' => $_SERVER['HTTP_REFERER'],
423
+ 'last_active_timestamp' => date("Y-m-d H:i:s")
424
+ );
425
+ $rows_affected = $wpdb->insert( $wplc_tblname_chats, $ins_array );
426
+ $lastid = $wpdb->insert_id;
427
+ return $lastid;
428
+ }
429
+
430
+ }
431
+
432
+
433
+
434
+ function wplc_get_msg() {
435
+ return "<a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=morechats\" title=\"".__("Get Pro Add-on to accept more chats","wplivechat")."\" target=\"_BLANK\">Get Pro Add-on to accept more chats</a>";
436
+ }
437
+ function wplc_update_chat_statuses() {
438
+
439
+ global $wpdb;
440
+ global $wplc_tblname_chats;
441
+ $results = $wpdb->get_results(
442
+ "
443
+ SELECT *
444
+ FROM $wplc_tblname_chats
445
+ WHERE `status` = '2' OR `status` = '3' OR `status` = '5'
446
+ "
447
+ );
448
+ foreach ($results as $result) {
449
+ $id = $result->id;
450
+ $timestamp = strtotime($result->last_active_timestamp);
451
+ if ($result->status == 2) {
452
+ if ((time() - $timestamp) >= 60) { // 1 minute max
453
+ wplc_change_chat_status($id,0);
454
+ }
455
+ }
456
+ else if ($result->status == 3) {
457
+ if ((time() - $timestamp) >= 600) { // 10 minute max
458
+ wplc_change_chat_status($id,1);
459
+ }
460
+ }
461
+ else if ($result->status == 5) {
462
+ if ((time() - $timestamp) >= 120) { // 2 minute timeout
463
+ wplc_change_chat_status($id,7); // 7 - timedout
464
+ }
465
+ }
466
+ }
467
+ }
js/wplc_u.js CHANGED
@@ -28,7 +28,7 @@ jQuery(document).ready(function() {
28
  stage: stage
29
  };
30
  }
31
- jQuery.post(ajaxurl, data, function(response) {
32
  //console.log("wplc_relay_stage");
33
  });
34
  }
@@ -48,7 +48,7 @@ jQuery(document).ready(function() {
48
  security: wplc_nonce,
49
  cid: wplc_check_cookie_id
50
  };
51
- jQuery.post(ajaxurl, data, function(response) {
52
  //console.log("wplc_user_close_chat");
53
  });
54
  });
@@ -93,7 +93,7 @@ jQuery(document).ready(function() {
93
  name: wplc_name,
94
  email: wplc_email
95
  };
96
- jQuery.post(ajaxurl, data, function(response) {
97
  //console.log("wplc_start_chat");
98
  wplc_chat_session_id = response;
99
  wplc_check_cookie_id = response;
@@ -108,7 +108,7 @@ jQuery(document).ready(function() {
108
  security: wplc_nonce,
109
  id: cid
110
  };
111
- jQuery.post(ajaxurl, data, function(response) {
112
  //console.log("wplc_user_awaiting_chat");
113
 
114
  if (response == "3") {
@@ -153,7 +153,7 @@ jQuery(document).ready(function() {
153
  cid: wplc_cid,
154
  msg: wplc_chat
155
  };
156
- jQuery.post(ajaxurl, data, function(response) {
157
  //console.log("wplc_user_send_msg");
158
  });
159
 
@@ -165,7 +165,7 @@ jQuery(document).ready(function() {
165
  cid: cid,
166
  security: wplc_nonce
167
  };
168
- jQuery.post(ajaxurl, data, function(response) {
169
  //console.log("wplc_update_user_chat_boxes");
170
  jQuery("#wplc_chatbox").append(response);
171
  var height = jQuery('#wplc_chatbox')[0].scrollHeight;
@@ -208,7 +208,7 @@ jQuery(document).ready(function() {
208
  security: wplc_nonce,
209
  cid: wplc_check_cookie_id
210
  };
211
- jQuery.post(ajaxurl, data, function(response) {
212
  //console.log("wplc_user_reactivate_chat");
213
  jQuery("#wp-live-chat-react").hide();
214
  jQuery("#wp-live-chat-4").show();
28
  stage: stage
29
  };
30
  }
31
+ jQuery.post(wplc_ajaxurl, data, function(response) {
32
  //console.log("wplc_relay_stage");
33
  });
34
  }
48
  security: wplc_nonce,
49
  cid: wplc_check_cookie_id
50
  };
51
+ jQuery.post(wplc_ajaxurl, data, function(response) {
52
  //console.log("wplc_user_close_chat");
53
  });
54
  });
93
  name: wplc_name,
94
  email: wplc_email
95
  };
96
+ jQuery.post(wplc_ajaxurl, data, function(response) {
97
  //console.log("wplc_start_chat");
98
  wplc_chat_session_id = response;
99
  wplc_check_cookie_id = response;
108
  security: wplc_nonce,
109
  id: cid
110
  };
111
+ jQuery.post(wplc_ajaxurl, data, function(response) {
112
  //console.log("wplc_user_awaiting_chat");
113
 
114
  if (response == "3") {
153
  cid: wplc_cid,
154
  msg: wplc_chat
155
  };
156
+ jQuery.post(wplc_ajaxurl, data, function(response) {
157
  //console.log("wplc_user_send_msg");
158
  });
159
 
165
  cid: cid,
166
  security: wplc_nonce
167
  };
168
+ jQuery.post(wplc_ajaxurl, data, function(response) {
169
  //console.log("wplc_update_user_chat_boxes");
170
  jQuery("#wplc_chatbox").append(response);
171
  var height = jQuery('#wplc_chatbox')[0].scrollHeight;
208
  security: wplc_nonce,
209
  cid: wplc_check_cookie_id
210
  };
211
+ jQuery.post(wplc_ajaxurl, data, function(response) {
212
  //console.log("wplc_user_reactivate_chat");
213
  jQuery("#wp-live-chat-react").hide();
214
  jQuery("#wp-live-chat-4").show();
readme.txt CHANGED
@@ -23,7 +23,7 @@ The most cost effective Live Chat plugin. Chat with your visitors for free! WP L
23
  = Pro add-on =
24
  * Initiate live chats with online visitors
25
  * Chat to more than one visitor at a time
26
- * Access historical chat records
27
  * Set up your user profile
28
  * Add your company logo to the live chat window
29
  * Add your photo to the live chat window
@@ -32,6 +32,10 @@ The most cost effective Live Chat plugin. Chat with your visitors for free! WP L
32
  * Fully customizable live chat experience
33
  * Get the [WP Live Chat Support Pro Add-on](http://wp-livechat.com/purchase-pro/) for only $14.95 once off!
34
 
 
 
 
 
35
 
36
 
37
  == Installation ==
@@ -61,6 +65,10 @@ Once installed and activated, a link should appear in your left navigation panel
61
 
62
  == Changelog ==
63
 
 
 
 
 
64
  = 2.4 =
65
  * You now have full control of the fill and font color of your live chat box
66
  * Added the ability to turn live chat on and off
23
  = Pro add-on =
24
  * Initiate live chats with online visitors
25
  * Chat to more than one visitor at a time
26
+ * Access historical live chat records
27
  * Set up your user profile
28
  * Add your company logo to the live chat window
29
  * Add your photo to the live chat window
32
  * Fully customizable live chat experience
33
  * Get the [WP Live Chat Support Pro Add-on](http://wp-livechat.com/purchase-pro/) for only $14.95 once off!
34
 
35
+ = Coming Soon =
36
+ * Multiple live chat operators
37
+ * Better control of chat history
38
+ * More advanced customization
39
 
40
 
41
  == Installation ==
65
 
66
  == Changelog ==
67
 
68
+ = 2.5 =
69
+ * Major performance improvements
70
+ * Small UI improvements
71
+
72
  = 2.4 =
73
  * You now have full control of the fill and font color of your live chat box
74
  * Added the ability to turn live chat on and off
wp-live-chat-support.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Live Chat Support
4
  Plugin URI: http://www.wp-livechat.com
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 Support. No third party connection required!
6
- Version: 2.4
7
  Author: WP-LiveChat
8
  Author URI: http://www.wp-livechat.com
9
  */
@@ -17,35 +17,13 @@ global $wplc_tblname_chats;
17
  global $wplc_tblname_msgs;
18
  $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
19
  $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
20
- $wplc_version = "2.4";
21
 
 
22
 
23
- add_action('wp_footer', 'wplc_display_box');
24
- add_action('wp_ajax_wplc_start_chat', 'wplc_action_callback');
25
- add_action('wp_ajax_nopriv_wplc_start_chat', 'wplc_action_callback');
26
- add_action('wp_ajax_wplc_relay_stage', 'wplc_action_callback');
27
- add_action('wp_ajax_nopriv_wplc_relay_stage', 'wplc_action_callback');
28
- add_action('wp_ajax_wplc_update_admin_chat', 'wplc_action_callback');
29
- add_action('wp_ajax_wplc_update_admin_status', 'wplc_action_callback');
30
- add_action('wp_ajax_wplc_user_awaiting_chat', 'wplc_action_callback');
31
- add_action('wp_ajax_nopriv_wplc_user_awaiting_chat', 'wplc_action_callback');
32
- add_action('wp_ajax_wplc_user_send_msg', 'wplc_action_callback');
33
- add_action('wp_ajax_nopriv_wplc_user_send_msg', 'wplc_action_callback');
34
- add_action('wp_ajax_wplc_user_close_chat', 'wplc_action_callback');
35
- add_action('wp_ajax_nopriv_wplc_user_close_chat', 'wplc_action_callback');
36
- add_action('wp_ajax_wplc_user_reactivate_chat', 'wplc_action_callback');
37
- add_action('wp_ajax_nopriv_wplc_user_reactivate_chat', 'wplc_action_callback');
38
- add_action('wp_ajax_wplc_admin_accept_chat', 'wplc_action_callback');
39
- add_action('wp_ajax_wplc_update_admin_chat_boxes', 'wplc_action_callback');
40
- add_action('wp_ajax_wplc_update_user_chat_boxes', 'wplc_action_callback');
41
- add_action('wp_ajax_nopriv_wplc_update_user_chat_boxes', 'wplc_action_callback');
42
- add_action('wp_ajax_wplc_admin_send_msg', 'wplc_action_callback');
43
  add_action('wp_ajax_wplc_admin_set_transient', 'wplc_action_callback');
44
- add_action('wp_ajax_wplc_update_admin_return_chat_status', 'wplc_action_callback');
45
-
46
-
47
-
48
 
 
49
  add_action('admin_head', 'wplc_head');
50
  add_action( 'wp_enqueue_scripts', 'wplc_add_user_stylesheet' );
51
  add_action('admin_menu', 'wplc_admin_menu');
@@ -53,6 +31,28 @@ add_action('admin_head', 'wplc_superadmin_javascript');
53
  register_activation_hook( __FILE__, 'wplc_activate' );
54
 
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  function wplc_admin_menu() {
57
  $wplc_mainpage = add_menu_page('WP Live Chat', __('Live Chat','wplivechat'), 'manage_options', 'wplivechat-menu', 'wplc_admin_menu_layout');
58
  add_submenu_page('wplivechat-menu', __('Settings','wplivechat'), __('Settings','wplivechat'), 'manage_options' , 'wplivechat-menu-settings', 'wplc_admin_settings_layout');
@@ -70,9 +70,11 @@ function wplc_user_top_js() {
70
  $wplc_settings = get_option("WPLC_SETTINGS");
71
  ?>
72
  <script type="text/javascript">
73
- var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
 
 
74
  var wplc_nonce = '<?php echo $ajax_nonce; ?>';
75
- </script>
76
  <?php
77
  }
78
 
@@ -160,300 +162,7 @@ function wplc_display_box() {
160
  }
161
 
162
 
163
- function wplc_action_callback() {
164
- global $wpdb;
165
- global $wplc_tblname_chats;
166
- $check = check_ajax_referer( 'wplc', 'security' );
167
-
168
- if ($check == 1) {
169
- if ($_POST['action'] == "wplc_start_chat") {
170
- if ($_POST['cid']) {
171
- if ($_POST['name'] && $_POST['email']) {
172
- echo wplc_user_initiate_chat($_POST['name'],$_POST['email'],$_POST['cid']); // echo the chat session id
173
- } else {
174
- echo "error2";
175
- }
176
- } else {
177
- if ($_POST['name'] && $_POST['email']) {
178
- echo wplc_user_initiate_chat($_POST['name'],$_POST['email']); // echo the chat session id
179
- } else {
180
- echo "error2";
181
- }
182
- }
183
- }
184
- if ($_POST['action'] == "wplc_relay_stage") {
185
-
186
- if ($_POST['stage'] == "1") { // chat window is displayed to user
187
- echo wplc_log_user_on_page("user".time(),"no email set");
188
- }
189
- else if ($_POST['stage'] == "2") { // user still hasnt opened chat window but is now on another page
190
- echo wplc_update_user_on_page($_POST['cid']);
191
-
192
- }
193
- }
194
- if ($_POST['action'] == "wplc_update_admin_chat") {
195
- wplc_list_chats();
196
- }
197
- if ($_POST['action'] == "wplc_update_admin_status") {
198
- wplc_update_chat_statuses();
199
- }
200
- if ($_POST['action'] == "wplc_admin_accept_chat") {
201
- wplc_admin_accept_chat($_POST['cid']);
202
- }
203
- if ($_POST['action'] == "wplc_update_admin_chat_boxes") {
204
- echo wplc_return_admin_chat_messages($_POST['cid']);
205
- wplc_mark_as_read_admin_chat_messages($_POST['cid']);
206
- }
207
- if ($_POST['action'] == "wplc_update_admin_return_chat_status") {
208
- echo wplc_return_chat_status($_POST['cid']);
209
- }
210
-
211
- if ($_POST['action'] == "wplc_admin_send_msg") {
212
- $chat_id = $_POST['cid'];
213
- $chat_msg = $_POST['msg'];
214
- $wplc_rec_msg = wplc_record_chat_msg("2",$chat_id,$chat_msg);
215
- if ($wplc_rec_msg) {
216
- echo 'sent';
217
- } else {
218
- echo "There was an error sending your chat message. Please contact support";
219
- }
220
- }
221
- if ($_POST['action'] == "wplc_admin_set_transient") {
222
- set_transient("wplc_is_admin_logged_in", "1", 70 );
223
-
224
- }
225
-
226
-
227
- // user
228
-
229
- if ($_POST['action'] == "wplc_user_awaiting_chat") {
230
- $chat_id = $_POST['id'];
231
- echo wplc_return_chat_status($chat_id);
232
- }
233
- if ($_POST['action'] == "wplc_user_close_chat") {
234
- $chat_id = $_POST['cid'];
235
- wplc_change_chat_status($_POST['cid'],1);
236
- }
237
- if ($_POST['action'] == "wplc_user_send_msg") {
238
- $chat_id = $_POST['cid'];
239
- $chat_msg = $_POST['msg'];
240
- $wplc_rec_msg = wplc_record_chat_msg("1",$chat_id,$chat_msg);
241
- if ($wplc_rec_msg) {
242
- echo 'sent';
243
- } else {
244
- echo "There was an error sending your chat message. Please contact support";
245
- }
246
- }
247
-
248
-
249
-
250
-
251
-
252
-
253
-
254
- if ($_POST['action'] == "wplc_update_user_chat_boxes") {
255
- echo wplc_return_user_chat_messages($_POST['cid']);
256
- wplc_mark_as_read_user_chat_messages($_POST['cid']);
257
- }
258
- if ($_POST['action'] == "wplc_user_reactivate_chat") {
259
- wplc_change_chat_status($_POST['cid'],3);
260
- echo wplc_return_chat_messages($_POST['cid']);
261
-
262
- }
263
 
264
- }
265
-
266
- die(); // this is required to return a proper result
267
-
268
- }
269
-
270
- function wplc_record_chat_msg($from,$cid,$msg) {
271
- global $wpdb;
272
- global $wplc_tblname_msgs;
273
-
274
- if ($from == "1") {
275
- $fromname = wplc_return_chat_name($cid);
276
- $orig = '2';
277
- }
278
- else {
279
- if (function_exists("wplc_register_pro_version")) { $fromname = wplc_return_from_name(); }
280
- else { $fromname = "admin"; }
281
- $orig = '1';
282
- }
283
-
284
- $ins_array = array(
285
- 'chat_sess_id' => $cid,
286
- 'timestamp' => date("Y-m-d H:i:s"),
287
- 'from' => $fromname,
288
- 'msg' => $msg,
289
- 'status' => 0,
290
- 'originates' => $orig
291
- );
292
- $rows_affected = $wpdb->insert( $wplc_tblname_msgs, $ins_array );
293
-
294
- wplc_update_active_timestamp($cid);
295
- wplc_change_chat_status($cid,3);
296
- return true;
297
-
298
-
299
- }
300
-
301
- function wplc_update_active_timestamp($cid) {
302
- global $wpdb;
303
- global $wplc_tblname_chats;
304
- $results = $wpdb->get_results(
305
- "
306
- UPDATE $wplc_tblname_chats
307
- SET `last_active_timestamp` = '".date("Y-m-d H:i:s")."'
308
- WHERE `id` = '$cid'
309
- LIMIT 1
310
- "
311
- );
312
- wplc_change_chat_status($cid,3);
313
- return true;
314
-
315
- }
316
-
317
- function wplc_return_admin_chat_messages($cid) {
318
- global $wpdb;
319
- global $wplc_tblname_msgs;
320
- $results = $wpdb->get_results(
321
- "
322
- SELECT *
323
- FROM $wplc_tblname_msgs
324
- WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '2'
325
- ORDER BY `timestamp` ASC
326
-
327
- "
328
- );
329
- $msg_hist = "";
330
- foreach ($results as $result) {
331
- $id = $result->id;
332
- $from = $result->from;
333
-
334
- $msg = stripslashes($result->msg);
335
- //$timestamp = strtotime($result->timestamp);
336
- //$timeshow = date("H:i",$timestamp);
337
- $msg_hist .= "<strong>$from</strong>: $msg<br />";
338
-
339
- }
340
-
341
- return $msg_hist;
342
-
343
-
344
- }
345
- function wplc_return_user_chat_messages($cid) {
346
- global $wpdb;
347
- global $wplc_tblname_msgs;
348
- $results = $wpdb->get_results(
349
- "
350
- SELECT *
351
- FROM $wplc_tblname_msgs
352
- WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '1'
353
- ORDER BY `timestamp` ASC
354
-
355
- "
356
- );
357
- $msg_hist = "";
358
- foreach ($results as $result) {
359
- $id = $result->id;
360
- $from = $result->from;
361
-
362
- $msg = stripslashes($result->msg);
363
- //$timestamp = strtotime($result->timestamp);
364
- //$timeshow = date("H:i",$timestamp);
365
- $msg_hist .= "<strong>$from</strong>: $msg<br />";
366
-
367
- }
368
-
369
- return $msg_hist;
370
-
371
-
372
- }
373
- function wplc_return_chat_messages($cid) {
374
- global $wpdb;
375
- global $wplc_tblname_msgs;
376
- $results = $wpdb->get_results(
377
- "
378
- SELECT *
379
- FROM $wplc_tblname_msgs
380
- WHERE `chat_sess_id` = '$cid'
381
- ORDER BY `timestamp` ASC
382
- LIMIT 0, 100
383
- "
384
- );
385
- foreach ($results as $result) {
386
- $from = $result->from;
387
- $msg = $result->msg;
388
- $timestamp = strtotime($result->timestamp);
389
- $timeshow = date("H:i:s",$timestamp);
390
- $msg_hist .= "<strong>$from</strong>: $msg<br />";
391
-
392
- }
393
- return $msg_hist;
394
-
395
-
396
- }
397
- function wplc_mark_as_read_admin_chat_messages($cid) {
398
- global $wpdb;
399
- global $wplc_tblname_msgs;
400
- $results = $wpdb->get_results(
401
- "
402
- SELECT *
403
- FROM $wplc_tblname_msgs
404
- WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '2'
405
- ORDER BY `timestamp` DESC
406
-
407
- "
408
- );
409
-
410
-
411
- foreach ($results as $result) {
412
- $id = $result->id;
413
- $check = $wpdb->query(
414
- "
415
- UPDATE $wplc_tblname_msgs
416
- SET `status` = 1
417
- WHERE `id` = '$id'
418
- LIMIT 1
419
-
420
- "
421
- );
422
- }
423
- return "ok";
424
-
425
-
426
- }
427
- function wplc_mark_as_read_user_chat_messages($cid) {
428
- global $wpdb;
429
- global $wplc_tblname_msgs;
430
- $results = $wpdb->get_results(
431
- "
432
- SELECT *
433
- FROM $wplc_tblname_msgs
434
- WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '1'
435
- ORDER BY `timestamp` DESC
436
-
437
- "
438
- );
439
-
440
-
441
- foreach ($results as $result) {
442
- $id = $result->id;
443
- $check = $wpdb->query(
444
- "
445
- UPDATE $wplc_tblname_msgs
446
- SET `status` = 1
447
- WHERE `id` = '$id'
448
- LIMIT 1
449
-
450
- "
451
- );
452
- }
453
- return "ok";
454
-
455
-
456
- }
457
  function wplc_admin_display_chat($cid) {
458
  global $wpdb;
459
  global $wplc_tblname_msgs;
@@ -480,190 +189,7 @@ function wplc_admin_accept_chat($cid) {
480
 
481
  }
482
  add_action('admin_head','wplc_update_chat_statuses');
483
- function wplc_update_chat_statuses() {
484
-
485
- global $wpdb;
486
- global $wplc_tblname_chats;
487
- $results = $wpdb->get_results(
488
- "
489
- SELECT *
490
- FROM $wplc_tblname_chats
491
- WHERE `status` = '2' OR `status` = '3' OR `status` = '5'
492
- "
493
- );
494
- foreach ($results as $result) {
495
- $id = $result->id;
496
- $timestamp = strtotime($result->last_active_timestamp);
497
- if ($result->status == 2) {
498
- if ((time() - $timestamp) >= 60) { // 1 minute max
499
- wplc_change_chat_status($id,0);
500
- }
501
- }
502
- else if ($result->status == 3) {
503
- if ((time() - $timestamp) >= 600) { // 10 minute max
504
- wplc_change_chat_status($id,1);
505
- }
506
- }
507
- else if ($result->status == 5) {
508
- if ((time() - $timestamp) >= 120) { // 2 minute timeout
509
- wplc_change_chat_status($id,7); // 7 - timedout
510
- }
511
- }
512
- }
513
- }
514
-
515
- function wplc_user_initiate_chat($name,$email,$cid = null) {
516
- global $wpdb;
517
- global $wplc_tblname_chats;
518
-
519
- if (function_exists("wplc_register_pro_version")) {
520
- wplc_pro_notify_via_email();
521
- }
522
-
523
- if ($cid != null) { // change from a visitor to a chat
524
- $query =
525
- "
526
- UPDATE $wplc_tblname_chats
527
- SET
528
- `status` = '2',
529
- `timestamp` = '".date("Y-m-d H:i:s")."',
530
- `name` = '$name',
531
- `email` = '$email',
532
- `ip` = '".$_SERVER['REMOTE_ADDR']."',
533
- `url` = '".$_SERVER['HTTP_REFERER']."',
534
- `last_active_timestamp` = '".date("Y-m-d H:i:s")."'
535
-
536
- WHERE `id` = '$cid'
537
- LIMIT 1
538
- ";
539
- $results = $wpdb->query($query);
540
- return $cid;
541
- }
542
- else { // create new ID for the chat
543
- $ins_array = array(
544
- 'status' => '2',
545
- 'timestamp' => date("Y-m-d H:i:s"),
546
- 'name' => $name,
547
- 'email' => $email,
548
- 'ip' => $_SERVER['REMOTE_ADDR'],
549
- 'url' => $_SERVER['HTTP_REFERER'],
550
- 'last_active_timestamp' => date("Y-m-d H:i:s")
551
- );
552
- $rows_affected = $wpdb->insert( $wplc_tblname_chats, $ins_array );
553
- $lastid = $wpdb->insert_id;
554
- return $lastid;
555
- }
556
-
557
- }
558
- function wplc_log_user_on_page($name,$email) {
559
- global $wpdb;
560
- global $wplc_tblname_chats;
561
-
562
- $ins_array = array(
563
- 'status' => '5',
564
- 'timestamp' => date("Y-m-d H:i:s"),
565
- 'name' => $name,
566
- 'email' => $email,
567
- 'ip' => $_SERVER['REMOTE_ADDR'],
568
- 'url' => $_SERVER['HTTP_REFERER'],
569
- 'last_active_timestamp' => date("Y-m-d H:i:s")
570
- );
571
-
572
- $rows_affected = $wpdb->insert( $wplc_tblname_chats, $ins_array );
573
-
574
- $lastid = $wpdb->insert_id;
575
-
576
-
577
- return $lastid;
578
-
579
- }
580
- function wplc_update_user_on_page($cid) {
581
- global $wpdb;
582
- global $wplc_tblname_chats;
583
-
584
- $query =
585
- "
586
- UPDATE $wplc_tblname_chats
587
- SET
588
- `url` = '".$_SERVER['HTTP_REFERER']."',
589
- `last_active_timestamp` = '".date("Y-m-d H:i:s")."',
590
- `ip` = '".$_SERVER['REMOTE_ADDR']."',
591
- `status` = '5'
592
-
593
- WHERE `id` = '$cid'
594
- LIMIT 1
595
- ";
596
- $results = $wpdb->query($query);
597
- return $query;
598
-
599
-
600
-
601
- }
602
- function wplc_change_chat_status($id,$status) {
603
- global $wpdb;
604
- global $wplc_tblname_chats;
605
- $results = $wpdb->get_results(
606
- "
607
- UPDATE $wplc_tblname_chats
608
- SET `status` = '$status'
609
- WHERE `id` = '$id'
610
- LIMIT 1
611
- "
612
- );
613
- return true;
614
-
615
- }
616
- function wplc_return_chat_name($cid) {
617
- global $wpdb;
618
- global $wplc_tblname_chats;
619
- $results = $wpdb->get_results(
620
- "
621
- SELECT *
622
- FROM $wplc_tblname_chats
623
- WHERE `id` = '$cid'
624
- "
625
- );
626
- foreach ($results as $result) {
627
- return $result->name;
628
- }
629
 
630
- }
631
- function wplc_return_chat_status($cid) {
632
- global $wpdb;
633
- global $wplc_tblname_chats;
634
- $results = $wpdb->get_results(
635
- "
636
- SELECT *
637
- FROM $wplc_tblname_chats
638
- WHERE `id` = '$cid'
639
- "
640
- );
641
- foreach ($results as $result) {
642
- return $result->status;
643
- }
644
- }
645
-
646
-
647
- function wplc_return_status($status) {
648
- if ($status == 1) {
649
- return "complete";
650
- }
651
- if ($status == 2) {
652
- return "pending";
653
- }
654
- if ($status == 3) {
655
- return "active";
656
- }
657
- if ($status == 4) {
658
- return "deleted";
659
- }
660
- if ($status == 5) {
661
- return "browsing";
662
- }
663
- if ($status == 6) {
664
- return "requesting chat";
665
- }
666
- }
667
 
668
  function wplc_superadmin_javascript() {
669
 
@@ -726,7 +252,7 @@ function wplc_admin_javascript() {
726
  ?>
727
  <script type="text/javascript">
728
  jQuery(document).ready(function() {
729
-
730
  var wplc_autoLoad = null;
731
  var wplc_refresh_chat_area = null;
732
  var wplc_refresh_status = null;
@@ -740,7 +266,7 @@ function wplc_admin_javascript() {
740
  action: 'wplc_update_admin_chat',
741
  security: '<?php echo $ajax_nonce; ?>'
742
  };
743
- jQuery.post(ajaxurl, data, function(response) {
744
  //console.log("wplc_update_admin_chat");
745
  jQuery("#wplc_admin_chat_area").html(response);
746
  if (response.indexOf("pending") >= 0) {
@@ -764,7 +290,7 @@ function wplc_admin_javascript() {
764
  action: 'wplc_update_admin_status',
765
  security: '<?php echo $ajax_nonce; ?>'
766
  };
767
- jQuery.post(ajaxurl, data, function(response) {
768
  //console.log("wplc_update_admin_status");
769
  //alert(response);
770
  });
@@ -780,75 +306,25 @@ function wplc_admin_javascript() {
780
  }
781
 
782
 
783
- function wplc_list_chats() {
784
-
785
- global $wpdb;
786
- global $wplc_tblname_chats;
787
-
788
- $results = $wpdb->get_results(
789
- "
790
- SELECT *
791
- FROM $wplc_tblname_chats
792
- WHERE `status` = 3 OR `status` = 2
793
- ORDER BY `timestamp` ASC
794
-
795
- "
796
- );
797
- echo "
798
-
799
-
800
- <table class=\"wp-list-table widefat fixed \" cellspacing=\"0\">
801
- <thead>
802
- <tr>
803
- <th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>".__("IP","wplivechat")."</span></th>
804
- <th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>".__("Name","wplivechat")."</span></th>
805
- <th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">".__("Email","wplivechat")."</th>
806
- <th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">".__("URL","wplivechat")."</th>
807
- <th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">".__("Status","wplivechat")."</th>
808
- <th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>".__("Action","wplivechat")."</span></th>
809
- </tr>
810
- </thead>
811
- <tbody id=\"the-list\" class='list:wp_list_text_link'>
812
- ";
813
-
814
- if (!$results) {
815
- echo "<tr><td></td><td>".__("No chat sessions available at the moment","wplivechat")."</td></tr>";
816
- }
817
- else {
818
- foreach ($results as $result) {
819
- unset($trstyle);
820
- unset($actions);
821
- $wplc_c++;
822
-
823
- if ($result->status == 2) {
824
- $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
825
- $actions = "<a href=\"#\" onclick=\"window.open('$url', 'mywindow".$result->id."', 'location=no,status=1,scrollbars=1,width=500,height=650');return false;\">Accept Chat</a>";
826
- $trstyle = "style='background-color:#FFFBE4; height:30px;'";
827
- }
828
- if ($result->status == 3) {
829
- $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
830
- $actions = "<a href=\"#\" onclick=\"window.open('$url', 'mywindow".$result->id."', 'location=no,status=1,scrollbars=1,width=500,height=650');return false;\">Open Chat Window</a>";
831
- $trstyle = "style='background-color:#F7FCFE; height:30px;'";
832
- }
833
 
 
 
 
 
 
 
834
 
835
- echo "<tr id=\"record_".$result->id."\" $trstyle>";
836
- echo "<td class='chat_id column-chat_d'>".$result->ip."</td>";
837
- echo "<td class='chat_name column_chat_name' id='chat_name_".$result->id."'><img src=\"http://www.gravatar.com/avatar/".md5($result->email)."?s=40\" /> ".$result->name."</td>";
838
- echo "<td class='chat_email column_chat_email' id='chat_email_".$result->id."'>".$result->email."</td>";
839
- echo "<td class='chat_name column_chat_url' id='chat_url_".$result->id."'>".$result->url."</td>";
840
- echo "<td class='chat_status column_chat_status' id='chat_status_".$result->id."'><strong>".wplc_return_status($result->status)."</strong></td>";if ($wplc_c>1 && !function_exists("wplc_register_pro_version")) { $actions = wplc_get_msg(); }
841
- echo "<td class='chat_action column-chat_action' id='chat_action_".$result->id."'>$actions</td>";
842
- echo "</tr>";
843
 
844
- }
845
- }
846
- echo "</table><br /><br />";
847
-
848
 
849
- }
850
 
851
- function wplc_admin_menu_layout() {
852
  if (function_exists("wplc_register_pro_version")) {
853
  wplc_pro_admin_menu_layout_display();
854
  } else {
@@ -858,14 +334,18 @@ function wplc_admin_menu_layout() {
858
  }
859
 
860
  function wplc_admin_menu_layout_display() {
861
-
862
  if (!isset($_GET['action'])) {
863
 
864
  ?>
865
  <h1>Live Chat</h1>
866
  <div id="wplc_sound"></div>
 
 
 
 
867
  <div id="wplc_admin_chat_area">
868
- <?php wplc_list_chats(); ?>
 
869
  </div>
870
  <h1>Online Visitors</h1>
871
  <p><?php _e("With the Pro add-on of WP Live Chat Support, you can","wplivechat"); ?> <a href="http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate1" title="<?php _e("see who's online and initiate chats","wplivechat"); ?>" target=\"_BLANK\"><?php _e("see who's online and initiate chats","wplivechat"); ?></a> <?php _e("with your online visitors with the click of a button.","wplivechat"); ?> <a href="http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate2" title="<?php _e("Buy the Pro add-on now for only $14.95 once off. Updates free forever.","wplivechat"); ?>" target=\"_BLANK\"><strong><?php _e("Buy the Pro add-on now for only $14.95 once off. Updates free forever.","wplivechat"); ?></strong></a></p>
@@ -898,8 +378,10 @@ function wplc_draw_chat_area($cid) {
898
  if ($result->status == 1) { $status = "Previous"; } else { $status = "Active"; }
899
 
900
  echo "<h2>$status Chat with ".$result->name."</h2>";
 
901
  echo "<div style='display:block;'>";
902
  echo "<div style='float:left; width:100px;'><img src=\"http://www.gravatar.com/avatar/".md5($result->email)."\" /></div>";
 
903
  echo "<div style='float:left; width:350px;'>";
904
  echo "<table>";
905
  echo "<tr><td>Email address</td><td><a href='mailto:".$result->email."' title='".$result->email."'>".$result->email."</a></td></tr>";
@@ -929,17 +411,15 @@ function wplc_draw_chat_area($cid) {
929
 
930
  }
931
  }
932
- function wplc_get_msg() {
933
- return "<a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=morechats\" title=\"".__("Get Pro Add-on to accept more chats","wplivechat")."\" target=\"_BLANK\">Get Pro Add-on to accept more chats</a>";
934
- }
935
 
936
  function wplc_return_admin_chat_javascript($cid) {
937
  $ajax_nonce = wp_create_nonce("wplc");
938
  ?>
939
  <script type="text/javascript">
940
  jQuery(document).ready(function() {
941
-
942
-
 
943
  var wplc_nonce = '<?php echo $ajax_nonce; ?>';
944
  var wplc_gcid = '<?php echo $cid; ?>';
945
 
@@ -957,7 +437,7 @@ function wplc_return_admin_chat_javascript($cid) {
957
  cid: cid,
958
  security: wplc_nonce
959
  };
960
- jQuery.post(ajaxurl, data, function(response) {
961
  //console.log("wplc_admin_accept_chat");
962
  wplc_refresh_chat_boxes[cid] = setInterval(function (){wpcl_admin_update_chat_box(cid);}, 3000);
963
  jQuery("#admin_chat_box_"+cid).show();
@@ -988,7 +468,7 @@ function wplc_return_admin_chat_javascript($cid) {
988
  cid: wplc_cid,
989
  msg: wplc_chat
990
  };
991
- jQuery.post(ajaxurl, data, function(response) {
992
  //console.log("wplc_admin_send_msg");
993
 
994
  });
@@ -999,16 +479,23 @@ function wplc_return_admin_chat_javascript($cid) {
999
 
1000
  wplc_auto_refresh = setInterval(function (){wpcl_admin_auto_update_chat_box(wplc_gcid);}, 3500);
1001
  function wpcl_admin_auto_update_chat_box(cid) {
1002
-
 
 
1003
  var data = {
1004
  action: 'wplc_update_admin_chat_boxes',
1005
  cid: cid,
1006
  security: wplc_nonce
1007
  };
1008
- jQuery.post(ajaxurl, data, function(response) {
1009
  //console.log("wplc_update_admin_chat_boxes");
1010
  //jQuery("#admin_chat_box_area_"+cid).html(response);
1011
  jQuery("#admin_chat_box_area_"+cid).append(response);
 
 
 
 
 
1012
  var height = jQuery('#admin_chat_box_area_'+cid)[0].scrollHeight;
1013
  jQuery('#admin_chat_box_area_'+cid).scrollTop(height);
1014
  });
@@ -1026,7 +513,7 @@ function wplc_return_admin_chat_javascript($cid) {
1026
  cid: <?php echo $cid; ?>,
1027
  security: '<?php echo $ajax_nonce; ?>'
1028
  };
1029
- jQuery.post(ajaxurl, data, function(response) {
1030
  //console.log("wplc_update_admin_return_chat_status");
1031
  if (chat_status != response) {
1032
  chat_status = response;
@@ -1323,4 +810,7 @@ function wplc_head() {
1323
  function wplc_logout() {
1324
  delete_transient('wplc_is_admin_logged_in');
1325
  }
1326
- add_action('wp_logout', 'wplc_logout');
 
 
 
3
  Plugin Name: WP Live Chat Support
4
  Plugin URI: http://www.wp-livechat.com
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 Support. No third party connection required!
6
+ Version: 2.5
7
  Author: WP-LiveChat
8
  Author URI: http://www.wp-livechat.com
9
  */
17
  global $wplc_tblname_msgs;
18
  $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
19
  $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
20
+ $wplc_version = "2.5";
21
 
22
+ require_once ("functions.php");
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  add_action('wp_ajax_wplc_admin_set_transient', 'wplc_action_callback');
 
 
 
 
25
 
26
+ add_action('wp_footer', 'wplc_display_box');
27
  add_action('admin_head', 'wplc_head');
28
  add_action( 'wp_enqueue_scripts', 'wplc_add_user_stylesheet' );
29
  add_action('admin_menu', 'wplc_admin_menu');
31
  register_activation_hook( __FILE__, 'wplc_activate' );
32
 
33
 
34
+
35
+
36
+ function wplc_action_callback() {
37
+ global $wpdb;
38
+ global $wplc_tblname_chats;
39
+ $check = check_ajax_referer( 'wplc', 'security' );
40
+
41
+ if ($check == 1) {
42
+
43
+ if ($_POST['action'] == "wplc_admin_set_transient") {
44
+ set_transient("wplc_is_admin_logged_in", "1", 70 );
45
+
46
+ }
47
+ }
48
+
49
+ die(); // this is required to return a proper result
50
+
51
+ }
52
+
53
+
54
+
55
+
56
  function wplc_admin_menu() {
57
  $wplc_mainpage = add_menu_page('WP Live Chat', __('Live Chat','wplivechat'), 'manage_options', 'wplivechat-menu', 'wplc_admin_menu_layout');
58
  add_submenu_page('wplivechat-menu', __('Settings','wplivechat'), __('Settings','wplivechat'), 'manage_options' , 'wplivechat-menu-settings', 'wplc_admin_settings_layout');
70
  $wplc_settings = get_option("WPLC_SETTINGS");
71
  ?>
72
  <script type="text/javascript">
73
+ <?php if (!function_exists("wplc_register_pro_version")) { ?>
74
+ var wplc_ajaxurl = '<?php echo plugins_url('/ajax.php', __FILE__); ?>';
75
+ <?php } ?>
76
  var wplc_nonce = '<?php echo $ajax_nonce; ?>';
77
+ </script>
78
  <?php
79
  }
80
 
162
  }
163
 
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  function wplc_admin_display_chat($cid) {
167
  global $wpdb;
168
  global $wplc_tblname_msgs;
189
 
190
  }
191
  add_action('admin_head','wplc_update_chat_statuses');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
  function wplc_superadmin_javascript() {
195
 
252
  ?>
253
  <script type="text/javascript">
254
  jQuery(document).ready(function() {
255
+ var wplc_ajaxurl = '<?php echo plugins_url('/ajax.php', __FILE__); ?>';
256
  var wplc_autoLoad = null;
257
  var wplc_refresh_chat_area = null;
258
  var wplc_refresh_status = null;
266
  action: 'wplc_update_admin_chat',
267
  security: '<?php echo $ajax_nonce; ?>'
268
  };
269
+ jQuery.post(wplc_ajaxurl, data, function(response) {
270
  //console.log("wplc_update_admin_chat");
271
  jQuery("#wplc_admin_chat_area").html(response);
272
  if (response.indexOf("pending") >= 0) {
290
  action: 'wplc_update_admin_status',
291
  security: '<?php echo $ajax_nonce; ?>'
292
  };
293
+ jQuery.post(wplc_ajaxurl, data, function(response) {
294
  //console.log("wplc_update_admin_status");
295
  //alert(response);
296
  });
306
  }
307
 
308
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
 
310
+ function wplc_admin_menu_layout() {
311
+ if (function_exists("wplc_register_pro_version")) {
312
+ global $wplc_pro_version;
313
+ if ($wplc_pro_version < 2.3) {
314
+ ?>
315
+ <div class='error below-h1'>
316
 
317
+ <p>Dear Pro User<br /></p>
318
+ <p>You are using an outdated version of WP Live Chat Support Pro. Please <a href="<?php echo get_option('siteurl'); ?>/wp-admin/update-core.php\" target=\"_BLANK\">update to at least version 2.3</a> to ensure all functionality is in working order.</p>
319
+ <p>&nbsp;</p>
320
+ <p>If you are having difficulty updating the plugin, please contact nick@wp-livechat.com</p>
 
 
 
 
321
 
322
+ </div>
323
+ <?php
324
+ }
 
325
 
 
326
 
327
+ }
328
  if (function_exists("wplc_register_pro_version")) {
329
  wplc_pro_admin_menu_layout_display();
330
  } else {
334
  }
335
 
336
  function wplc_admin_menu_layout_display() {
 
337
  if (!isset($_GET['action'])) {
338
 
339
  ?>
340
  <h1>Live Chat</h1>
341
  <div id="wplc_sound"></div>
342
+
343
+
344
+
345
+
346
  <div id="wplc_admin_chat_area">
347
+
348
+ <?php if (function_exists("wplc_register_pro_version")) { wplc_list_chats_pro(); } else { wplc_list_chats(); } ?>
349
  </div>
350
  <h1>Online Visitors</h1>
351
  <p><?php _e("With the Pro add-on of WP Live Chat Support, you can","wplivechat"); ?> <a href="http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate1" title="<?php _e("see who's online and initiate chats","wplivechat"); ?>" target=\"_BLANK\"><?php _e("see who's online and initiate chats","wplivechat"); ?></a> <?php _e("with your online visitors with the click of a button.","wplivechat"); ?> <a href="http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate2" title="<?php _e("Buy the Pro add-on now for only $14.95 once off. Updates free forever.","wplivechat"); ?>" target=\"_BLANK\"><strong><?php _e("Buy the Pro add-on now for only $14.95 once off. Updates free forever.","wplivechat"); ?></strong></a></p>
378
  if ($result->status == 1) { $status = "Previous"; } else { $status = "Active"; }
379
 
380
  echo "<h2>$status Chat with ".$result->name."</h2>";
381
+ echo "<style>#adminmenuwrap { display:none; } #adminmenuback { display:none; } #wpadminbar { display:none; } #wpfooter { display:none; } .update-nag { display:none; }</style>";
382
  echo "<div style='display:block;'>";
383
  echo "<div style='float:left; width:100px;'><img src=\"http://www.gravatar.com/avatar/".md5($result->email)."\" /></div>";
384
+ echo "<div id=\"wplc_sound_update\"></div>";
385
  echo "<div style='float:left; width:350px;'>";
386
  echo "<table>";
387
  echo "<tr><td>Email address</td><td><a href='mailto:".$result->email."' title='".$result->email."'>".$result->email."</a></td></tr>";
411
 
412
  }
413
  }
 
 
 
414
 
415
  function wplc_return_admin_chat_javascript($cid) {
416
  $ajax_nonce = wp_create_nonce("wplc");
417
  ?>
418
  <script type="text/javascript">
419
  jQuery(document).ready(function() {
420
+
421
+
422
+ var wplc_ajaxurl = '<?php echo plugins_url('/ajax.php', __FILE__); ?>';
423
  var wplc_nonce = '<?php echo $ajax_nonce; ?>';
424
  var wplc_gcid = '<?php echo $cid; ?>';
425
 
437
  cid: cid,
438
  security: wplc_nonce
439
  };
440
+ jQuery.post(wplc_ajaxurl, data, function(response) {
441
  //console.log("wplc_admin_accept_chat");
442
  wplc_refresh_chat_boxes[cid] = setInterval(function (){wpcl_admin_update_chat_box(cid);}, 3000);
443
  jQuery("#admin_chat_box_"+cid).show();
468
  cid: wplc_cid,
469
  msg: wplc_chat
470
  };
471
+ jQuery.post(wplc_ajaxurl, data, function(response) {
472
  //console.log("wplc_admin_send_msg");
473
 
474
  });
479
 
480
  wplc_auto_refresh = setInterval(function (){wpcl_admin_auto_update_chat_box(wplc_gcid);}, 3500);
481
  function wpcl_admin_auto_update_chat_box(cid) {
482
+ current_len = jQuery("#admin_chat_box_area_"+cid).html().length;
483
+
484
+
485
  var data = {
486
  action: 'wplc_update_admin_chat_boxes',
487
  cid: cid,
488
  security: wplc_nonce
489
  };
490
+ jQuery.post(wplc_ajaxurl, data, function(response) {
491
  //console.log("wplc_update_admin_chat_boxes");
492
  //jQuery("#admin_chat_box_area_"+cid).html(response);
493
  jQuery("#admin_chat_box_area_"+cid).append(response);
494
+ new_length = jQuery("#admin_chat_box_area_"+cid).html().length;
495
+ if (current_len < new_length) {
496
+ document.getElementById("wplc_sound_update").innerHTML="<embed src='<?php echo plugins_url('/ding.mp3', __FILE__); ?>' hidden=true autostart=true loop=false>";
497
+ }
498
+
499
  var height = jQuery('#admin_chat_box_area_'+cid)[0].scrollHeight;
500
  jQuery('#admin_chat_box_area_'+cid).scrollTop(height);
501
  });
513
  cid: <?php echo $cid; ?>,
514
  security: '<?php echo $ajax_nonce; ?>'
515
  };
516
+ jQuery.post(wplc_ajaxurl, data, function(response) {
517
  //console.log("wplc_update_admin_return_chat_status");
518
  if (chat_status != response) {
519
  chat_status = response;
810
  function wplc_logout() {
811
  delete_transient('wplc_is_admin_logged_in');
812
  }
813
+ add_action('wp_logout', 'wplc_logout');
814
+
815
+
816
+