Zendesk Chat - Version 1.0.2

Version Description

  • Maintenance update: More curl robustness enhancements.
Download this release

Release Info

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

Code changes from version 1.0.1 to 1.0.2

Files changed (2) hide show
  1. readme.txt +3 -0
  2. zopim.php +18 -29
readme.txt CHANGED
@@ -30,6 +30,9 @@ Great for improving interaction with your users and increasing the time they spe
30
31
== Changelog ==
32
33
= 1.0.1 =
34
* Maintenance update: More robust connectivity, CURL errors caught
35
* Note: PHP Curl is required (and has always been).
30
31
== Changelog ==
32
33
+ = 1.0.2 =
34
+ * Maintenance update: More curl robustness enhancements.
35
+
36
= 1.0.1 =
37
* Maintenance update: More robust connectivity, CURL errors caught
38
* Note: PHP Curl is required (and has always been).
zopim.php CHANGED
@@ -5,7 +5,7 @@ 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.0
9
Author URI: http://www.isidorechan.com/
10
*/
11
@@ -40,7 +40,7 @@ function zopimme() {
40
41
// Use zopim's code...
42
echo "
43
- <!-- Start of Zopim Live Chat Script -->
44
<script type=\"text/javascript\">
45
document.write(unescape(\"%3Cscript src='\" + document.location.protocol + \"//".ZOPIM_SCRIPT_DOMAIN."/?".$code."' charset='utf-8' type='text/javascript'%3E%3C/script%3E\"));
46
</script>
@@ -51,7 +51,7 @@ document.write(unescape(\"%3Cscript src='\" + document.location.protocol + \"//"
51
if (get_option('zopimLang') != "" && get_option('zopimLang') != "--") {
52
$theoptions[] = " language: '".get_option('zopimLang')."'";
53
}
54
-
55
56
if ( isset($current_user) && get_option("zopimGetVisitorInfo") == "checked" )
57
{
@@ -96,10 +96,10 @@ document.write(unescape(\"%3Cscript src='\" + document.location.protocol + \"//"
96
if (get_option('zopimGreetings') != "") {
97
$greetings = json_to_array(get_option('zopimGreetings'));
98
echo "\n\$zopim.livechat.setGreetings({
99
- 'online': ['".addslashes($greetings->online->bar)."', '".addslashes($greetings->online->window)."'],
100
'offline': ['".addslashes($greetings->offline->bar)."', '".addslashes($greetings->offline->window)."'],
101
'away': ['".addslashes($greetings->away->bar)."', '".addslashes($greetings->away->window)."'] });
102
- ";
103
}
104
echo "</script>";
105
}
@@ -108,7 +108,7 @@ function zopim_create_menu() {
108
109
//create new top-level menu
110
add_menu_page('Account Configuration', 'Zopim Chat', 'administrator', 'zopim_account_config', 'zopim_account_config', ZOPIM_SMALL_LOGO);
111
- // add_submenu_page('zopim_about', "About", "About", "administrator", 'zopim_about', 'zopim_about');
112
add_submenu_page('zopim_account_config', 'Account Configuration', 'Account Setup', 'administrator', 'zopim_account_config', 'zopim_account_config');
113
add_submenu_page('zopim_account_config', 'Customize Widget', 'Customize', 'administrator', 'zopim_customize_widget', 'zopim_customize_widget');
114
add_submenu_page('zopim_account_config', 'IM Integration', 'IM Chat Bots', 'administrator', 'zopim_instant_messaging', 'zopim_instant_messaging');
@@ -120,7 +120,7 @@ function zopim_create_menu() {
120
121
function check_zopimCode() {
122
/*
123
- // if (get_option('zopimCode') == '' && ($_GET["page"] != "zopim_account_config")) {
124
if (ereg("zopim", $_GET["page"] )) {
125
//add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>" . sprintf( "Please <a href=\"%s\">input your Zopim account details</a>.", "admin.php?page=zopim_account_config" ) . "</p></div>";' ) );
126
add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>This Zopim plugin is a work in progress. We will launch on the 25th of January. Thank you for your interest.</p></div>";' ) );
@@ -144,7 +144,7 @@ function zopim_about() {
144
function zopim_dashboard() {
145
146
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>.
147
- ';
148
}
149
150
// Register the option settings we will be using
@@ -199,35 +199,24 @@ add_action('admin_menu', 'zopim_create_menu');
199
200
function do_post_request($url, $_data, $optional_headers = null)
201
{
202
- $gadURL = ZOPIM_GETACCOUNTDETAILS_URL;
203
if (get_option('zopimUseSSL') != "zopimUseSSL") {
204
- $gadURL = str_replace("https", "http", $gadURL);
205
}
206
207
- $data = array();
208
-
209
while(list($n,$v) = each($_data)){
210
$data[] = urlencode($n)."=".urlencode($v);
211
}
212
213
$data = implode('&', $data);
214
- $params = array('http' => array(
215
- 'method' => 'POST',
216
- 'content' => $data
217
- ));
218
- if ($optional_headers !== null) {
219
- $params['http']['header'] = $optional_headers;
220
- }
221
- $ctx = stream_context_create($params);
222
- $fp = @fopen($url, 'rb', false, $ctx);
223
224
- if (!$fp) {
225
- // echo ("Problem with $url, $php_errormsg");
226
- }
227
- $response = @stream_get_contents($fp);
228
- if ($response === false) {
229
- // echo("Problem reading data from $url, $php_errormsg");
230
- }
231
232
return $response;
233
}
@@ -246,7 +235,7 @@ function to_json($variable) {
246
247
// json_decode does exist but only in php > 5.2.0
248
require_once('JSON.php');
249
-
250
$jsonparser = new Services_JSON();
251
252
return ($jsonparser->encode($variable));
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.0.2
9
Author URI: http://www.isidorechan.com/
10
*/
11
40
41
// Use zopim's code...
42
echo "
43
+ <!-- Start of Zopim Live Chat Script -->
44
<script type=\"text/javascript\">
45
document.write(unescape(\"%3Cscript src='\" + document.location.protocol + \"//".ZOPIM_SCRIPT_DOMAIN."/?".$code."' charset='utf-8' type='text/javascript'%3E%3C/script%3E\"));
46
</script>
51
if (get_option('zopimLang') != "" && get_option('zopimLang') != "--") {
52
$theoptions[] = " language: '".get_option('zopimLang')."'";
53
}
54
+
55
56
if ( isset($current_user) && get_option("zopimGetVisitorInfo") == "checked" )
57
{
96
if (get_option('zopimGreetings') != "") {
97
$greetings = json_to_array(get_option('zopimGreetings'));
98
echo "\n\$zopim.livechat.setGreetings({
99
+ 'online': ['".addslashes($greetings->online->bar)."', '".addslashes($greetings->online->window)."'],
100
'offline': ['".addslashes($greetings->offline->bar)."', '".addslashes($greetings->offline->window)."'],
101
'away': ['".addslashes($greetings->away->bar)."', '".addslashes($greetings->away->window)."'] });
102
+ ";
103
}
104
echo "</script>";
105
}
108
109
//create new top-level menu
110
add_menu_page('Account Configuration', 'Zopim Chat', 'administrator', 'zopim_account_config', 'zopim_account_config', ZOPIM_SMALL_LOGO);
111
+ // add_submenu_page('zopim_about', "About", "About", "administrator", 'zopim_about', 'zopim_about');
112
add_submenu_page('zopim_account_config', 'Account Configuration', 'Account Setup', 'administrator', 'zopim_account_config', 'zopim_account_config');
113
add_submenu_page('zopim_account_config', 'Customize Widget', 'Customize', 'administrator', 'zopim_customize_widget', 'zopim_customize_widget');
114
add_submenu_page('zopim_account_config', 'IM Integration', 'IM Chat Bots', 'administrator', 'zopim_instant_messaging', 'zopim_instant_messaging');
120
121
function check_zopimCode() {
122
/*
123
+ // if (get_option('zopimCode') == '' && ($_GET["page"] != "zopim_account_config")) {
124
if (ereg("zopim", $_GET["page"] )) {
125
//add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>" . sprintf( "Please <a href=\"%s\">input your Zopim account details</a>.", "admin.php?page=zopim_account_config" ) . "</p></div>";' ) );
126
add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>This Zopim plugin is a work in progress. We will launch on the 25th of January. Thank you for your interest.</p></div>";' ) );
144
function zopim_dashboard() {
145
146
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>.
147
+ ';
148
}
149
150
// Register the option settings we will be using
199
200
function do_post_request($url, $_data, $optional_headers = null)
201
{
202
if (get_option('zopimUseSSL') != "zopimUseSSL") {
203
+ $url = str_replace("https", "http", $url);
204
}
205
206
+ $data = array();
207
while(list($n,$v) = each($_data)){
208
$data[] = urlencode($n)."=".urlencode($v);
209
}
210
211
$data = implode('&', $data);
212
+ $ch = curl_init();
213
+ curl_setopt($ch, CURLOPT_URL, $url);
214
+ curl_setopt($ch, CURLOPT_POST, true);
215
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
216
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
217
218
+ $response = curl_exec($ch);
219
+ curl_close($ch);
220
221
return $response;
222
}
235
236
// json_decode does exist but only in php > 5.2.0
237
require_once('JSON.php');
238
+
239
$jsonparser = new Services_JSON();
240
241
return ($jsonparser->encode($variable));