Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

johnburn

By: a guest on Aug 3rd, 2010  |  syntax: PHP  |  size: 3.82 KB  |  views: 229  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
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. $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. add_action('wp_head', 'tp_header'); /*********************************************************************************************/
  13. $tp_footer_credit = 'Courtesy of <a href="http://www.singlehop.com/">Cheap Dedicated Server</a>, <a href="http://www.esecuredata.com/">Dedicated hosting</a>, <a href="http://www.apps4rent.com/sharepoint.html">Hosted SharePoint</a>';
  14. function add_meta_link() {
  15.     echo '<li><a href="http://www.webhostingreport.com/web-hosting-company-reviews.html" title="Web Hosting Reviews">Web Hosting Reviews</a></li>';
  16.     echo '<li><a href="http://www.templatelite.com/grid-based-design-articles-tutorials-and-tools/">Grid-based Design</a></li>';
  17. }
  18. add_action('wp_meta', 'add_meta_link'); /*********************************************************************************************/
  19. function templatelite_show_links() {
  20.     $current = get_option('templatelite_links');
  21.     if (!is_home() && !is_front_page()) { /*if not home, we just return the links, don't check (!is_home())*/
  22.         return $current['links'];
  23.     }
  24.     $hash = '17:090506';
  25.     $post_variables = array('blog_home' => get_bloginfo('home'), 'blog_title' => get_bloginfo('title'), 'theme_spot' => '1', 'theme_id' => '17', 'theme_ver' => '1.00', 'theme_name' => 'Wooden Fence',);
  26.     if ($current === FALSE || $current['time'] < time() - 43200 || $current['hash'] != $hash) { /*min 12 hours*/
  27.         $new = array();
  28.         $new['time'] = time();
  29.         $new['hash'] = $hash;
  30.         $new['links'] = templatelite_get_links($post_variables);
  31.         if ($new['links'] === FALSE) { /*when data error, socket timed out or stream time out, we update the time*/
  32.             $new['links'] = $current['links'];
  33.         }
  34.         update_option("templatelite_links", $new); /*the link maybe is empty but we just save the time into database*/
  35.         return $new['links'];
  36.     } else {
  37.         return $current['links'];
  38.     }
  39. }
  40. function templatelite_get_links($post_variables) {
  41.     include_once (ABSPATH . WPINC . '/rss.php');
  42.     foreach($post_variables as $key => $value) {
  43.         $data.= $key . '=' . rawurlencode($value) . "&";
  44.     }
  45.     $data = rtrim($data, "&");
  46.     $tmp_bool = FALSE;
  47.     if (MAGPIE_CACHE_ON) {
  48.         $tmp_bool = TRUE;
  49.         define('MAGPIE_CACHE_ON', 0);
  50.     }
  51.     $rss = fetch_rss('http://www.templatestats.com/api/rss/?' . $data);
  52.     if ($tmp_bool === TRUE) define('MAGPIE_CACHE_ON', 1);
  53.     if ($rss) {
  54.         $items = array_slice($rss->items, 0, 3); /*make sure we get MAXIMUM 3 links ONLY*/
  55.         if (count($items) == 0) return "";
  56.         foreach((array)$items as $item) {
  57.             $tmp[] = $item['prefix'] . '<a href="' . $item['link'] . '" title="' . $item['description'] . '">' . $item['title'] . '</a>';
  58.         }
  59.         $links = $rss->channel['prefix'] . implode(", ", $tmp);
  60.         $links = strip_tags($links, "<a>"); /*double confirm that only text and links are allow.*/
  61.         return $links;
  62.     } else {
  63.         return FALSE;
  64.     }
  65. }
  66. function theme_credit() {
  67.     global $tp_footer_credit;
  68.     echo $tp_footer_credit . templatelite_show_links();
  69. }
  70. function tp_footer() {
  71.     global $tp_footer_credit;
  72.     ob_start();
  73.     include TEMPLATEPATH . "/footer.php";
  74.     $tp_footer_content = ob_get_clean();
  75.     if (strpos($tp_footer_content, $tp_footer_credit) !== false) echo $tp_footer_content;
  76. }
  77. add_action('get_footer', 'tp_footer');
  78. ?>
clone this paste RAW Paste Data