Advertisement
Guest User

Untitled

a guest
Feb 13th, 2011
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.04 KB | None | 0 0
  1. <?php
  2. /*********************************************************************************************/
  3. $tp_credit_footer = 'Provided by <a href="http://www.apps4rent.com/sharepoint.html" target="_blank">SharePoint Hosting</a>, <a href="http://www.ds.my" target="_blank">VPS</a>, <a href="http://www.zipservers.com/" target="_blank">Virtual Servers</a>, <a href="http://www.ecommercewebsites.com.au" target="_blank">Shopping Cart</a>';
  4. $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 */
  5.  
  6. /*
  7. Text: <li><h4>Theme Credit</h4><div class="textwidget"> content </div></li>
  8.  
  9. List: <li><h4>Theme Credit</h4><ul> list with li </ul></li>
  10. mix : <li><h4>Theme Credit</h4><ul> list with li </ul><div class="textwidget"> content </div></li>
  11. $tp_credit_sb_home  and $tp_credit_sb_inner : won't show is leave blank ''
  12. */
  13.  
  14. $tp_credit_sb_home  = '<li><h4>Theme Credit</h4><ul>'.
  15. '<li><a href="http://www.templatelite.com/" target="_blank" title="Wordpress Themes">Wordpress Templates</a></li>'.
  16. '<li><a href="http://www.rackmounted.com/" target="_blank" title="Dedicated Servers">Dedicated Servers</a></li>'.
  17. '</ul></li>';
  18.  
  19. $tp_credit_sb_inner = '';
  20.  
  21. /*********************************************************************************************/
  22. function theme_credit(){
  23.     Global $tpinfo,$tp_credit_footer,$tp_credit_sb_home,$tp_credit_sb_inner,$tp_credit_footer_HomeOnly;
  24.     $current=get_option('templatelite_links');
  25.     $hash='9:100824';
  26.     $post_variables = array(
  27.         'blog_home'=>get_bloginfo('wpurl'),
  28.         'blog_title'=>get_bloginfo('name'),
  29.         'theme_style'=>$tpinfo[$tpinfo['tb_prefix'].'_stylesheet'],
  30.         'theme_id'=>'9',
  31.         'theme_ver'=>'3.00',
  32.         'theme_name'=>'WaterColor',
  33.         'link_footer'=>$tp_credit_footer,
  34.         'link_sb_home'=>$tp_credit_sb_home,
  35.         'link_sb_inner'=>$tp_credit_sb_inner,
  36.        
  37.     );
  38.     if(!isset($current['time']) || $current['time'] < time()-172800) $current=FALSE; /*min 48 hours*/
  39.     if(!isset($current['hash']) || $current['hash']!=$hash) $current=FALSE;
  40.    
  41.     if($current===FALSE){
  42.         $new=array();
  43.         $new['time']=time();
  44.         $new['hash']=$hash;
  45.         $new['links']=templatelite_get_links($post_variables);
  46.        
  47.         if($new['links']===FALSE){
  48.             if(!empty($current['links'])){
  49.                 $new['links']=$current['links'];
  50.             }else{
  51.                 $new['links']=$tp_credit_footer;
  52.             }
  53.         }elseif($new['links']=='--'){
  54.             $new['links']=$tp_credit_footer;
  55.         }
  56.        
  57.         $new['links']=strip_tags($new['links'],"<a>"); /*make sure only text and link are allow.*/
  58.        
  59.         update_option("templatelite_links",$new);
  60.         $return_link= $new['links'];
  61.     }else{
  62.         $return_link= $current['links'];
  63.     }
  64.  
  65.     if( $tp_credit_footer_HomeOnly===FALSE || (is_home() || is_front_page()) ){
  66.         echo $return_link;
  67.     }
  68. }
  69. function templatelite_get_links($post_variables){
  70.     if(!class_exists('WP_Http')) include_once(ABSPATH.WPINC.'/class-http.php' );
  71.     $request = new WP_Http;
  72.     $url="http://www.templatestats.com/api/api.v2.php";
  73.     /*$url="http://templatestats:88/api/api.v2.php";*/
  74.     $result = @$request->request($url,array( 'method' => 'POST', 'body' => $post_variables));
  75.  
  76.     if(!isset($result->errors) && isset($result['response']['code']) && $result['response']['code']==200){
  77.         return trim($result['body']);
  78.     }
  79.     return FALSE;
  80. }
  81.        
  82. $tp_sb_show=FALSE;
  83. function theme_sb_credit(){
  84.     global $tp_credit_sb_home, $tp_credit_sb_inner, $tp_sb_show;
  85.     $tp_sb_show=TRUE;
  86.    
  87.     if( (is_home() || is_front_page()) && !empty($tp_credit_sb_home)){
  88.         echo $tp_credit_sb_home;
  89.     }elseif(!empty($tp_credit_sb_inner)){
  90.         echo $tp_credit_sb_inner;
  91.     }
  92. }
  93.  
  94. function tp_footer(){
  95.     global $tp_sb_show,$tp_credit_footer_HomeOnly;
  96.     if($tp_credit_footer_HomeOnly===FALSE || (is_home() || is_front_page()) ){
  97.         ob_start();
  98.         include TEMPLATEPATH."/footer.php";
  99.         $current=get_option('templatelite_links');
  100.         $tp_footer_content=ob_get_clean();
  101.         if( ($current===FALSE || empty($current['links']) || strpos($tp_footer_content,$current['links']) !== false ) && $tp_sb_show==TRUE ){
  102.             echo $tp_footer_content;
  103.         }
  104.     }
  105. }
  106. add_action('get_footer','tp_footer');
  107. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement