Advertisement
verygoodplugins

Untitled

Jan 14th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. function wpf_print_head_scripts() {
  2.  
  3.     <?php if(!is_admin() && !current_user_can('manage_options')) : ?>
  4.  
  5.         // Don't track admins
  6.  
  7.         <!-- Chatra {literal} -->
  8.         <script>
  9.  
  10.             <?php if (is_user_logged_in()) : ?>
  11.  
  12.                 <?php $current_user = wp_get_current_user(); ?>
  13.  
  14.                 window.ChatraSetup = {
  15.                     clientId: <?php echo $current_user->ID; ?>
  16.                 };
  17.  
  18.                 window.ChatraIntegration = {
  19.                     // main fields
  20.                     name: '<?php echo htmlspecialchars($current_user->user_firstname . ' ' . $current_user->user_lastname,ENT_QUOTES); ?>',
  21.                     email: '<?php echo htmlspecialchars( $current_user->user_email, ENT_QUOTES); ?>',
  22.  
  23.                     <?php if (class_exists('EDD_Customer')) :
  24.  
  25.                          $oCustomer = new EDD_Customer($current_user->user_email);
  26.                          $nID = $oCustomer->id;
  27.  
  28.                          if ($nID != 0) :
  29.                             $sCustomerURL = admin_url('edit.php?post_type=download&page=edd-customers&view=overview&id=' . urlencode($nID)); ?>
  30.                             'EDD URL': '<?php echo $sCustomerURL ?>'
  31.  
  32.                          <?php endif; ?>
  33.  
  34.                     <?php endif; ?>
  35.  
  36.                 };
  37.  
  38.             <?php endif; ?>
  39.  
  40.  
  41.             ChatraID = 'eJ4iwDrjhx7LacbTE';
  42.             (function(d, w, c) {
  43.                 var n = d.getElementsByTagName('script')[0],
  44.                     s = d.createElement('script');
  45.                 w[c] = w[c] || function() {
  46.                     (w[c].q = w[c].q || []).push(arguments);
  47.                 };
  48.                 s.async = true;
  49.                 s.src = (d.location.protocol === 'https:' ? 'https:': 'http:')
  50.                     + '//call.chatra.io/chatra.js';
  51.                 n.parentNode.insertBefore(s, n);
  52.             })(document, window, 'Chatra');
  53.  
  54.  
  55.         </script>
  56.         <!-- /Chatra {/literal} -->
  57.  
  58.     <?php endif; ?>
  59.  
  60.     <?php
  61.  
  62. }
  63.  
  64. add_action( 'wp_print_scripts', 'wpf_print_head_scripts' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement