Version Description
Download this release
Release Info
Developer | WP-LiveChat |
Plugin | WP Live Chat Support |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- beep-2.mp3 +0 -0
- jquery-cookie.js +72 -0
- readme.txt +66 -0
- screenshot-1.JPG +0 -0
- screenshot-2.JPG +0 -0
- wp-live-chat-support.php +1141 -0
- wplcstyle.css +10 -0
beep-2.mp3
ADDED
Binary file
|
jquery-cookie.js
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* jQuery Cookie Plugin v1.3
|
3 |
+
* https://github.com/carhartl/jquery-cookie
|
4 |
+
*
|
5 |
+
* Copyright 2011, Klaus Hartl
|
6 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
7 |
+
* http://www.opensource.org/licenses/mit-license.php
|
8 |
+
* http://www.opensource.org/licenses/GPL-2.0
|
9 |
+
*/
|
10 |
+
(function ($, document, undefined) {
|
11 |
+
|
12 |
+
var pluses = /\+/g;
|
13 |
+
|
14 |
+
function raw(s) {
|
15 |
+
return s;
|
16 |
+
}
|
17 |
+
|
18 |
+
function decoded(s) {
|
19 |
+
return decodeURIComponent(s.replace(pluses, ' '));
|
20 |
+
}
|
21 |
+
|
22 |
+
var config = $.cookie = function (key, value, options) {
|
23 |
+
|
24 |
+
// write
|
25 |
+
if (value !== undefined) {
|
26 |
+
options = $.extend({}, config.defaults, options);
|
27 |
+
|
28 |
+
if (value === null) {
|
29 |
+
options.expires = -1;
|
30 |
+
}
|
31 |
+
|
32 |
+
if (typeof options.expires === 'number') {
|
33 |
+
var days = options.expires, t = options.expires = new Date();
|
34 |
+
t.setDate(t.getDate() + days);
|
35 |
+
}
|
36 |
+
|
37 |
+
value = config.json ? JSON.stringify(value) : String(value);
|
38 |
+
|
39 |
+
return (document.cookie = [
|
40 |
+
encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
|
41 |
+
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
42 |
+
options.path ? '; path=' + options.path : '',
|
43 |
+
options.domain ? '; domain=' + options.domain : '',
|
44 |
+
options.secure ? '; secure' : ''
|
45 |
+
].join(''));
|
46 |
+
}
|
47 |
+
|
48 |
+
// read
|
49 |
+
var decode = config.raw ? raw : decoded;
|
50 |
+
var cookies = document.cookie.split('; ');
|
51 |
+
for (var i = 0, l = cookies.length; i < l; i++) {
|
52 |
+
var parts = cookies[i].split('=');
|
53 |
+
if (decode(parts.shift()) === key) {
|
54 |
+
var cookie = decode(parts.join('='));
|
55 |
+
return config.json ? JSON.parse(cookie) : cookie;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
return null;
|
60 |
+
};
|
61 |
+
|
62 |
+
config.defaults = {};
|
63 |
+
|
64 |
+
$.removeCookie = function (key, options) {
|
65 |
+
if ($.cookie(key) !== null) {
|
66 |
+
$.cookie(key, null, options);
|
67 |
+
return true;
|
68 |
+
}
|
69 |
+
return false;
|
70 |
+
};
|
71 |
+
|
72 |
+
})(jQuery, document);
|
readme.txt
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WP Live Chat Support ===
|
2 |
+
Contributors: WP-LiveChat
|
3 |
+
Donate link: http://www.wp-livechat.com
|
4 |
+
Tags: live chat, live support, live help, plugin, widget, wordpress chat, customer support, chat
|
5 |
+
Requires at least: 3.4
|
6 |
+
Tested up to: 3.5
|
7 |
+
Stable tag: trunk
|
8 |
+
|
9 |
+
The easiest to use Live Chat plugin. Chat with your visitors!
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
The easiest to use Live Chat plugin. Chat with your visitors! Perfect for small businesses. No third party connections or subscriptions required. There's no need to pay monthly subscriptions in order to better understand your visitors. This is a fully functional chat plugin. Increase your conversion rates by communicating directly with your visitors when they're ready to do so.
|
14 |
+
|
15 |
+
= Free version =
|
16 |
+
* Chat with your visitors
|
17 |
+
* Easy to use interface for both the admin and the visitor
|
18 |
+
* Fully functional free version
|
19 |
+
* No advertising or links
|
20 |
+
* No monthly subscriptions needed
|
21 |
+
|
22 |
+
|
23 |
+
= Pro add-on =
|
24 |
+
* Chat to more than one visitor at a time
|
25 |
+
* Initiate chat's with online visitors
|
26 |
+
* Access historical chat records
|
27 |
+
* Set up your user profile
|
28 |
+
* Add your company logo to the chat window
|
29 |
+
* Add your photo to the chat window
|
30 |
+
* Edit all text fields
|
31 |
+
* World-class support
|
32 |
+
* Fully customizable chat experience
|
33 |
+
* Get the [WP Live Chat Support Pro Add-on](http://wp-livechat.com/purchase-pro/) for only $9.95 once off!
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
== Installation ==
|
38 |
+
|
39 |
+
1. Once activated, click the "Live Chat" link under your settings tabs.
|
40 |
+
2. Edit the settings to your preference.
|
41 |
+
3. Test it out in a post or page.
|
42 |
+
|
43 |
+
|
44 |
+
== Frequently Asked Questions ==
|
45 |
+
|
46 |
+
= I've installed the plugin, now what? =
|
47 |
+
|
48 |
+
Once installed and activated, a link should appear in your left navigation panel within your WP-ADMIN section. Click on the "Live Chat" link and follow the on screen instructions.
|
49 |
+
|
50 |
+
|
51 |
+
== Screenshots ==
|
52 |
+
|
53 |
+
1. Front-end Chat Window
|
54 |
+
2. Back-end Chat Window
|
55 |
+
|
56 |
+
|
57 |
+
== Upgrade Notice ==
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
== Changelog ==
|
62 |
+
|
63 |
+
= 1.0 =
|
64 |
+
* Launch!
|
65 |
+
|
66 |
+
|
screenshot-1.JPG
ADDED
Binary file
|
screenshot-2.JPG
ADDED
Binary file
|
wp-live-chat-support.php
ADDED
@@ -0,0 +1,1141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
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. No third party connection required!
|
6 |
+
Version: 1.0
|
7 |
+
Author: WP-LiveChat
|
8 |
+
Author URI: http://www.wp-livechat.com
|
9 |
+
*/
|
10 |
+
|
11 |
+
error_reporting(E_ERROR);
|
12 |
+
global $wplc_version;
|
13 |
+
global $wplc_p_version;
|
14 |
+
global $wplc_tblname;
|
15 |
+
global $wpdb;
|
16 |
+
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 = "1.0";
|
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');
|
52 |
+
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');
|
59 |
+
add_submenu_page('wplivechat-menu', __('History','wplivechat'), __('History','wplivechat'), 'manage_options' , 'wplivechat-menu-history', 'wplc_admin_history_layout');
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
function wplc_draw_user_box() {
|
65 |
+
$ajax_nonce = wp_create_nonce("wplc");
|
66 |
+
wp_register_script( 'wplc-user-jquery-cookie', plugins_url('/jquery-cookie.js', __FILE__) );
|
67 |
+
wp_enqueue_script( 'wplc-user-jquery-cookie' );
|
68 |
+
$wplc_settings = get_option("WPLC_SETTINGS");
|
69 |
+
|
70 |
+
|
71 |
+
?>
|
72 |
+
|
73 |
+
<script type="text/javascript">
|
74 |
+
jQuery(document).ready(function() {
|
75 |
+
|
76 |
+
|
77 |
+
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
|
78 |
+
var wplc_nonce = '<?php echo $ajax_nonce; ?>';
|
79 |
+
function wplc_relay_user_stage(e,t){if(t.length){var n={action:"wplc_relay_stage",security:wplc_nonce,stage:e,cid:t}}else{var n={action:"wplc_relay_stage",security:wplc_nonce,stage:e}}jQuery.post(ajaxurl,n,function(e){})}function wplc_user_await_session(e){var t={action:"wplc_user_awaiting_chat",security:wplc_nonce,id:e};jQuery.post(ajaxurl,t,function(t){if(t=="3"){clearInterval(wplc_user_waiting);var n=jQuery("#wplc_name").val();jQuery("#wplc_cid").val(e);jQuery("#wp-live-chat-3").hide();jQuery("#wp-live-chat-4").show();jQuery.cookie("wplc_cid",e,{expires:1,path:"/"});jQuery.cookie("wplc_name",n,{expires:1,path:"/"});jQuery.cookie("wplc_stage",3,{expires:1,path:"/"});wplc_user_auto_refresh=setInterval(function(){wpcl_user_auto_update_chat_box(e)},3500)}});return}function wpcl_user_auto_update_chat_box(e){var t={action:"wplc_update_user_chat_boxes",cid:e,security:wplc_nonce};jQuery.post(ajaxurl,t,function(e){jQuery("#wplc_chatbox").append(e);var t=jQuery("#wplc_chatbox")[0].scrollHeight;jQuery("#wplc_chatbox").scrollTop(t)})}var wplc_check_cookie_id;var wplc_check_cookie_stage;var wplc_check_hide_cookie;wplc_check_cookie_id=jQuery.cookie("wplc_cid");wplc_check_cookie_stage=jQuery.cookie("wplc_stage");wplc_check_hide_cookie=jQuery.cookie("wplc_hide");jQuery("#wp-live-chat-close").live("click",function(){jQuery("#wp-live-chat").hide();jQuery.cookie("wplc_hide","yes",{expires:1,path:"/"});clearInterval(wplc_user_auto_refresh);var e={action:"wplc_user_close_chat",security:wplc_nonce,cid:wplc_check_cookie_id};jQuery.post(ajaxurl,e,function(e){})});jQuery("#wplc-sb").live("click",function(){jQuery("#wp-live-chat-1").hide();jQuery("#wp-live-chat-2").show()});var wplc_user_waiting=null;jQuery("#wplc_start_chat_btn").live("click",function(){var e=jQuery("#wplc_name").val();var t=jQuery("#wplc_email").val();if(e.length<=0){alert("Please enter your name");return false}if(t.length<=0){alert("Please enter your email address");return false}jQuery("#wp-live-chat-2").hide();jQuery("#wp-live-chat-3").show();wplc_check_cookie_id=jQuery.cookie("wplc_cid");var n;var r={action:"wplc_start_chat",security:wplc_nonce,name:e,email:t};jQuery.post(ajaxurl,r,function(e){n=e;wplc_check_cookie_id=e;wplc_user_waiting=setInterval(function(){wplc_user_await_session(n)},5e3)})});jQuery("#wplc_chatmsg").keyup(function(e){if(e.keyCode==13){jQuery("#wplc_send_msg").click()}});jQuery("#wplc_send_msg").live("click",function(){var e=jQuery("#wplc_cid").val();var t=jQuery("#wplc_chatmsg").val();var n=jQuery("#wplc_name").val();if(typeof n=="undefined"||n==null||n==""){n=jQuery.cookie("wplc_name")}jQuery("#wplc_chatmsg").val("");jQuery("#wplc_chatbox").append("<strong>"+n+"</strong>: "+t+"<br />");var r=jQuery("#wplc_chatbox")[0].scrollHeight;jQuery("#wplc_chatbox").scrollTop(r);var i={action:"wplc_user_send_msg",security:wplc_nonce,cid:e,msg:t};jQuery.post(ajaxurl,i,function(e){})});if(wplc_check_hide_cookie=="yes"){jQuery("#wp-live-chat").hide()}else{if(typeof wplc_check_cookie_id=="undefined"||wplc_check_cookie_id==null){wplc_dc=setTimeout(function(){jQuery("#wp-live-chat").css({display:"block"})},1e4)}else{jQuery("#wplc_cid").val(wplc_check_cookie_id);jQuery("#wp-live-chat-1").hide();jQuery("#wp-live-chat-2").hide();jQuery("#wp-live-chat-3").hide();jQuery("#wp-live-chat-4").hide();jQuery("#wp-live-chat-react").show();jQuery("#wp-live-chat").css({display:"block"});var data={action:"wplc_user_reactivate_chat",security:wplc_nonce,cid:wplc_check_cookie_id};jQuery.post(ajaxurl,data,function(e){jQuery("#wp-live-chat-react").hide();jQuery("#wp-live-chat-4").show();wplc_user_auto_refresh=setInterval(function(){wpcl_user_auto_update_chat_box(wplc_check_cookie_id)},3500)})}}
|
80 |
+
|
81 |
+
});
|
82 |
+
</script>
|
83 |
+
|
84 |
+
<?php
|
85 |
+
wplc_output_box();
|
86 |
+
|
87 |
+
}
|
88 |
+
function wplc_output_box() {
|
89 |
+
$wplc_settings = get_option("WPLC_SETTINGS");
|
90 |
+
|
91 |
+
if ($wplc_settings["wplc_settings_align"] == 1) { $wplc_box_align = "left:100px;"; } else { $wplc_box_align = "right:100px;"; }
|
92 |
+
|
93 |
+
|
94 |
+
?>
|
95 |
+
<div id="wp-live-chat" style="position:fixed;bottom:0px; <?php echo $wplc_box_align; ?> ;z-index:105;display:none; background-color:#FFF; border:1px solid #CCC; padding:15px;">
|
96 |
+
|
97 |
+
|
98 |
+
<?php if (function_exists("wplc_register_pro_version")) {
|
99 |
+
wplc_pro_output_box();
|
100 |
+
} else {
|
101 |
+
?>
|
102 |
+
|
103 |
+
<div id="wp-live-chat-close">X</div>
|
104 |
+
<div id="wp-live-chat-1">
|
105 |
+
<h4>Need Help?</h4>
|
106 |
+
<p>Click the link below for assistance</p>
|
107 |
+
<a href="javascript:void(0);" id="wplc-sb">Start live chat</a>
|
108 |
+
</div>
|
109 |
+
<div id="wp-live-chat-2" style="display:none;">
|
110 |
+
<h4>Start Live Chat</h4>
|
111 |
+
<table>
|
112 |
+
<tr>
|
113 |
+
<td><?php _e("Name","wplivechat"); ?></td>
|
114 |
+
<td><input type="text" name="wplc_name" id="wplc_name" value="" /></td>
|
115 |
+
</tr>
|
116 |
+
<tr>
|
117 |
+
<td><?php _e("Email","wplivechat"); ?></td>
|
118 |
+
<td><input type="text" name="wplc_email" id="wplc_email" value="" /></td>
|
119 |
+
</tr>
|
120 |
+
<tr>
|
121 |
+
<td></td>
|
122 |
+
<td><input id="wplc_start_chat_btn" type="button" value="Start Chat" /></td>
|
123 |
+
</tr>
|
124 |
+
</table>
|
125 |
+
</div>
|
126 |
+
<div id="wp-live-chat-3" style="display:none;">
|
127 |
+
<p>Connecting you to a sales person. Please be patient.</p>
|
128 |
+
</div>
|
129 |
+
<div id="wp-live-chat-react" style="display:none;">
|
130 |
+
<p>Reactivating your previous chat...</p>
|
131 |
+
</div>
|
132 |
+
<div id="wp-live-chat-4" style="display:none;">
|
133 |
+
<div id="wplc_chatbox" style="height:200px; overflow:auto; width:100%;"></div>
|
134 |
+
<p>
|
135 |
+
<input type="text" name="wplc_chatmsg" id="wplc_chatmsg" value="" />
|
136 |
+
<input type="hidden" name="wplc_cid" id="wplc_cid" value="" />
|
137 |
+
<input id="wplc_send_msg" type="button" value="<?php _e("Send","wplc"); ?>" /></p>
|
138 |
+
</div>
|
139 |
+
|
140 |
+
</div>
|
141 |
+
<?php
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
function wplc_display_box() {
|
146 |
+
$wplc_is_admin_logged_in = get_transient("wplc_is_admin_logged_in");
|
147 |
+
|
148 |
+
if ($wplc_is_admin_logged_in == 1) {
|
149 |
+
if (function_exists("wplc_register_pro_version")) {
|
150 |
+
wplc_pro_draw_user_box();
|
151 |
+
} else {
|
152 |
+
wplc_draw_user_box();
|
153 |
+
}
|
154 |
+
}
|
155 |
+
else {
|
156 |
+
if (function_exists("wplc_register_pro_version")) { wplc_pro_draw_not_available_box(); }
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
|
161 |
+
function wplc_action_callback() {
|
162 |
+
global $wpdb;
|
163 |
+
global $wplc_tblname_chats;
|
164 |
+
$check = check_ajax_referer( 'wplc', 'security' );
|
165 |
+
|
166 |
+
if ($check == 1) {
|
167 |
+
if ($_POST['action'] == "wplc_start_chat") {
|
168 |
+
if ($_POST['cid']) {
|
169 |
+
if ($_POST['name'] && $_POST['email']) {
|
170 |
+
echo wplc_user_initiate_chat($_POST['name'],$_POST['email'],$_POST['cid']); // echo the chat session id
|
171 |
+
} else {
|
172 |
+
echo "error2";
|
173 |
+
}
|
174 |
+
} else {
|
175 |
+
if ($_POST['name'] && $_POST['email']) {
|
176 |
+
echo wplc_user_initiate_chat($_POST['name'],$_POST['email']); // echo the chat session id
|
177 |
+
} else {
|
178 |
+
echo "error2";
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
if ($_POST['action'] == "wplc_relay_stage") {
|
183 |
+
if ($_POST['stage'] == "1") { // chat window is displayed to user
|
184 |
+
echo wplc_log_user_on_page("user".time(),"no email set");
|
185 |
+
}
|
186 |
+
else if ($_POST['stage'] == "2") { // user still hasnt opened chat window but is now on another page
|
187 |
+
echo wplc_update_user_on_page($_POST['cid']);
|
188 |
+
|
189 |
+
}
|
190 |
+
}
|
191 |
+
if ($_POST['action'] == "wplc_update_admin_chat") {
|
192 |
+
wplc_list_chats();
|
193 |
+
}
|
194 |
+
if ($_POST['action'] == "wplc_update_admin_status") {
|
195 |
+
wplc_update_chat_statuses();
|
196 |
+
}
|
197 |
+
if ($_POST['action'] == "wplc_admin_accept_chat") {
|
198 |
+
wplc_admin_accept_chat($_POST['cid']);
|
199 |
+
}
|
200 |
+
if ($_POST['action'] == "wplc_update_admin_chat_boxes") {
|
201 |
+
echo wplc_return_admin_chat_messages($_POST['cid']);
|
202 |
+
wplc_mark_as_read_admin_chat_messages($_POST['cid']);
|
203 |
+
}
|
204 |
+
if ($_POST['action'] == "wplc_update_admin_return_chat_status") {
|
205 |
+
echo wplc_return_chat_status($_POST['cid']);
|
206 |
+
}
|
207 |
+
|
208 |
+
if ($_POST['action'] == "wplc_admin_send_msg") {
|
209 |
+
$chat_id = $_POST['cid'];
|
210 |
+
$chat_msg = $_POST['msg'];
|
211 |
+
$wplc_rec_msg = wplc_record_chat_msg("2",$chat_id,$chat_msg);
|
212 |
+
if ($wplc_rec_msg) {
|
213 |
+
echo 'sent';
|
214 |
+
} else {
|
215 |
+
echo "There was an error sending your chat message. Please contact support";
|
216 |
+
}
|
217 |
+
}
|
218 |
+
if ($_POST['action'] == "wplc_admin_set_transient") {
|
219 |
+
set_transient("wplc_is_admin_logged_in", "1", 350 );
|
220 |
+
|
221 |
+
}
|
222 |
+
|
223 |
+
|
224 |
+
// user
|
225 |
+
|
226 |
+
if ($_POST['action'] == "wplc_user_awaiting_chat") {
|
227 |
+
$chat_id = $_POST['id'];
|
228 |
+
echo wplc_return_chat_status($chat_id);
|
229 |
+
}
|
230 |
+
if ($_POST['action'] == "wplc_user_close_chat") {
|
231 |
+
$chat_id = $_POST['cid'];
|
232 |
+
wplc_change_chat_status($_POST['cid'],1);
|
233 |
+
}
|
234 |
+
if ($_POST['action'] == "wplc_user_send_msg") {
|
235 |
+
$chat_id = $_POST['cid'];
|
236 |
+
$chat_msg = $_POST['msg'];
|
237 |
+
$wplc_rec_msg = wplc_record_chat_msg("1",$chat_id,$chat_msg);
|
238 |
+
if ($wplc_rec_msg) {
|
239 |
+
echo 'sent';
|
240 |
+
} else {
|
241 |
+
echo "There was an error sending your chat message. Please contact support";
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
|
246 |
+
|
247 |
+
|
248 |
+
|
249 |
+
|
250 |
+
|
251 |
+
if ($_POST['action'] == "wplc_update_user_chat_boxes") {
|
252 |
+
echo wplc_return_user_chat_messages($_POST['cid']);
|
253 |
+
wplc_mark_as_read_user_chat_messages($_POST['cid']);
|
254 |
+
}
|
255 |
+
if ($_POST['action'] == "wplc_user_reactivate_chat") {
|
256 |
+
wplc_change_chat_status($_POST['cid'],3);
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
}
|
261 |
+
|
262 |
+
die(); // this is required to return a proper result
|
263 |
+
|
264 |
+
}
|
265 |
+
|
266 |
+
function wplc_record_chat_msg($from,$cid,$msg) {
|
267 |
+
global $wpdb;
|
268 |
+
global $wplc_tblname_msgs;
|
269 |
+
|
270 |
+
if ($from == "1") {
|
271 |
+
$fromname = wplc_return_chat_name($cid);
|
272 |
+
$orig = '2';
|
273 |
+
}
|
274 |
+
else {
|
275 |
+
if (function_exists("wplc_register_pro_version")) { $fromname = wplc_return_from_name(); }
|
276 |
+
else { $fromname = "admin"; }
|
277 |
+
$orig = '1';
|
278 |
+
}
|
279 |
+
|
280 |
+
$ins_array = array(
|
281 |
+
'chat_sess_id' => $cid,
|
282 |
+
'timestamp' => date("Y-m-d H:i:s"),
|
283 |
+
'from' => $fromname,
|
284 |
+
'msg' => $msg,
|
285 |
+
'status' => 0,
|
286 |
+
'originates' => $orig
|
287 |
+
);
|
288 |
+
$rows_affected = $wpdb->insert( $wplc_tblname_msgs, $ins_array );
|
289 |
+
|
290 |
+
wplc_update_active_timestamp($cid);
|
291 |
+
|
292 |
+
return true;
|
293 |
+
|
294 |
+
|
295 |
+
}
|
296 |
+
|
297 |
+
function wplc_update_active_timestamp($cid) {
|
298 |
+
global $wpdb;
|
299 |
+
global $wplc_tblname_chats;
|
300 |
+
$results = $wpdb->get_results(
|
301 |
+
"
|
302 |
+
UPDATE $wplc_tblname_chats
|
303 |
+
SET `last_active_timestamp` = '".date("Y-m-d H:i:s")."'
|
304 |
+
WHERE `id` = '$cid'
|
305 |
+
LIMIT 1
|
306 |
+
"
|
307 |
+
);
|
308 |
+
wplc_change_chat_status($cid,3);
|
309 |
+
return true;
|
310 |
+
|
311 |
+
}
|
312 |
+
|
313 |
+
function wplc_return_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` ASC
|
322 |
+
|
323 |
+
"
|
324 |
+
);
|
325 |
+
$msg_hist = "";
|
326 |
+
foreach ($results as $result) {
|
327 |
+
$id = $result->id;
|
328 |
+
$from = $result->from;
|
329 |
+
|
330 |
+
$msg = stripslashes($result->msg);
|
331 |
+
//$timestamp = strtotime($result->timestamp);
|
332 |
+
//$timeshow = date("H:i",$timestamp);
|
333 |
+
$msg_hist .= "<strong>$from</strong>: $msg<br />";
|
334 |
+
|
335 |
+
}
|
336 |
+
|
337 |
+
return $msg_hist;
|
338 |
+
|
339 |
+
|
340 |
+
}
|
341 |
+
function wplc_return_user_chat_messages($cid) {
|
342 |
+
global $wpdb;
|
343 |
+
global $wplc_tblname_msgs;
|
344 |
+
$results = $wpdb->get_results(
|
345 |
+
"
|
346 |
+
SELECT *
|
347 |
+
FROM $wplc_tblname_msgs
|
348 |
+
WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '1'
|
349 |
+
ORDER BY `timestamp` ASC
|
350 |
+
|
351 |
+
"
|
352 |
+
);
|
353 |
+
$msg_hist = "";
|
354 |
+
foreach ($results as $result) {
|
355 |
+
$id = $result->id;
|
356 |
+
$from = $result->from;
|
357 |
+
|
358 |
+
$msg = stripslashes($result->msg);
|
359 |
+
//$timestamp = strtotime($result->timestamp);
|
360 |
+
//$timeshow = date("H:i",$timestamp);
|
361 |
+
$msg_hist .= "<strong>$from</strong>: $msg<br />";
|
362 |
+
|
363 |
+
}
|
364 |
+
|
365 |
+
return $msg_hist;
|
366 |
+
|
367 |
+
|
368 |
+
}
|
369 |
+
function wplc_return_chat_messages($cid) {
|
370 |
+
global $wpdb;
|
371 |
+
global $wplc_tblname_msgs;
|
372 |
+
$results = $wpdb->get_results(
|
373 |
+
"
|
374 |
+
SELECT *
|
375 |
+
FROM $wplc_tblname_msgs
|
376 |
+
WHERE `chat_sess_id` = '$cid'
|
377 |
+
ORDER BY `timestamp` ASC
|
378 |
+
LIMIT 0, 100
|
379 |
+
"
|
380 |
+
);
|
381 |
+
foreach ($results as $result) {
|
382 |
+
$from = $result->from;
|
383 |
+
$msg = $result->msg;
|
384 |
+
$timestamp = strtotime($result->timestamp);
|
385 |
+
$timeshow = date("H:i:s",$timestamp);
|
386 |
+
$msg_hist .= "<strong>$from</strong>: $msg<br />";
|
387 |
+
|
388 |
+
}
|
389 |
+
return $msg_hist;
|
390 |
+
|
391 |
+
|
392 |
+
}
|
393 |
+
function wplc_mark_as_read_admin_chat_messages($cid) {
|
394 |
+
global $wpdb;
|
395 |
+
global $wplc_tblname_msgs;
|
396 |
+
$results = $wpdb->get_results(
|
397 |
+
"
|
398 |
+
SELECT *
|
399 |
+
FROM $wplc_tblname_msgs
|
400 |
+
WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '2'
|
401 |
+
ORDER BY `timestamp` DESC
|
402 |
+
|
403 |
+
"
|
404 |
+
);
|
405 |
+
|
406 |
+
|
407 |
+
foreach ($results as $result) {
|
408 |
+
$id = $result->id;
|
409 |
+
$check = $wpdb->query(
|
410 |
+
"
|
411 |
+
UPDATE $wplc_tblname_msgs
|
412 |
+
SET `status` = 1
|
413 |
+
WHERE `id` = '$id'
|
414 |
+
LIMIT 1
|
415 |
+
|
416 |
+
"
|
417 |
+
);
|
418 |
+
}
|
419 |
+
return "ok";
|
420 |
+
|
421 |
+
|
422 |
+
}
|
423 |
+
function wplc_mark_as_read_user_chat_messages($cid) {
|
424 |
+
global $wpdb;
|
425 |
+
global $wplc_tblname_msgs;
|
426 |
+
$results = $wpdb->get_results(
|
427 |
+
"
|
428 |
+
SELECT *
|
429 |
+
FROM $wplc_tblname_msgs
|
430 |
+
WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '1'
|
431 |
+
ORDER BY `timestamp` DESC
|
432 |
+
|
433 |
+
"
|
434 |
+
);
|
435 |
+
|
436 |
+
|
437 |
+
foreach ($results as $result) {
|
438 |
+
$id = $result->id;
|
439 |
+
$check = $wpdb->query(
|
440 |
+
"
|
441 |
+
UPDATE $wplc_tblname_msgs
|
442 |
+
SET `status` = 1
|
443 |
+
WHERE `id` = '$id'
|
444 |
+
LIMIT 1
|
445 |
+
|
446 |
+
"
|
447 |
+
);
|
448 |
+
}
|
449 |
+
return "ok";
|
450 |
+
|
451 |
+
|
452 |
+
}
|
453 |
+
function wplc_admin_display_chat($cid) {
|
454 |
+
global $wpdb;
|
455 |
+
global $wplc_tblname_msgs;
|
456 |
+
$results = $wpdb->get_results(
|
457 |
+
"
|
458 |
+
SELECT *
|
459 |
+
FROM $wplc_tblname_msgs
|
460 |
+
WHERE `chat_sess_id` = '$cid'
|
461 |
+
ORDER BY `timestamp` DESC
|
462 |
+
LIMIT 0, 100
|
463 |
+
"
|
464 |
+
);
|
465 |
+
foreach ($results as $result) {
|
466 |
+
$from = $result->from;
|
467 |
+
$msg = stripslashes($result->msg);
|
468 |
+
$msg_hist .= "$from: $msg<br />";
|
469 |
+
|
470 |
+
}
|
471 |
+
echo $msg_hist;
|
472 |
+
}
|
473 |
+
function wplc_admin_accept_chat($cid) {
|
474 |
+
wplc_change_chat_status($cid,3);
|
475 |
+
return true;
|
476 |
+
|
477 |
+
}
|
478 |
+
function wplc_update_chat_statuses() {
|
479 |
+
global $wpdb;
|
480 |
+
global $wplc_tblname_chats;
|
481 |
+
$results = $wpdb->get_results(
|
482 |
+
"
|
483 |
+
SELECT *
|
484 |
+
FROM $wplc_tblname_chats
|
485 |
+
WHERE `status` = '2' OR `status` = '3' OR `status` = '5'
|
486 |
+
"
|
487 |
+
);
|
488 |
+
foreach ($results as $result) {
|
489 |
+
$id = $result->id;
|
490 |
+
$timestamp = strtotime($result->last_active_timestamp);
|
491 |
+
if ($result->status == 2) {
|
492 |
+
if ((time() - $timestamp) >= 60) { // 1 minute max
|
493 |
+
wplc_change_chat_status($id,0);
|
494 |
+
}
|
495 |
+
}
|
496 |
+
else if ($result->status == 3) {
|
497 |
+
if ((time() - $timestamp) >= 600) { // 10 minute max
|
498 |
+
wplc_change_chat_status($id,1);
|
499 |
+
}
|
500 |
+
}
|
501 |
+
else if ($result->status == 5) {
|
502 |
+
if ((time() - $timestamp) >= 120) { // 2 minute timeout
|
503 |
+
wplc_change_chat_status($id,7); // 7 - timedout
|
504 |
+
}
|
505 |
+
}
|
506 |
+
echo time()." ".$timestamp;
|
507 |
+
}
|
508 |
+
}
|
509 |
+
|
510 |
+
function wplc_user_initiate_chat($name,$email,$cid = null) {
|
511 |
+
global $wpdb;
|
512 |
+
global $wplc_tblname_chats;
|
513 |
+
|
514 |
+
if ($cid != null) { // change from a visitor to a chat
|
515 |
+
$query =
|
516 |
+
"
|
517 |
+
UPDATE $wplc_tblname_chats
|
518 |
+
SET
|
519 |
+
`status` = '2',
|
520 |
+
`timestamp` = '".date("Y-m-d H:i:s")."',
|
521 |
+
`name` = '$name',
|
522 |
+
`email` = '$email',
|
523 |
+
`ip` = '".$_SERVER['REMOTE_ADDR']."',
|
524 |
+
`url` = '".$_SERVER['HTTP_REFERER']."',
|
525 |
+
`last_active_timestamp` = '".date("Y-m-d H:i:s")."'
|
526 |
+
|
527 |
+
WHERE `id` = '$cid'
|
528 |
+
LIMIT 1
|
529 |
+
";
|
530 |
+
$results = $wpdb->query($query);
|
531 |
+
return $cid;
|
532 |
+
}
|
533 |
+
else { // create new ID for the chat
|
534 |
+
$ins_array = array(
|
535 |
+
'status' => '2',
|
536 |
+
'timestamp' => date("Y-m-d H:i:s"),
|
537 |
+
'name' => $name,
|
538 |
+
'email' => $email,
|
539 |
+
'ip' => $_SERVER['REMOTE_ADDR'],
|
540 |
+
'url' => $_SERVER['HTTP_REFERER'],
|
541 |
+
'last_active_timestamp' => date("Y-m-d H:i:s")
|
542 |
+
);
|
543 |
+
$rows_affected = $wpdb->insert( $wplc_tblname_chats, $ins_array );
|
544 |
+
$lastid = $wpdb->insert_id;
|
545 |
+
return $lastid;
|
546 |
+
}
|
547 |
+
|
548 |
+
}
|
549 |
+
function wplc_log_user_on_page($name,$email) {
|
550 |
+
global $wpdb;
|
551 |
+
global $wplc_tblname_chats;
|
552 |
+
|
553 |
+
$ins_array = array(
|
554 |
+
'status' => '5',
|
555 |
+
'timestamp' => date("Y-m-d H:i:s"),
|
556 |
+
'name' => $name,
|
557 |
+
'email' => $email,
|
558 |
+
'ip' => $_SERVER['REMOTE_ADDR'],
|
559 |
+
'url' => $_SERVER['HTTP_REFERER'],
|
560 |
+
'last_active_timestamp' => date("Y-m-d H:i:s")
|
561 |
+
);
|
562 |
+
|
563 |
+
$rows_affected = $wpdb->insert( $wplc_tblname_chats, $ins_array );
|
564 |
+
|
565 |
+
$lastid = $wpdb->insert_id;
|
566 |
+
|
567 |
+
|
568 |
+
return $lastid;
|
569 |
+
|
570 |
+
}
|
571 |
+
function wplc_update_user_on_page($cid) {
|
572 |
+
global $wpdb;
|
573 |
+
global $wplc_tblname_chats;
|
574 |
+
|
575 |
+
$query =
|
576 |
+
"
|
577 |
+
UPDATE $wplc_tblname_chats
|
578 |
+
SET
|
579 |
+
`url` = '".$_SERVER['HTTP_REFERER']."',
|
580 |
+
`last_active_timestamp` = '".date("Y-m-d H:i:s")."',
|
581 |
+
`ip` = '".$_SERVER['REMOTE_ADDR']."',
|
582 |
+
`status` = '5'
|
583 |
+
|
584 |
+
WHERE `id` = '$cid'
|
585 |
+
LIMIT 1
|
586 |
+
";
|
587 |
+
$results = $wpdb->query($query);
|
588 |
+
return $query;
|
589 |
+
|
590 |
+
|
591 |
+
|
592 |
+
}
|
593 |
+
function wplc_change_chat_status($id,$status) {
|
594 |
+
global $wpdb;
|
595 |
+
global $wplc_tblname_chats;
|
596 |
+
$results = $wpdb->get_results(
|
597 |
+
"
|
598 |
+
UPDATE $wplc_tblname_chats
|
599 |
+
SET `status` = '$status'
|
600 |
+
WHERE `id` = '$id'
|
601 |
+
LIMIT 1
|
602 |
+
"
|
603 |
+
);
|
604 |
+
return true;
|
605 |
+
|
606 |
+
}
|
607 |
+
function wplc_return_chat_name($cid) {
|
608 |
+
global $wpdb;
|
609 |
+
global $wplc_tblname_chats;
|
610 |
+
$results = $wpdb->get_results(
|
611 |
+
"
|
612 |
+
SELECT *
|
613 |
+
FROM $wplc_tblname_chats
|
614 |
+
WHERE `id` = '$cid'
|
615 |
+
"
|
616 |
+
);
|
617 |
+
foreach ($results as $result) {
|
618 |
+
return $result->name;
|
619 |
+
}
|
620 |
+
|
621 |
+
}
|
622 |
+
function wplc_return_chat_status($cid) {
|
623 |
+
global $wpdb;
|
624 |
+
global $wplc_tblname_chats;
|
625 |
+
$results = $wpdb->get_results(
|
626 |
+
"
|
627 |
+
SELECT *
|
628 |
+
FROM $wplc_tblname_chats
|
629 |
+
WHERE `id` = '$cid'
|
630 |
+
"
|
631 |
+
);
|
632 |
+
foreach ($results as $result) {
|
633 |
+
return $result->status;
|
634 |
+
}
|
635 |
+
}
|
636 |
+
|
637 |
+
|
638 |
+
function wplc_return_status($status) {
|
639 |
+
if ($status == 1) {
|
640 |
+
return "complete";
|
641 |
+
}
|
642 |
+
if ($status == 2) {
|
643 |
+
return "pending";
|
644 |
+
}
|
645 |
+
if ($status == 3) {
|
646 |
+
return "active";
|
647 |
+
}
|
648 |
+
if ($status == 4) {
|
649 |
+
return "deleted";
|
650 |
+
}
|
651 |
+
if ($status == 5) {
|
652 |
+
return "browsing";
|
653 |
+
}
|
654 |
+
if ($status == 6) {
|
655 |
+
return "requesting chat";
|
656 |
+
}
|
657 |
+
}
|
658 |
+
|
659 |
+
function wplc_superadmin_javascript() {
|
660 |
+
|
661 |
+
if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu') {
|
662 |
+
|
663 |
+
if (!isset($_GET['action'])) {
|
664 |
+
if (function_exists("wplc_register_pro_version")) {
|
665 |
+
wplc_pro_admin_javascript();
|
666 |
+
} else {
|
667 |
+
wplc_admin_javascript();
|
668 |
+
}
|
669 |
+
|
670 |
+
} // main page
|
671 |
+
else if (isset($_GET['action'])) {
|
672 |
+
if (function_exists("wplc_register_pro_version")) {
|
673 |
+
wplc_return_pro_admin_chat_javascript($_GET['cid']);
|
674 |
+
} else {
|
675 |
+
wplc_return_admin_chat_javascript($_GET['cid']);
|
676 |
+
}
|
677 |
+
|
678 |
+
}
|
679 |
+
|
680 |
+
|
681 |
+
|
682 |
+
}
|
683 |
+
|
684 |
+
$ajax_nonce = wp_create_nonce("wplc");
|
685 |
+
?>
|
686 |
+
<script type="text/javascript">
|
687 |
+
jQuery(document).ready(function() {
|
688 |
+
|
689 |
+
|
690 |
+
var wplc_set_transient = null;
|
691 |
+
|
692 |
+
wplc_set_transient = setInterval(function (){wpcl_admin_set_transient();}, 300000);
|
693 |
+
wpcl_admin_set_transient();
|
694 |
+
function wpcl_admin_set_transient() {
|
695 |
+
var data = {
|
696 |
+
action: 'wplc_admin_set_transient',
|
697 |
+
security: '<?php echo $ajax_nonce; ?>'
|
698 |
+
};
|
699 |
+
jQuery.post(ajaxurl, data, function(response) {
|
700 |
+
//console.log("wplc_admin_set_transient");
|
701 |
+
});
|
702 |
+
}
|
703 |
+
|
704 |
+
|
705 |
+
});
|
706 |
+
|
707 |
+
|
708 |
+
|
709 |
+
</script>
|
710 |
+
<?php
|
711 |
+
}
|
712 |
+
function wplc_admin_javascript() {
|
713 |
+
$ajax_nonce = wp_create_nonce("wplc");
|
714 |
+
?>
|
715 |
+
<script type="text/javascript">
|
716 |
+
jQuery(document).ready(function() {
|
717 |
+
|
718 |
+
var wplc_autoLoad = null;
|
719 |
+
var wplc_refresh_chat_area = null;
|
720 |
+
var wplc_refresh_status = null;
|
721 |
+
|
722 |
+
var wplc_nonce = '<?php echo $ajax_nonce; ?>';
|
723 |
+
|
724 |
+
|
725 |
+
|
726 |
+
wplc_refresh_chat_area = setInterval(function (){wpcl_admin_update_chats();}, 4000);
|
727 |
+
function wpcl_admin_update_chats(cid) {
|
728 |
+
var data = {
|
729 |
+
action: 'wplc_update_admin_chat',
|
730 |
+
security: wplc_nonce
|
731 |
+
};
|
732 |
+
jQuery.post(ajaxurl, data, function(response) {
|
733 |
+
//console.log("wplc_update_admin_chat");
|
734 |
+
jQuery("#wplc_admin_chat_area").html(response);
|
735 |
+
if (response.indexOf("pending") >= 0) {
|
736 |
+
document.getElementById("wplc_sound").innerHTML="<embed src='<?php echo plugins_url('/beep-2.mp3', __FILE__); ?>' hidden=true autostart=true loop=false>";
|
737 |
+
}
|
738 |
+
|
739 |
+
|
740 |
+
});
|
741 |
+
}
|
742 |
+
|
743 |
+
wplc_refresh_status = setInterval(function (){wplc_update_statuses();}, 10000);
|
744 |
+
function wplc_update_statuses() {
|
745 |
+
var data = {
|
746 |
+
action: 'wplc_update_admin_status',
|
747 |
+
security: wplc_nonce
|
748 |
+
};
|
749 |
+
jQuery.post(ajaxurl, data, function(response) {
|
750 |
+
//console.log("wplc_update_admin_status");
|
751 |
+
//alert(response);
|
752 |
+
});
|
753 |
+
};
|
754 |
+
|
755 |
+
|
756 |
+
});
|
757 |
+
|
758 |
+
|
759 |
+
|
760 |
+
</script>
|
761 |
+
<?php
|
762 |
+
}
|
763 |
+
|
764 |
+
|
765 |
+
function wplc_list_chats() {
|
766 |
+
|
767 |
+
global $wpdb;
|
768 |
+
global $wplc_tblname_chats;
|
769 |
+
|
770 |
+
$results = $wpdb->get_results(
|
771 |
+
"
|
772 |
+
SELECT *
|
773 |
+
FROM $wplc_tblname_chats
|
774 |
+
WHERE `status` = 3 OR `status` = 2
|
775 |
+
ORDER BY `timestamp` ASC
|
776 |
+
|
777 |
+
"
|
778 |
+
);
|
779 |
+
echo "
|
780 |
+
|
781 |
+
|
782 |
+
<table class=\"wp-list-table widefat fixed \" cellspacing=\"0\">
|
783 |
+
<thead>
|
784 |
+
<tr>
|
785 |
+
<th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>".__("IP","wplivechat")."</span></th>
|
786 |
+
<th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>".__("Name","wplivechat")."</span></th>
|
787 |
+
<th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">".__("Email","wplivechat")."</th>
|
788 |
+
<th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">".__("URL","wplivechat")."</th>
|
789 |
+
<th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">".__("Status","wplivechat")."</th>
|
790 |
+
<th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>".__("Action","wplivechat")."</span></th>
|
791 |
+
</tr>
|
792 |
+
</thead>
|
793 |
+
<tbody id=\"the-list\" class='list:wp_list_text_link'>
|
794 |
+
";
|
795 |
+
|
796 |
+
if (!$results) {
|
797 |
+
echo "<tr><td></td><td>".__("No chat sessions available at the moment","wplivechat")."</td></tr>";
|
798 |
+
}
|
799 |
+
else {
|
800 |
+
foreach ($results as $result) {
|
801 |
+
unset($trstyle);
|
802 |
+
unset($actions);
|
803 |
+
$wplc_c++;
|
804 |
+
|
805 |
+
if ($result->status == 2) {
|
806 |
+
$url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
|
807 |
+
$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>";
|
808 |
+
$trstyle = "style='background-color:#FFFBE4; height:30px;'";
|
809 |
+
}
|
810 |
+
if ($result->status == 3) {
|
811 |
+
$url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
|
812 |
+
$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>";
|
813 |
+
$trstyle = "style='background-color:#F7FCFE; height:30px;'";
|
814 |
+
}
|
815 |
+
|
816 |
+
|
817 |
+
echo "<tr id=\"record_".$result->id."\" $trstyle>";
|
818 |
+
echo "<td class='chat_id column-chat_d'>".$result->ip."</td>";
|
819 |
+
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>";
|
820 |
+
echo "<td class='chat_email column_chat_email' id='chat_email_".$result->id."'>".$result->email."</td>";
|
821 |
+
echo "<td class='chat_name column_chat_url' id='chat_url_".$result->id."'>".$result->url."</td>";
|
822 |
+
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(); }
|
823 |
+
echo "<td class='chat_action column-chat_action' id='chat_action_".$result->id."'>$actions</td>";
|
824 |
+
echo "</tr>";
|
825 |
+
|
826 |
+
}
|
827 |
+
}
|
828 |
+
echo "</table><br /><br />";
|
829 |
+
|
830 |
+
|
831 |
+
}
|
832 |
+
|
833 |
+
function wplc_admin_menu_layout() {
|
834 |
+
if (function_exists("wplc_register_pro_version")) {
|
835 |
+
wplc_pro_admin_menu_layout_display();
|
836 |
+
} else {
|
837 |
+
wplc_admin_menu_layout_display();
|
838 |
+
}
|
839 |
+
|
840 |
+
}
|
841 |
+
|
842 |
+
function wplc_admin_menu_layout_display() {
|
843 |
+
|
844 |
+
if (!isset($_GET['action'])) {
|
845 |
+
|
846 |
+
?>
|
847 |
+
<h1>Live Chat</h1>
|
848 |
+
<div id="wplc_sound"></div>
|
849 |
+
<div id="wplc_admin_chat_area">
|
850 |
+
<?php wplc_list_chats(); ?>
|
851 |
+
</div>
|
852 |
+
<h1>Online Visitors</h1>
|
853 |
+
<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 $9.95 once off","wplivechat"); ?>" target=\"_BLANK\"><?php _e("Buy the Pro add-on now for only $9.95 once off","wplivechat"); ?></a></p>
|
854 |
+
<?php
|
855 |
+
}
|
856 |
+
else {
|
857 |
+
|
858 |
+
if ($_GET['action'] == 'ac') {
|
859 |
+
wplc_change_chat_status($_GET['cid'],3);
|
860 |
+
wplc_draw_chat_area($_GET['cid']);
|
861 |
+
}
|
862 |
+
}
|
863 |
+
}
|
864 |
+
|
865 |
+
function wplc_draw_chat_area($cid) {
|
866 |
+
|
867 |
+
global $wpdb;
|
868 |
+
global $wplc_tblname_chats;
|
869 |
+
$results = $wpdb->get_results(
|
870 |
+
"
|
871 |
+
SELECT *
|
872 |
+
FROM $wplc_tblname_chats
|
873 |
+
WHERE `id` = '$cid'
|
874 |
+
LIMIT 1
|
875 |
+
"
|
876 |
+
);
|
877 |
+
|
878 |
+
|
879 |
+
foreach ($results as $result) {
|
880 |
+
if ($result->status == 1) { $status = "Previous"; } else { $status = "Active"; }
|
881 |
+
|
882 |
+
echo "<h2>$status Chat with ".$result->name."</h2>";
|
883 |
+
echo "<div style='display:block;'>";
|
884 |
+
echo "<div style='float:left; width:100px;'><img src=\"http://www.gravatar.com/avatar/".md5($result->email)."\" /></div>";
|
885 |
+
echo "<div style='float:left; width:350px;'>";
|
886 |
+
echo "<table>";
|
887 |
+
echo "<tr><td>Email address</td><td><a href='mailto:".$result->email."' title='".$result->email."'>".$result->email."</a></td></tr>";
|
888 |
+
echo "<tr><td>IP Address</td><td><a href='http://www.ip-adress.com/ip_tracer/".$result->ip."' title='Whois for ".$result->ip."'>".$result->ip."</a></td></tr>";
|
889 |
+
echo "<tr><td>From URL</td><td>".$result->url. " (<a href='".$result->url."' target='_BLANK'>open</a>)"."</td></tr>";
|
890 |
+
echo "<tr><td>Date</td><td>".$result->timestamp."</td></tr>";
|
891 |
+
echo "</table><br />";
|
892 |
+
echo "</div>";
|
893 |
+
echo "</div>";
|
894 |
+
|
895 |
+
echo "
|
896 |
+
<div id='admin_chat_box'>
|
897 |
+
<div id='admin_chat_box_area_".$result->id."' style='height:200px; width:290px; border:1px solid #ccc; overflow:auto;'>".wplc_return_chat_messages($cid)."</div>
|
898 |
+
<p>
|
899 |
+
";
|
900 |
+
if ($result->status != 1) {
|
901 |
+
echo "
|
902 |
+
<input type='text' name='wplc_admin_chatmsg' id='wplc_admin_chatmsg' value='' />
|
903 |
+
<input id='wplc_admin_cid' type='hidden' value='".$_GET['cid']."' />
|
904 |
+
<input id='wplc_admin_send_msg' type='button' value='".__("Send","wplc")."' />
|
905 |
+
</p>
|
906 |
+
</div>
|
907 |
+
";
|
908 |
+
//echo wplc_return_admin_chat_javascript($_GET['cid']);
|
909 |
+
}
|
910 |
+
|
911 |
+
}
|
912 |
+
}
|
913 |
+
function wplc_get_msg() {
|
914 |
+
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>";
|
915 |
+
}
|
916 |
+
|
917 |
+
function wplc_return_admin_chat_javascript($cid) {
|
918 |
+
$ajax_nonce = wp_create_nonce("wplc");
|
919 |
+
?>
|
920 |
+
<script type="text/javascript">
|
921 |
+
jQuery(document).ready(function() {
|
922 |
+
|
923 |
+
var wplc_nonce = '<?php echo $ajax_nonce; ?>';
|
924 |
+
var wplc_gcid = '<?php echo $cid; ?>';
|
925 |
+
function wpcl_admin_auto_update_chat_box(e){var t={action:"wplc_update_admin_chat_boxes",cid:e,security:wplc_nonce};jQuery.post(ajaxurl,t,function(t){jQuery("#admin_chat_box_area_"+e).append(t);var n=jQuery("#admin_chat_box_area_"+e)[0].scrollHeight;jQuery("#admin_chat_box_area_"+e).scrollTop(n)})}function wpcl_admin_auto_check_status_of_chat(e){var t={action:"wplc_update_admin_return_chat_status",cid:e,security:wplc_nonce};jQuery.post(ajaxurl,t,function(t){var n=t;if(n=="1"){clearInterval(wplc_auto_check_status_of_chat);clearInterval(wplc_auto_refresh);jQuery("#admin_chat_box_area_"+e).append("<em>User has left the chat</em>");var r=jQuery("#admin_chat_box_area_"+e)[0].scrollHeight;jQuery("#admin_chat_box_area_"+e).scrollTop(r);jQuery("#wplc_admin_send_msg").attr("disabled","disabled")}})}if(jQuery("#wplc_admin_cid").length){var wplc_cid=jQuery("#wplc_admin_cid").val();var height=jQuery("#admin_chat_box_area_"+wplc_cid)[0].scrollHeight;jQuery("#admin_chat_box_area_"+wplc_cid).scrollTop(height)}jQuery(".wplc_admin_accept").live("click",function(){var e=jQuery(this).attr("cid");var t={action:"wplc_admin_accept_chat",cid:e,security:wplc_nonce};jQuery.post(ajaxurl,t,function(t){wplc_refresh_chat_boxes[e]=setInterval(function(){wpcl_admin_update_chat_box(e)},3e3);jQuery("#admin_chat_box_"+e).show()})});jQuery("#wplc_admin_chatmsg").keyup(function(e){if(e.keyCode==13){jQuery("#wplc_admin_send_msg").click()}});jQuery("#wplc_admin_send_msg").live("click",function(){var e=jQuery("#wplc_admin_cid").val();var t=jQuery("#wplc_admin_chatmsg").val();var n="a"+"d"+"m"+"i"+"n";jQuery("#wplc_admin_chatmsg").val("");jQuery("#admin_chat_box_area_"+e).append("<strong>"+n+"</strong>: "+t+"<br />");var r=jQuery("#admin_chat_box_area_"+e)[0].scrollHeight;jQuery("#admin_chat_box_area_"+e).scrollTop(r);var i={action:"wplc_admin_send_msg",security:wplc_nonce,cid:e,msg:t};jQuery.post(ajaxurl,i,function(e){})});wplc_auto_refresh=setInterval(function(){wpcl_admin_auto_update_chat_box(wplc_gcid)},3500);wplc_auto_check_status_of_chat=setInterval(function(){wpcl_admin_auto_check_status_of_chat(wplc_gcid)},5e3)
|
926 |
+
|
927 |
+
|
928 |
+
|
929 |
+
});
|
930 |
+
</script>
|
931 |
+
<?php
|
932 |
+
}
|
933 |
+
function wplc_activate() {
|
934 |
+
wplc_handle_db();
|
935 |
+
if (!get_option("WPLC_SETTINGS")) {
|
936 |
+
add_option('WPLC_SETTINGS',array("wplc_settings_align" => "2", "other" => "other"));
|
937 |
+
}
|
938 |
+
}
|
939 |
+
|
940 |
+
|
941 |
+
function wplc_handle_db() {
|
942 |
+
global $wpdb;
|
943 |
+
global $wplc_version;
|
944 |
+
global $wplc_tblname_chats;
|
945 |
+
global $wplc_tblname_msgs;
|
946 |
+
|
947 |
+
$sql = "
|
948 |
+
CREATE TABLE `".$wplc_tblname_chats."` (
|
949 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
950 |
+
`timestamp` datetime NOT NULL,
|
951 |
+
`name` varchar(700) NOT NULL,
|
952 |
+
`email` varchar(700) NOT NULL,
|
953 |
+
`ip` varchar(700) NOT NULL,
|
954 |
+
`status` int(11) NOT NULL,
|
955 |
+
`url` varchar(700) NOT NULL,
|
956 |
+
`last_active_timestamp` datetime NOT NULL,
|
957 |
+
PRIMARY KEY (`id`)
|
958 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
959 |
+
";
|
960 |
+
|
961 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
962 |
+
dbDelta($sql);
|
963 |
+
|
964 |
+
$sql = "
|
965 |
+
CREATE TABLE `".$wplc_tblname_msgs."` (
|
966 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
967 |
+
`chat_sess_id` int(11) NOT NULL,
|
968 |
+
`from` varchar(150) NOT NULL,
|
969 |
+
`msg` varchar(700) NOT NULL,
|
970 |
+
`timestamp` datetime NOT NULL,
|
971 |
+
`status` INT(3) NOT NULL,
|
972 |
+
`originates` INT(3) NOT NULL,
|
973 |
+
PRIMARY KEY (`id`)
|
974 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
975 |
+
";
|
976 |
+
|
977 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
978 |
+
dbDelta($sql);
|
979 |
+
|
980 |
+
|
981 |
+
|
982 |
+
add_option("wplc_db_version", $wplc_version);
|
983 |
+
update_option("wplc_db_version",$wplc_version);
|
984 |
+
}
|
985 |
+
|
986 |
+
function wplc_add_user_stylesheet() {
|
987 |
+
wp_register_style( 'wplc-style', plugins_url('wplcstyle.css', __FILE__) );
|
988 |
+
wp_enqueue_style( 'wplc-style' );
|
989 |
+
}
|
990 |
+
|
991 |
+
function wplc_admin_settings_layout() {
|
992 |
+
wplc_settings_page_basic();
|
993 |
+
}
|
994 |
+
function wplc_admin_history_layout() {
|
995 |
+
echo"<div class=\"wrap\"><div id=\"icon-edit\" class=\"icon32 icon32-posts-post\"><br></div><h2>".__("WP Live Chat History","wplivechat")."</h2>";
|
996 |
+
if (function_exists("wplc_register_pro_version")) {
|
997 |
+
wplc_pro_admin_display_history();
|
998 |
+
}
|
999 |
+
else {
|
1000 |
+
echo "<br /><br >This option is only available in the <a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=history1\" title=\"".__("Pro Add-on","wplivechat")."\" target=\"_BLANK\">Pro Add-on</a> of WP Live Chat. <a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=history2\" title=\"".__("Pro Add-on","wplivechat")."\" target=\"_BLANK\">Get it now for only $9.95 once off!</a>";
|
1001 |
+
}
|
1002 |
+
}
|
1003 |
+
|
1004 |
+
function wplc_settings_page_basic() {
|
1005 |
+
echo"<div class=\"wrap\"><div id=\"icon-edit\" class=\"icon32 icon32-posts-post\"><br></div><h2>".__("WP Live Chat Settings","wplivechat")."</h2>";
|
1006 |
+
|
1007 |
+
$wplc_settings = get_option("WPLC_SETTINGS");
|
1008 |
+
|
1009 |
+
|
1010 |
+
if ($wplc_settings["wplc_settings_align"]) { $wplc_settings_align[intval($wplc_settings["wplc_settings_align"])] = "SELECTED"; }
|
1011 |
+
|
1012 |
+
|
1013 |
+
|
1014 |
+
echo "<form action='' name='wplc_settings' method='post' id='wplc_settings'>";
|
1015 |
+
|
1016 |
+
if (function_exists("wplc_register_pro_version")) {
|
1017 |
+
$wplc_pro_chat_name = wplc_settings_page_pro('chat_name');
|
1018 |
+
$wplc_pro_chat_pic = wplc_settings_page_pro('chat_pic');
|
1019 |
+
$wplc_pro_chat_logo = wplc_settings_page_pro('chat_logo');
|
1020 |
+
$wplc_pro_chat_delay = wplc_settings_page_pro('chat_delay');
|
1021 |
+
$wplc_pro_chat_fs = wplc_settings_page_pro('wplc_chat_window_text1');
|
1022 |
+
} else {
|
1023 |
+
$wplc_pro_chat_name = "
|
1024 |
+
<tr>
|
1025 |
+
<td width='200' valign='top'>".__("Name","wplivechat").":</td>
|
1026 |
+
<td>
|
1027 |
+
<input type='text' size='50' maxlength='50' disabled readonly value='admin' /><small><i> ".__("available in the","wplivechat")." <a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=name\" title=\"".__("Pro Add-on","wplivechat")."\" target=\"_BLANK\">".__("Pro Add-on","wplivechat")."</a> ".__("only","wplivechat").". </i></small>
|
1028 |
+
</td>
|
1029 |
+
</tr>
|
1030 |
+
";
|
1031 |
+
$wplc_pro_chat_pic = "
|
1032 |
+
<tr>
|
1033 |
+
<td width='200' valign='top'>".__("Picture","wplivechat").":</td>
|
1034 |
+
<td>
|
1035 |
+
<input id=\"wplc_pro_pic_button\" type=\"button\" value=\"".__("Upload Image","wplivechat")."\" readonly disabled /><small><i> ".__("available in the","wplivechat")." <a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=pic\" title=\"".__("Pro Add-on","wplivechat")."\" target=\"_BLANK\">".__("Pro Add-on","wplivechat")."</a> ".__("only","wplivechat").". </i></small>
|
1036 |
+
</td>
|
1037 |
+
</tr>
|
1038 |
+
";
|
1039 |
+
$wplc_pro_chat_logo = "
|
1040 |
+
<tr>
|
1041 |
+
<td width='200' valign='top'>".__("Logo","wplivechat").":</td>
|
1042 |
+
<td>
|
1043 |
+
<input id=\"wplc_pro_logo_button\" type=\"button\" value=\"".__("Upload Image","wplivechat")."\" readonly disabled /><small><i> ".__("available in the","wplivechat")." <a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=pic\" title=\"".__("Pro Add-on","wplivechat")."\" target=\"_BLANK\">".__("Pro Add-on","wplivechat")."</a> ".__("only","wplivechat").". </i></small>
|
1044 |
+
</td>
|
1045 |
+
</tr>
|
1046 |
+
";
|
1047 |
+
$wplc_pro_chat_delay = "
|
1048 |
+
<tr>
|
1049 |
+
<td width='200' valign='top'>".__("Chat Delay (seconds)","wplivechat").":</td>
|
1050 |
+
<td>
|
1051 |
+
<input type='text' size='50' maxlength='50' disabled readonly value='10' /> <small><i> ".__("available in the","wplivechat")." <a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=delay\" title=\"".__("Pro Add-on","wplivechat")."\" target=\"_BLANK\">".__("Pro Add-on","wplivechat")."</a> ".__("only","wplivechat").". </i></small>
|
1052 |
+
</td>
|
1053 |
+
</tr>
|
1054 |
+
";
|
1055 |
+
$wplc_pro_chat_fs = "
|
1056 |
+
<tr style='height:30px;'><td></td><td></td></tr>
|
1057 |
+
<tr>
|
1058 |
+
<td width='200' valign='top'>".__("First Section Text","wplivechat").":</td>
|
1059 |
+
<td>
|
1060 |
+
<input type='text' size='50' maxlength='50' class='regular-text' readonly value='Need help?' /> <br />
|
1061 |
+
<input type='text' size='50' maxlength='50' class='regular-text' readonly value='Click the link below for assistance' /> <br />
|
1062 |
+
<input type='text' size='50' maxlength='50' class='regular-text' readonly value='Start live chat' /> <br />
|
1063 |
+
</td>
|
1064 |
+
</tr>
|
1065 |
+
<tr>
|
1066 |
+
<td width='200' valign='top'>".__("Second Section Text","wplivechat").":</td>
|
1067 |
+
<td>
|
1068 |
+
<input type='text' size='50' maxlength='50' class='regular-text' readonly value='Start Chat' /> <br />
|
1069 |
+
<input type='text' size='50' maxlength='50' class='regular-text' readonly value='Connecting you to a sales person. Please be patient.' /> <br />
|
1070 |
+
|
1071 |
+
|
1072 |
+
</td>
|
1073 |
+
</tr>
|
1074 |
+
<tr>
|
1075 |
+
<td width='200' valign='top'>".__("Reactive Chat Section Text","wplivechat").":</td>
|
1076 |
+
<td>
|
1077 |
+
<input type='text' size='50' maxlength='50' class='regular-text' readonly value='Reactivating your previous chat...' /><small><i> ".__("Edit these text fields using the ","wplivechat")." <a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=textfields\" title=\"".__("Pro Add-on","wplivechat")."\" target=\"_BLANK\">".__("Pro Add-on","wplivechat")."</a>. </i></small> <br />
|
1078 |
+
|
1079 |
+
|
1080 |
+
</td>
|
1081 |
+
</tr>
|
1082 |
+
";
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
|
1086 |
+
|
1087 |
+
echo "
|
1088 |
+
|
1089 |
+
<h3>".__("Chat Window Settings",'wplivechat')."</h3>
|
1090 |
+
<table class='form-table'>
|
1091 |
+
$wplc_pro_chat_name
|
1092 |
+
$wplc_pro_chat_pic
|
1093 |
+
$wplc_pro_chat_logo
|
1094 |
+
$wplc_pro_chat_delay
|
1095 |
+
<tr>
|
1096 |
+
<td width='200' valign='top'>".__("Chat Box Alignment","wplivechat").":</td>
|
1097 |
+
<td>
|
1098 |
+
<select id='wplc_settings_align' name='wplc_settings_align'>
|
1099 |
+
<option value=\"1\" ".$wplc_settings_align[1].">".__("Bottom left","wplivechat")."</option>
|
1100 |
+
<option value=\"2\" ".$wplc_settings_align[2].">".__("Bottom right","wplivechat")."</option>
|
1101 |
+
</select>
|
1102 |
+
</td>
|
1103 |
+
</tr>
|
1104 |
+
$wplc_pro_chat_fs
|
1105 |
+
|
1106 |
+
</table>
|
1107 |
+
|
1108 |
+
|
1109 |
+
<p class='submit'><input type='submit' name='wplc_save_settings' class='button-primary' value='".__("Save Settings","wplivechat")." »' /></p>
|
1110 |
+
|
1111 |
+
|
1112 |
+
</form>
|
1113 |
+
";
|
1114 |
+
|
1115 |
+
echo "</div>";
|
1116 |
+
|
1117 |
+
|
1118 |
+
}
|
1119 |
+
function wplc_head() {
|
1120 |
+
global $wpdb;
|
1121 |
+
|
1122 |
+
if (isset($_POST['wplc_save_settings'])){
|
1123 |
+
|
1124 |
+
$wplc_data['wplc_settings_align'] = attribute_escape($_POST['wplc_settings_align']);
|
1125 |
+
update_option('WPLC_SETTINGS', $wplc_data);
|
1126 |
+
|
1127 |
+
if (function_exists("wplc_register_pro_version")) {
|
1128 |
+
wplc_pro_save_settings();
|
1129 |
+
}
|
1130 |
+
|
1131 |
+
echo "<div class='updated'>";
|
1132 |
+
_e("Your settings have been saved.","wplivechat");
|
1133 |
+
echo "</div>";
|
1134 |
+
|
1135 |
+
|
1136 |
+
}
|
1137 |
+
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
|
1141 |
+
|
wplcstyle.css
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#wp-live-chat input[type="button"] { width:100px !important; }
|
2 |
+
#wp-live-chat input[type="text"] { width:150px !important; }
|
3 |
+
#wplc_chatbox { border: 1px solid #CCC; overflow: auto; padding-top:5px; }
|
4 |
+
#wp-live-chat-close { position:absolute; right:5px; top:5px; width:10px; height:10px; cursor: pointer; }
|
5 |
+
#wp-live-chat table { border: 0 !important; }
|
6 |
+
#wp-live-chat table td { border: 0 !important; }
|
7 |
+
#wp-live-chat h4 { font-size:20px; margin:3px; }
|
8 |
+
#wp-live-chat p { font-size:14px; margin:3px; }
|
9 |
+
#wp-live-chat #wplc-sb { font-size:14px; font-weight:bold; }
|
10 |
+
#wp-live-chat-4 { padding-top:8px; }
|