Terms of use • Doc/FAQSupport forum — Displays a tile with subscribe buttons. To use, call the_subscribe_links(); where you want the tile to appear. Alternatively, do nothing and the tile will display when wp_meta(); is called. Author: Denis de Bernardy Version: 2.6 Author URI: http://www.semiologic.com */ /* Terms of use ------------ This software is copyright Mesoconcepts Ltd, and is distributed under the terms of the Mesoconcepts license. In a nutshell, you may freely use it for any purpose, but may not redistribute it without written permission. http://www.semiologic.com/legal/license/ Hat tips -------- * James Huff * Duke Thor **/ load_plugin_textdomain('sem-subscribe-me'); if ( !defined('sem_cache_path') ) { define('sem_cache_path', ABSPATH . 'wp-content/cache/'); # same as wp-cache } if ( !defined('sem_cache_timeout') ) { define('sem_cache_timeout', 3600); # one hour } if ( !defined('site_url') ) { define('site_url', trailingslashit(get_settings('siteurl'))); } if ( !defined('site_path') ) { define('site_path', str_replace(('http://' . $_SERVER['HTTP_HOST']), '', site_url)); } class sem_subscribe_me { # # Variables # var $path; var $cache_file; var $captions = array( 'subscribe_to_feed' => 'Subscribe to %feed%', 'syndicate' => 'Syte' ); var $services = array( 'local_feed', 'msn', 'yahoo', 'google', 'bloglines', 'help_link' ); var $service_names = array( 'local_feed' => 'RSS Feed', 'msn' => 'MyMSN', 'yahoo' => 'MyYahoo!', 'google' => 'Google Reader', 'bloglines' => 'Bloglines', 'newsgator' => 'Newsgator', 'feedster' => 'Feedster', 'newsisfree' => 'NewsIsFree', 'help_link' => 'Help with feeds' ); var $service_icons = array( 'local_feed' => 'feed-icon.gif', 'msn' => 'addmymsn.gif', 'yahoo' => 'addmyyahoo.gif', 'google' => 'addgoogle.gif', 'bloglines' => 'addbloglines.gif', 'newsgator' => 'addnewsgator.gif', 'feedster' => 'addmyfeedster.gif', 'newsisfree' => 'addnewsisfree.gif' ); var $service_subscribe_urls = array( 'msn' => 'http://my.msn.com/addtomymsn.armx?id=rss&ut=%feed_url%&ru=%site_url%', 'yahoo' => 'http://add.my.yahoo.com/rss?url=%feed_url%', 'google' => 'http://fusion.google.com/add?feedurl=%feed_url%', 'bloglines' => 'http://www.bloglines.com/sub/%feed_url%', 'newsgator' => 'http://www.newsgator.com/ngs/subscriber/subext.aspx?url=%feed_url%', 'feedster' => 'http://www.feedster.com/myfeedster.php?action=addrss&rssurl=%feed_url%&confirm=no', 'newsisfree' => 'http://www.newsisfree.com/user/sub/?url=%feed_url%' ); # # Constructor # function sem_subscribe_me() { $this->path = str_replace( str_replace("\\", "/", ABSPATH), '', str_replace("\\", "/", dirname(__FILE__)) ); $this->cache_file = sem_cache_path . 'sem-subscribe-me'; $services = get_settings('sem_subscribe_me_services'); if ( $services ) { $this->services =& $services; } else { update_option('sem_subscribe_me_services', $this->services); } if ( isset($_GET['action']) && in_array($_GET['action'], array('flush', 'flush_cache')) ) { $this->flush_cache(); } add_action('wp_meta', array(&$this, 'auto_display'), 5); add_action('admin_menu', array(&$this, 'add2admin_menu')); #add_action('generate_rewrite_rules', array(&$this, 'flush_cache'), 0); add_action('init', array(&$this, 'init')); } # end sem_subscribe_me() # # init() # function init() { global $sem_theme_captions; if ( isset($sem_theme_captions) ) { $this->captions = $sem_theme_captions->register($this->captions); } else { array_walk($this->captions, '__'); } } # end init() # # flush_cache() # function flush_cache() { if ( is_writable(sem_cache_path) ) { #$cache_files = glob($this->cache_file ."*"); $cache_files = glob(sem_cache_path ."*"); if ( $cache_files ) { foreach ( $cache_files as $cache_file ) { if ( is_file($cache_file) && is_writable($cache_file) ) { unlink( $cache_file ); } } } } } # end flush_cache() # # add2admin_menu() # function add2admin_menu() { add_options_page( __('Subscribe Me', 'sem-subscribe-me'), __('Subscribe Me', 'sem-subscribe-me'), 8, str_replace("\\", "/", __FILE__), array(&$this, 'display_admin_page') ); } # end add2admin_menu() # # display_admin_page() # function display_admin_page() { # Process updates, if any if ( isset($_POST['action']) && ( $_POST['action'] == 'update_sem_subscribe_me' ) ) { $this->services = array(); foreach ( $this->service_names as $service_id => $service_name ) { if ( isset($_POST['sem_subscribe_me_' . $service_id]) ) { $this->services[] = $service_id; } } update_option('sem_subscribe_me_services', $this->services); $this->flush_cache(); echo "
\n" . "

