__construct(); } /** * PHP5 constructor */ function __construct() { // Get directory name (default: rss-links-manager) $dirname = dirname(plugin_basename(__FILE__)); // Get i18n file load_plugin_textdomain($this->textdomain, false, "$dirname/i18n/"); // Get feed settings $this->get_options(); // Remove main and comments feed remove_action('wp_head', 'feed_links', 2); // Remove extra feeds if disabled if($this->options['extras']['status'] === false) remove_action('wp_head', 'feed_links_extra', 3); // Add custom feed links to wp_head add_action('wp_head', array(&$this, 'feed_links'), 2); // Add plugin options link to admin menu add_action('admin_menu', array(&$this, 'admin_menu_link')); // Add settings link to plugin page add_filter('plugin_row_meta', array(&$this, 'plugin_settings_link'), 10, 2); // Register uninstall hook register_uninstall_hook(__FILE__, array(&$this, 'uninstall')); } /** * Add plugin options page */ function admin_menu_link() { add_options_page('RSS Links Manager', 'RSS Links Manager', 'manage_options', basename(__FILE__), array(&$this, 'admin_options_page')); } /** * Add settings link to the plugin's link array */ function plugin_settings_link($links, $file) { $basename = plugin_basename(__FILE__); if($file == $basename) { $links[] = '' . __('Settings', $this->textdomain) . ''; } return $links; } /** * Get plugin options */ function get_options() { if(!$options = get_option($this->options_name)) { // Default options $options = array( 'main' => array( 'url' => get_bloginfo('url') . '/feed/', 'title' => get_bloginfo('name') . ' » Feed', 'type' => feed_content_type(), 'status'=> true ), 'comments' => array( 'url' => get_bloginfo('url') . '/comments/feed/', 'title' => get_bloginfo('name') . ' » Comments Feed', 'type' => feed_content_type(), 'status'=> true ), 'extras' => array( 'status'=> true ) ); update_option($this->options_name, $options); } $this->options = $options; } /** * Plugin options page */ function admin_options_page() { // Save options if(isset($_POST['rss_links_manager_save'])) { if(wp_verify_nonce($_POST['_wpnonce'], 'rss-links-manager-update-options')) { $this->options = array( 'main' => array( 'url' => $_POST['feed_url'], 'title' => $_POST['feed_title'], 'type' => $_POST['feed_type'], 'status'=> (isset($_POST['feed_status']) && $_POST['feed_status'] === 'on') ? true : false ), 'comments' => array( 'url' => $_POST['coms_url'], 'title' => $_POST['coms_title'], 'type' => $_POST['coms_type'], 'status'=> (isset($_POST['coms_status']) && $_POST['coms_status'] === 'on') ? true : false ), 'extras' => array( 'status'=> (isset($_POST['extra_status']) && $_POST['extra_status'] === 'on') ? true : false ) ); update_option($this->options_name, $this->options); echo '

' . __('Your changes were successfully saved!', $this->textdomain) . '

'; } else { echo '

' . __('Whoops! There was a problem with the data you posted. Please try again.', $this->textdomain) . '

'; } } ?>

RSS Links Manager

textdomain); ?>

options; // Remove extra feeds array unset($feeds['extras']); // Output feed links foreach($feeds as $feed) { if($feed['status'] === true) { echo '\n"; } } } /** * Uninstall hook */ function uninstall() { if(__FILE__ != WP_UNINSTALL_PLUGIN) return; // Delete options on uninstall delete_option($this->options_name); } } } // Initialise plugin if(class_exists('RSSLinksManager')) new RSSLinksManager(); ?>