Advertisement
johnburn

Untitled

May 5th, 2011
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.36 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 '</style>';
  10. }
  11.  
  12. add_action('wp_head', 'tp_header');
  13. /*********************************************************************************************/
  14. $tp_credit_footer = 'Supported by <a href="http://www.themegrade.com/" target="_blank">Wordpress Themes</a>, <a href="http://www.apps4rent.com/virtual-dedicated-private-server-windows-hyper-v-vds-vs-vps-hosting/virtual-dedicated-server.html" target="_blank">Virtual Dedicated Servers</a>,  <a href="http://www.naruko.sg/" target="_blank">Niu Er</a>';
  15. $tp_credit_footer_HomeOnly=FALSE; /* FALSE or TRUE : TRUE will show only home/front page ( include page 2,3,4... ); FALSE show on every pages */
  16.  
  17. /*
  18. Text: <li><h4>Theme Credit</h4><div class="textwidget"> content </div></li>
  19. List: <li><h4>Theme Credit</h4><ul> list with li </ul></li>
  20. mix : <li><h4>Theme Credit</h4><ul> list with li </ul><div class="textwidget"> content </div></li>
  21. $tp_credit_sb_home  and $tp_credit_sb_inner : won't show is leave blank ''
  22. */
  23.  
  24. $tp_credit_sb_home  = '<li><h4>Theme Credit</h4><ul>'.
  25. '<li><a href="http://www.singlehop.com/cloud/" target="_blank">Cloud Hosting</a></li>'.
  26. '</ul></li>';
  27.  
  28. $tp_credit_sb_inner = '';
  29.  
  30. /*********************************************************************************************/
  31. function theme_credit(){
  32.     Global $tpinfo,$tp_credit_footer,$tp_credit_sb_home,$tp_credit_sb_inner,$tp_credit_footer_HomeOnly;
  33.     $current=get_option('templatelite_links');
  34.     $hash='18:100918';
  35.     $post_variables = array(
  36.         'blog_home'=>get_bloginfo('wpurl'),
  37.         'blog_title'=>get_bloginfo('name'),
  38.         'theme_style'=>$tpinfo[$tpinfo['tb_prefix'].'_stylesheet'],
  39.         'theme_id'=>'18',
  40.         'theme_ver'=>'1.00',
  41.         'theme_name'=>'Paper Craft',
  42.         'link_footer'=>$tp_credit_footer,
  43.         'link_sb_home'=>$tp_credit_sb_home,
  44.         'link_sb_inner'=>$tp_credit_sb_inner,
  45.        
  46.     );
  47.     if(!isset($current['time']) || $current['time'] < time()-172800) $current=FALSE; /*min 48 hours*/
  48.     if(!isset($current['hash']) || $current['hash']!=$hash) $current=FALSE;
  49.    
  50.     if($current===FALSE){
  51.         $new=array();
  52.         $new['time']=time();
  53.         $new['hash']=$hash;
  54.         $new['links']=templatelite_get_links($post_variables);
  55.        
  56.         if($new['links']===FALSE){
  57.             if(!empty($current['links'])){
  58.                 $new['links']=$current['links'];
  59.             }else{
  60.                 $new['links']=$tp_credit_footer;
  61.             }
  62.         }elseif($new['links']=='--'){
  63.             $new['links']=$tp_credit_footer;
  64.         }
  65.        
  66.         $new['links']=strip_tags($new['links'],"<a>"); /*make sure only text and link are allow.*/
  67.        
  68.         update_option("templatelite_links",$new);
  69.         $return_link= $new['links'];
  70.     }else{
  71.         $return_link= $current['links'];
  72.     }
  73.  
  74.     if( $tp_credit_footer_HomeOnly===FALSE || (is_home() || is_front_page()) ){
  75.         echo $return_link;
  76.     }
  77. }
  78. function templatelite_get_links($post_variables){
  79.     if(!class_exists('WP_Http')) include_once(ABSPATH.WPINC.'/class-http.php' );
  80.     $request = new WP_Http;
  81.     $url="http://www.templatestats.com/api/api.v2.php";
  82.     /*$url="http://templatestats:88/api/api.v2.php";*/
  83.     $result = @$request->request($url,array( 'method' => 'POST', 'body' => $post_variables));
  84.  
  85.     if(!isset($result->errors) && isset($result['response']['code']) && $result['response']['code']==200){
  86.         return trim($result['body']);
  87.     }
  88.     return FALSE;
  89. }
  90.        
  91. $tp_sb_show=FALSE;
  92. function theme_sb_credit(){
  93.     global $tp_credit_sb_home, $tp_credit_sb_inner, $tp_sb_show;
  94.     $tp_sb_show=TRUE;
  95.    
  96.     if( (is_home() || is_front_page()) && !empty($tp_credit_sb_home)){
  97.         echo $tp_credit_sb_home;
  98.     }elseif(!empty($tp_credit_sb_inner)){
  99.         echo $tp_credit_sb_inner;
  100.     }
  101. }
  102.  
  103. function tp_footer(){
  104.     global $tp_sb_show,$tp_credit_footer_HomeOnly;
  105.     if($tp_credit_footer_HomeOnly===FALSE || (is_home() || is_front_page()) ){
  106.         ob_start();
  107.         include TEMPLATEPATH."/footer.php";
  108.         $current=get_option('templatelite_links');
  109.         $tp_footer_content=ob_get_clean();
  110.         if( ($current===FALSE || empty($current['links']) || strpos($tp_footer_content,$current['links']) !== false ) && $tp_sb_show==TRUE ){
  111.             echo $tp_footer_content;
  112.         }
  113.     }
  114. }
  115. add_action('get_footer','tp_footer');
  116. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement