Zendesk Chat - Version 1.2.5

Version Description

  • Enhancement to Theme Editor - now autoloads blog's url automatically
Download this release

Release Info

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

Code changes from version 1.2.2 to 1.2.5

Files changed (4) hide show
  1. accountconfig.php +36 -17
  2. customizewidget.php +0 -426
  3. readme.txt +18 -5
  4. zopim.php +114 -57
accountconfig.php CHANGED
@@ -115,8 +115,27 @@ function zopim_account_config() {
115
  <span style="float:right;"><a href="admin.php?page=zopim_account_config&action=deactivate">Deactivate</a></span>
116
  Currently Activated Account &rarr; <b><?php echo get_option('zopimUsername'); ?></b> <div style="display:inline-block;background:#444;color:#fff;font-size:10px;text-transform:uppercase;padding:3px 8px;-moz-border-radius:5px;-webkit-border-radius:5px;"><?php echo ucwords($accountDetails->package_id); ?></div>
117
  <br><p><br>You can <a href="admin.php?page=zopim_customize_widget">customize</a> the chat widget, <a href="admin.php?page=zopim_instant_messaging">relay messages</a> to your favourite IM client, or <a href="admin.php?page=zopim_dashboard">launch the dashboard</a> for advanced features.
118
- </div>
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  <?php } else { ?>
121
  <div id="icon-options-general" class="icon32"><br/></div><h2>Set up your Zopim Account</h2>
122
  <?php if ($error && $error["auth"]) {
@@ -136,28 +155,28 @@ Congratulations on successfully installing the Zopim WordPress plugin! Activate
136
  <input type="hidden" name="action" value="login">
137
  <table class="form-table">
138
 
139
- <tr valign="top">
140
- <th scope="row">Zopim Username (E-mail)</th>
141
- <td><input type="text" name="zopimUsername" value="<?php echo get_option('zopimUsername'); ?>" /></td>
142
- </tr>
143
 
144
- <tr valign="top">
145
- <th scope="row">Zopim Password</th>
146
- <td><input type="password" name="zopimPassword" value="<?php if (get_option('zopimSalt') != "") { echo "password"; }; ?>" /></td>
147
- </tr>
148
 
149
- <tr valign="center">
150
- <th scope="row">Use SSL</th>
151
- <td><input type="checkbox" name="zopimUseSSL" value="zopimUseSSL" <?php if (get_option('zopimUseSSL') == "zopimUseSSL") { echo "checked='checked'"; } ?> /> uncheck this if you are unable to login</td>
152
- </tr>
153
  </table>
154
  <br/>
155
  The Zopim chat bar will displayed on your blog once your account is linked up.
156
  <br/>
157
- <p class="submit">
158
- <input type="submit" class="button-primary" value="<?php _e('Link Up') ?>" />
159
- Don't have a zopim account? <a href="<?php echo ZOPIM_SIGNUP_REDIRECT_URL; ?>" target="_blank" data-popup="true">Sign up now</a>.
160
- </p>
161
 
162
  </form>
163
 
115
  <span style="float:right;"><a href="admin.php?page=zopim_account_config&action=deactivate">Deactivate</a></span>
116
  Currently Activated Account &rarr; <b><?php echo get_option('zopimUsername'); ?></b> <div style="display:inline-block;background:#444;color:#fff;font-size:10px;text-transform:uppercase;padding:3px 8px;-moz-border-radius:5px;-webkit-border-radius:5px;"><?php echo ucwords($accountDetails->package_id); ?></div>
117
  <br><p><br>You can <a href="admin.php?page=zopim_customize_widget">customize</a> the chat widget, <a href="admin.php?page=zopim_instant_messaging">relay messages</a> to your favourite IM client, or <a href="admin.php?page=zopim_dashboard">launch the dashboard</a> for advanced features.
 
118
 
119
+
120
+ <form method="post" action="admin.php?page=zopim_account_config">
121
+ <?php
122
+ if (isset($_POST['widget-options'])) {
123
+ $opts = $_POST['widget-options'];
124
+ update_option('zopimWidgetOptions', $opts);
125
+ echo '<i>Widget options updated.<br/></i>';
126
+ }
127
+
128
+ ?>
129
+ <p>
130
+ Optional code for customization with Zopim API:
131
+ <br/>
132
+ <textarea name="widget-options" style="width:680px; height: 200px;"><?php echo esc_textarea(zopim_get_widget_options()); ?></textarea>
133
+ <br/>
134
+ <input type="submit" value="Update widget options" />
135
+ </p>
136
+ </form>
137
+
138
+ </div>
139
  <?php } else { ?>
140
  <div id="icon-options-general" class="icon32"><br/></div><h2>Set up your Zopim Account</h2>
141
  <?php if ($error && $error["auth"]) {
155
  <input type="hidden" name="action" value="login">
156
  <table class="form-table">
157
 
158
+ <tr valign="top">
159
+ <th scope="row">Zopim Username (E-mail)</th>
160
+ <td><input type="text" name="zopimUsername" value="<?php echo get_option('zopimUsername'); ?>" /></td>
161
+ </tr>
162
 
163
+ <tr valign="top">
164
+ <th scope="row">Zopim Password</th>
165
+ <td><input type="password" name="zopimPassword" value="<?php if (get_option('zopimSalt') != "") { echo "password"; }; ?>" /></td>
166
+ </tr>
167
 
168
+ <tr valign="center">
169
+ <th scope="row">Use SSL</th>
170
+ <td><input type="checkbox" name="zopimUseSSL" value="zopimUseSSL" <?php if (get_option('zopimUseSSL') == "zopimUseSSL") { echo "checked='checked'"; } ?> /> uncheck this if you are unable to login</td>
171
+ </tr>
172
  </table>
173
  <br/>
174
  The Zopim chat bar will displayed on your blog once your account is linked up.
175
  <br/>
176
+ <p class="submit">
177
+ <input type="submit" class="button-primary" value="<?php _e('Link Up') ?>" />
178
+ Don't have a zopim account? <a href="<?php echo ZOPIM_SIGNUP_REDIRECT_URL; ?>" target="_blank" data-popup="true">Sign up now</a>.
179
+ </p>
180
 
181
  </form>
182
 
customizewidget.php DELETED
@@ -1,426 +0,0 @@
1
- <?php
2
-
3
- // Zopim Customize Widget Page
4
- function zopim_customize_widget() {
5
- global $current_user;
6
- $ul = $current_user->data->first_name;
7
- $useremail = $current_user->data->user_email;
8
- $greetings = json_to_array(get_option('zopimGreetings'));
9
- $message = "";
10
-
11
- if (count($_POST) > 0) {
12
- update_option('zopimLang', $_POST["zopimLang"]);
13
- update_option('zopimPosition', $_POST["zopimPosition"]);
14
- update_option("zopimBubbleEnable", $_POST["zopimBubbleEnable"] );
15
- update_option('zopimColor', $_POST["zopimColor"]);
16
- update_option('zopimTheme', $_POST["zopimTheme"]);
17
- update_option('zopimBubbleTitle', stripslashes($_POST["zopimBubbleTitle"]));
18
- update_option('zopimBubbleText', stripslashes($_POST["zopimBubbleText"]));
19
-
20
- update_checkbox("zopimGetVisitorInfo");
21
- update_checkbox("zopimHideOnOffline");
22
- update_checkbox("zopimUseGreetings");
23
- update_checkbox("zopimUseBubble");
24
-
25
- if (isset($_POST['zopimUseGreetings']) && $_POST['zopimUseGreetings'] != "") {
26
- $greetings->online->window = stripslashes($_POST["zopimOnlineLong"]);
27
- $greetings->online->bar = stripslashes($_POST["zopimOnlineShort"]);
28
- $greetings->away->window = stripslashes($_POST["zopimAwayLong"]);
29
- $greetings->away->bar = stripslashes($_POST["zopimAwayShort"]);
30
- $greetings->offline->window = stripslashes($_POST["zopimOfflineLong"]);
31
- $greetings->offline->bar = stripslashes($_POST["zopimOfflineShort"]);
32
-
33
- update_option('zopimGreetings', to_json($greetings));
34
- }
35
-
36
- $message = "<b>Changes saved!</b><br>";
37
- }
38
-
39
- zopimme();
40
-
41
- $accountDetails = getAccountDetails(get_option('zopimSalt'));
42
-
43
- if (get_option('zopimCode')=="zopim") {
44
- $message = '<div class="metabox-holder">
45
- <div class="postbox">
46
- <h3 class="hndle"><span>Customizing in Demo Mode</span></h3>
47
- <div style="padding:10px;line-height:17px;">
48
- Currently customizing in demo mode. Messages in this widget will go to Zopim staff. The chat widget will not appear on your site until you <a href="admin.php?page=zopim_account_config">activate / link up an account</a>. <br>
49
- </div>
50
- </div>
51
- </div>';
52
- $accountDetails->widget_customization_enabled = 1;
53
- $accountDetails->color_customization_enabled = 1;
54
- }
55
- else if (isset($accountDetails->error)) {
56
- $message = '<div class="metabox-holder">
57
- <div class="postbox">
58
- <h3 class="hndle"><span>Account no longer linked!</span></h3>
59
- <div style="padding:10px;line-height:17px;">
60
- 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.
61
- </div>
62
- </div>
63
- </div>';
64
- }
65
- else {
66
- $message .= "Click 'Save Changes' when you're done. Happy customizing!";
67
- }
68
- // unset($accountDetails->widget_customization_enabled);
69
- // unset($accountDetails->color_customization_enabled);
70
- ?>
71
-
72
- <script type="text/javascript">
73
-
74
- function updateWidget() {
75
- var lang = document.getElementById('zopimLang').options[ document.getElementById('zopimLang').options.selectedIndex ].value;
76
- $zopim.livechat.setLanguage(lang);
77
-
78
- if (document.getElementById("zopimGetVisitorInfo").checked) {
79
- $zopim.livechat.setName('<?php echo $ul; ?>');
80
- $zopim.livechat.setEmail('<?php echo $useremail; ?>');
81
- }
82
- else {
83
- $zopim.livechat.setName('Visitor');
84
- $zopim.livechat.setEmail('');
85
- }
86
-
87
- document.getElementById("zopimHideOnOffline").checked? $zopim.livechat.button.setHideWhenOffline(true): $zopim.livechat.button.setHideWhenOffline(false);
88
-
89
- $zopim.livechat.window.setColor(document.getElementById("zopimColor").value);
90
- $zopim.livechat.window.setTheme(document.getElementById("zopimTheme").value);
91
-
92
- if (document.getElementById("zopimUseBubble").checked) {
93
- $zopim.livechat.bubble.setTitle(document.getElementById("zopimBubbleTitle").value);
94
- $zopim.livechat.bubble.setText(document.getElementById("zopimBubbleText").value);
95
- }
96
- else {
97
- $zopim.livechat.bubble.setTitle('Questions?');
98
- $zopim.livechat.bubble.setText('Click here to chat with us!');
99
- }
100
-
101
- $zopim.livechat.setGreetings({
102
- 'online': [document.getElementById("zopimOnlineShort").value, document.getElementById("zopimOnlineLong").value],
103
- 'offline': [document.getElementById("zopimOfflineShort").value, document.getElementById("zopimOfflineLong").value],
104
- 'away': [document.getElementById("zopimAwayShort").value, document.getElementById("zopimAwayLong").value]
105
- });
106
- }
107
-
108
- function updatePosition() {
109
- var position = document.getElementById('zopimPosition').options[ document.getElementById('zopimPosition').options.selectedIndex ].value;
110
- $zopim.livechat.button.setPosition(position);
111
- }
112
-
113
- function updateBubbleStatus() {
114
- var value = document.getElementById("zopimBubbleEnable").value;
115
- switch (value) {
116
- case 'default':
117
- $zopim.livechat.bubble.reset();
118
- break;
119
- case 'show':
120
- $zopim.livechat.bubble.show();
121
- break;
122
- case 'hide':
123
- $zopim.livechat.bubble.hide();
124
- break;
125
- }
126
- }
127
-
128
- function greetingsChanged() {
129
- var inputs = [ 'zopimOnlineShort', 'zopimAwayShort', 'zopimOfflineShort',
130
- 'zopimOnlineLong' , 'zopimAwayLong', 'zopimOfflineLong' ];
131
- var isDisabled = false;
132
-
133
- document.getElementById('zopimUseGreetings').checked? (isDisabled = false): (isDisabled = true);
134
-
135
- for (var i=0; i<inputs.length; i++) {
136
- document.getElementById(inputs[i]).disabled = isDisabled;
137
- }
138
-
139
- updateWidget();
140
- }
141
-
142
- function bubbleChanged() {
143
- var inputs = [ 'zopimBubbleTitle', 'zopimBubbleText' ];
144
- var isDisabled = false;
145
-
146
- document.getElementById('zopimUseBubble').checked? (isDisabled = false): (isDisabled = true);
147
-
148
- for (var i = 0; i < inputs.length; i++) {
149
- document.getElementById(inputs[i]).disabled = isDisabled;
150
- }
151
-
152
- updateWidget();
153
- }
154
-
155
- var timer;
156
- function updateSoon() {
157
- clearTimeout(timer);
158
- timer = setTimeout("updateWidget()", 300);
159
- }
160
-
161
- </script>
162
-
163
- <style type="text/css">
164
- .smallExplanation {
165
- background:#FAFAFA;
166
- color:#667788;
167
- font-size:8pt;
168
- line-height:13px;
169
- margin:4px 0 0 0;
170
- padding:8px;
171
- display: inline-block;
172
- }
173
- .inputtextshort {
174
- width:200px;
175
- }
176
- .inputtext {
177
- width:450px;
178
- }
179
- .secthead {
180
- border-bottom:1px solid #EEEEEE;
181
- color:#8899AA;
182
- font-size:13px;
183
- line-height:21px;
184
- }
185
- .sethead {
186
- width:200px;
187
- }
188
- .swatch {
189
- float: left;
190
- width: 15px
191
- }
192
- .swatch:hover {
193
- background-image:url(http://www.zopim.com/static/images/colorselectbg.gif);
194
- cursor:pointer;
195
- }
196
- .sorry {
197
- color:#c33;
198
- }
199
- </style>
200
-
201
- <div class="wrap">
202
- <div id="icon-themes" class="icon32"><br/></div><h2>Customize your widget</h2>
203
-
204
- <?php echo $message; ?>
205
- <form method="post" action="admin.php?page=zopim_customize_widget">
206
- <div class="metabox-holder">
207
- <div class="postbox">
208
- <h3 class="hndle"><span>General Settings</span></h3>
209
- <div style="padding:10px;">
210
- <table class="form-table">
211
- <tr valign="top">
212
- <th scope="row" class="sethead">Language</th>
213
- <td>
214
- <select name="zopimLang" id="zopimLang" onchange="updateWidget()">
215
- <?php
216
- $languages = get_languages();
217
- echo generate_options($languages, get_option('zopimLang'));
218
- ?>
219
- </select>
220
- </td>
221
- </tr>
222
- <tr valign="top" style="display:none;">
223
- <th scope="row">Use Logged in Username / Email</th>
224
- <td><input onchange="updateWidget()" type="checkbox" id="zopimGetVisitorInfo" name="zopimGetVisitorInfo" value="zopimGetVisitorInfo" <?php if (get_option('zopimGetVisitorInfo')!="disabled") { echo "checked='checked'"; } ?> /></td>
225
- </tr>
226
- <tr valign="top">
227
- <th scope="row" class="sethead">Position</th>
228
- <td>
229
-
230
- <select name="zopimPosition" id="zopimPosition" onchange="updatePosition()">
231
- <?php
232
- $positions = array("br" => "Bottom Right", "bl" => "Bottom Left");
233
- echo generate_options($positions, get_option('zopimPosition'));
234
- ?>
235
- </select>
236
- </td>
237
- </tr>
238
-
239
- <tr valign="top">
240
- <th scope="row">Hide chat bar when offline<br>
241
- <!-- <div class="smallExplanation">Hide the chat bar when no agents are available to answer questions. This prevents visitors from sending you offline messages. </div> -->
242
- </th>
243
- <td>
244
- <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
245
- <a href="#" onclick="$zopim.livechat.button.show();return false">(Show preview chat bar)</a>
246
- </td>
247
- </tr>
248
- </table>
249
- </div>
250
- </div>
251
- </div>
252
- <div class="metabox-holder">
253
- <div class="postbox">
254
- <h3 class="hndle"><span>Color & Theme Settings</span></h3>
255
- <div style="padding:10px;">
256
- Theme settings show up instantly on the preview widget. Try it out!<br/>
257
- <table class="form-table" style="width: 700px">
258
- <tr valign="top">
259
- <td colspan="2">
260
- <input type="hidden" id="zopimColor" name="zopimColor" value="<?php echo get_option('zopimColor'); ?>">
261
- <?php
262
-
263
- if ($accountDetails->color_customization_enabled == 1) {
264
- echo "<div style='display:inline-block;border:11px solid #888;background:#888;color:#fee;'>";
265
- $colors = zopim_url_get(ZOPIM_COLORS_LIST);
266
- $colors = explode("\n", $colors);
267
-
268
- $i=0;
269
- foreach ($colors as $color) {
270
- echo "<div class='swatch' style='background-color: $color;' onclick=\"document.getElementById('zopimColor').value='$color'; updateWidget();\">&nbsp</div>";
271
- if (++$i%40==0) {
272
- echo "<br>";
273
- }
274
- }
275
- echo "<br><a href=# style='color:#ff8' onclick=\"document.getElementById('zopimColor').value=''; updateWidget();\">Restore default color</a></div>";
276
- } else {
277
- echo "<div class='sorry'>Sorry, your plan does not allow for color customization. Please upgrade to enjoy choice of color!</div>";
278
- }
279
- ?>
280
- </td>
281
- </tr>
282
- <tr valign="top">
283
- <th scope="row" class="sethead">Select A Theme</th>
284
- <td style="width: 400px"><div align="left">
285
- <?php
286
-
287
- if ($accountDetails->widget_customization_enabled == 1) {
288
- echo '<select name="zopimTheme" id="zopimTheme" onchange="updateWidget()">';
289
- $themes = zopim_url_get(ZOPIM_THEMES_LIST);
290
- $themes = valuekeys(explode("\n", $themes));
291
- ksort($themes);
292
-
293
- echo generate_options($themes, get_option('zopimTheme'));
294
- echo "</select> <a href='#' onclick='\$zopim.livechat.window.toggle();return false;'>Open the chat panel</a> to see changes";
295
- }
296
- else {
297
- echo "<div class='sorry'>Sorry, your plan does not allow for theme customization. Please upgrade to enjoy choice of themes!</div>";
298
- echo '<input type=hidden value="" name="zopimTheme" id="zopimTheme">';
299
- }
300
- ?>
301
- </td>
302
- </tr>
303
- </table>
304
- </div>
305
- </div>
306
- </div>
307
-
308
- <?php
309
- (get_option('zopimUseBubble') && get_option('zopimUseBubble')!="disabled")? ($useBubble = true): ($useBubble = false);
310
- ?>
311
- <div class="metabox-holder">
312
- <div class="postbox">
313
- <h3 class="hndle"><span>Help Bubble Settings</span></h3>
314
- <div style="padding:10px;">
315
- <table class="form-table">
316
- <tr valign="top">
317
- <th scope="row">Display Help Bubble<br></th>
318
- <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>
319
- </tr>
320
- <tr>
321
- <td colspan="2"><div class="secthead">Help Bubble Text</div></td>
322
- </tr>
323
- <tr>
324
- <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>
325
- </tr>
326
- <tr valign="top">
327
- <th scope="row" class="sethead">Help Bubble Title</th>
328
- <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> -->
329
- </tr>
330
- <tr valign="top">
331
- <th scope="row" class="sethead">Help Bubble Message</th>
332
- <td><input class="inputtext" name="zopimBubbleText" id="zopimBubbleText" onKeyup="updateSoon()" value="<?php echo get_option('zopimBubbleText'); ?>" <?php if(!$useBubble) { echo "disabled='disabled'"; } ?>></td>
333
- </tr>
334
- </table>
335
- </div>
336
- </div>
337
- </div>
338
-
339
- <?php
340
- (get_option('zopimUseGreetings') && get_option('zopimUseGreetings')!="disabled")? ($useGreetings = true): ($useGreetings = false);
341
- ?>
342
- <div class="metabox-holder">
343
- <div class="postbox">
344
- <h3 class="hndle"><span>Greeting Message Settings</span></h3>
345
- <div style="padding:10px;">
346
- <table class="form-table">
347
- <tr>
348
- <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>
349
- </tr>
350
- <tr>
351
- <td colspan="2"><div class="secthead">Message Shown on Chat Bar (max 26 characters)</div></td>
352
- </tr>
353
- <tr valign="top">
354
- <th scope="row" class="sethead">Online</th>
355
- <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>
356
- </tr>
357
- <tr valign="top">
358
- <th scope="row" class="sethead">Away</th>
359
- <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>
360
- </tr>
361
- <tr valign="top">
362
- <th scope="row" class="sethead">Offline</th>
363
- <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>
364
- </tr>
365
- <tr>
366
- <td colspan="2"><div class="secthead">Message Shown on Chat Panel (max 140 characters)</div></td>
367
- </tr>
368
- <tr valign="top">
369
- <th scope="row" class="sethead">Online</th>
370
- <td><textarea class="inputtext" name="zopimOnlineLong" id="zopimOnlineLong" onKeyup="updateSoon()" <?php if (!$useGreetings) echo "disabled='disabled'"?> ><?php echo $greetings->online->window; ?></textarea></td>
371
- </tr>
372
- <tr valign="top">
373
- <th scope="row" class="sethead">Away</th>
374
- <td><textarea class="inputtext" name="zopimAwayLong" id="zopimAwayLong" onKeyup="updateSoon()" <?php if (!$useGreetings) echo "disabled='disabled'"?> ><?php echo $greetings->away->window; ?></textarea></td>
375
- </tr>
376
- <tr valign="top">
377
- <th scope="row" class="sethead">Offline</th>
378
- <td><textarea class="inputtext" name="zopimOfflineLong" id="zopimOfflineLong" onKeyup="updateSoon()" <?php if (!$useGreetings) echo "disabled='disabled'"?> ><?php echo $greetings->offline->window; ?></textarea></td>
379
- </tr>
380
- </table>
381
- </div>
382
- </div>
383
- </div>
384
-
385
- <p class="submit">
386
- <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
387
- </p>
388
-
389
- </form>
390
- </div>
391
-
392
- <?php }
393
-
394
- function valuekeys($array) {
395
- $newarray = array();
396
- foreach ($array as $s) { $newarray[$s] = $s; }
397
- return $newarray;
398
- }
399
-
400
- function generate_options($options, $current) {
401
- $out = "";
402
- foreach ($options as $key => $value) {
403
- if ($value != "") {
404
- $isselected = "";
405
- if ($current == $key) {
406
- $isselected = "selected";
407
- }
408
- $out .= '<option value="'.$key.'" '.$isselected.'>'.$value.'</option>';
409
- }
410
- }
411
- return $out;
412
- }
413
-
414
- function get_languages() {
415
- $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"}';
416
- return json_to_array($langjson);
417
- }
418
-
419
- function update_checkbox($fieldname) {
420
- if (isset($_POST["$fieldname"]) && $_POST["$fieldname"] != "")
421
- update_option($fieldname, $_POST["$fieldname"]);
422
- else
423
- update_option($fieldname, "disabled");
424
- }
425
-
426
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,15 +1,15 @@
1
  === Zopim Live Chat ===
2
  Contributors: bencxr
3
  Tags: widget, plugin, sidebar, page, admin, enhancement, livechat, chat, widget
4
- Requires at least: 2.7
5
- Tested up to: 3.3.1
6
- Stable tag: 1.2.2
7
 
8
  Zopim is an award winning chat solution that helps website owners to engage their visitors and convert customers into fans!
9
 
10
  == Description ==
11
 
12
- Ever wondered how to chat with visitors to your website? With <a href="https://www.zopim.com/?iref=wp_plugin">Zopim</a> Live Chat, they are just a click away!
13
 
14
  Using our <a href="http://blog.zopim.com/2010/10/28/awards-are-rolling-in/">award-winning</a> tool to respond instantly to visitors and engage them proactively. Live chat can’t be simpler with Zopim.
15
 
@@ -43,7 +43,7 @@ Just to name a few!
43
 
44
  Love to know more about the product? Please visit our <a href="https://www.zopim.com/product">website</a>.
45
 
46
- What are you waiting for? Download Zopim Live Chat plugin now and <a href="https://www.zopim.com/?iref=wordpress_plugin#signup">sign up here</a> for a free account!
47
 
48
  **See languages available, lovingly translated by Zopim users (in alphabetical order)**
49
 
@@ -51,6 +51,19 @@ What are you waiting for? Download Zopim Live Chat plugin now and <a href="https
51
 
52
  == Changelog ==
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  = 1.2.2 =
55
  * adds User Capability levels, allowing non-admins to use the plugin admin interface
56
  * Admins can use add the following code
1
  === Zopim Live Chat ===
2
  Contributors: bencxr
3
  Tags: widget, plugin, sidebar, page, admin, enhancement, livechat, chat, widget
4
+ Requires at least: 3.1
5
+ Tested up to: 3.4.2
6
+ Stable tag: 1.2.5
7
 
8
  Zopim is an award winning chat solution that helps website owners to engage their visitors and convert customers into fans!
9
 
10
  == Description ==
11
 
12
+ Ever wondered how to chat with visitors to your website? With <a href="http://www.zopim.com/?utm_source=wpdirectory&utm_medium=link&utm_campaign=wp%2Bplugin">Zopim</a> Live Chat, they are just a click away!
13
 
14
  Using our <a href="http://blog.zopim.com/2010/10/28/awards-are-rolling-in/">award-winning</a> tool to respond instantly to visitors and engage them proactively. Live chat can’t be simpler with Zopim.
15
 
43
 
44
  Love to know more about the product? Please visit our <a href="https://www.zopim.com/product">website</a>.
45
 
46
+ What are you waiting for? Download Zopim Live Chat plugin now and <a href="https://www.zopim.com/?aref=MjUxMjY4:1TeORR:9SP1e-iPTuAVXROJA6UU5seC8x4&visit_id=6ffe00ec3cfc11e2b5ab22000a1db8fa&utm_source=wpdirectory&utm_medium=link&utm_campaign=wp%2Bsignup#signup">sign up here</a> for a free account!
47
 
48
  **See languages available, lovingly translated by Zopim users (in alphabetical order)**
49
 
51
 
52
  == Changelog ==
53
 
54
+ = 1.2.5 =
55
+ * Enhancement to Theme Editor - now autoloads blog's url automatically
56
+
57
+ = 1.2.4 =
58
+ * Adds an optional widget settings box
59
+ * Widget settings saved from old wordpress plugin will be migrated to the optional settings box
60
+ * Visitor info uses new wp api and now enabled by default
61
+ * Required Wordpress version bumped to 3.1
62
+
63
+ = 1.2.3 =
64
+ * Replaces old customize widget page with new theme editor
65
+ * Remove customizewidget.php
66
+
67
  = 1.2.2 =
68
  * adds User Capability levels, allowing non-admins to use the plugin admin interface
69
  * Admins can use add the following code
zopim.php CHANGED
@@ -5,30 +5,27 @@ Plugin Name: Zopim Widget
5
  Plugin URI: http://www.zopim.com/?iref=wp_plugin
6
  Description: Zopim is an award winning chat solution that helps website owners to engage their visitors and convert customers into fans!
7
  Author: Zopim
8
- Version: 1.2.2
9
  Author URI: http://www.zopim.com/?iref=wp_plugin
10
  */
11
 
12
  define('ZOPIM_SCRIPT_DOMAIN', "zopim.com");
13
  define('ZOPIM_BASE_URL', "https://www.zopim.com/");
14
- define('ZOPIM_SIGNUP_REDIRECT_URL', ZOPIM_BASE_URL."?iref=wp_plugin#signup");
15
  define('ZOPIM_GETACCOUNTDETAILS_URL', ZOPIM_BASE_URL."plugins/getAccountDetails");
16
  define('ZOPIM_SETDISPLAYNAME_URL', ZOPIM_BASE_URL."plugins/setDisplayName");
17
  define('ZOPIM_IMINFO_URL', ZOPIM_BASE_URL."plugins/getImSetupInfo");
18
  define('ZOPIM_IMREMOVE_URL', ZOPIM_BASE_URL."plugins/removeImSetup");
19
  define('ZOPIM_LOGIN_URL', ZOPIM_BASE_URL."plugins/login");
20
  define('ZOPIM_SIGNUP_URL', ZOPIM_BASE_URL."plugins/createTrialAccount");
21
- define('ZOPIM_THEMES_LIST', "http://zopim.com/assets/dashboard/themes/window/plugins-themes.txt");
22
- define('ZOPIM_COLORS_LIST', "http://zopim.com/assets/dashboard/themes/window/plugins-colors.txt");
23
- define('ZOPIM_LANGUAGES_URL', "http://translate.zopim.com/projects/zopim/");
24
- define('ZOPIM_DASHBOARD_URL', "http://dashboard.zopim.com/?iref=wp_plugin");
25
  define('ZOPIM_SMALL_LOGO', "http://zopim.com/assets/branding/zopim.com/chatman/online.png");
26
  define('ZOPIM_IM_LOGOS', "http://www.zopim.com/static/images/im/");
27
- define('ZOPIM_THEMES_URL', "http://");
28
- define('ZOPIM_COLOURS_URL', "http://");
29
 
30
  require_once dirname( __FILE__ ) . '/accountconfig.php';
31
- require_once dirname( __FILE__ ) . '/customizewidget.php';
32
  require_once dirname( __FILE__ ) . '/imintegration.php';
33
 
34
  function add_zopim_caps() {
@@ -42,6 +39,7 @@ add_action( 'admin_init', 'add_zopim_caps');
42
  // We need some CSS to position the paragraph
43
  function zopimme() {
44
  global $current_user, $zopimshown;
 
45
 
46
  $code = get_option('zopimCode');
47
 
@@ -58,28 +56,65 @@ d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
58
  _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');
59
  $.src='//cdn.zopim.com/?".$code."';z.t=+new Date;$.
60
  type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
61
- </script>
62
- <!--End of Zopim Live Chat Script-->";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
 
64
  $theoptions = array();
65
- if (get_option('zopimLang') != "" && get_option('zopimLang') != "--")
66
- $theoptions[] = " language: '".get_option('zopimLang')."'";
67
 
68
- if (isset($current_user) && get_option("zopimGetVisitorInfo") == "checked") {
69
- $ul = $current_user->data->first_name;
70
- $useremail = $current_user->data->user_email;
71
- if ($ul!="" && $useremail != "")
72
- $theoptions[] = "name: '$ul', email: '$useremail'";
73
- }
74
 
75
- echo "\n<script type=\"text/javascript\">\n\$zopim( function() {";
 
76
 
77
  if (count($theoptions) > 0)
78
- echo '$zopim.livechat.set({'.implode(", ", $theoptions)."});";
79
 
80
- get_option('zopimPosition') != "" && print("\n\$zopim.livechat.button.setPosition('".get_option('zopimPosition')."');");
81
- get_option('zopimTheme') != "" && print("\n\$zopim.livechat.window.setTheme('".get_option('zopimTheme')."');");
82
- get_option('zopimColor') != "" && print("\n\$zopim.livechat.window.setColor('".get_option('zopimColor')."');");
83
 
84
  if (get_option('zopimUseGreetings') == "zopimUseGreetings") {
85
  if (get_option('zopimGreetings') != "") {
@@ -89,7 +124,7 @@ type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
89
  $greetings->$i->$j = str_replace("\r\n", "\\n", $greetings->$i->$j);
90
  }
91
  }
92
- echo "\n\$zopim.livechat.setGreetings({
93
  'online' : ['".addslashes($greetings->online->bar)."', '".addslashes($greetings->online->window)."'],
94
  'offline': ['".addslashes($greetings->offline->bar)."', '".addslashes($greetings->offline->window)."'],
95
  'away' : ['".addslashes($greetings->away->bar)."', '".addslashes($greetings->away->window)."'] });";
@@ -97,19 +132,22 @@ type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
97
  }
98
 
99
  if (get_option('zopimUseBubble') == "zopimUseBubble") {
100
- get_option('zopimBubbleTitle') != "" && print("\n\$zopim.livechat.bubble.setTitle('".addslashes(get_option('zopimBubbleTitle'))."');");
101
- get_option('zopimBubbleText') != "" && print("\n\$zopim.livechat.bubble.setText('".addslashes(get_option('zopimBubbleText'))."');");
102
  }
103
 
104
  if (get_option('zopimBubbleEnable') == "show")
105
- echo "\n\$zopim.livechat.bubble.show(true);";
106
  else if (get_option('zopimBubbleEnable') == "hide")
107
- echo "\n\$zopim.livechat.bubble.hide(true);";
108
 
109
  // this must be called last
110
  if (get_option('zopimHideOnOffline') == "zopimHideOnOffline")
111
- echo "\n\$zopim.livechat.button.setHideWhenOffline(true);";
112
- echo "\n})</script>";
 
 
 
113
  }
114
 
115
  function zopim_create_menu() {
@@ -119,6 +157,7 @@ function zopim_create_menu() {
119
  // add_submenu_page('zopim_about', "About", "About", "access_zopim", 'zopim_about', 'zopim_about');
120
  add_submenu_page('zopim_account_config', 'Account Configuration', 'Account Setup', 'access_zopim', 'zopim_account_config', 'zopim_account_config');
121
  add_submenu_page('zopim_account_config', 'Customize Widget', 'Customize', 'access_zopim', 'zopim_customize_widget', 'zopim_customize_widget');
 
122
  add_submenu_page('zopim_account_config', 'IM Integration', 'IM Chat Bots', 'access_zopim', 'zopim_instant_messaging', 'zopim_instant_messaging');
123
  add_submenu_page('zopim_account_config', 'Dashboard', 'Dashboard', 'access_zopim', 'zopim_dashboard', 'zopim_dashboard');
124
 
@@ -130,9 +169,50 @@ function zopim_about() {
130
  echo "about";
131
  }
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  function zopim_dashboard() {
134
- echo '<div id="dashboarddiv"><iframe id="dashboardiframe" src="'.ZOPIM_DASHBOARD_URL.'i" height=700 width=98% scrolling="no"></iframe></div> You may also <a href="'.ZOPIM_DASHBOARD_URL.'" target="_newWindow" onClick="javascript:document.getElementById(\'dashboarddiv\').innerHTML=\'\'; ">access the dashboard in a new window</a>.
135
- ';
 
 
 
 
 
 
 
 
136
  }
137
 
138
  // Register the option settings we will be using
@@ -143,30 +223,7 @@ function register_zopim_plugin_settings() {
143
  register_setting( 'zopim-settings-group', 'zopimUsername' );
144
  register_setting( 'zopim-settings-group', 'zopimSalt' );
145
  register_setting( 'zopim-settings-group', 'zopimUseSSL' );
146
- // General Widget settings
147
- register_setting( 'zopim-settings-group', 'zopimGetVisitorInfo' );
148
- register_setting( 'zopim-settings-group', 'zopimLang' );
149
- // Chat button settings
150
- register_setting( 'zopim-settings-group', 'zopimPosition' );
151
- register_setting( 'zopim-settings-group', 'zopimHideOnOffline' );
152
- register_setting( 'zopim-settings-group', 'zopimBubbleTitle' );
153
- register_setting( 'zopim-settings-group', 'zopimBubbleText' );
154
- register_setting( 'zopim-settings-group', 'zopimBubbleEnable' );
155
- register_setting( 'zopim-settings-group', 'zopimUseBubble' );
156
- // Themes / Color
157
- register_setting( 'zopim-settings-group', 'zopimColor' );
158
- register_setting( 'zopim-settings-group', 'zopimTheme' );
159
- // Message Settings
160
- register_setting( 'zopim-settings-group', 'zopimGreetings' );
161
- register_setting( 'zopim-settings-group', 'zopimUseGreetings' );
162
-
163
- get_option('zopimCode') == "" && update_option('zopimCode', "zopim");
164
- get_option('zopimBubbleTitle') == "" && update_option('zopimBubbleTitle', "Questions?");
165
- get_option('zopimBubbleText') == "" && update_option('zopimBubbleText', "Click here to chat with us!");
166
- get_option('zopimBubbleEnable') == "" && update_option('zopimBubbleEnable', "checked");
167
- get_option('zopimUseGreetings') == "" && update_option('zopimUseGreetings', "disabled");
168
- get_option('zopimUseBubble') == "" && update_option('zopimUseBubble', "disabled");
169
- 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"}}');
170
  }
171
 
172
  add_action('get_footer', 'zopimme');
5
  Plugin URI: http://www.zopim.com/?iref=wp_plugin
6
  Description: Zopim is an award winning chat solution that helps website owners to engage their visitors and convert customers into fans!
7
  Author: Zopim
8
+ Version: 1.2.5
9
  Author URI: http://www.zopim.com/?iref=wp_plugin
10
  */
11
 
12
  define('ZOPIM_SCRIPT_DOMAIN', "zopim.com");
13
  define('ZOPIM_BASE_URL', "https://www.zopim.com/");
14
+ define('ZOPIM_SIGNUP_REDIRECT_URL', ZOPIM_BASE_URL."?aref=MjUxMjY4:1TeORR:9SP1e-iPTuAVXROJA6UU5seC8x4&visit_id=6ffe00ec3cfc11e2b5ab22000a1db8fa&utm_source=account%2Bsetup%2Bpage&utm_medium=link&utm_campaign=wp%2Bsignup2#signup");
15
  define('ZOPIM_GETACCOUNTDETAILS_URL', ZOPIM_BASE_URL."plugins/getAccountDetails");
16
  define('ZOPIM_SETDISPLAYNAME_URL', ZOPIM_BASE_URL."plugins/setDisplayName");
17
  define('ZOPIM_IMINFO_URL', ZOPIM_BASE_URL."plugins/getImSetupInfo");
18
  define('ZOPIM_IMREMOVE_URL', ZOPIM_BASE_URL."plugins/removeImSetup");
19
  define('ZOPIM_LOGIN_URL', ZOPIM_BASE_URL."plugins/login");
20
  define('ZOPIM_SIGNUP_URL', ZOPIM_BASE_URL."plugins/createTrialAccount");
21
+ define('ZOPIM_DASHBOARD_URL', "http://dashboard.zopim.com/?utm_source=wp&utm_medium=iframe&utm_campaign=wp%2Bdashboard");
22
+ define('ZOPIM_DASHBOARD_LINK', "http://dashboard.zopim.com/?utm_source=wp&utm_medium=link&utm_campaign=wp%2Bdashboard");
23
+ define('ZOPIM_THEMEEDITOR_URL', "http://dashboard.zopim.com/themeEditor/?utm_source=wp&utm_medium=iframe&utm_campaign=wp%2Bthemeditor");
24
+ define('ZOPIM_THEMEEDITOR_LINK', "http://dashboard.zopim.com/themeEditor/?utm_source=wp&utm_medium=link&utm_campaign=wp%2Bthemeeditor");
25
  define('ZOPIM_SMALL_LOGO', "http://zopim.com/assets/branding/zopim.com/chatman/online.png");
26
  define('ZOPIM_IM_LOGOS', "http://www.zopim.com/static/images/im/");
 
 
27
 
28
  require_once dirname( __FILE__ ) . '/accountconfig.php';
 
29
  require_once dirname( __FILE__ ) . '/imintegration.php';
30
 
31
  function add_zopim_caps() {
39
  // We need some CSS to position the paragraph
40
  function zopimme() {
41
  global $current_user, $zopimshown;
42
+ get_currentuserinfo();
43
 
44
  $code = get_option('zopimCode');
45
 
56
  _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');
57
  $.src='//cdn.zopim.com/?".$code."';z.t=+new Date;$.
58
  type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
59
+ </script>";
60
+
61
+ echo '<script>';
62
+ if (isset($current_user)):
63
+ $firstname = $current_user->display_name;
64
+ $useremail = $current_user->user_email;
65
+ if ($firstname!="" && $useremail != ""):
66
+ echo "\$zopim(function(){\$zopim.livechat.set({name: '$firstname', email: '$useremail'}); });";
67
+ endif;
68
+ endif;
69
+
70
+ echo zopim_get_widget_options();
71
+ echo '</script>';
72
+ echo "<!--End of Zopim Live Chat Script-->";
73
+ }
74
+
75
+ function zopim_get_widget_options() {
76
+ $opts = get_option('zopimWidgetOptions');
77
+ if ($opts) return stripslashes($opts);
78
+
79
+ $opts = zopim_old_plugin_settings();
80
+ update_option('zopimWidgetOptions', $opts);
81
+
82
+ $list = array(
83
+ 'zopimLang',
84
+ 'zopimPosition',
85
+ 'zopimTheme',
86
+ 'zopimColor',
87
+ 'zopimUseGreetings',
88
+ 'zopimUseBubble',
89
+ 'zopimBubbleTitle',
90
+ 'zopimBubbleText',
91
+ 'zopimBubbleEnable',
92
+ 'zopimHideOnOffline'
93
+ );
94
+
95
+ foreach ($list as $key):
96
+ delete_option($key);
97
+ endforeach;
98
+
99
+ if ($opts) return $opts;
100
+ else return '';
101
+ }
102
 
103
+ function zopim_old_plugin_settings() {
104
  $theoptions = array();
 
 
105
 
106
+ if (get_option('zopimLang') != "" && get_option('zopimLang') != "--")
107
+ $theoptions[] = " language: '".get_option('zopimLang')."'";
 
 
 
 
108
 
109
+ $zopim_embed_opts = '';
110
+ $zopim_embed_opts .= "\$zopim( function() {";
111
 
112
  if (count($theoptions) > 0)
113
+ $zopim_embed_opts .= '$zopim.livechat.set({'.implode(", ", $theoptions)."});";
114
 
115
+ if (get_option('zopimPosition')) $zopim_embed_opts .= "\n\$zopim.livechat.button.setPosition('".get_option('zopimPosition')."');";
116
+ if (get_option('zopimTheme')) $zopim_embed_opts .= "\n\$zopim.livechat.window.setTheme('".get_option('zopimTheme')."');";
117
+ if (get_option('zopimColor')) $zopim_embed_opts .= "\n\$zopim.livechat.window.setColor('".get_option('zopimColor')."');";
118
 
119
  if (get_option('zopimUseGreetings') == "zopimUseGreetings") {
120
  if (get_option('zopimGreetings') != "") {
124
  $greetings->$i->$j = str_replace("\r\n", "\\n", $greetings->$i->$j);
125
  }
126
  }
127
+ $zopim_embed_opts .= "\n\$zopim.livechat.setGreetings({
128
  'online' : ['".addslashes($greetings->online->bar)."', '".addslashes($greetings->online->window)."'],
129
  'offline': ['".addslashes($greetings->offline->bar)."', '".addslashes($greetings->offline->window)."'],
130
  'away' : ['".addslashes($greetings->away->bar)."', '".addslashes($greetings->away->window)."'] });";
132
  }
133
 
134
  if (get_option('zopimUseBubble') == "zopimUseBubble") {
135
+ if (get_option('zopimBubbleTitle')) $zopim_embed_opts .= "\n\$zopim.livechat.bubble.setTitle('".addslashes(get_option('zopimBubbleTitle'))."');";
136
+ if (get_option('zopimBubbleText')) $zopim_embed_opts .= "\n\$zopim.livechat.bubble.setText('".addslashes(get_option('zopimBubbleText'))."');";
137
  }
138
 
139
  if (get_option('zopimBubbleEnable') == "show")
140
+ $zopim_embed_opts .= "\n\$zopim.livechat.bubble.show(true);";
141
  else if (get_option('zopimBubbleEnable') == "hide")
142
+ $zopim_embed_opts .= "\n\$zopim.livechat.bubble.hide(true);";
143
 
144
  // this must be called last
145
  if (get_option('zopimHideOnOffline') == "zopimHideOnOffline")
146
+ $zopim_embed_opts .= "\n\$zopim.livechat.button.setHideWhenOffline(true);";
147
+
148
+ $zopim_embed_opts .= "\n})";
149
+ return $zopim_embed_opts;
150
+
151
  }
152
 
153
  function zopim_create_menu() {
157
  // add_submenu_page('zopim_about', "About", "About", "access_zopim", 'zopim_about', 'zopim_about');
158
  add_submenu_page('zopim_account_config', 'Account Configuration', 'Account Setup', 'access_zopim', 'zopim_account_config', 'zopim_account_config');
159
  add_submenu_page('zopim_account_config', 'Customize Widget', 'Customize', 'access_zopim', 'zopim_customize_widget', 'zopim_customize_widget');
160
+
161
  add_submenu_page('zopim_account_config', 'IM Integration', 'IM Chat Bots', 'access_zopim', 'zopim_instant_messaging', 'zopim_instant_messaging');
162
  add_submenu_page('zopim_account_config', 'Dashboard', 'Dashboard', 'access_zopim', 'zopim_dashboard', 'zopim_dashboard');
163
 
169
  echo "about";
170
  }
171
 
172
+ function zopim_resize_iframe($target) {
173
+
174
+ ?>
175
+ <script>
176
+ (function() {
177
+ var wpwrap = document.getElementById('wpwrap');
178
+ var ztarget = document.getElementById('<?php echo $target; ?>');
179
+ // window.addEventListener('resize', zopim_resize, false);
180
+ function zopim_resize() {
181
+ if (wpwrap && wpwrap.clientHeight) {
182
+ ztarget.height = Math.max(wpwrap.clientHeight - 110, 700);
183
+ }
184
+ }
185
+ zopim_resize();
186
+ })()
187
+ </script>
188
+
189
+ <?php
190
+ }
191
+
192
+ function zopim_customize_widget() {
193
+
194
+ $params = '';
195
+ $code = get_option('zopimCode');
196
+ if (!empty($code)) $params .= '&account_key=' . urlencode($code);
197
+
198
+ $params .= '&url=' . urlencode(get_site_option('siteurl'));
199
+
200
+ echo '<div id="dashboarddiv"><iframe id="themeEditor" src="'.ZOPIM_THEMEEDITOR_URL.$params.'" height=700 width=98% scrolling="no"></iframe></div>';
201
+ echo 'You may also <a href="'.ZOPIM_THEMEEDITOR_LINK.$params.'" target="customize" onclick="javascript:document.getElementById(\'dashboarddiv\').innerHTML=\'\'; ">access the theme editor in a new window</a>.';
202
+ zopim_resize_iframe('themeEditor');
203
+ }
204
+
205
  function zopim_dashboard() {
206
+ global $current_user;
207
+
208
+ if (isset($current_user)):
209
+ $useremail = $current_user->data->user_email;
210
+ endif;
211
+ // Get Blog's URL
212
+
213
+ echo '<div id="dashboarddiv"><iframe id="dashboardiframe" src="'.ZOPIM_DASHBOARD_URL.'" height=700 width=98% scrolling="no"></iframe></div>';
214
+ echo 'You may also <a href="'.ZOPIM_DASHBOARD_LINK.'" target="dashboard" onclick="javascript:document.getElementById(\'dashboarddiv\').innerHTML=\'\'; ">access the dashboard in a new window</a>.';
215
+ zopim_resize_iframe('dashboardiframe');
216
  }
217
 
218
  // Register the option settings we will be using
223
  register_setting( 'zopim-settings-group', 'zopimUsername' );
224
  register_setting( 'zopim-settings-group', 'zopimSalt' );
225
  register_setting( 'zopim-settings-group', 'zopimUseSSL' );
226
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  }
228
 
229
  add_action('get_footer', 'zopimme');