예제 #1
0
/**
 * Load Intercom and send across user information and server info
 *
 * Only loaded if the user has opted in.
 *
 * @return void
 */
function hmbkp_load_intercom_script()
{
    if (!get_option('hmbkp_enable_support')) {
        return;
    }
    require_once HMBKP_PLUGIN_PATH . 'classes/class-requirements.php';
    foreach (HMBKP_Requirements::get_requirement_groups() as $group) {
        foreach (HMBKP_Requirements::get_requirements($group) as $requirement) {
            $info[$requirement->name()] = $requirement->result();
        }
    }
    foreach (HMBKP_Services::get_services() as $file => $service) {
        array_merge($info, call_user_func(array($service, 'intercom_data')));
    }
    $current_user = wp_get_current_user();
    $info['user_hash'] = hash_hmac("sha256", $current_user->user_email, "fcUEt7Vi4ym5PXdcr2UNpGdgZTEvxX9NJl8YBTxK");
    $info['email'] = $current_user->user_email;
    $info['created_at'] = strtotime($current_user->user_registered);
    $info['app_id'] = "7f1l4qyq";
    $info['name'] = $current_user->display_name;
    $info['widget'] = array('activator' => '#intercom');
    ?>

	<script id="IntercomSettingsScriptTag">
		window.intercomSettings = <?php 
    echo json_encode($info);
    ?>
;
	</script>
	<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://static.intercomcdn.com/intercom.v1.js';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}};})()</script>

<?php 
}
?>

<h2><?php 
_e('Enable BackUpWordPress Support', 'hmbkp');
?>
</h2>

<p class="howto"><?php 
printf(__('BackUpWordPress uses %s to provide support. In addition to allowing you to send and receive messages we also send the following server information along with your requests:', 'hmbkp'), '<a target="blank" href="https://www.intercom.io">Intercom</a>');
?>
</p>

<div class="server-info">

<?php 
foreach (HMBKP_Requirements::get_requirement_groups() as $group) {
    ?>

	<table class="fixed widefat">

		<thead>
			<tr>
				<th scope="col" colspan="2"><?php 
    echo ucwords($group);
    ?>
</th>
			</tr>
		</thead>

		<tbody>
예제 #3
0
    /**
     * Load Intercom and send across user information and server info. Only loaded if the user has opted in.
     *
     * @param $hook
     */
    public function load_intercom_script()
    {
        if (!get_option('hmbkp_enable_support')) {
            return;
        }
        foreach (HMBKP_Requirements::get_requirement_groups() as $group) {
            foreach (HMBKP_Requirements::get_requirements($group) as $requirement) {
                $info[$requirement->name()] = $requirement->result();
            }
        }
        foreach (HMBKP_Services::get_services() as $file => $service) {
            array_merge($info, call_user_func(array($service, 'intercom_data')));
        }
        $current_user = wp_get_current_user();
        $info['user_hash'] = hash_hmac('sha256', $current_user->user_email, 'fcUEt7Vi4ym5PXdcr2UNpGdgZTEvxX9NJl8YBTxK');
        $info['email'] = $current_user->user_email;
        $info['created_at'] = strtotime($current_user->user_registered);
        $info['app_id'] = '7f1l4qyq';
        $info['name'] = $current_user->display_name;
        $info['widget'] = array('activator' => '#intercom');
        ?>

		<script id="IntercomSettingsScriptTag">
			window.intercomSettings = <?php 
        echo json_encode($info);
        ?>
;
		</script>
		<script>!function(){function e(){var a=c.createElement("script");a.type="text/javascript",a.async=!0,a.src="https://static.intercomcdn.com/intercom.v1.js";var b=c.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b)}var a=window,b=a.Intercom;if("function"==typeof b)b("reattach_activator"),b("update",intercomSettings);else{var c=document,d=function(){d.c(arguments)};d.q=[],d.c=function(a){d.q.push(a)},a.Intercom=d,a.attachEvent?a.attachEvent("onload",e):a.addEventListener("load",e,!1)}}();</script>

	<?php 
    }