Always load GA snippet when not in production

This commit is contained in:
QWp6t
2014-08-06 21:57:32 -07:00
parent dc0e838c2f
commit dd7635ced8

View File

@@ -84,21 +84,21 @@ add_action('wp_head', 'roots_jquery_local_fallback');
*/
function roots_google_analytics() { ?>
<script>
<?php if(WP_ENV==='production') :?>
<?php if (WP_ENV === 'production') : ?>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
<?php else: ?>
<?php else : ?>
function ga() {
console.log("GoogleAnalytics: " + [].slice.call(arguments));
console.log('GoogleAnalytics: ' + [].slice.call(arguments));
}
<?php endif; ?>
ga('create','<?php echo GOOGLE_ANALYTICS_ID; ?>','auto');ga('send','pageview');
</script>
<?php }
if (GOOGLE_ANALYTICS_ID && !current_user_can('manage_options')) {
if (GOOGLE_ANALYTICS_ID && (WP_ENV !== 'production' || !current_user_can('manage_options'))) {
add_action('wp_footer', 'roots_google_analytics', 20);
}