Zendesk Chat - Version 1.1.3

Version Description

  • Update Zopim embed script
  • Add option to override dashboard settings for chat bubble text
Download this release

Release Info

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

Code changes from version 1.1.2 to 1.1.3

Files changed (3) hide show
  1. customizewidget.php +205 -246
  2. readme.txt +7 -6
  3. zopim.php +154 -214
customizewidget.php CHANGED
@@ -3,48 +3,45 @@
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
-
11
- $message = "";
12
-
13
-
14
- if (count($_POST) > 0) {
15
- update_option('zopimLang', $_POST["zopimLang"]);
16
- update_option('zopimPosition', $_POST["zopimPosition"]);
17
- update_option("zopimBubbleEnable", $_POST["zopimBubbleEnable"] );
18
- update_option('zopimColor', $_POST["zopimColor"]);
19
- update_option('zopimTheme', $_POST["zopimTheme"]);
20
- update_option('zopimBubbleTitle', stripslashes($_POST["zopimBubbleTitle"]));
21
- update_option('zopimBubbleText', stripslashes($_POST["zopimBubbleText"]));
22
-
23
- update_checkbox("zopimGetVisitorInfo");
24
- update_checkbox("zopimHideOnOffline");
25
- update_checkbox("zopimUseGreetings");
26
-
27
- if ( isset($_POST['zopimUseGreetings']) && $_POST['zopimUseGreetings'] != "") {
28
- $greetings->online->window = stripslashes($_POST["zopimOnlineLong"]);
29
- $greetings->online->bar = stripslashes($_POST["zopimOnlineShort"]);
30
- $greetings->away->window = stripslashes($_POST["zopimAwayLong"]);
31
- $greetings->away->bar = stripslashes($_POST["zopimAwayShort"]);
32
- $greetings->offline->window = stripslashes($_POST["zopimOfflineLong"]);
33
- $greetings->offline->bar = stripslashes($_POST["zopimOfflineShort"]);
34
-
35
- update_option('zopimGreetings', to_json($greetings));
36
- }
37
-
38
- $message = "<b>Changes saved!</b><br>";
39
- }
40
-
41
- zopimme();
42
-
43
-
44
- $accountDetails = getAccountDetails(get_option('zopimSalt'));
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
- $accountDetails->widget_customization_enabled = 1;
57
- $accountDetails->color_customization_enabled = 1;
58
- } else if (isset($accountDetails->error)) {
59
- $message = '
60
- <div class="metabox-holder">
61
- <div class="postbox">
62
- <h3 class="hndle"><span>Account no longer linked!</span></h3>
63
- <div style="padding:10px;line-height:17px;">
64
- 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.
65
- </div>
66
- </div>
67
- </div>';
68
- } else {
69
- $message .= "Click 'Save Changes' when you're done. Happy customizing!";
70
- }
71
-
72
- // unset($accountDetails->widget_customization_enabled);
73
- // unset($accountDetails->color_customization_enabled);
74
  ?>
75
 
76
- <script type="text/javascript">
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
- function updatePosition() {
 
 
111
 
112
- var position = document.getElementById('zopimPosition').options[ document.getElementById('zopimPosition').options.selectedIndex ].value;
113
- $zopim.livechat.button.setPosition(position);
114
- }
 
 
 
 
 
115
 
