Zendesk Chat - Version 1.2.1

Version Description

Download this release

Release Info

Developer bencxr
Plugin Icon 128x128 Zendesk Chat
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2.0 to 1.2.1

Files changed (5) hide show
  1. accountconfig.php +10 -7
  2. customizewidget.php +2 -3
  3. imintegration.php +2 -2
  4. readme.txt +1 -1
  5. zopim.php +89 -110
accountconfig.php CHANGED
@@ -10,22 +10,25 @@ function zopim_account_config() {
10
11
<?php
12
13
- if ($_GET["action"]=="deactivate") {
14
update_option('zopimSalt', "");
15
update_option('zopimCode', "zopim");
16
}
17
18
$message = "";
19
- if ($_POST["action"]=="login") {
20
- if ($_POST["zopimUseSSL"] == "") {
21
$_POST["zopimUseSSL"] = "nossl";
22
}
23
update_option('zopimUseSSL', $_POST["zopimUseSSL"]);
24
25
if ($_POST["zopimPassword"] != "password") {
26
27
$logindata = array("email" => $_POST["zopimUsername"], "password" => $_POST["zopimPassword"]);
28
- $loginresult = json_to_array(do_post_request(ZOPIM_LOGIN_URL, $logindata));
29
30
if (isset($loginresult->error)) {
31
$error["login"] = "<b>Could not log in to Zopim. Please check your login details. If problem persists, try connecting without SSL enabled.</b>";
@@ -49,7 +52,7 @@ function zopim_account_config() {
49
$error["login"] = "<b>Could not log in to Zopim. We were unable to contact Zopim servers. Please check with your server administrator to ensure that <a href='http://www.php.net/manual/en/book.curl.php'>PHP Curl</a> is installed and permissions are set correctly.</b>";
50
}
51
}
52
- } else if ($_POST["action"]=="signup") {
53
54
if ($_POST["zopimUseSSL"] == "") {
55
$_POST["zopimUseSSL"] = "nossl";
@@ -67,7 +70,7 @@ function zopim_account_config() {
67
"recaptcha_response_field" => $_POST["recaptcha_response_field"]
68
);
69
70
- $signupresult = json_to_array(do_post_request(ZOPIM_SIGNUP_URL, $createdata));
71
if (isset($signupresult->error)) {
72
$message = "<div style='color:#c33;'>Error during activation: <b>".$signupresult->error."</b>. Please try again.</div>";
73
} else if (isset($signupresult->account_key)) {
@@ -78,10 +81,10 @@ function zopim_account_config() {
78
}
79
}
80
81
if (get_option('zopimCode') != "" && get_option('zopimCode') != "zopim") {
82
83
$accountDetails = getAccountDetails(get_option('zopimSalt'));
84
-
85
if (!isset($accountDetails) || isset($accountDetails->error)) {
86
$gotologin = 1;
87
$error["auth"] = '
10
11
<?php
12
13
+ if (isset($_GET["action"]) && $_GET["action"]=="deactivate") {
14
update_option('zopimSalt', "");
15
update_option('zopimCode', "zopim");
16
}
17
18
$message = "";
19
+ $authenticated = "";
20
+
21
+ if (isset($_POST["action"]) && $_POST["action"]=="login") {
22
+ if (!isset($_POST["zopimUseSSL"]) || $_POST["zopimUseSSL"] == '') {
23
$_POST["zopimUseSSL"] = "nossl";
24
}
25
+
26
update_option('zopimUseSSL', $_POST["zopimUseSSL"]);
27
28
if ($_POST["zopimPassword"] != "password") {
29
30
$logindata = array("email" => $_POST["zopimUsername"], "password" => $_POST["zopimPassword"]);
31
+ $loginresult = json_to_array(zopim_post_request(ZOPIM_LOGIN_URL, $logindata));
32
33
if (isset($loginresult->error)) {
34
$error["login"] = "<b>Could not log in to Zopim. Please check your login details. If problem persists, try connecting without SSL enabled.</b>";
52
$error["login"] = "<b>Could not log in to Zopim. We were unable to contact Zopim servers. Please check with your server administrator to ensure that <a href='http://www.php.net/manual/en/book.curl.php'>PHP Curl</a> is installed and permissions are set correctly.</b>";
53
}
54
}
55
+ } else if (isset($_POST["action"]) && $_POST["action"]=="signup") {
56
57
if ($_POST["zopimUseSSL"] == "") {
58
$_POST["zopimUseSSL"] = "nossl";
70
"recaptcha_response_field" => $_POST["recaptcha_response_field"]
71
);
72
73
+ $signupresult = json_to_array(zopim_post_request(ZOPIM_SIGNUP_URL, $createdata));
74
if (isset($signupresult->error)) {
75
$message = "<div style='color:#c33;'>Error during activation: <b>".$signupresult->error."</b>. Please try again.</div>";
76
} else if (isset($signupresult->account_key)) {
81
}
82
}
83
84
+ $error = NULL;
85
if (get_option('zopimCode') != "" && get_option('zopimCode') != "zopim") {
86
87
$accountDetails = getAccountDetails(get_option('zopimSalt'));
88
if (!isset($accountDetails) || isset($accountDetails->error)) {
89
$gotologin = 1;
90
$error["auth"] = '
customizewidget.php CHANGED
@@ -1,7 +1,6 @@
1
<?php
2
3
// Zopim Customize Widget Page
4
-
5
function zopim_customize_widget() {
6
global $current_user;
7
$ul = $current_user->data->first_name;
@@ -263,7 +262,7 @@ line-height:21px;
263
264
if ($accountDetails->color_customization_enabled == 1) {
265
echo "<div style='display:inline-block;border:11px solid #888;background:#888;color:#fee;'>";
266
- $colors = curl_get_url(ZOPIM_COLORS_LIST);
267
$colors = explode("\n", $colors);
268
269
$i=0;
@@ -287,7 +286,7 @@ line-height:21px;
287
288
if ($accountDetails->widget_customization_enabled == 1) {
289
echo '<select name="zopimTheme" id="zopimTheme" onchange="updateWidget()">';
290
- $themes = curl_get_url(ZOPIM_THEMES_LIST);
291
$themes = valuekeys(explode("\n", $themes));
292
ksort($themes);
293
1
<?php
2
3
// Zopim Customize Widget Page
4
function zopim_customize_widget() {
5
global $current_user;
6
$ul = $current_user->data->first_name;
262
263
if ($accountDetails->color_customization_enabled == 1) {
264
echo "<div style='display:inline-block;border:11px solid #888;background:#888;color:#fee;'>";
265
+ $colors = zopim_url_get(ZOPIM_COLORS_LIST);
266
$colors = explode("\n", $colors);
267
268
$i=0;
286
287
if ($accountDetails->widget_customization_enabled == 1) {
288
echo '<select name="zopimTheme" id="zopimTheme" onchange="updateWidget()">';
289
+ $themes = zopim_url_get(ZOPIM_THEMES_LIST);
290
$themes = valuekeys(explode("\n", $themes));
291
ksort($themes);
292
imintegration.php CHANGED
@@ -15,9 +15,9 @@ $salt = array('salt' => get_option('zopimSalt'));
15
if (isset($_GET["remove"]) && $_GET["remove"] == 1) {
16
echo "Removed IM Set Up. <br><br>";
17
18
- json_to_array(do_post_request(ZOPIM_IMREMOVE_URL, $salt));
19
}
20
- $iminfo = json_to_array(do_post_request(ZOPIM_IMINFO_URL, $salt));
21
22
if (isset($iminfo->bots)) { // Can set up IM ?>
23
15
if (isset($_GET["remove"]) && $_GET["remove"] == 1) {
16
echo "Removed IM Set Up. <br><br>";
17
18
+ json_to_array(zopim_post_request(ZOPIM_IMREMOVE_URL, $salt));
19
}
20
+ $iminfo = json_to_array(zopim_post_request(ZOPIM_IMINFO_URL, $salt));
21
22
if (isset($iminfo->bots)) { // Can set up IM ?>
23
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: bencxr
3
Tags: widget, plugin, sidebar, page, admin, enhancement, livechat, chat, widget
4
Requires at least: 2.7
5
Tested up to: 3.3.1
6
- Stable tag: 1.2.0
7
8
Zopim is an award winning facebook-like chatbar built for websites. It connects website owners and visitors together via a cross-browser platform.
9
3
Tags: widget, plugin, sidebar, page, admin, enhancement, livechat, chat, widget
4
Requires at least: 2.7
5
Tested up to: 3.3.1
6
+ Stable tag: 1.2.1
7
8
Zopim is an award winning facebook-like chatbar built for websites. It connects website owners and visitors together via a cross-browser platform.
9
zopim.php CHANGED
@@ -5,7 +5,7 @@ Plugin Name: Zopim Widget
5
Plugin URI: http://www.zopim.com/?iref=wp_plugin
6
Description: Zopim embeds a chatbar on your website, so that any visitor can chat with you directly by clicking on the chatbar.
7
Author: Zopim
8
- Version: 1.2.0
9
Author URI: http://www.zopim.com/?iref=wp_plugin
10
*/
11
@@ -33,17 +33,17 @@ require_once dirname( __FILE__ ) . '/imintegration.php';
33
34
// We need some CSS to position the paragraph
35
function zopimme() {
36
- global $current_user, $zopimshown;
37
38
- $code = get_option('zopimCode');
39
40
- if (($code == "" || $code=="zopim") && (!ereg("zopim", $_GET["page"]))&& (!ereg("zopim", $_SERVER["SERVER_NAME"]))) { return; }
41
42
- // dont show this more than once
43
- if (isset($zopimshown) && $zopimshown == 1) { return; }
44
- $zopimshown = 1;
45
46
- echo "<!--Start of Zopim Live Chat Script-->
47
<script type=\"text/javascript\">
48
window.\$zopim||(function(d,s){var z=\$zopim=function(c){z._.push(c)},$=z.s=
49
d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
@@ -53,44 +53,44 @@ type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
53
</script>
54
<!--End of Zopim Live Chat Script-->";
55
56
- $theoptions = array();
57
- if (get_option('zopimLang') != "" && get_option('zopimLang') != "--")
58
$theoptions[] = " language: '".get_option('zopimLang')."'";
59
60
- if (isset($current_user) && get_option("zopimGetVisitorInfo") == "checked") {
61
$ul = $current_user->data->first_name;
62
$useremail = $current_user->data->user_email;
63
if ($ul!="" && $useremail != "")
64
$theoptions[] = "name: '$ul', email: '$useremail'";
65
- }
66
67
- echo "\n<script type=\"text/javascript\">\n\$zopim( function() {";
68
69
- if (count($theoptions) > 0)
70
echo '$zopim.livechat.set({'.implode(", ", $theoptions)."});";
71
72
- get_option('zopimPosition') != "" && print("\n\$zopim.livechat.button.setPosition('".get_option('zopimPosition')."');");
73
- get_option('zopimTheme') != "" && print("\n\$zopim.livechat.window.setTheme('".get_option('zopimTheme')."');");
74
- get_option('zopimColor') != "" && print("\n\$zopim.livechat.window.setColor('".get_option('zopimColor')."');");
75
76
- if (get_option('zopimUseGreetings') == "zopimUseGreetings") {
77
- if (get_option('zopimGreetings') != "") {
78
$greetings = json_to_array(get_option('zopimGreetings'));
79
foreach ($greetings as $i => $v) {
80
foreach ($v as $j => $k) {
81
$greetings->$i->$j = str_replace("\r\n", "\\n", $greetings->$i->$j);
82
- }
83
- }
84
echo "\n\$zopim.livechat.setGreetings({
85
'online' : ['".addslashes($greetings->online->bar)."', '".addslashes($greetings->online->window)."'],
86
'offline': ['".addslashes($greetings->offline->bar)."', '".addslashes($greetings->offline->window)."'],
87
'away' : ['".addslashes($greetings->away->bar)."', '".addslashes($greetings->away->window)."'] });";
88
- }
89
- }
90
91
if (get_option('zopimUseBubble') == "zopimUseBubble") {
92
- get_option('zopimBubbleTitle') != "" && print("\n\$zopim.livechat.bubble.setTitle('".addslashes(get_option('zopimBubbleTitle'))."');");
93
- get_option('zopimBubbleText') != "" && print("\n\$zopim.livechat.bubble.setText('".addslashes(get_option('zopimBubbleText'))."');");
94
}
95
96
if (get_option('zopimBubbleEnable') == "show")
@@ -99,23 +99,23 @@ type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
99
echo "\n\$zopim.livechat.bubble.hide(true);";
100
101
// this must be called last
102
- if (get_option('zopimHideOnOffline') == "zopimHideOnOffline")
103
echo "\n\$zopim.livechat.button.setHideWhenOffline(true);";
104
- echo "\n})</script>";
105
}
106
107
function zopim_create_menu() {
108
- //create new top-level menu
109
- add_menu_page('Account Configuration', 'Zopim Chat', 'administrator', 'zopim_account_config', 'zopim_account_config', ZOPIM_SMALL_LOGO);
110
111
- // add_submenu_page('zopim_about', "About", "About", "administrator", 'zopim_about', 'zopim_about');
112
- add_submenu_page('zopim_account_config', 'Account Configuration', 'Account Setup', 'administrator', 'zopim_account_config', 'zopim_account_config');
113
- add_submenu_page('zopim_account_config', 'Customize Widget', 'Customize', 'administrator', 'zopim_customize_widget', 'zopim_customize_widget');
114
- add_submenu_page('zopim_account_config', 'IM Integration', 'IM Chat Bots', 'administrator', 'zopim_instant_messaging', 'zopim_instant_messaging');
115
- add_submenu_page('zopim_account_config', 'Dashboard', 'Dashboard', 'administrator', 'zopim_dashboard', 'zopim_dashboard');
116
117
- //call register settings function
118
- add_action( 'admin_init', 'register_mysettings' );
119
}
120
121
function check_zopimCode() {
@@ -126,114 +126,93 @@ function check_zopimCode() {
126
add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>This Zopim plugin is a work in progress. We will launch on the 25th of January. Thank you for your interest.</p></div>";' ) );
127
}
128
*/
129
- return false;
130
}
131
132
function zopim_loader() {
133
- add_action( 'admin_menu', 'check_zopimCode' );
134
}
135
136
add_action( 'init', 'zopim_loader' );
137
138
function zopim_about() {
139
- echo "about";
140
}
141
142
function zopim_dashboard() {
143
- echo '<div id="dashboarddiv"><iframe id="dashboardiframe" src="'.ZOPIM_DASHBOARD_URL.'" height=700 width=98% scrolling="no"></iframe></div> You may also <a href="'.ZOPIM_DASHBOARD_URL.'" target="_newWindow" onClick="javascript:document.getElementById(\'dashboarddiv\').innerHTML=\'\'; ">access the dashboard in a new window</a>.
144
';
145
}
146
147
// Register the option settings we will be using
148
- function register_mysettings() {
149
-
150
- // Authentication and codes
151
- register_setting( 'zopim-settings-group', 'zopimCode' );
152
- register_setting( 'zopim-settings-group', 'zopimUsername' );
153
- register_setting( 'zopim-settings-group', 'zopimSalt' );
154
- register_setting( 'zopim-settings-group', 'zopimUseSSL' );
155
- // General Widget settings
156
- register_setting( 'zopim-settings-group', 'zopimGetVisitorInfo' );
157
- register_setting( 'zopim-settings-group', 'zopimLang' );
158
- // Chat button settings
159
- register_setting( 'zopim-settings-group', 'zopimPosition' );
160
- register_setting( 'zopim-settings-group', 'zopimHideOnOffline' );
161
- register_setting( 'zopim-settings-group', 'zopimBubbleTitle' );
162
- register_setting( 'zopim-settings-group', 'zopimBubbleText' );
163
- register_setting( 'zopim-settings-group', 'zopimBubbleEnable' );
164
- register_setting( 'zopim-settings-group', 'zopimUseBubble' );
165
- // Themes / Color
166
- register_setting( 'zopim-settings-group', 'zopimColor' );
167
- register_setting( 'zopim-settings-group', 'zopimTheme' );
168
- // Message Settings
169
- register_setting( 'zopim-settings-group', 'zopimGreetings' );
170
- register_setting( 'zopim-settings-group', 'zopimUseGreetings' );
171
-
172
- get_option('zopimCode') == "" && update_option('zopimCode', "zopim");
173
- get_option('zopimBubbleTitle') == "" && update_option('zopimBubbleTitle', "Questions?");
174
- get_option('zopimBubbleText') == "" && update_option('zopimBubbleText', "Click here to chat with us!");
175
- get_option('zopimBubbleEnable') == "" && update_option('zopimBubbleEnable', "checked");
176
- get_option('zopimUseGreetings') == "" && update_option('zopimUseGreetings', "disabled");
177
- get_option('zopimUseBubble') == "" && update_option('zopimUseBubble', "disabled");
178
- get_option('zopimGreetings') == "" && update_option('zopimGreetings', '{"away":{"window":"If you leave a question or comment, our agents will be notified and will try to attend to you shortly =)","bar":"Click here to chat"},"offline":{"window":"We are offline, but if you leave your message and contact details, we will try to get back to you =)","bar":"Leave a message"},"online":{"window":"Leave a question or comment and our agents will try to attend to you shortly =)","bar":"Click here to chat"}}');
179
}
180
181
add_action('get_footer', 'zopimme');
182
// create custom plugin settings menu
183
add_action('admin_menu', 'zopim_create_menu');
184
185
- function do_post_request($url, $_data, $optional_headers = null)
186
{
187
- if (get_option('zopimUseSSL') != "zopimUseSSL")
188
- $url = str_replace("https", "http", $url);
189
-
190
- $data = array();
191
-
192
- while(list($n,$v) = each($_data)){
193
- $data[] = urlencode($n)."=".urlencode($v);
194
- }
195
-
196
- $data = implode('&', $data);
197
198
- $ch = curl_init();
199
200
- curl_setopt($ch, CURLOPT_URL, $url);
201
- curl_setopt($ch, CURLOPT_POST, true);
202
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
203
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
204
-
205
- $response = curl_exec($ch);
206
- curl_close($ch);
207
208
- return $response;
209
}
210
211
function json_to_array($json) {
212
- require_once('JSON.php');
213
- $jsonparser = new Services_JSON();
214
- return ($jsonparser->decode($json));
215
}
216
217
function to_json($variable) {
218
- require_once('JSON.php');
219
- $jsonparser = new Services_JSON();
220
- return ($jsonparser->encode($variable));
221
}
222
223
function getAccountDetails($salt) {
224
- $salty = array("salt" => get_option('zopimSalt'));
225
- return json_to_array(do_post_request(ZOPIM_GETACCOUNTDETAILS_URL, $salty));
226
- }
227
-
228
- function curl_get_url($filename) {
229
- $ch = curl_init();
230
- $timeout = 5; // set to zero for no timeout
231
- curl_setopt ($ch, CURLOPT_URL, $filename);
232
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
233
- curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
234
- $file_contents = curl_exec($ch);
235
- curl_close($ch);
236
- return $file_contents;
237
}
238
239
?>
5
Plugin URI: http://www.zopim.com/?iref=wp_plugin
6
Description: Zopim embeds a chatbar on your website, so that any visitor can chat with you directly by clicking on the chatbar.
7
Author: Zopim
8
+ Version: 1.2.1
9
Author URI: http://www.zopim.com/?iref=wp_plugin
10
*/
11
33
34
// We need some CSS to position the paragraph
35
function zopimme() {
36
+ global $current_user, $zopimshown;
37
38
+ $code = get_option('zopimCode');
39
40
+ if (($code == "" || $code=="zopim") && (!ereg("zopim", $_GET["page"]))&& (!ereg("zopim", $_SERVER["SERVER_NAME"]))) { return; }
41
42
+ // dont show this more than once
43
+ if (isset($zopimshown) && $zopimshown == 1) { return; }
44
+ $zopimshown = 1;
45
46
+ echo "<!--Start of Zopim Live Chat Script-->
47
<script type=\"text/javascript\">
48
window.\$zopim||(function(d,s){var z=\$zopim=function(c){z._.push(c)},$=z.s=
49
d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
53
</script>
54
<!--End of Zopim Live Chat Script-->";
55
56
+ $theoptions = array();
57
+ if (get_option('zopimLang') != "" && get_option('zopimLang') != "--")
58
$theoptions[] = " language: '".get_option('zopimLang')."'";
59
60
+ if (isset($current_user) && get_option("zopimGetVisitorInfo") == "checked") {
61
$ul = $current_user->data->first_name;
62
$useremail = $current_user->data->user_email;
63
if ($ul!="" && $useremail != "")
64
$theoptions[] = "name: '$ul', email: '$useremail'";
65
+ }
66
67
+ echo "\n<script type=\"text/javascript\">\n\$zopim( function() {";
68
69
+ if (count($theoptions) > 0)
70
echo '$zopim.livechat.set({'.implode(", ", $theoptions)."});";
71
72
+ get_option('zopimPosition') != "" && print("\n\$zopim.livechat.button.setPosition('".get_option('zopimPosition')."');");
73
+ get_option('zopimTheme') != "" && print("\n\$zopim.livechat.window.setTheme('".get_option('zopimTheme')."');");
74
+ get_option('zopimColor') != "" && print("\n\$zopim.livechat.window.setColor('".get_option('zopimColor')."');");
75
76
+ if (get_option('zopimUseGreetings') == "zopimUseGreetings") {
77
+ if (get_option('zopimGreetings') != "") {
78
$greetings = json_to_array(get_option('zopimGreetings'));
79
foreach ($greetings as $i => $v) {
80
foreach ($v as $j => $k) {
81
$greetings->$i->$j = str_replace("\r\n", "\\n", $greetings->$i->$j);
82
+ }
83
+ }
84
echo "\n\$zopim.livechat.setGreetings({
85
'online' : ['".addslashes($greetings->online->bar)."', '".addslashes($greetings->online->window)."'],
86
'offline': ['".addslashes($greetings->offline->bar)."', '".addslashes($greetings->offline->window)."'],
87
'away' : ['".addslashes($greetings->away->bar)."', '".addslashes($greetings->away->window)."'] });";
88
+ }
89
+ }
90
91
if (get_option('zopimUseBubble') == "zopimUseBubble") {
92
+ get_option('zopimBubbleTitle') != "" && print("\n\$zopim.livechat.bubble.setTitle('".addslashes(get_option('zopimBubbleTitle'))."');");
93
+ get_option('zopimBubbleText') != "" && print("\n\$zopim.livechat.bubble.setText('".addslashes(get_option('zopimBubbleText'))."');");
94
}
95
96
if (get_option('zopimBubbleEnable') == "show")
99
echo "\n\$zopim.livechat.bubble.hide(true);";
100
101
// this must be called last
102
+ if (get_option('zopimHideOnOffline') == "zopimHideOnOffline")
103
echo "\n\$zopim.livechat.button.setHideWhenOffline(true);";
104
+ echo "\n})</script>";
105
}
106
107
function zopim_create_menu() {
108
+ //create new top-level menu
109
+ add_menu_page('Account Configuration', 'Zopim Chat', 'administrator', 'zopim_account_config', 'zopim_account_config', ZOPIM_SMALL_LOGO);
110
111
+ // add_submenu_page('zopim_about', "About", "About", "administrator", 'zopim_about', 'zopim_about');
112
+ add_submenu_page('zopim_account_config', 'Account Configuration', 'Account Setup', 'administrator', 'zopim_account_config', 'zopim_account_config');
113
+ add_submenu_page('zopim_account_config', 'Customize Widget', 'Customize', 'administrator', 'zopim_customize_widget', 'zopim_customize_widget');
114
+ add_submenu_page('zopim_account_config', 'IM Integration', 'IM Chat Bots', 'administrator', 'zopim_instant_messaging', 'zopim_instant_messaging');
115
+ add_submenu_page('zopim_account_config', 'Dashboard', 'Dashboard', 'administrator', 'zopim_dashboard', 'zopim_dashboard');
116
117
+ //call register settings function
118
+ add_action( 'admin_init', 'register_zopim_plugin_settings' );
119
}
120
121
function check_zopimCode() {
126
add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>This Zopim plugin is a work in progress. We will launch on the 25th of January. Thank you for your interest.</p></div>";' ) );
127
}
128
*/
129
+ return false;
130
}
131
132
function zopim_loader() {
133
+ add_action( 'admin_menu', 'check_zopimCode' );
134
}
135
136
add_action( 'init', 'zopim_loader' );
137
138
function zopim_about() {
139
+ echo "about";
140
}
141
142
function zopim_dashboard() {
143
+ echo '<div id="dashboarddiv"><iframe id="dashboardiframe" src="'.ZOPIM_DASHBOARD_URL.'i" height=700 width=98% scrolling="no"></iframe></div> You may also <a href="'.ZOPIM_DASHBOARD_URL.'" target="_newWindow" onClick="javascript:document.getElementById(\'dashboarddiv\').innerHTML=\'\'; ">access the dashboard in a new window</a>.
144
';
145
}
146
147
// Register the option settings we will be using
148
+ function register_zopim_plugin_settings() {
149
+
150
+ // Authentication and codes
151
+ register_setting( 'zopim-settings-group', 'zopimCode' );
152
+ register_setting( 'zopim-settings-group', 'zopimUsername' );
153
+ register_setting( 'zopim-settings-group', 'zopimSalt' );
154
+ register_setting( 'zopim-settings-group', 'zopimUseSSL' );
155
+ // General Widget settings
156
+ register_setting( 'zopim-settings-group', 'zopimGetVisitorInfo' );
157
+ register_setting( 'zopim-settings-group', 'zopimLang' );
158
+ // Chat button settings
159
+ register_setting( 'zopim-settings-group', 'zopimPosition' );
160
+ register_setting( 'zopim-settings-group', 'zopimHideOnOffline' );
161
+ register_setting( 'zopim-settings-group', 'zopimBubbleTitle' );
162
+ register_setting( 'zopim-settings-group', 'zopimBubbleText' );
163
+ register_setting( 'zopim-settings-group', 'zopimBubbleEnable' );
164
+ register_setting( 'zopim-settings-group', 'zopimUseBubble' );
165
+ // Themes / Color
166
+ register_setting( 'zopim-settings-group', 'zopimColor' );
167
+ register_setting( 'zopim-settings-group', 'zopimTheme' );
168
+ // Message Settings
169
+ register_setting( 'zopim-settings-group', 'zopimGreetings' );
170
+ register_setting( 'zopim-settings-group', 'zopimUseGreetings' );
171
+
172
+ get_option('zopimCode') == "" && update_option('zopimCode', "zopim");
173
+ get_option('zopimBubbleTitle') == "" && update_option('zopimBubbleTitle', "Questions?");
174
+ get_option('zopimBubbleText') == "" && update_option('zopimBubbleText', "Click here to chat with us!");
175
+ get_option('zopimBubbleEnable') == "" && update_option('zopimBubbleEnable', "checked");
176
+ get_option('zopimUseGreetings') == "" && update_option('zopimUseGreetings', "disabled");
177
+ get_option('zopimUseBubble') == "" && update_option('zopimUseBubble', "disabled");
178
+ get_option('zopimGreetings') == "" && update_option('zopimGreetings', '{"away":{"window":"If you leave a question or comment, our agents will be notified and will try to attend to you shortly =)","bar":"Click here to chat"},"offline":{"window":"We are offline, but if you leave your message and contact details, we will try to get back to you =)","bar":"Leave a message"},"online":{"window":"Leave a question or comment and our agents will try to attend to you shortly =)","bar":"Click here to chat"}}');
179
}
180
181
add_action('get_footer', 'zopimme');
182
// create custom plugin settings menu
183
add_action('admin_menu', 'zopim_create_menu');
184
185
+ function zopim_post_request($url, $_data, $optional_headers = null)
186
{
187
+ if (get_option('zopimUseSSL') != "zopimUseSSL")
188
+ $url = str_replace("https", "http", $url);
189
190
+ $args = array('body' => $_data);
191
+ $response = wp_remote_post( $url, $args );
192
+ return $response['body'];
193
194
+ }
195
196
+ function zopim_url_get($filename) {
197
+ $response = wp_remote_get($filename);
198
+ return $response['body'];
199
}
200
201
function json_to_array($json) {
202
+ require_once('JSON.php');
203
+ $jsonparser = new Services_JSON();
204
+ return ($jsonparser->decode($json));
205
}
206
207
function to_json($variable) {
208
+ require_once('JSON.php');
209
+ $jsonparser = new Services_JSON();
210
+ return ($jsonparser->encode($variable));
211
}
212
213
function getAccountDetails($salt) {
214
+ $salty = array("salt" => get_option('zopimSalt'));
215
+ return json_to_array(zopim_post_request(ZOPIM_GETACCOUNTDETAILS_URL, $salty));
216
}
217
218
?>