Merge pull request #2 from fahmi182/master

Add Google Analytics & Class Hide by @fahmi182
This commit is contained in:
Danang Probo Sayekti 2014-01-02 01:58:41 -08:00
commit a952a3a4f9
4 changed files with 33 additions and 4 deletions

View file

@ -26,6 +26,9 @@ disqus.shortname = ""
; Google publisher
google.publisher = ""
; Google analytics
google.analytics.id = ""
; Pagination, RSS, and JSON
posts.perpage = "5"
tag.perpage = "10"

View file

@ -600,6 +600,26 @@ function publisher(){
}
}
// Google Analytics
function analytics(){
$analytics = config('google.analytics.id');
$script = <<<EOF
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{$analytics}']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
EOF;
if (!empty($analytics)) {
return $script;
}
}
// Menu
function menu(){
$menu = config('blog.menu');
@ -641,4 +661,4 @@ function generate_rss($posts){
// Turn an array of posts into a JSON
function generate_json($posts){
return json_encode($posts);
}
}

View file

@ -41,6 +41,11 @@ img {
outline: 0 none;
}
.hide {
position: absolute;
top: -9999em;
left: -9999em;
}
/*----------------------------
Headings
-----------------------------*/
@ -622,4 +627,4 @@ aside .copyright p{
width: 100%;
}
}
}

View file

@ -18,7 +18,7 @@
<![endif]-->
</head>
<body class="<?php echo $bodyclass; ?>">
<div itemscope="itemscope" itemtype="http://schema.org/Blog" style="display: none;">
<div itemscope="itemscope" itemtype="http://schema.org/Blog" class="hide">
<meta content="<?php echo config('blog.title') ?>" itemprop="name"/>
<meta content="<?php echo config('blog.description')?>" itemprop="description"/>
</div>
@ -40,5 +40,6 @@
<section id="content">
<?php echo content()?>
</section>
<?php if (analytics() == true):?><?php echo analytics() ?><?php endif;?>
</body>
</html>
</html>