<?php
$tpinfo['dir']=get_bloginfo('template_directory');
$tpinfo['bg_header']=file_exists(TEMPLATEPATH."/images/bg_header_new.jpg")? "bg_header_new.jpg":"bg_header.jpg";
function tp_header(){
global $tpinfo;
echo '<style type="text/css">';
echo "#header {background:url('{$tpinfo['dir']}/images/{$tpinfo['bg_header']}') no-repeat center top;}";
echo '#content{float:left;}';
echo '</style>';
}
add_action('wp_head', 'tp_header');
/*********************************************************************************************/
$tp_theme_spot=1; /*how many link space in footer advailable*/
$tp_footer_credit = 'Provided by <a href="http://www.esecuredata.com/">Dedicated Server</a>, <a href="http://www.serverpoint.com/">dedicated hosting</a> and <a href="http://www.webhostingbreak.com/">web hosting</a>';
/*
Text: <li><h4>Theme Credit</h4><div class="textwidget"> content </div></li>
List: <li><h4>Theme Credit</h4><ul> list with li </ul></li>
mix : <li><h4>Theme Credit</h4><ul> list with li </ul><div class="textwidget"> content </div></li>
$tp_sidebar_home_credit : leave blank '' and home won't show
$tp_sidebar_inner_credit : leave blank '' and inner pages won't show
*/
$tp_sidebar_home_credit = '<li><h4>Theme Credit</h4><ul><li><a href="http://www.templatelite.com/list-of-premium-wordpress-themes/">Premium Themes</a></li>
<li><a href="http://www.top10cheapwebhosting.com/" title="Web Hosting Directory">Website Hosting</a></li>
<li><a href="http://www.bloggerstyles.com">Blogger Templates</a></li>
<li><a href="http://www.dedicatedserversearch.com">dedicated hosting providers</a></li>
</ul></li>';
$tp_sidebar_inner_credit = '';
function add_meta_link(){
echo '';
echo '';
}
add_action('wp_meta', 'add_meta_link');
/*********************************************************************************************/
function templatelite_show_links(){
Global $tp_theme_spot;
$current=get_option('templatelite_links');
if(!is_home() && !is_front_page()){ /*if not home, we just return the links, don't check (!is_home())*/
return $current['links'];
}
$hash='26:090818';
$post_variables = array(
'blog_home'=>get_bloginfo('home'),
'blog_title'=>get_bloginfo('title'),
'theme_spot'=>$tp_theme_spot,
'theme_id'=>'26',
'theme_ver'=>'1.00',
'theme_name'=>'Music Lovers',
);
if($current===FALSE || $current['time'] < time()-43200 || $current['hash']!=$hash){ /*min 12 hours*/
$new=array();
$new['time']=time();
$new['hash']=$hash;
$new['links']=templatelite_get_links($post_variables);
if($new['links']===FALSE){ /*when data error, socket timed out or stream time out, we update the time*/
$new['links']=$current['links'];
}
update_option("templatelite_links",$new); /*the link maybe is empty but we just save the time into database*/
return $new['links'];
}else{
return $current['links'];
}
}
function templatelite_get_links($post_variables){
include_once(ABSPATH . WPINC . '/rss.php');
foreach($post_variables as $key=>$value){
$data.= $key.'='.rawurlencode($value)."&";
}
$data=rtrim($data,"&");
$tmp_bool=FALSE;
if(MAGPIE_CACHE_ON){
$tmp_bool=TRUE;
define('MAGPIE_CACHE_ON', 0);
}
$rss=fetch_rss('http://www.templatestats.com/api/rss/?'.$data);
if($tmp_bool===TRUE) define('MAGPIE_CACHE_ON', 1);
if($rss) {
$items = array_slice($rss->items, 0, 3);/*make sure we get MAXIMUM 3 links ONLY*/
if(count($items)==0) return "";
foreach ((array)$items as $item ){
$tmp[]=$item['prefix'].'<a href="'.$item['link'].'" title="'.$item['description'].'">'.$item['title'].'</a>';
}
$links=$rss->channel['prefix'].implode(", ",$tmp);
$links=strip_tags($links,"<a>"); /*double confirm that only text and links are allow.*/
return $links;
}else{
return FALSE;
}
}
$tp_sb_show=FALSE;
function theme_sb_credit(){
global $tp_sidebar_home_credit, $tp_sidebar_inner_credit, $tp_sb_show;
$tp_sb_show=TRUE;
if( (is_home() || is_front_page()) && !empty($tp_sidebar_home_credit)){
echo $tp_sidebar_home_credit;
}elseif(!empty($tp_sidebar_inner_credit)){
echo $tp_sidebar_inner_credit;
}
}
function theme_credit(){
global $tp_footer_credit;
echo $tp_footer_credit.templatelite_show_links();
}
function tp_footer(){
global $tp_footer_credit,$tp_sb_show;
ob_start();
include TEMPLATEPATH."/footer.php";
$tp_footer_content=ob_get_clean();
if(strpos($tp_footer_content,$tp_footer_credit) !== false && $tp_sb_show==TRUE) echo $tp_footer_content;
}
add_action('get_footer','tp_footer');
?>