116
- function updateBubbleStatus() {
117
- var value = document.getElementById("zopimBubbleEnable").value;
118
- switch (value) {
119
- case 'default':
120
- $zopim.livechat.bubble.reset();
121
- break;
122
- case 'show':
123
- $zopim.livechat.bubble.show();
124
- break;
125
- case 'hide':
126
- $zopim.livechat.bubble.hide();
127
- break;
128
- }
129
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
  function greetingsChanged() {
132
- var inputs = ['zopimOnlineShort', 'zopimAwayShort', 'zopimOfflineShort',
133
- 'zopimOnlineLong' , 'zopimAwayLong', 'zopimOfflineLong'];
134
  var isDisabled = false;
135
 
136
- if (document.getElementById('zopimUseGreetings').checked)
137
- isDisabled = false;
138
- else
139
- isDisabled = true;
140
 
141
  for (var i=0; i<inputs.length; i++) {
142
- var el = document.getElementById(inputs[i]);
143
- el.disabled = isDisabled;
144
  }
145
 
146
  updateWidget();
147
  }
148
 
149
- var timer;
150
- function updateSoon() {
 
151
 
152
- clearTimeout(timer);
153
- timer = setTimeout("updateWidget()", 300);
154
- }
155
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
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
- <tr valign="top">
206
  <th scope="row" class="sethead">Language</th>
207
  <td>
208
-
209
- <select name="zopimLang" id="zopimLang" onchange="updateWidget()">
210
  <?php
211
-
212
- $languages = get_languages();
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'"; } ?> /> This prevents visitors from sending you offline messages -
241
- <a href="#" onclick="$zopim.livechat.button.show();return false">force show chat button</a>
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
- Settings reflect instantly on your preview widget. Try it out!<br/>
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
- if ($accountDetails->widget_customization_enabled == 1) {
284
- echo '<select name="zopimTheme" id="zopimTheme" onchange="updateWidget()">';
285
- $themes = curl_get_url(ZOPIM_THEMES_LIST);
286
- $themes = valuekeys(explode("\n", $themes));
287
- ksort($themes);
288
-
289
- echo generate_options($themes, get_option('zopimTheme'));
290
- echo "</select> <a href='#' onclick='\$zopim.livechat.window.toggle();return false;'>View the Chat Panel</a> for changes";
291
- } else {
292
- echo "<div class='sorry'>Sorry, your plan does not allow for theme customization. Please upgrade to enjoy choice of themes!</div>";
293
- echo '<input type=hidden value="" name="zopimTheme" id="zopimTheme">';
 
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
- <tr valign="top">
310
- <th scope="row">Display Help Bubble<br>
311
- </th>
312
- <td>
313
- <select onchange="updateBubbleStatus()" type="checkbox" id="zopimBubbleEnable" name="zopimBubbleEnable">
314
- <?php
315
- $bubble_modes = array("default" => "Let user decide", "show" => "Always show", "hide" => "Always hide");
316
- echo generate_options($bubble_modes, get_option('zopimBubbleEnable'));
317
- ?>
318
- </select>
319
- </tr>
320
- <tr valign="top">
321
- <th scope="row" class="sethead">Help Bubble Title
322
- <!--<div class="smallExplanation">Entice your visitors with this friendly chat bubble title!</div>--></th>
323
- <td>
324
-
325
- <input class="inputtextshort" name="zopimBubbleTitle" id="zopimBubbleTitle" onKeyup="updateSoon()" value="<?php echo get_option('zopimBubbleTitle'); ?>"> <a href="#" onclick="updateBubbleStatus();">Refresh</a>
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
- if (get_option('zopimUseGreetings') && get_option('zopimUseGreetings')!="disabled") {
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><td colspan="2"><div class="secthead">Message Shown on Chat Bar (max 26 characters)</div></td></tr>
364
- <tr valign="top">
365
- <th scope="row" class="sethead">Online</th>
366
- <td>
367
- <input class="inputtextshort" name="zopimOnlineShort" id="zopimOnlineShort" onKeyup="updateSoon()"
368
- value="<?php echo $greetings->online->bar; ?>"
369
- <?php if (!$useGreetings) echo "disabled='disabled'"?>
370
- maxlength="26">
371
- </td>
372
- </tr>
373
-
374
- <tr valign="top">
375
  <th scope="row" class="sethead">Away</th>
376
- <td>
377
- <input class="inputtextshort" name="zopimAwayShort" id="zopimAwayShort" onKeyup="updateSoon()" value="<?php echo $greetings->away->bar; ?>" <?php if (!$useGreetings) echo "disabled='disabled'"?> maxlength="26">
378
- </td>
379
- </tr>
380
-
381
- <tr valign="top">
382
  <th scope="row" class="sethead">Offline</th>
383
- <td>
384
- <input class="inputtextshort" name="zopimOfflineShort" id="zopimOfflineShort" onKeyup="updateSoon()" value="<?php echo $greetings->offline->bar; ?>" <?php if (!$useGreetings) echo "disabled='disabled'"?> maxlength="26">
385
- </td>
386
- </tr>
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
- <textarea class="inputtext" name="zopimOnlineLong" id="zopimOnlineLong" onKeyup="updateSoon()" <?php if (!$useGreetings) echo "disabled='disabled'"?> ><?php echo $greetings->online->window; ?></textarea>
394
- </td>
395
- </tr>
396
-
397
- <tr valign="top">
398
  <th scope="row" class="sethead">Away</th>
399
- <td>
400
- <textarea class="inputtext" name="zopimAwayLong" id="zopimAwayLong" onKeyup="updateSoon()" <?php if (!$useGreetings) echo "disabled='disabled'"?> ><?php echo $greetings->away->window; ?></textarea>
401
- </td>
402
- </tr>
403
-
404
- <tr valign="top">
405
  <th scope="row" class="sethead">Offline</th>
406
- <td>
407
- <textarea class="inputtext" name="zopimOfflineLong" id="zopimOfflineLong" onKeyup="updateSoon()" <?php if (!$useGreetings) echo "disabled='disabled'"?> ><?php echo $greetings->offline->window; ?></textarea>
408
- </td>
409
- </tr>
410
  </table>
411
-
412
  </div>
413
  </div>
414
  </div>
415
 
416
-
417
-
418
- <p class="submit">
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
- } else {
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.2
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 it's look and feel with your site. When done, enable it by visiting the account configuration page and completing the instant signup process.
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: Isidore
8
- Version: 1.1.1
9
- Author URI: http://www.isidorechan.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,114 +32,89 @@ require_once dirname( __FILE__ ) . '/imintegration.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
- // Use zopim's code...
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
- z.s=d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o
51
- ){z.set._.push(o)};$.setAttribute('charset','utf-8');$.async=!0;z.set.
52
- _=[];$.src=('https:'==d.location.protocol?'https://ssl':'http://cdn')+
53
- '.zopim.com/?".$code."';$.type='text/java'+s;z.
54
- t=+new Date;z._=[];e.parentNode.insertBefore($,e)})(document,'script')
55
  </script>
