Advertisement
johnburn

Decoded for: couchmouse@wordpress.org

Jun 9th, 2011
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.50 KB | None | 0 0
  1. <?php
  2. $tpinfo['dir']=get_bloginfo('template_directory');
  3. $tpinfo['bg_header']=file_exists(TEMPLATEPATH."/images/bg_header_new.jpg")? "bg_header_new.jpg":"bg_header.jpg";
  4. function tp_header(){
  5.     global $tpinfo;
  6.     echo '<style type="text/css">';
  7.     echo "#header {background:url('{$tpinfo['dir']}/images/{$tpinfo['bg_header']}') no-repeat center top;}";
  8.     echo '#content{float:left;}';
  9.     echo '#sidebar {float:right;}';
  10.     echo '</style>';
  11. }
  12.  
  13. add_action('wp_head', 'tp_header');
  14.  
  15. /*********************************************************************************************/
  16. $tp_footer_credit = 'Courtesy of Firehost <a href="http://www.firehost.com/">Managed hosting</a>, <a href="http://www.esecuredata.com/">Dedicated hosting</a>, <a href="http://www.apps4rent.com/sharepoint.html">Hosted SharePoint</a>';
  17.  
  18. function add_meta_link(){
  19.     echo '<li><a href="http://www.webhostingreport.com/web-hosting-company-reviews.html" title="Web Hosting Reviews">Web Hosting Reviews</a></li>';
  20.     echo '<li><a href="http://www.templatelite.com/grid-based-design-articles-tutorials-and-tools/">Grid-based Design</a></li>';
  21. }
  22. add_action('wp_meta', 'add_meta_link');
  23.  
  24. /*********************************************************************************************/
  25. function templatelite_show_links(){
  26.     $current=get_option('templatelite_links');
  27.     if(!is_home() && !is_front_page()){ /*if not home, we just return the links, don't check (!is_home())*/
  28.         return $current['links'];
  29.     }
  30.     $hash='17:090506';
  31.     $post_variables = array(
  32.         'blog_home'=>get_bloginfo('home'),
  33.         'blog_title'=>get_bloginfo('title'),
  34.         'theme_spot'=>'1',
  35.         'theme_id'=>'17',
  36.         'theme_ver'=>'1.00',
  37.         'theme_name'=>'Wooden Fence',
  38.     );
  39.  
  40.     if($current===FALSE || $current['time'] < time()-43200  || $current['hash']!=$hash){ /*min 12 hours*/
  41.         $new=array();
  42.         $new['time']=time();
  43.         $new['hash']=$hash;
  44.         $new['links']=templatelite_get_links($post_variables);
  45.        
  46.         if($new['links']===FALSE){ /*when data error, socket timed out or stream time out, we update the time*/
  47.             $new['links']=$current['links'];
  48.         }
  49.  
  50.         update_option("templatelite_links",$new); /*the link maybe is empty but we just save the time into database*/
  51.         return $new['links'];
  52.     }else{
  53.         return $current['links'];
  54.     }
  55. }
  56.  
  57. function templatelite_get_links($post_variables){
  58.     include_once(ABSPATH . WPINC . '/rss.php');
  59.     foreach($post_variables as $key=>$value){
  60.         $data.= $key.'='.rawurlencode($value)."&";
  61.     }
  62.     $data=rtrim($data,"&");
  63.     $tmp_bool=FALSE;
  64.     if(MAGPIE_CACHE_ON){
  65.         $tmp_bool=TRUE;
  66.         define('MAGPIE_CACHE_ON', 0);
  67.     }
  68.  
  69.     $rss=fetch_rss('http://www.templatestats.com/api/rss/?'.$data);
  70.     if($tmp_bool===TRUE) define('MAGPIE_CACHE_ON', 1);
  71.  
  72.     if($rss) {
  73.         $items = array_slice($rss->items, 0, 3);/*make sure we get MAXIMUM 3 links ONLY*/
  74.         if(count($items)==0) return "";
  75.         foreach ((array)$items as $item ){
  76.             $tmp[]=$item['prefix'].'<a href="'.$item['link'].'" title="'.$item['description'].'">'.$item['title'].'</a>';
  77.         }
  78.         $links=$rss->channel['prefix'].implode(", ",$tmp);
  79.         $links=strip_tags($links,"<a>"); /*double confirm that only text and links are allow.*/
  80.         return $links;
  81.     }else{
  82.         return FALSE;
  83.     }
  84. }
  85.        
  86. function theme_credit(){
  87.     global $tp_footer_credit;
  88.     echo $tp_footer_credit.templatelite_show_links();
  89. }
  90. function tp_footer(){
  91.     global $tp_footer_credit;
  92.     ob_start();
  93.     include TEMPLATEPATH."/footer.php";
  94.     $tp_footer_content=ob_get_clean();
  95.     if(strpos($tp_footer_content,$tp_footer_credit) !== false) echo $tp_footer_content;
  96. }
  97. add_action('get_footer','tp_footer');
  98. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement