Merge pull request #1382 from roots/QWp6t-ga

Move GA snippet to roots/soil
This commit is contained in:
Ben Word
2015-03-13 10:59:04 -05:00
2 changed files with 1 additions and 30 deletions

View File

@@ -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);
}

View File

@@ -10,6 +10,7 @@ use Roots\Sage;
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