" . "" . __('Options saved.', 'sem-subscribe-me') . "" . "

\n" . "
\n"; } # Display admin page $feed_url = apply_filters( 'bloginfo', get_feed_link('rss2'), 'rss2_url' ); foreach ( $this->service_names as $service_id => $service_name ) { if ( !isset($this->captions[$service_id]) ) { $this->captions[$service_id] = __($service_name, 'sem-subscribe-me'); } } echo "
\n" . "

" . __('Syndication Options', 'sem-subscribe-me') . "

\n" . "
\n" . "\n"; echo "
\n" . "" . __('Active syndication services', 'sem-subscribe-me') . "\n" . "

" . __('Select your favorite syndication services.', 'sem-subscribe-me') . "

\n" . "\n"; foreach ( $this->service_names as $service_id => $service_name ) { echo ""; switch ( $service_id ) { case 'local_feed': echo ""; break; case 'help_link': echo ""; break; default: echo ""; break; } echo ""; echo "\n"; } echo "
" . "path . "/" . $this->service_icons[$service_id] . ")" . " center left no-repeat;" . " padding-left: 18px;\"" . ">" . $this->captions[$service_id] . "" . "" . "" . $this->captions[$service_id] . "" . "" . "service_subscribe_urls[$service_id] ) ) . "\"" . ">" . "path . "/" . $this->service_icons[$service_id] . "\"" . " alt=\"" . str_replace( "%feed%", $this->captions[$service_id], $this->captions['subscribe_to_feed'] ) . "\"" . " align=\"middle\"" . " style=\"border: none;\"" . " />" . "" . "" . "" . "
\n" . "
\n" . "

" . "" . "

\n"; echo "
" . "
\n"; } # end display_admin_page() # # display() # function display() { # disable auto_display if ( !defined('sem_subscribe_me_displayed') ) { define('sem_subscribe_me_displayed', true); } # return cache if ( file_exists($this->cache_file) ) { if ( ( filemtime($this->cache_file) + sem_cache_timeout ) >= time() ) { return file_get_contents($this->cache_file); } elseif ( is_writable(sem_cache_path) ) { $this->flush_cache(); } } # display $o = ""; $feed_url = apply_filters( 'bloginfo', get_feed_link('rss2'), 'rss2_url' ); if ( !empty($this->services) ) { foreach ( $this->service_names as $service_id => $service_name ) { if ( !isset($this->captions[$service_id]) ) { $this->captions[$service_id] = __($service_name, 'sem-subscribe-me'); } } $o = "
\n" . "\n" . "
\n"; } if ( is_writable(sem_cache_path) && is_writable($this->cache_file) ) { $fp = fopen($this->cache_file, "w+"); fwrite($fp, $o); fclose($fp); } return $o; } # end display() # # auto_display() # function auto_display() { if ( !defined('sem_subscribe_me_displayed') ) { echo "
  • \n"; $this->display(); echo "
  • \n"; } } # end auto_display() } # end sem_subscribe_me $sem_subscribe_me =& new sem_subscribe_me(); # # Template tags # function the_subscribe_links() { global $sem_subscribe_me; echo $sem_subscribe_me->display(); } # end the_subscribe_links() ######################## # # Backward compatibility # function sem_subscribe_me() { the_subscribe_links(); } # end sem_subscribe_me() ?>