Advertisement
verygoodplugins

Untitled

Jul 6th, 2021
944
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. function wpf_print_head_scripts() {
  2.  
  3.     if ( ! is_admin() ) : ?>
  4.  
  5.         <!-- Chatra {literal} -->
  6.         <script>
  7.  
  8.             <?php if ( is_user_logged_in() ) : ?>
  9.  
  10.                 <?php $current_user = wp_get_current_user(); ?>
  11.  
  12.                 window.ChatraSetup = {
  13.                     clientId: <?php echo $current_user->ID; ?>
  14.                 };
  15.  
  16.                 window.ChatraIntegration = {
  17.                     // main fields
  18.                     name: '<?php echo htmlspecialchars( $current_user->user_firstname . ' ' . $current_user->user_lastname, ENT_QUOTES ); ?>',
  19.                     email: '<?php echo $current_user->user_email; ?>',
  20.  
  21.                 };
  22.  
  23.             <?php endif; ?>
  24.  
  25.  
  26.             ChatraID = 'eJ4iwDrjhx7LacbTE';
  27.             (function(d, w, c) {
  28.                 var n = d.getElementsByTagName('script')[0],
  29.                     s = d.createElement('script');
  30.                 w[c] = w[c] || function() {
  31.                     (w[c].q = w[c].q || []).push(arguments);
  32.                 };
  33.                 s.async = true;
  34.                 s.src = (d.location.protocol === 'https:' ? 'https:': 'http:')
  35.                     + '//call.chatra.io/chatra.js';
  36.                 n.parentNode.insertBefore(s, n);
  37.             })(document, window, 'Chatra');
  38.  
  39.  
  40.         </script>
  41.         <!-- /Chatra {/literal} -->
  42.  
  43.     <?php
  44.  
  45. }
  46.  
  47. add_action( 'wp_print_scripts', 'wpf_print_head_scripts' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement