Skip to content

Instantly share code, notes, and snippets.

@hereswhatidid
Created September 19, 2013 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hereswhatidid/6625490 to your computer and use it in GitHub Desktop.
Save hereswhatidid/6625490 to your computer and use it in GitHub Desktop.
Add custom javascript to page head in WordPress
<?php
add_action( 'wp_head', 'header_scripts' );
function header_scripts() {
echo '<!--Start of Zopim Live Chat Script-->'."\n";
echo '<script type="text/javascript">'."\n";
echo 'window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s='."\n";
echo 'd.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.'."\n";
echo '_.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute(\'charset\',\'utf-8\');'."\n";
echo '$.src=\'//v2.zopim.com/?1JmbWASHEGvl7oxKGkdaQzNfQYWLE7El\';z.t=+new Date;$.'."\n";
echo 'type=\'text/javascript\';e.parentNode.insertBefore($,e)})(document,\'script\');'."\n";
echo '</script>'."\n";
echo '<!--End of Zopim Live Chat Script-->'."\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment