header cleanup including moving google analytics to the roots_head hook

This commit is contained in:
Ben Word
2011-06-26 20:07:36 -06:00
parent d92a532ad2
commit a088b21d9c
2 changed files with 61 additions and 51 deletions

View File

@@ -1,5 +1,6 @@
<?php
add_action('roots_head', 'roots_google_analytics');
add_action('roots_head', 'roots_1140_head');
add_action('roots_head', 'roots_adapt_head');
add_action('roots_header_before', 'roots_1140_header_before');
@@ -8,12 +9,26 @@ add_action('roots_footer_before', 'roots_1140_footer_before');
add_action('roots_footer_after', 'roots_1140_footer_after');
add_action('roots_post_inside_before', 'roots_page_breadcrumb');
function roots_google_analytics() {
global $roots_options;
$google_analytics_id = $roots_options['google_analytics_id'];
$get_google_analytics_id = esc_attr($roots_options['google_analytics_id']);
if ($google_analytics_id !== '') {
echo "\n\t<script>\n";
echo "\t\tvar _gaq=[['_setAccount','$get_google_analytics_id'],['_trackPageview'],['_trackPageLoadTime']];\n";
echo "\t\t(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;\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";
}
}
function roots_1140_head() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
$template_uri = get_template_directory_uri();
if ($roots_css_framework === '1140') {
echo "<script src=\"$template_uri/js/libs/css3-mediaqueries.js\"></script>";
echo "\t<script src=\"$template_uri/js/libs/css3-mediaqueries.js\"></script>";
}
}
@@ -22,21 +37,21 @@ function roots_adapt_head() {
$roots_css_framework = $roots_options['css_framework'];
$template_uri = get_template_directory_uri();
if ($roots_css_framework === 'adapt') {
echo "<script>\n";
echo "var ADAPT_CONFIG = {\n";
echo " path: '/css/adapt/',\n";
echo " dynamic: true,\n";
echo " range: [\n";
echo " '0px to 760px = mobile.css',\n";
echo " '760px to 980px = 720.css',\n";
echo " '980px to 1280px = 960.css',\n";
echo " '1280px to 1600px = 1200.css',\n";
echo " '1600px to 1920px = 1560.css',\n";
echo " '1920px = fluid.css'\n";
echo " ]\n";
echo "};\n";
echo "</script>\n";
echo "<script src=\"$template_uri/js/libs/adapt.min.js\"></script>";
echo "\n\t<script>\n";
echo "\t\tvar ADAPT_CONFIG = {\n";
echo "\t\t\tpath: '/css/adapt/',\n";
echo "\t\t\tdynamic: true,\n";
echo "\t\t\trange: [\n";
echo "\t\t\t\t'0px to 760px = mobile.css',\n";
echo "\t\t\t\t'760px to 980px = 720.css',\n";
echo "\t\t\t\t'980px to 1280px = 960.css',\n";
echo "\t\t\t\t'1280px to 1600px = 1200.css',\n";
echo "\t\t\t\t'1600px to 1920px = 1560.css',\n";
echo "\t\t\t\t'1920px = fluid.css'\n";
echo "\t\t\t]\n";
echo "\t\t};\n";
echo "\t</script>\n";
echo "\t<script src=\"$template_uri/js/libs/adapt.min.js\"></script>";
}
}
@@ -44,7 +59,7 @@ function roots_1140_header_before() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === '1140') {
echo "<div class=\"row\">";
echo "<div class=\"row\">\n";
}
}
@@ -52,8 +67,8 @@ function roots_1140_header_after() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === '1140') {
echo "</div><!-- /.row -->";
echo "<div class=\"row\">";
echo "</div><!-- /.row -->\n";
echo "<div class=\"row\">\n";
}
}
@@ -61,8 +76,8 @@ function roots_1140_footer_before() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === '1140') {
echo "</div><!-- /.row -->";
echo "<div class=\"row\">";
echo "</div><!-- /.row -->\n";
echo "<div class=\"row\">\n";
}
}
@@ -70,7 +85,7 @@ function roots_1140_footer_after() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === '1140') {
echo "</div><!-- /.row -->";
echo "</div><!-- /.row -->\n";
}
}