Browse Source

Merge pull request #2 from fahmi182/master

Add Google Analytics & Class Hide by @fahmi182
pull/4/merge
Danang Probo Sayekti 12 years ago
parent
commit
a952a3a4f9
4 changed files with 33 additions and 4 deletions
  1. +3
    -0
      system/config.ini
  2. +21
    -1
      system/includes/functions.php
  3. +6
    -1
      themes/default/css/style.css
  4. +3
    -2
      themes/default/layout.html.php

+ 3
- 0
system/config.ini 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"


+ 21
- 1
system/includes/functions.php 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);
}
}

+ 6
- 1
themes/default/css/style.css 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%;
}
}
}

+ 3
- 2
themes/default/layout.html.php 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>

Loading…
Cancel
Save