Skip to content

Commit

Permalink
Merge pull request #1382 from roots/QWp6t-ga
Browse files Browse the repository at this point in the history
Move GA snippet to roots/soil
  • Loading branch information
retlehs committed Mar 13, 2015
2 parents d240605 + 67acc1a commit 403ec06
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 30 deletions.
30 changes: 0 additions & 30 deletions lib/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,33 +141,3 @@ function jquery_local_fallback($src, $handle = null) {
return $src;
}
add_action('wp_head', __NAMESPACE__ . '\\jquery_local_fallback');

/**
* Google Analytics snippet from HTML5 Boilerplate
*
* Cookie domain is 'auto' configured. See: http://goo.gl/VUCHKM
*/
function google_analytics() {
?>
<script>
<?php if (WP_ENV === 'production' && !current_user_can('manage_options')) : ?>
(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 : ?>
function ga() {
if (window.console) {
console.log('Google Analytics: ' + [].slice.call(arguments));
}
}
<?php endif; ?>
ga('create','<?= GOOGLE_ANALYTICS_ID; ?>','auto');ga('send','pageview');
</script>
<?php
}

if (GOOGLE_ANALYTICS_ID) {
add_action('wp_footer', __NAMESPACE__ . '\\google_analytics', 20);
}
1 change: 1 addition & 0 deletions lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
add_theme_support('soil-clean-up'); // Enable clean up from Soil
add_theme_support('soil-relative-urls'); // Enable relative URLs from Soil
add_theme_support('soil-nice-search'); // Enable nice search from Soil
add_theme_support('soil-google-analytics'); // Enable H5BP's Google Analytics snippet
add_theme_support('bootstrap-gallery'); // Enable Bootstrap's thumbnails component on [gallery]
add_theme_support('jquery-cdn'); // Enable to load jQuery from the Google CDN

Expand Down

0 comments on commit 403ec06

Please sign in to comment.