Version Description
- Update Zopim embed script
- Add option to override dashboard settings for chat bubble text
Download this release
Release Info
Developer | bencxr |
Plugin | Zendesk Chat |
Version | 1.1.3 |
Comparing to | |
See all releases |
Code changes from version 1.1.2 to 1.1.3
- customizewidget.php +205 -246
- readme.txt +7 -6
- zopim.php +154 -214
customizewidget.php
CHANGED
@@ -3,48 +3,45 @@
|
|
3 |
// Zopim Customize Widget Page
|
4 |
|
5 |
function zopim_customize_widget() {
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
if (get_option('zopimCode')=="zopim") {
|
47 |
-
|
48 |
$message = '<div class="metabox-holder">
|
49 |
<div class="postbox">
|
50 |
<h3 class="hndle"><span>Customizing in Demo Mode</span></h3>
|
@@ -53,106 +50,116 @@ function zopim_customize_widget() {
|
|
53 |
</div>
|
54 |
</div>
|
55 |
</div>';
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
<div class="metabox-holder">
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
?>
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
function updateWidget() {
|
79 |
-
|
80 |
-
var lang = document.getElementById('zopimLang').options[ document.getElementById('zopimLang').options.selectedIndex ].value;
|
81 |
-
$zopim.livechat.setLanguage(lang);
|
82 |
-
|
83 |
-
if (document.getElementById("zopimGetVisitorInfo").checked) {
|
84 |
-
$zopim.livechat.setName('<?php echo $ul; ?>');
|
85 |
-
$zopim.livechat.setEmail('<?php echo $useremail; ?>');
|
86 |
-
} else {
|
87 |
-
$zopim.livechat.setName('Visitor');
|
88 |
-
$zopim.livechat.setEmail('');
|
89 |
-
}
|
90 |
-
|
91 |
-
if (document.getElementById("zopimHideOnOffline").checked) {
|
92 |
-
$zopim.livechat.button.setHideWhenOffline(true);
|
93 |
-
} else {
|
94 |
-
$zopim.livechat.button.setHideWhenOffline(false);
|
95 |
-
}
|
96 |
-
|
97 |
-
$zopim.livechat.window.setColor(document.getElementById("zopimColor").value);
|
98 |
-
$zopim.livechat.window.setTheme(document.getElementById("zopimTheme").value);
|
99 |
-
|
100 |
-
$zopim.livechat.bubble.setTitle(document.getElementById("zopimBubbleTitle").value);
|
101 |
-
$zopim.livechat.bubble.setText(document.getElementById("zopimBubbleText").value);
|
102 |
-
|
103 |
-
$zopim.livechat.setGreetings({
|
104 |
-
'online': [document.getElementById("zopimOnlineShort").value, document.getElementById("zopimOnlineLong").value],
|
105 |
-
'offline': [document.getElementById("zopimOfflineShort").value, document.getElementById("zopimOfflineLong").value],
|
106 |
-
'away': [document.getElementById("zopimAwayShort").value, document.getElementById("zopimAwayLong").value]
|
107 |
-
});
|
108 |
-
}
|
109 |
|
110 |
-
|
|
|
|
|
111 |
|
112 |
-
|
113 |
-
$zopim.livechat.
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
function greetingsChanged() {
|
132 |
-
var inputs
|
133 |
-
|
134 |
var isDisabled = false;
|
135 |
|
136 |
-
|
137 |
-
isDisabled = false;
|
138 |
-
else
|
139 |
-
isDisabled = true;
|
140 |
|
141 |
for (var i=0; i<inputs.length; i++) {
|
142 |
-
|
143 |
-
el.disabled = isDisabled;
|
144 |
}
|
145 |
|
146 |
updateWidget();
|
147 |
}
|
148 |
|
149 |
-
|
150 |
-
|
|
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
<style type="text/css">
|
158 |
.smallExplanation {
|
@@ -202,15 +209,13 @@ line-height:21px;
|
|
202 |
<h3 class="hndle"><span>General Settings</span></h3>
|
203 |
<div style="padding:10px;">
|
204 |
<table class="form-table">
|
205 |
-
|
206 |
<th scope="row" class="sethead">Language</th>
|
207 |
<td>
|
208 |
-
|
209 |
-
<select name="zopimLang" id="zopimLang" onchange="updateWidget()">
|
210 |
<?php
|
211 |
-
|
212 |
-
|
213 |
-
echo generate_options($languages, get_option('zopimLang'));
|
214 |
?>
|
215 |
</select>
|
216 |
</td>
|
@@ -237,8 +242,8 @@ line-height:21px;
|
|
237 |
<!-- <div class="smallExplanation">Hide the chat bar when no agents are available to answer questions. This prevents visitors from sending you offline messages. </div> -->
|
238 |
</th>
|
239 |
<td>
|
240 |
-
<input onchange="updateWidget()" type="checkbox" id="zopimHideOnOffline" name="zopimHideOnOffline" value="zopimHideOnOffline" <?php if (get_option('zopimHideOnOffline') && get_option('zopimHideOnOffline')!="disabled") { echo "checked='checked'"; } ?> />
|
241 |
-
<a href="#" onclick="$zopim.livechat.button.show();return false">
|
242 |
</td>
|
243 |
</tr>
|
244 |
</table>
|
@@ -249,7 +254,7 @@ line-height:21px;
|
|
249 |
<div class="postbox">
|
250 |
<h3 class="hndle"><span>Color & Theme Settings</span></h3>
|
251 |
<div style="padding:10px;">
|
252 |
-
|
253 |
<table class="form-table" style="width: 700px">
|
254 |
<tr valign="top">
|
255 |
<td colspan="2">
|
@@ -280,17 +285,18 @@ line-height:21px;
|
|
280 |
<td style="width: 400px"><div align="left">
|
281 |
<?php
|
282 |
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
|
|
294 |
}
|
295 |
?>
|
296 |
</td>
|
@@ -300,53 +306,39 @@ line-height:21px;
|
|
300 |
</div>
|
301 |
</div>
|
302 |
|
|
|
|
|
|
|
303 |
<div class="metabox-holder">
|
304 |
<div class="postbox">
|
305 |
<h3 class="hndle"><span>Help Bubble Settings</span></h3>
|
306 |
<div style="padding:10px;">
|
307 |
<table class="form-table">
|
308 |
-
|
309 |
-
<
|
310 |
-
<
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
</
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
<
|
324 |
-
|
325 |
-
|
326 |
-
</td>
|
327 |
-
</tr>
|
328 |
-
|
329 |
-
<tr valign="top">
|
330 |
-
<th scope="row" class="sethead">Help Bubble Message
|
331 |
-
<!--<div class="smallExplanation">Welcome your visitors and encourage them to talk with you</div>--></th>
|
332 |
-
<td>
|
333 |
-
|
334 |
-
<input class="inputtext" name="zopimBubbleText" id="zopimBubbleText" onKeyup="updateSoon()" value="<?php echo get_option('zopimBubbleText'); ?>">
|
335 |
-
</td>
|
336 |
-
</tr>
|
337 |
-
|
338 |
-
|
339 |
</table>
|
340 |
</div>
|
341 |
</div>
|
342 |
</div>
|
343 |
|
344 |
<?php
|
345 |
-
|
346 |
-
$useGreetings = true;
|
347 |
-
} else {
|
348 |
-
$useGreetings = false;
|
349 |
-
}
|
350 |
?>
|
351 |
<div class="metabox-holder">
|
352 |
<div class="postbox">
|
@@ -354,70 +346,46 @@ line-height:21px;
|
|
354 |
<div style="padding:10px;">
|
355 |
<table class="form-table">
|
356 |
<tr>
|
357 |
-
<td colspan="2">
|
358 |
-
<input type="checkbox" id="zopimUseGreetings" onchange="greetingsChanged()" value="zopimUseGreetings" name="zopimUseGreetings"
|
359 |
-
<?php if ($useGreetings) { echo "checked='checked'"; } ?>/>
|
360 |
-
Use these greeting messages
|
361 |
-
</td>
|
362 |
</tr>
|
363 |
-
<tr
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
</td>
|
372 |
-
</tr>
|
373 |
-
|
374 |
-
<tr valign="top">
|
375 |
<th scope="row" class="sethead">Away</th>
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
</tr>
|
380 |
-
|
381 |
-
<tr valign="top">
|
382 |
<th scope="row" class="sethead">Offline</th>
|
383 |
-
<td>
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
<tr><td colspan="2"><div class="secthead">Message Shown on Chat Panel (max 140 characters)</div></td></tr>
|
390 |
-
<tr valign="top">
|
391 |
<th scope="row" class="sethead">Online</th>
|
392 |
-
<td>
|
393 |
-
|
394 |
-
|
395 |
-
</tr>
|
396 |
-
|
397 |
-
<tr valign="top">
|
398 |
<th scope="row" class="sethead">Away</th>
|
399 |
-
<td>
|
400 |
-
|
401 |
-
|
402 |
-
</tr>
|
403 |
-
|
404 |
-
<tr valign="top">
|
405 |
<th scope="row" class="sethead">Offline</th>
|
406 |
-
<td>
|
407 |
-
|
408 |
-
</td>
|
409 |
-
</tr>
|
410 |
</table>
|
411 |
-
|
412 |
</div>
|
413 |
</div>
|
414 |
</div>
|
415 |
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
420 |
-
</p>
|
421 |
|
422 |
</form>
|
423 |
</div>
|
@@ -425,20 +393,14 @@ line-height:21px;
|
|
425 |
<?php }
|
426 |
|
427 |
function valuekeys($array) {
|
428 |
-
|
429 |
$newarray = array();
|
430 |
-
foreach ($array as $s) {
|
431 |
-
$newarray[$s] = $s;
|
432 |
-
}
|
433 |
-
|
434 |
return $newarray;
|
435 |
}
|
436 |
|
437 |
function generate_options($options, $current) {
|
438 |
-
|
439 |
$out = "";
|
440 |
foreach ($options as $key => $value) {
|
441 |
-
|
442 |
if ($value != "") {
|
443 |
$isselected = "";
|
444 |
if ($current == $key) {
|
@@ -447,22 +409,19 @@ function generate_options($options, $current) {
|
|
447 |
$out .= '<option value="'.$key.'" '.$isselected.'>'.$value.'</option>';
|
448 |
}
|
449 |
}
|
450 |
-
|
451 |
return $out;
|
452 |
}
|
453 |
|
454 |
function get_languages() {
|
455 |
$langjson = '{"--":" - Auto Detect - ","ar":"Arabic","bn":"Bengali","bg":"Bulgarian","zh_CN":"Chinese (China)","zh_TW":"Chinese (Taiwan)","hr":"Croatian","cs":"Czech","da":"Danish","nl":"Dutch; Flemish","et":"Estonian","fo":"Faroese","fi":"Finnish","fr":"French","ka":"Georgian","de":"German","el":"Greek","he":"Hebrew","hu":"Hungarian","is":"Icelandic","id":"Indonesian","it":"Italian","ja":"Japanese","ko":"Korean","ku":"Kurdish","lv":"Latvian","lt":"Lithuanian","mk":"Macedonian","ms":"Malay","nb":"Norwegian Bokmal","fa":"Persian","pl":"Polish","pt":"Portuguese","pt_BR":"Portuguese (Brazil)","ro":"Romanian","ru":"Russian","sr":"Serbian","sk":"Slovak","sl":"Slovenian","es":"Spanish; Castilian","sv":"Swedish","th":"Thai","tr":"Turkish","uk":"Ukrainian","ur":"Urdu","vi":"Vietnamese"}';
|
456 |
-
|
457 |
return json_to_array($langjson);
|
458 |
}
|
459 |
|
460 |
function update_checkbox($fieldname) {
|
461 |
-
if (isset($_POST["$fieldname"]) && $_POST["$fieldname"] != "")
|
462 |
update_option($fieldname, $_POST["$fieldname"]);
|
463 |
-
|
464 |
update_option($fieldname, "disabled");
|
465 |
-
}
|
466 |
}
|
467 |
|
468 |
?>
|
3 |
// Zopim Customize Widget Page
|
4 |
|
5 |
function zopim_customize_widget() {
|
6 |
+
global $current_user;
|
7 |
+
$ul = $current_user->data->first_name;
|
8 |
+
$useremail = $current_user->data->user_email;
|
9 |
+
$greetings = json_to_array(get_option('zopimGreetings'));
|
10 |
+
$message = "";
|
11 |
+
|
12 |
+
if (count($_POST) > 0) {
|
13 |
+
update_option('zopimLang', $_POST["zopimLang"]);
|
14 |
+
update_option('zopimPosition', $_POST["zopimPosition"]);
|
15 |
+
update_option("zopimBubbleEnable", $_POST["zopimBubbleEnable"] );
|
16 |
+
update_option('zopimColor', $_POST["zopimColor"]);
|
17 |
+
update_option('zopimTheme', $_POST["zopimTheme"]);
|
18 |
+
update_option('zopimBubbleTitle', stripslashes($_POST["zopimBubbleTitle"]));
|
19 |
+
update_option('zopimBubbleText', stripslashes($_POST["zopimBubbleText"]));
|
20 |
+
|
21 |
+
update_checkbox("zopimGetVisitorInfo");
|
22 |
+
update_checkbox("zopimHideOnOffline");
|
23 |
+
update_checkbox("zopimUseGreetings");
|
24 |
+
update_checkbox("zopimUseBubble");
|
25 |
+
|
26 |
+
if (isset($_POST['zopimUseGreetings']) && $_POST['zopimUseGreetings'] != "") {
|
27 |
+
$greetings->online->window = stripslashes($_POST["zopimOnlineLong"]);
|
28 |
+
$greetings->online->bar = stripslashes($_POST["zopimOnlineShort"]);
|
29 |
+
$greetings->away->window = stripslashes($_POST["zopimAwayLong"]);
|
30 |
+
$greetings->away->bar = stripslashes($_POST["zopimAwayShort"]);
|
31 |
+
$greetings->offline->window = stripslashes($_POST["zopimOfflineLong"]);
|
32 |
+
$greetings->offline->bar = stripslashes($_POST["zopimOfflineShort"]);
|
33 |
+
|
34 |
+
update_option('zopimGreetings', to_json($greetings));
|
35 |
+
}
|
36 |
+
|
37 |
+
$message = "<b>Changes saved!</b><br>";
|
38 |
+
}
|
39 |
+
|
40 |
+
zopimme();
|
41 |
+
|
42 |
+
$accountDetails = getAccountDetails(get_option('zopimSalt'));
|
43 |
+
|
44 |
+
if (get_option('zopimCode')=="zopim") {
|
|
|
|
|
|
|
45 |
$message = '<div class="metabox-holder">
|
46 |
<div class="postbox">
|
47 |
<h3 class="hndle"><span>Customizing in Demo Mode</span></h3>
|
50 |
</div>
|
51 |
</div>
|
52 |
</div>';
|
53 |
+
$accountDetails->widget_customization_enabled = 1;
|
54 |
+
$accountDetails->color_customization_enabled = 1;
|
55 |
+
}
|
56 |
+
else if (isset($accountDetails->error)) {
|
57 |
+
$message = '<div class="metabox-holder">
|
58 |
+
<div class="postbox">
|
59 |
+
<h3 class="hndle"><span>Account no longer linked!</span></h3>
|
60 |
+
<div style="padding:10px;line-height:17px;">
|
61 |
+
We could not connect to your Zopim account. As a result, this customization page is running in demo mode.<br> Please <a href="admin.php?page=zopim_account_config">check your password in account setup</a> and try again.
|
62 |
+
</div>
|
63 |
+
</div>
|
64 |
+
</div>';
|
65 |
+
}
|
66 |
+
else {
|
67 |
+
$message .= "Click 'Save Changes' when you're done. Happy customizing!";
|
68 |
+
}
|
69 |
+
// unset($accountDetails->widget_customization_enabled);
|
70 |
+
// unset($accountDetails->color_customization_enabled);
|
71 |
?>
|
72 |
|
73 |
+
<script type="text/javascript">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
+
function updateWidget() {
|
76 |
+
var lang = document.getElementById('zopimLang').options[ document.getElementById('zopimLang').options.selectedIndex ].value;
|
77 |
+
$zopim.livechat.setLanguage(lang);
|
78 |
|
79 |
+
if (document.getElementById("zopimGetVisitorInfo").checked) {
|
80 |
+
$zopim.livechat.setName('<?php echo $ul; ?>');
|
81 |
+
$zopim.livechat.setEmail('<?php echo $useremail; ?>');
|
82 |
+
}
|
83 |
+
else {
|
84 |
+
$zopim.livechat.setName('Visitor');
|
85 |
+
$zopim.livechat.setEmail('');
|
86 |
+
}
|
87 |
|
88 |
+
document.getElementById("zopimHideOnOffline").checked? $zopim.livechat.button.setHideWhenOffline(true): $zopim.livechat.button.setHideWhenOffline(false);
|
89 |
+
|
90 |
+
$zopim.livechat.window.setColor(document.getElementById("zopimColor").value);
|
91 |
+
$zopim.livechat.window.setTheme(document.getElementById("zopimTheme").value);
|
92 |
+
|
93 |
+
if (document.getElementById("zopimUseBubble").checked) {
|
94 |
+
$zopim.livechat.bubble.setTitle(document.getElementById("zopimBubbleTitle").value);
|
95 |
+
$zopim.livechat.bubble.setText(document.getElementById("zopimBubbleText").value);
|
96 |
+
}
|
97 |
+
else {
|
98 |
+
$zopim.livechat.bubble.setTitle('Questions?');
|
99 |
+
$zopim.livechat.bubble.setText('Click here to chat with us!');
|
100 |
+
}
|
101 |
+
|
102 |
+
$zopim.livechat.setGreetings({
|
103 |
+
'online': [document.getElementById("zopimOnlineShort").value, document.getElementById("zopimOnlineLong").value],
|
104 |
+
'offline': [document.getElementById("zopimOfflineShort").value, document.getElementById("zopimOfflineLong").value],
|
105 |
+
'away': [document.getElementById("zopimAwayShort").value, document.getElementById("zopimAwayLong").value]
|
106 |
+
});
|
107 |
+
}
|
108 |
+
|
109 |
+
function updatePosition() {
|
110 |
+
var position = document.getElementById('zopimPosition').options[ document.getElementById('zopimPosition').options.selectedIndex ].value;
|
111 |
+
$zopim.livechat.button.setPosition(position);
|
112 |
+
}
|
113 |
+
|
114 |
+
function updateBubbleStatus() {
|
115 |
+
var value = document.getElementById("zopimBubbleEnable").value;
|
116 |
+
switch (value) {
|
117 |
+
case 'default':
|
118 |
+
$zopim.livechat.bubble.reset();
|
119 |
+
break;
|
120 |
+
case 'show':
|
121 |
+
$zopim.livechat.bubble.show();
|
122 |
+
break;
|
123 |
+
case 'hide':
|
124 |
+
$zopim.livechat.bubble.hide();
|
125 |
+
break;
|
126 |
+
}
|
127 |
+
}
|
128 |
|
129 |
function greetingsChanged() {
|
130 |
+
var inputs = [ 'zopimOnlineShort', 'zopimAwayShort', 'zopimOfflineShort',
|
131 |
+
'zopimOnlineLong' , 'zopimAwayLong', 'zopimOfflineLong' ];
|
132 |
var isDisabled = false;
|
133 |
|
134 |
+
document.getElementById('zopimUseGreetings').checked? (isDisabled = false): (isDisabled = true);
|
|
|
|
|
|
|
135 |
|
136 |
for (var i=0; i<inputs.length; i++) {
|
137 |
+
document.getElementById(inputs[i]).disabled = isDisabled;
|
|
|
138 |
}
|
139 |
|
140 |
updateWidget();
|
141 |
}
|
142 |
|
143 |
+
function bubbleChanged() {
|
144 |
+
var inputs = [ 'zopimBubbleTitle', 'zopimBubbleText' ];
|
145 |
+
var isDisabled = false;
|
146 |
|
147 |
+
document.getElementById('zopimUseBubble').checked? (isDisabled = false): (isDisabled = true);
|
148 |
+
|
149 |
+
for (var i = 0; i < inputs.length; i++) {
|
150 |
+
document.getElementById(inputs[i]).disabled = isDisabled;
|
151 |
+
}
|
152 |
+
|
153 |
+
updateWidget();
|
154 |
+
}
|
155 |
+
|
156 |
+
var timer;
|
157 |
+
function updateSoon() {
|
158 |
+
clearTimeout(timer);
|
159 |
+
timer = setTimeout("updateWidget()", 300);
|
160 |
+
}
|
161 |
+
|
162 |
+
</script>
|
163 |
|
164 |
<style type="text/css">
|
165 |
.smallExplanation {
|
209 |
<h3 class="hndle"><span>General Settings</span></h3>
|
210 |
<div style="padding:10px;">
|
211 |
<table class="form-table">
|
212 |
+
<tr valign="top">
|
213 |
<th scope="row" class="sethead">Language</th>
|
214 |
<td>
|
215 |
+
<select name="zopimLang" id="zopimLang" onchange="updateWidget()">
|
|
|
216 |
<?php
|
217 |
+
$languages = get_languages();
|
218 |
+
echo generate_options($languages, get_option('zopimLang'));
|
|
|
219 |
?>
|
220 |
</select>
|
221 |
</td>
|
242 |
<!-- <div class="smallExplanation">Hide the chat bar when no agents are available to answer questions. This prevents visitors from sending you offline messages. </div> -->
|
243 |
</th>
|
244 |
<td>
|
245 |
+
<input onchange="updateWidget()" type="checkbox" id="zopimHideOnOffline" name="zopimHideOnOffline" value="zopimHideOnOffline" <?php if (get_option('zopimHideOnOffline') && get_option('zopimHideOnOffline')!="disabled") { echo "checked='checked'"; } ?> /> Prevents visitors from sending you offline messages
|
246 |
+
<a href="#" onclick="$zopim.livechat.button.show();return false">(Show preview chat bar)</a>
|
247 |
</td>
|
248 |
</tr>
|
249 |
</table>
|
254 |
<div class="postbox">
|
255 |
<h3 class="hndle"><span>Color & Theme Settings</span></h3>
|
256 |
<div style="padding:10px;">
|
257 |
+
Theme settings show up instantly on the preview widget. Try it out!<br/>
|
258 |
<table class="form-table" style="width: 700px">
|
259 |
<tr valign="top">
|
260 |
<td colspan="2">
|
285 |
<td style="width: 400px"><div align="left">
|
286 |
<?php
|
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 |
+
|
294 |
+
echo generate_options($themes, get_option('zopimTheme'));
|
295 |
+
echo "</select> <a href='#' onclick='\$zopim.livechat.window.toggle();return false;'>Open the chat panel</a> to see changes";
|
296 |
+
}
|
297 |
+
else {
|
298 |
+
echo "<div class='sorry'>Sorry, your plan does not allow for theme customization. Please upgrade to enjoy choice of themes!</div>";
|
299 |
+
echo '<input type=hidden value="" name="zopimTheme" id="zopimTheme">';
|
300 |
}
|
301 |
?>
|
302 |
</td>
|
306 |
</div>
|
307 |
</div>
|
308 |
|
309 |
+
<?php
|
310 |
+
(get_option('zopimUseBubble') && get_option('zopimUseBubble')!="disabled")? ($useBubble = true): ($useBubble = false);
|
311 |
+
?>
|
312 |
<div class="metabox-holder">
|
313 |
<div class="postbox">
|
314 |
<h3 class="hndle"><span>Help Bubble Settings</span></h3>
|
315 |
<div style="padding:10px;">
|
316 |
<table class="form-table">
|
317 |
+
<tr valign="top">
|
318 |
+
<th scope="row">Display Help Bubble<br></th>
|
319 |
+
<td><select onchange="updateBubbleStatus()" type="checkbox" id="zopimBubbleEnable" name="zopimBubbleEnable"> <?php $bubble_modes = array("default" => "Let user decide", "show" => "Always show", "hide" => "Always hide"); echo generate_options($bubble_modes, get_option('zopimBubbleEnable')); ?> </select>
|
320 |
+
</tr>
|
321 |
+
<tr>
|
322 |
+
<td colspan="2"><div class="secthead">Help Bubble Text</div></td>
|
323 |
+
</tr>
|
324 |
+
<tr>
|
325 |
+
<td colspan="2"><input type="checkbox" id="zopimUseBubble" onchange="bubbleChanged()" value="zopimUseBubble" name="zopimUseBubble" <?php if ($useBubble) { echo "checked='checked'"; } ?>/> Enable help bubble text settings (override dashboard settings) - save settings to view changes.</td>
|
326 |
+
</tr>
|
327 |
+
<tr valign="top">
|
328 |
+
<th scope="row" class="sethead">Help Bubble Title</th>
|
329 |
+
<td><input class="inputtextshort" name="zopimBubbleTitle" id="zopimBubbleTitle" onKeyup="updateSoon()" value="<?php echo get_option('zopimBubbleTitle'); ?>" <?php if(!$useBubble) { echo "disabled='disabled'"; } ?>><!-- <a href="#" onclick="updateBubbleStatus();">Refresh</a></td> -->
|
330 |
+
</tr>
|
331 |
+
<tr valign="top">
|
332 |
+
<th scope="row" class="sethead">Help Bubble Message</th>
|
333 |
+
<td><input class="inputtext" name="zopimBubbleText" id="zopimBubbleText" onKeyup="updateSoon()" value="<?php echo get_option('zopimBubbleText'); ?>" <?php if(!$useBubble) { echo "disabled='disabled'"; } ?>></td>
|
334 |
+
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
</table>
|
336 |
</div>
|
337 |
</div>
|
338 |
</div>
|
339 |
|
340 |
<?php
|
341 |
+
(get_option('zopimUseGreetings') && get_option('zopimUseGreetings')!="disabled")? ($useGreetings = true): ($useGreetings = false);
|
|
|
|
|
|
|
|
|
342 |
?>
|
343 |
<div class="metabox-holder">
|
344 |
<div class="postbox">
|
346 |
<div style="padding:10px;">
|
347 |
<table class="form-table">
|
348 |
<tr>
|
349 |
+
<td colspan="2"><input type="checkbox" id="zopimUseGreetings" onchange="greetingsChanged()" value="zopimUseGreetings" name="zopimUseGreetings" <?php if ($useGreetings) { echo "checked='checked'"; } ?>/> Enable greeting message settings (override dashboard settings) </td>
|
|
|
|
|
|
|
|
|
350 |
</tr>
|
351 |
+
<tr>
|
352 |
+
<td colspan="2"><div class="secthead">Message Shown on Chat Bar (max 26 characters)</div></td>
|
353 |
+
</tr>
|
354 |
+
<tr valign="top">
|
355 |
+
<th scope="row" class="sethead">Online</th>
|
356 |
+
<td><input class="inputtextshort" name="zopimOnlineShort" id="zopimOnlineShort" onKeyup="updateSoon()" value="<?php echo $greetings->online->bar; ?>" <?php if (!$useGreetings) echo "disabled='disabled'"?> maxlength="26"></td>
|
357 |
+
</tr>
|
358 |
+
<tr valign="top">
|
|
|
|
|
|
|
|
|
359 |
<th scope="row" class="sethead">Away</th>
|
360 |
+
<td><input class="inputtextshort" name="zopimAwayShort" id="zopimAwayShort" onKeyup="updateSoon()" value="<?php echo $greetings->away->bar; ?>" <?php if (!$useGreetings) echo "disabled='disabled'"?> maxlength="26"></td>
|
361 |
+
</tr>
|
362 |
+
<tr valign="top">
|
|
|
|
|
|
|
363 |
<th scope="row" class="sethead">Offline</th>
|
364 |
+
<td><input class="inputtextshort" name="zopimOfflineShort" id="zopimOfflineShort" onKeyup="updateSoon()" value="<?php echo $greetings->offline->bar; ?>" <?php if (!$useGreetings) echo "disabled='disabled'"?> maxlength="26"></td>
|
365 |
+
</tr>
|
366 |
+
<tr>
|
367 |
+
<td colspan="2"><div class="secthead">Message Shown on Chat Panel (max 140 characters)</div></td>
|
368 |
+
</tr>
|
369 |
+
<tr valign="top">
|
|
|
|
|
370 |
<th scope="row" class="sethead">Online</th>
|
371 |
+
<td><textarea class="inputtext" name="zopimOnlineLong" id="zopimOnlineLong" onKeyup="updateSoon()" <?php if (!$useGreetings) echo "disabled='disabled'"?> ><?php echo $greetings->online->window; ?></textarea></td>
|
372 |
+
</tr>
|
373 |
+
<tr valign="top">
|
|
|
|
|
|
|
374 |
<th scope="row" class="sethead">Away</th>
|
375 |
+
<td><textarea class="inputtext" name="zopimAwayLong" id="zopimAwayLong" onKeyup="updateSoon()" <?php if (!$useGreetings) echo "disabled='disabled'"?> ><?php echo $greetings->away->window; ?></textarea></td>
|
376 |
+
</tr>
|
377 |
+
<tr valign="top">
|
|
|
|
|
|
|
378 |
<th scope="row" class="sethead">Offline</th>
|
379 |
+
<td><textarea class="inputtext" name="zopimOfflineLong" id="zopimOfflineLong" onKeyup="updateSoon()" <?php if (!$useGreetings) echo "disabled='disabled'"?> ><?php echo $greetings->offline->window; ?></textarea></td>
|
380 |
+
</tr>
|
|
|
|
|
381 |
</table>
|
|
|
382 |
</div>
|
383 |
</div>
|
384 |
</div>
|
385 |
|
386 |
+
<p class="submit">
|
387 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
388 |
+
</p>
|
|
|
|
|
389 |
|
390 |
</form>
|
391 |
</div>
|
393 |
<?php }
|
394 |
|
395 |
function valuekeys($array) {
|
|
|
396 |
$newarray = array();
|
397 |
+
foreach ($array as $s) { $newarray[$s] = $s; }
|
|
|
|
|
|
|
398 |
return $newarray;
|
399 |
}
|
400 |
|
401 |
function generate_options($options, $current) {
|
|
|
402 |
$out = "";
|
403 |
foreach ($options as $key => $value) {
|
|
|
404 |
if ($value != "") {
|
405 |
$isselected = "";
|
406 |
if ($current == $key) {
|
409 |
$out .= '<option value="'.$key.'" '.$isselected.'>'.$value.'</option>';
|
410 |
}
|
411 |
}
|
|
|
412 |
return $out;
|
413 |
}
|
414 |
|
415 |
function get_languages() {
|
416 |
$langjson = '{"--":" - Auto Detect - ","ar":"Arabic","bn":"Bengali","bg":"Bulgarian","zh_CN":"Chinese (China)","zh_TW":"Chinese (Taiwan)","hr":"Croatian","cs":"Czech","da":"Danish","nl":"Dutch; Flemish","et":"Estonian","fo":"Faroese","fi":"Finnish","fr":"French","ka":"Georgian","de":"German","el":"Greek","he":"Hebrew","hu":"Hungarian","is":"Icelandic","id":"Indonesian","it":"Italian","ja":"Japanese","ko":"Korean","ku":"Kurdish","lv":"Latvian","lt":"Lithuanian","mk":"Macedonian","ms":"Malay","nb":"Norwegian Bokmal","fa":"Persian","pl":"Polish","pt":"Portuguese","pt_BR":"Portuguese (Brazil)","ro":"Romanian","ru":"Russian","sr":"Serbian","sk":"Slovak","sl":"Slovenian","es":"Spanish; Castilian","sv":"Swedish","th":"Thai","tr":"Turkish","uk":"Ukrainian","ur":"Urdu","vi":"Vietnamese"}';
|
|
|
417 |
return json_to_array($langjson);
|
418 |
}
|
419 |
|
420 |
function update_checkbox($fieldname) {
|
421 |
+
if (isset($_POST["$fieldname"]) && $_POST["$fieldname"] != "")
|
422 |
update_option($fieldname, $_POST["$fieldname"]);
|
423 |
+
else
|
424 |
update_option($fieldname, "disabled");
|
|
|
425 |
}
|
426 |
|
427 |
?>
|
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.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 |
|
@@ -42,8 +42,11 @@ Zopim shows up as a chatbar docked to the bottom of your website. Visitors chat
|
|
42 |
|
43 |
* Arabic | Bulgarian | Chinese | Croatian | Czech | Danish | Dutch; Flemish | Estonian | Faroese | Finnish | French | Georgian | German | Greek | Hebrew | Hungarian | Icelandic | Indonesian | Italian | Japanese | Korean | Kurdish | Latvian | Lithuanian | Macedonian | Malay | Norwegian Bokmal | Persian | Polish | Portuguese | Romanian | Russian | Serbian | Slovak | Slovenian | Spanish; Castilian | Swedish | Thai | Turkish | Ukranian | Urdu | Vietnamese
|
44 |
|
45 |
-
|
46 |
== Changelog ==
|
|
|
|
|
|
|
|
|
47 |
= 1.1.2 =
|
48 |
* Maintenance update: Compatibility update for Wordpress 3.3.1
|
49 |
|
@@ -53,7 +56,7 @@ Zopim shows up as a chatbar docked to the bottom of your website. Visitors chat
|
|
53 |
= 1.1.0 =
|
54 |
* Maintenance update: Greeting messages are now saved properly.
|
55 |
* Add more language options in customization page.
|
56 |
-
* Using new Zopim async embed script: improve page's load time and do not block page's rendering anymore
|
57 |
|
58 |
= 1.0.7 =
|
59 |
* Maintenance update: Remove phased out "middle left", "middle right" positions
|
@@ -151,12 +154,10 @@ Dont worry!! We are happy to assist! Just come on down to our site at http://www
|
|
151 |
|
152 |
== Usage ==
|
153 |
|
154 |
-
After enabling the plug in, head on to the widget customization page to change settings and integrate
|
155 |
|
156 |
== Installation ==
|
157 |
|
158 |
*Server Requirements:* PHP4 or PHP5 with PHP Curl installed.
|
159 |
|
160 |
*Wordpress versions:* Wordpress 2.7 and up.
|
161 |
-
|
162 |
-
*Thanks for using us* :)
|
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.1.3
|
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 |
|
42 |
|
43 |
* Arabic | Bulgarian | Chinese | Croatian | Czech | Danish | Dutch; Flemish | Estonian | Faroese | Finnish | French | Georgian | German | Greek | Hebrew | Hungarian | Icelandic | Indonesian | Italian | Japanese | Korean | Kurdish | Latvian | Lithuanian | Macedonian | Malay | Norwegian Bokmal | Persian | Polish | Portuguese | Romanian | Russian | Serbian | Slovak | Slovenian | Spanish; Castilian | Swedish | Thai | Turkish | Ukranian | Urdu | Vietnamese
|
44 |
|
|
|
45 |
== Changelog ==
|
46 |
+
= 1.1.3 =
|
47 |
+
* Update Zopim embed script
|
48 |
+
* Add option to override dashboard settings for chat bubble text
|
49 |
+
|
50 |
= 1.1.2 =
|
51 |
* Maintenance update: Compatibility update for Wordpress 3.3.1
|
52 |
|
56 |
= 1.1.0 =
|
57 |
* Maintenance update: Greeting messages are now saved properly.
|
58 |
* Add more language options in customization page.
|
59 |
+
* Using new Zopim async embed script: improve page's load time and do not block page's rendering anymore
|
60 |
|
61 |
= 1.0.7 =
|
62 |
* Maintenance update: Remove phased out "middle left", "middle right" positions
|
154 |
|
155 |
== Usage ==
|
156 |
|
157 |
+
After enabling the plug in, head on to the widget customization page to change settings and integrate its look and feel to match your site. When done, enable it by visiting the account configuration page and completing the instant signup process.
|
158 |
|
159 |
== Installation ==
|
160 |
|
161 |
*Server Requirements:* PHP4 or PHP5 with PHP Curl installed.
|
162 |
|
163 |
*Wordpress versions:* Wordpress 2.7 and up.
|
|
|
|
zopim.php
CHANGED
@@ -4,27 +4,27 @@
|
|
4 |
Plugin Name: Zopim Widget
|
5 |
Plugin URI: http://www.zopim.org
|
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:
|
8 |
-
Version: 1.1.
|
9 |
-
Author URI: http://www.
|
10 |
*/
|
11 |
|
12 |
-
define('ZOPIM_SCRIPT_DOMAIN',
|
13 |
-
define('ZOPIM_BASE_URL',
|
14 |
define('ZOPIM_GETACCOUNTDETAILS_URL', ZOPIM_BASE_URL."plugins/getAccountDetails");
|
15 |
-
define('ZOPIM_SETDISPLAYNAME_URL',
|
16 |
-
define('ZOPIM_IMINFO_URL',
|
17 |
-
define('ZOPIM_IMREMOVE_URL',
|
18 |
-
define('ZOPIM_LOGIN_URL',
|
19 |
-
define('ZOPIM_SIGNUP_URL',
|
20 |
-
define('ZOPIM_THEMES_LIST',
|
21 |
-
define('ZOPIM_COLORS_LIST',
|
22 |
-
define('ZOPIM_LANGUAGES_URL',
|
23 |
-
define('ZOPIM_DASHBOARD_URL',
|
24 |
-
define('ZOPIM_SMALL_LOGO',
|
25 |
-
define('ZOPIM_IM_LOGOS',
|
26 |
-
define('ZOPIM_THEMES_URL',
|
27 |
-
define('ZOPIM_COLOURS_URL',
|
28 |
|
29 |
require_once dirname( __FILE__ ) . '/accountconfig.php';
|
30 |
require_once dirname( __FILE__ ) . '/customizewidget.php';
|
@@ -32,114 +32,89 @@ require_once dirname( __FILE__ ) . '/imintegration.php';
|
|
32 |
|
33 |
// We need some CSS to position the paragraph
|
34 |
function zopimme() {
|
35 |
-
|
36 |
|
37 |
-
|
38 |
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
echo "
|
47 |
-
<!-- Start of Zopim Live Chat Script -->
|
48 |
<script type=\"text/javascript\">
|
49 |
-
window.\$zopim||(function(d,s){var z=\$zopim=function(c){z._.push(c)},$=
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
t=+new Date;z._=[];e.parentNode.insertBefore($,e)})(document,'script')
|
55 |
</script>
|
56 |
-
<!--
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
if (get_option('zopimUseGreetings') == "zopimUseGreetings") {
|
109 |
-
if (get_option('zopimGreetings') != "") {
|
110 |
-
$greetings = json_to_array(get_option('zopimGreetings'));
|
111 |
-
foreach ($greetings as $i => $v) {
|
112 |
-
foreach ($v as $j => $k) {
|
113 |
-
$greetings->$i->$j = str_replace("\r\n", "\\n", $greetings->$i->$j);
|
114 |
-
}
|
115 |
-
}
|
116 |
-
echo "\n\$zopim.livechat.setGreetings({
|
117 |
-
'online' : ['".addslashes($greetings->online->bar)."', '".addslashes($greetings->online->window)."'],
|
118 |
-
'offline': ['".addslashes($greetings->offline->bar)."', '".addslashes($greetings->offline->window)."'],
|
119 |
-
'away' : ['".addslashes($greetings->away->bar)."', '".addslashes($greetings->away->window)."'] });
|
120 |
-
";
|
121 |
-
}
|
122 |
-
}
|
123 |
-
// this need to be called last
|
124 |
-
if (get_option('zopimHideOnOffline') == "zopimHideOnOffline") {
|
125 |
-
echo "\n\$zopim.livechat.button.setHideWhenOffline(true);";
|
126 |
-
}
|
127 |
-
echo "\n})</script>";
|
128 |
}
|
129 |
|
130 |
function zopim_create_menu() {
|
|
|
|
|
131 |
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
add_submenu_page('zopim_account_config', 'IM Integration', 'IM Chat Bots', 'administrator', 'zopim_instant_messaging', 'zopim_instant_messaging');
|
138 |
-
add_submenu_page('zopim_account_config', 'Dashboard', 'Dashboard', 'administrator', 'zopim_dashboard', 'zopim_dashboard');
|
139 |
-
|
140 |
|
141 |
-
|
142 |
-
|
143 |
}
|
144 |
|
145 |
function check_zopimCode() {
|
@@ -150,76 +125,56 @@ function check_zopimCode() {
|
|
150 |
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>";' ) );
|
151 |
}
|
152 |
*/
|
153 |
-
|
154 |
}
|
155 |
|
156 |
function zopim_loader() {
|
157 |
-
|
158 |
-
add_action( 'admin_menu', 'check_zopimCode' );
|
159 |
}
|
160 |
|
161 |
add_action( 'init', 'zopim_loader' );
|
162 |
|
163 |
function zopim_about() {
|
164 |
-
|
165 |
-
echo "about";
|
166 |
}
|
167 |
|
168 |
function zopim_dashboard() {
|
169 |
-
|
170 |
-
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>.
|
171 |
';
|
172 |
}
|
173 |
|
174 |
// Register the option settings we will be using
|
175 |
function register_mysettings() {
|
176 |
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
if (get_option('zopimBubbleTitle') == "") {
|
207 |
-
update_option('zopimBubbleTitle', "Questions?");
|
208 |
-
}
|
209 |
-
if (get_option('zopimBubbleText') == "") {
|
210 |
-
update_option('zopimBubbleText', "Click here to chat with us!");
|
211 |
-
}
|
212 |
-
if (get_option('zopimBubbleEnable') == "") {
|
213 |
-
update_option('zopimBubbleEnable', "checked");
|
214 |
-
}
|
215 |
-
|
216 |
-
if (get_option('zopimUseGreetings') == "") {
|
217 |
-
update_option('zopimUseGreetings', "disabled");
|
218 |
-
}
|
219 |
-
|
220 |
-
if (get_option('zopimGreetings') == "") {
|
221 |
-
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"}}');
|
222 |
-
}
|
223 |
}
|
224 |
|
225 |
add_action('get_footer', 'zopimme');
|
@@ -228,71 +183,56 @@ add_action('admin_menu', 'zopim_create_menu');
|
|
228 |
|
229 |
function do_post_request($url, $_data, $optional_headers = null)
|
230 |
{
|
231 |
-
|
232 |
-
|
233 |
-
}
|
234 |
|
235 |
-
|
236 |
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
|
241 |
-
|
242 |
|
243 |
-
|
244 |
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
|
250 |
-
|
251 |
-
|
252 |
|
253 |
-
|
254 |
}
|
255 |
|
256 |
function json_to_array($json) {
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
$jsonparser = new Services_JSON();
|
262 |
-
|
263 |
-
return ($jsonparser->decode($json));
|
264 |
}
|
265 |
|
266 |
function to_json($variable) {
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
$jsonparser = new Services_JSON();
|
272 |
-
|
273 |
-
return ($jsonparser->encode($variable));
|
274 |
}
|
275 |
|
276 |
function getAccountDetails($salt) {
|
277 |
-
|
278 |
-
|
279 |
-
"salt" => get_option('zopimSalt')
|
280 |
-
);
|
281 |
-
|
282 |
-
return json_to_array(do_post_request(ZOPIM_GETACCOUNTDETAILS_URL, $salty));
|
283 |
}
|
284 |
|
285 |
function curl_get_url($filename) {
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
return $file_contents;
|
296 |
}
|
297 |
|
298 |
?>
|
4 |
Plugin Name: Zopim Widget
|
5 |
Plugin URI: http://www.zopim.org
|
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.1.3
|
9 |
+
Author URI: http://www.zopim.com/
|
10 |
*/
|
11 |
|
12 |
+
define('ZOPIM_SCRIPT_DOMAIN', "zopim.com");
|
13 |
+
define('ZOPIM_BASE_URL', "https://www.zopim.com/");
|
14 |
define('ZOPIM_GETACCOUNTDETAILS_URL', ZOPIM_BASE_URL."plugins/getAccountDetails");
|
15 |
+
define('ZOPIM_SETDISPLAYNAME_URL', ZOPIM_BASE_URL."plugins/setDisplayName");
|
16 |
+
define('ZOPIM_IMINFO_URL', ZOPIM_BASE_URL."plugins/getImSetupInfo");
|
17 |
+
define('ZOPIM_IMREMOVE_URL', ZOPIM_BASE_URL."plugins/removeImSetup");
|
18 |
+
define('ZOPIM_LOGIN_URL', ZOPIM_BASE_URL."plugins/login");
|
19 |
+
define('ZOPIM_SIGNUP_URL', ZOPIM_BASE_URL."plugins/createTrialAccount");
|
20 |
+
define('ZOPIM_THEMES_LIST', "http://zopim.com/assets/dashboard/themes/window/plugins-themes.txt");
|
21 |
+
define('ZOPIM_COLORS_LIST', "http://zopim.com/assets/dashboard/themes/window/plugins-colors.txt");
|
22 |
+
define('ZOPIM_LANGUAGES_URL', "http://translate.zopim.com/projects/zopim/");
|
23 |
+
define('ZOPIM_DASHBOARD_URL', "http://dashboard.zopim.com/");
|
24 |
+
define('ZOPIM_SMALL_LOGO', "http://zopim.com/assets/branding/zopim.com/chatman/online.png");
|
25 |
+
define('ZOPIM_IM_LOGOS', "http://www.zopim.com/static/images/im/");
|
26 |
+
define('ZOPIM_THEMES_URL', "http://");
|
27 |
+
define('ZOPIM_COLOURS_URL', "http://");
|
28 |
|
29 |
require_once dirname( __FILE__ ) . '/accountconfig.php';
|
30 |
require_once dirname( __FILE__ ) . '/customizewidget.php';
|
32 |
|
33 |
// We need some CSS to position the paragraph
|
34 |
function zopimme() {
|
35 |
+
global $current_user, $zopimshown;
|
36 |
|
37 |
+
$code = get_option('zopimCode');
|
38 |
|
39 |
+
if (($code == "" || $code=="zopim") && (!ereg("zopim", $_GET["page"]))&& (!ereg("zopim", $_SERVER["SERVER_NAME"]))) { return; }
|
40 |
|
41 |
+
// dont show this more than once
|
42 |
+
if (isset($zopimshown) && $zopimshown == 1) { return; }
|
43 |
+
$zopimshown = 1;
|
44 |
|
45 |
+
echo "<!--Start of Zopim Live Chat Script-->
|
|
|
|
|
46 |
<script type=\"text/javascript\">
|
47 |
+
window.\$zopim||(function(d,s){var z=\$zopim=function(c){z._.push(c)},$=z.s=
|
48 |
+
d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
|
49 |
+
_.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');
|
50 |
+
$.src='//cdn.zopim.com/?".$code."';z.t=+new Date;$.
|
51 |
+
type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
|
|
|
52 |
</script>
|
53 |
+
<!--End of Zopim Live Chat Script-->";
|
54 |
+
|
55 |
+
$theoptions = array();
|
56 |
+
if (get_option('zopimLang') != "" && get_option('zopimLang') != "--")
|
57 |
+
$theoptions[] = " language: '".get_option('zopimLang')."'";
|
58 |
+
|
59 |
+
if (isset($current_user) && get_option("zopimGetVisitorInfo") == "checked") {
|
60 |
+
$ul = $current_user->data->first_name;
|
61 |
+
$useremail = $current_user->data->user_email;
|
62 |
+
if ($ul!="" && $useremail != "")
|
63 |
+
$theoptions[] = "name: '$ul', email: '$useremail'";
|
64 |
+
}
|
65 |
+
|
66 |
+
echo "\n<script type=\"text/javascript\">\n\$zopim( function() {";
|
67 |
+
|
68 |
+
if (count($theoptions) > 0)
|
69 |
+
echo '$zopim.livechat.set({'.implode(", ", $theoptions)."});";
|
70 |
+
|
71 |
+
get_option('zopimPosition') != "" && print("\n\$zopim.livechat.button.setPosition('".get_option('zopimPosition')."');");
|
72 |
+
get_option('zopimTheme') != "" && print("\n\$zopim.livechat.window.setTheme('".get_option('zopimTheme')."');");
|
73 |
+
get_option('zopimColor') != "" && print("\n\$zopim.livechat.window.setColor('".get_option('zopimColor')."');");
|
74 |
+
|
75 |
+
if (get_option('zopimUseGreetings') == "zopimUseGreetings") {
|
76 |
+
if (get_option('zopimGreetings') != "") {
|
77 |
+
$greetings = json_to_array(get_option('zopimGreetings'));
|
78 |
+
foreach ($greetings as $i => $v) {
|
79 |
+
foreach ($v as $j => $k) {
|
80 |
+
$greetings->$i->$j = str_replace("\r\n", "\\n", $greetings->$i->$j);
|
81 |
+
}
|
82 |
+
}
|
83 |
+
echo "\n\$zopim.livechat.setGreetings({
|
84 |
+
'online' : ['".addslashes($greetings->online->bar)."', '".addslashes($greetings->online->window)."'],
|
85 |
+
'offline': ['".addslashes($greetings->offline->bar)."', '".addslashes($greetings->offline->window)."'],
|
86 |
+
'away' : ['".addslashes($greetings->away->bar)."', '".addslashes($greetings->away->window)."'] });";
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
if (get_option('zopimUseBubble') == "zopimUseBubble") {
|
91 |
+
get_option('zopimBubbleTitle') != "" && print("\n\$zopim.livechat.bubble.setTitle('".addslashes(get_option('zopimBubbleTitle'))."');");
|
92 |
+
get_option('zopimBubbleText') != "" && print("\n\$zopim.livechat.bubble.setText('".addslashes(get_option('zopimBubbleText'))."');");
|
93 |
+
}
|
94 |
+
|
95 |
+
if (get_option('zopimBubbleEnable') == "show")
|
96 |
+
echo "\n\$zopim.livechat.bubble.show(true);";
|
97 |
+
else if (get_option('zopimBubbleEnable') == "hide")
|
98 |
+
echo "\n\$zopim.livechat.bubble.hide(true);";
|
99 |
+
|
100 |
+
// this must be called last
|
101 |
+
if (get_option('zopimHideOnOffline') == "zopimHideOnOffline")
|
102 |
+
echo "\n\$zopim.livechat.button.setHideWhenOffline(true);";
|
103 |
+
echo "\n})</script>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
}
|
105 |
|
106 |
function zopim_create_menu() {
|
107 |
+
//create new top-level menu
|
108 |
+
add_menu_page('Account Configuration', 'Zopim Chat', 'administrator', 'zopim_account_config', 'zopim_account_config', ZOPIM_SMALL_LOGO);
|
109 |
|
110 |
+
// add_submenu_page('zopim_about', "About", "About", "administrator", 'zopim_about', 'zopim_about');
|
111 |
+
add_submenu_page('zopim_account_config', 'Account Configuration', 'Account Setup', 'administrator', 'zopim_account_config', 'zopim_account_config');
|
112 |
+
add_submenu_page('zopim_account_config', 'Customize Widget', 'Customize', 'administrator', 'zopim_customize_widget', 'zopim_customize_widget');
|
113 |
+
add_submenu_page('zopim_account_config', 'IM Integration', 'IM Chat Bots', 'administrator', 'zopim_instant_messaging', 'zopim_instant_messaging');
|
114 |
+
add_submenu_page('zopim_account_config', 'Dashboard', 'Dashboard', 'administrator', 'zopim_dashboard', 'zopim_dashboard');
|
|
|
|
|
|
|
115 |
|
116 |
+
//call register settings function
|
117 |
+
add_action( 'admin_init', 'register_mysettings' );
|
118 |
}
|
119 |
|
120 |
function check_zopimCode() {
|
125 |
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>";' ) );
|
126 |
}
|
127 |
*/
|
128 |
+
return false;
|
129 |
}
|
130 |
|
131 |
function zopim_loader() {
|
132 |
+
add_action( 'admin_menu', 'check_zopimCode' );
|
|
|
133 |
}
|
134 |
|
135 |
add_action( 'init', 'zopim_loader' );
|
136 |
|
137 |
function zopim_about() {
|
138 |
+
echo "about";
|
|
|
139 |
}
|
140 |
|
141 |
function zopim_dashboard() {
|
142 |
+
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>.
|
|
|
143 |
';
|
144 |
}
|
145 |
|
146 |
// Register the option settings we will be using
|
147 |
function register_mysettings() {
|
148 |
|
149 |
+
// Authentication and codes
|
150 |
+
register_setting( 'zopim-settings-group', 'zopimCode' );
|
151 |
+
register_setting( 'zopim-settings-group', 'zopimUsername' );
|
152 |
+
register_setting( 'zopim-settings-group', 'zopimSalt' );
|
153 |
+
register_setting( 'zopim-settings-group', 'zopimUseSSL' );
|
154 |
+
// General Widget settings
|
155 |
+
register_setting( 'zopim-settings-group', 'zopimGetVisitorInfo' );
|
156 |
+
register_setting( 'zopim-settings-group', 'zopimLang' );
|
157 |
+
// Chat button settings
|
158 |
+
register_setting( 'zopim-settings-group', 'zopimPosition' );
|
159 |
+
register_setting( 'zopim-settings-group', 'zopimHideOnOffline' );
|
160 |
+
register_setting( 'zopim-settings-group', 'zopimBubbleTitle' );
|
161 |
+
register_setting( 'zopim-settings-group', 'zopimBubbleText' );
|
162 |
+
register_setting( 'zopim-settings-group', 'zopimBubbleEnable' );
|
163 |
+
register_setting( 'zopim-settings-group', 'zopimUseBubble' );
|
164 |
+
// Themes / Color
|
165 |
+
register_setting( 'zopim-settings-group', 'zopimColor' );
|
166 |
+
register_setting( 'zopim-settings-group', 'zopimTheme' );
|
167 |
+
// Message Settings
|
168 |
+
register_setting( 'zopim-settings-group', 'zopimGreetings' );
|
169 |
+
register_setting( 'zopim-settings-group', 'zopimUseGreetings' );
|
170 |
+
|
171 |
+
get_option('zopimCode') == "" && update_option('zopimCode', "zopim");
|
172 |
+
get_option('zopimBubbleTitle') == "" && update_option('zopimBubbleTitle', "Questions?");
|
173 |
+
get_option('zopimBubbleText') == "" && update_option('zopimBubbleText', "Click here to chat with us!");
|
174 |
+
get_option('zopimBubbleEnable') == "" && update_option('zopimBubbleEnable', "checked");
|
175 |
+
get_option('zopimUseGreetings') == "" && update_option('zopimUseGreetings', "disabled");
|
176 |
+
get_option('zopimUseBubble') == "" && update_option('zopimUseBubble', "disabled");
|
177 |
+
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"}}');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
179 |
|
180 |
add_action('get_footer', 'zopimme');
|
183 |
|
184 |
function do_post_request($url, $_data, $optional_headers = null)
|
185 |
{
|
186 |
+
if (get_option('zopimUseSSL') != "zopimUseSSL")
|
187 |
+
$url = str_replace("https", "http", $url);
|
|
|
188 |
|
189 |
+
$data = array();
|
190 |
|
191 |
+
while(list($n,$v) = each($_data)){
|
192 |
+
$data[] = urlencode($n)."=".urlencode($v);
|
193 |
+
}
|
194 |
|
195 |
+
$data = implode('&', $data);
|
196 |
|
197 |
+
$ch = curl_init();
|
198 |
|
199 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
200 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
201 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
202 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
203 |
|
204 |
+
$response = curl_exec($ch);
|
205 |
+
curl_close($ch);
|
206 |
|
207 |
+
return $response;
|
208 |
}
|
209 |
|
210 |
function json_to_array($json) {
|
211 |
+
require_once('JSON.php');
|
212 |
+
$jsonparser = new Services_JSON();
|
213 |
+
return ($jsonparser->decode($json));
|
|
|
|
|
|
|
|
|
214 |
}
|
215 |
|
216 |
function to_json($variable) {
|
217 |
+
require_once('JSON.php');
|
218 |
+
$jsonparser = new Services_JSON();
|
219 |
+
return ($jsonparser->encode($variable));
|
|
|
|
|
|
|
|
|
220 |
}
|
221 |
|
222 |
function getAccountDetails($salt) {
|
223 |
+
$salty = array("salt" => get_option('zopimSalt'));
|
224 |
+
return json_to_array(do_post_request(ZOPIM_GETACCOUNTDETAILS_URL, $salty));
|
|
|
|
|
|
|
|
|
225 |
}
|
226 |
|
227 |
function curl_get_url($filename) {
|
228 |
+
$ch = curl_init();
|
229 |
+
$timeout = 5; // set to zero for no timeout
|
230 |
+
curl_setopt ($ch, CURLOPT_URL, $filename);
|
231 |
+
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
|
232 |
+
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
|
233 |
+
$file_contents = curl_exec($ch);
|
234 |
+
curl_close($ch);
|
235 |
+
return $file_contents;
|
|
|
|
|
236 |
}
|
237 |
|
238 |
?>
|