forked from olayinkakings/affiliate-management-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlivechat.php
More file actions
65 lines (57 loc) · 1.99 KB
/
livechat.php
File metadata and controls
65 lines (57 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* @return string
*/
function getLiveChatJSONSettings()
{
$liveChatProps = [
'attributes' => []
];
$user = wp_get_current_user();
if ($user && $user->user_login) {
if ($user->user_firstname) {
$liveChatProps['name'] = $user->user_firstname;
if ($user->user_lastname) {
$liveChatProps['name'] .= ' ' . $user->user_lastname;
}
} else {
$liveChatProps['name'] = $user->user_login;
}
$liveChatProps['email'] = $user->user_email;
$liveChatProps['attributes']['cvolt_user_registered_at'] = strtotime($user->user_registered);
$liveChatProps['attributes']['cvolt_user_login'] = $user->user_login;
$dbVersion = get_option(\ClickerVolt\DB::OPTION_VERSION);
$liveChatProps['attributes']['cvolt_version_file'] = \ClickerVolt\DB::VERSION;
$liveChatProps['attributes']['cvolt_version_db'] = $dbVersion ? $dbVersion : "0";
}
return json_encode($liveChatProps);
}
/**
*
* @return string
*/
function getLiveChatScript($jsonSettings = null)
{
if ($jsonSettings === null) {
$jsonSettings = getLiveChatJSONSettings();
}
$js = <<<SCRIPT
<!-- Customerly Integration Code -->
<script>
try {
window.customerlySettings = JSON.parse('{$jsonSettings}');
} catch(error) {
window.customerlySettings = {};
}
window.customerlySettings['app_id'] = '92a343eb';
!function(){function e(){var e=t.createElement("script");
e.type="text/javascript",e.async=!0,
e.src="https://widget.customerly.io/widget/92a343eb";
var r=t.getElementsByTagName("script")[0];r.parentNode.insertBefore(e,r)}
var r=window,t=document,n=function(){n.c(arguments)};
r.customerly_queue=[],n.c=function(e){r.customerly_queue.push(e)},
r.customerly=n,r.attachEvent?r.attachEvent("onload",e):r.addEventListener("load",e,!1)}();
</script>
SCRIPT;
return $js;
}