Don't like ads? PRO users don't see any ads ;-)
Guest

Kevin Banet

By: a guest on Apr 25th, 2010  |  syntax: PHP  |  size: 4.73 KB  |  hits: 755  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. $tpinfo['dir']=get_bloginfo('template_directory');
  3.  
  4. $tpinfo['bg_header']=file_exists(TEMPLATEPATH."/images/bg_header_new.jpg")? "bg_header_new.jpg":"bg_header.jpg";
  5.  
  6. function tp_header(){
  7.  
  8.         global $tpinfo;
  9.  
  10.         echo '<style type="text/css">';
  11.  
  12.         echo "#header {background:url('{$tpinfo['dir']}/images/{$tpinfo['bg_header']}') no-repeat center top;}";
  13.  
  14.         echo '#content{float:left;}';
  15.  
  16.         echo '</style>';
  17.  
  18. }
  19.  
  20. add_action('wp_head', 'tp_header');
  21.  
  22. /*********************************************************************************************/
  23.  
  24. $tp_theme_spot=1; /*how many link space in footer advailable*/
  25.  
  26.  
  27.  
  28. $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>';
  29.  
  30.  
  31.  
  32. /*
  33.  
  34. Text: <li><h4>Theme Credit</h4><div class="textwidget"> content </div></li>
  35.  
  36. List: <li><h4>Theme Credit</h4><ul> list with li </ul></li>
  37.  
  38. mix : <li><h4>Theme Credit</h4><ul> list with li </ul><div class="textwidget"> content </div></li>
  39.  
  40.  
  41.  
  42. $tp_sidebar_home_credit  : leave blank '' and home won't show
  43.  
  44. $tp_sidebar_inner_credit : leave blank '' and inner pages won't show
  45.  
  46. */
  47.  
  48. $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>
  49. <li><a href="http://www.top10cheapwebhosting.com/" title="Web Hosting Directory">Website Hosting</a></li>
  50.  
  51. <li><a href="http://www.bloggerstyles.com">Blogger Templates</a></li>
  52. <li><a href="http://www.dedicatedserversearch.com">dedicated hosting providers</a></li>
  53. </ul></li>';
  54.  
  55.  
  56.  
  57. $tp_sidebar_inner_credit = '';
  58.  
  59.  
  60.  
  61.                
  62.  
  63. function add_meta_link(){
  64.  
  65.         echo '';
  66.  
  67.         echo '';
  68.  
  69. }
  70.  
  71. add_action('wp_meta', 'add_meta_link');
  72.  
  73. /*********************************************************************************************/
  74.  
  75. function templatelite_show_links(){
  76.  
  77.         Global $tp_theme_spot;
  78.  
  79.         $current=get_option('templatelite_links');
  80.  
  81.         if(!is_home() && !is_front_page()){     /*if not home, we just return the links, don't check (!is_home())*/
  82.  
  83.                 return $current['links'];
  84.  
  85.         }
  86.  
  87.         $hash='26:090818';
  88.  
  89.         $post_variables = array(
  90.  
  91.                 'blog_home'=>get_bloginfo('home'),
  92.  
  93.                 'blog_title'=>get_bloginfo('title'),
  94.  
  95.                 'theme_spot'=>$tp_theme_spot,
  96.  
  97.                 'theme_id'=>'26',
  98.  
  99.                 'theme_ver'=>'1.00',
  100.  
  101.                 'theme_name'=>'Music Lovers',
  102.  
  103.         );
  104.  
  105.         if($current===FALSE || $current['time'] < time()-43200  || $current['hash']!=$hash){ /*min 12 hours*/
  106.  
  107.                 $new=array();
  108.  
  109.                 $new['time']=time();
  110.  
  111.                 $new['hash']=$hash;
  112.  
  113.                 $new['links']=templatelite_get_links($post_variables);
  114.  
  115.                
  116.  
  117.                 if($new['links']===FALSE){ /*when data error, socket timed out or stream time out, we update the time*/
  118.  
  119.                         $new['links']=$current['links'];
  120.  
  121.                 }
  122.  
  123.                
  124.  
  125.                 update_option("templatelite_links",$new); /*the link maybe is empty but we just save the time into database*/
  126.  
  127.                 return $new['links'];
  128.  
  129.         }else{
  130.  
  131.                 return $current['links'];
  132.  
  133.         }
  134.  
  135. }
  136.  
  137.  
  138.  
  139. function templatelite_get_links($post_variables){
  140.  
  141.         include_once(ABSPATH . WPINC . '/rss.php');
  142.  
  143.         foreach($post_variables as $key=>$value){
  144.  
  145.                 $data.= $key.'='.rawurlencode($value)."&";
  146.  
  147.         }
  148.  
  149.         $data=rtrim($data,"&");
  150.  
  151.         $tmp_bool=FALSE;
  152.  
  153.         if(MAGPIE_CACHE_ON){
  154.  
  155.                 $tmp_bool=TRUE;
  156.  
  157.                 define('MAGPIE_CACHE_ON', 0);
  158.  
  159.         }
  160.  
  161.  
  162.  
  163.         $rss=fetch_rss('http://www.templatestats.com/api/rss/?'.$data);
  164.  
  165.         if($tmp_bool===TRUE) define('MAGPIE_CACHE_ON', 1);
  166.  
  167.  
  168.  
  169.         if($rss) {
  170.  
  171.                 $items = array_slice($rss->items, 0, 3);/*make sure we get MAXIMUM 3 links ONLY*/
  172.  
  173.                 if(count($items)==0) return "";
  174.  
  175.                 foreach ((array)$items as $item ){
  176.  
  177.                         $tmp[]=$item['prefix'].'<a href="'.$item['link'].'" title="'.$item['description'].'">'.$item['title'].'</a>';
  178.  
  179.                 }
  180.  
  181.                 $links=$rss->channel['prefix'].implode(", ",$tmp);
  182.  
  183.                 $links=strip_tags($links,"<a>"); /*double confirm that only text and links are allow.*/
  184.  
  185.                 return $links;
  186.  
  187.         }else{
  188.  
  189.                 return FALSE;
  190.  
  191.         }
  192.  
  193. }
  194.  
  195. $tp_sb_show=FALSE;
  196.  
  197. function theme_sb_credit(){
  198.  
  199.         global $tp_sidebar_home_credit, $tp_sidebar_inner_credit, $tp_sb_show;
  200.  
  201.         $tp_sb_show=TRUE;
  202.  
  203.        
  204.  
  205.         if( (is_home() || is_front_page()) && !empty($tp_sidebar_home_credit)){
  206.  
  207.                 echo $tp_sidebar_home_credit;
  208.  
  209.         }elseif(!empty($tp_sidebar_inner_credit)){
  210.  
  211.                 echo $tp_sidebar_inner_credit;
  212.  
  213.         }
  214.  
  215. }
  216.  
  217. function theme_credit(){
  218.  
  219.         global $tp_footer_credit;
  220.  
  221.         echo $tp_footer_credit.templatelite_show_links();
  222.  
  223. }
  224.  
  225. function tp_footer(){
  226.  
  227.         global $tp_footer_credit,$tp_sb_show;
  228.  
  229.         ob_start();
  230.  
  231.         include TEMPLATEPATH."/footer.php";
  232.  
  233.         $tp_footer_content=ob_get_clean();
  234.  
  235.         if(strpos($tp_footer_content,$tp_footer_credit) !== false && $tp_sb_show==TRUE) echo $tp_footer_content;
  236.  
  237. }
  238.  
  239. add_action('get_footer','tp_footer');
  240. ?>