Move Google Analytics code into footer template
Once again, HTML tags should be in the templates when possible. actions.php is no longer needed now as well.
This commit is contained in:
@@ -12,7 +12,6 @@ require_once locate_template('/lib/cleanup.php'); // Cleanup
|
||||
require_once locate_template('/lib/htaccess.php'); // Rewrites for assets, H5BP .htaccess
|
||||
require_once locate_template('/lib/widgets.php'); // Sidebars and widgets
|
||||
require_once locate_template('/lib/template-tags.php'); // Template tags
|
||||
require_once locate_template('/lib/actions.php'); // Actions
|
||||
require_once locate_template('/lib/scripts.php'); // Scripts and stylesheets
|
||||
require_once locate_template('/lib/post-types.php'); // Custom post types
|
||||
require_once locate_template('/lib/metaboxes.php'); // Custom metaboxes
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Add the asynchronous Google Analytics snippet from HTML5 Boilerplate
|
||||
* if an ID is defined in config.php
|
||||
*
|
||||
* @link mathiasbynens.be/notes/async-analytics-snippet
|
||||
*/
|
||||
function roots_google_analytics() {
|
||||
if (GOOGLE_ANALYTICS_ID) {
|
||||
echo "\n\t<script>\n";
|
||||
echo "\t\tvar _gaq=[['_setAccount','" . GOOGLE_ANALYTICS_ID . "'],['_trackPageview']];\n";
|
||||
echo "\t\t(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];\n";
|
||||
echo "\t\tg.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';\n";
|
||||
echo "\t\ts.parentNode.insertBefore(g,s)}(document,'script'));\n";
|
||||
echo "\t</script>\n";
|
||||
}
|
||||
}
|
||||
|
||||
add_action('wp_footer', 'roots_google_analytics');
|
||||
@@ -3,4 +3,13 @@
|
||||
<p>© <?php echo date('Y'); ?> <?php bloginfo('name'); ?></p>
|
||||
</footer>
|
||||
|
||||
<?php wp_footer(); ?>
|
||||
<?php if (GOOGLE_ANALYTICS_ID): ?>
|
||||
<script>
|
||||
var _gaq=[['_setAccount','<?php echo GOOGLE_ANALYTICS_ID; ?>'],['_trackPageview']];
|
||||
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
||||
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
|
||||
s.parentNode.insertBefore(g,s)}(document,'script'));
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php wp_footer(); ?>
|
||||
|
||||
Reference in New Issue
Block a user