56
- <!-- End of Zopim Live Chat Script -->
57
- ";
58
-
59
- $theoptions = array();
60
- if (get_option('zopimLang') != "" && get_option('zopimLang') != "--") {
61
- $theoptions[] = " language: '".get_option('zopimLang')."'";
62
- }
63
-
64
-
65
- if ( isset($current_user) && get_option("zopimGetVisitorInfo") == "checked" )
66
- {
67
- $ul = $current_user->data->first_name;
68
- $useremail = $current_user->data->user_email;
69
-
70
- if ($ul!="" && $useremail != "") {
71
- $theoptions[] = "
72
- name: '$ul',
73
- email: '$useremail'
74
- ";
75
- }
76
- }
77
-
78
- echo "
79
- \n<script type=\"text/javascript\">
80
- \n\$zopim( function() {
81
- ";
82
- if (count($theoptions) > 0) {
83
- echo '$zopim.livechat.set({';
84
- echo implode(", ", $theoptions);
85
- echo "});";
86
- }
87
- if (get_option('zopimPosition') != "") {
88
- echo "\n\$zopim.livechat.button.setPosition('".get_option('zopimPosition')."');";
89
- }
90
- if (get_option('zopimTheme') != "") {
91
- echo "\n\$zopim.livechat.window.setTheme('".get_option('zopimTheme')."');";
92
- }
93
- if (get_option('zopimColor') != "") {
94
- echo "\n\$zopim.livechat.window.setColor('".get_option('zopimColor')."');";
95
- }
96
- if (get_option('zopimBubbleTitle') != "") {
97
- echo "\n\$zopim.livechat.bubble.setTitle('".addslashes(get_option('zopimBubbleTitle'))."');";
98
- }
99
- if (get_option('zopimBubbleText') != "") {
100
- echo "\n\$zopim.livechat.bubble.setText('".addslashes(get_option('zopimBubbleText'))."');";
101
- }
102
- if (get_option('zopimBubbleEnable') == "show") {
103
- echo "\n\$zopim.livechat.bubble.show(true);";
104
- } elseif (get_option('zopimBubbleEnable') == "hide") {
105
- echo "\n\$zopim.livechat.bubble.hide(true);";
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
- //create new top-level menu
133
- add_menu_page('Account Configuration', 'Zopim Chat', 'administrator', 'zopim_account_config', 'zopim_account_config', ZOPIM_SMALL_LOGO);
134
- // add_submenu_page('zopim_about', "About", "About", "administrator", 'zopim_about', 'zopim_about');
135
- add_submenu_page('zopim_account_config', 'Account Configuration', 'Account Setup', 'administrator', 'zopim_account_config', 'zopim_account_config');
136
- add_submenu_page('zopim_account_config', 'Customize Widget', 'Customize', 'administrator', 'zopim_customize_widget', 'zopim_customize_widget');
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
- //call register settings function
142
- add_action( 'admin_init', 'register_mysettings' );
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
- return false;
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
- // Authentication and codes
178
- register_setting( 'zopim-settings-group', 'zopimCode' );
179
- register_setting( 'zopim-settings-group', 'zopimUsername' );
180
- register_setting( 'zopim-settings-group', 'zopimSalt' );
181
- register_setting( 'zopim-settings-group', 'zopimUseSSL' );
182
-
183
- // General Widget settings
184
- register_setting( 'zopim-settings-group', 'zopimGetVisitorInfo' );
185
- register_setting( 'zopim-settings-group', 'zopimLang' );
186
-
187
- // Chat button settings
188
- register_setting( 'zopim-settings-group', 'zopimPosition' );
189
- register_setting( 'zopim-settings-group', 'zopimHideOnOffline' );
190
- register_setting( 'zopim-settings-group', 'zopimBubbleTitle' );
191
- register_setting( 'zopim-settings-group', 'zopimBubbleText' );
192
- register_setting( 'zopim-settings-group', 'zopimBubbleEnable' );
193
-
194
- // Themes / Color
195
- register_setting( 'zopim-settings-group', 'zopimColor' );
196
- register_setting( 'zopim-settings-group', 'zopimTheme' );
197
-
198
- // Message Settings
199
- register_setting( 'zopim-settings-group', 'zopimGreetings' );
200
- register_setting( 'zopim-settings-group', 'zopimUseGreetings' );
201
-
202
- if (get_option('zopimCode') == "") {
203
- update_option('zopimCode', "zopim");
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
- if (get_option('zopimUseSSL') != "zopimUseSSL") {
232
- $url = str_replace("https", "http", $url);
233
- }
234
 
235
- $data = array();
236
 
237
- while(list($n,$v) = each($_data)){
238
- $data[] = urlencode($n)."=".urlencode($v);
239
- }
240
 
241
- $data = implode('&', $data);
242
 
243
- $ch = curl_init();
244
 
245
- curl_setopt($ch, CURLOPT_URL, $url);
246
- curl_setopt($ch, CURLOPT_POST, true);
247
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
248
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
249
 
250
- $response = curl_exec($ch);
251
- curl_close($ch);
252
 
253
- return $response;
254
  }
255
 
256
  function json_to_array($json) {
257
-
258
- // json_decode does exist but only in php > 5.2.0
259
- require_once('JSON.php');
260
-
261
- $jsonparser = new Services_JSON();
262
-
263
- return ($jsonparser->decode($json));
264
  }
265
 
266
  function to_json($variable) {
267
-
268
- // json_decode does exist but only in php > 5.2.0
269
- require_once('JSON.php');
270
-
271
- $jsonparser = new Services_JSON();
272
-
273
- return ($jsonparser->encode($variable));
274
  }
275
 
276
  function getAccountDetails($salt) {
277
-
278
- $salty = array(
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
- $ch = curl_init();
288
- $timeout = 5; // set to zero for no timeout
289
- curl_setopt ($ch, CURLOPT_URL, $filename);
290
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
291
- curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
292
- $file_contents = curl_exec($ch);
293
- curl_close($ch);
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
  ?>