getAdminOptions(); } /*-------------------------------------------------------------------- Administrative Functions --------------------------------------------------------------------*/ // Option loader function function getAdminOptions() { // Set default values for the options $adminKeyOpt = ""; $adminCalFeedsOpt = "http://www.google.com/calendar/feeds/i8m14fqigtkhpj744qml1vht920bq5j0%40import.calendar.google.com/public/full"; $adminPageMaxEntriesOpt = 15; $adminWikiOpt = "true"; $adminShowNav = "true"; $adminOptions = array($this->adminKeyOptName => $adminKeyOpt, $this->adminCalFeedsOptName => $adminCalFeedsOpt, $this->adminPageMaxEntriesOptName => $adminPageMaxEntriesOpt, $this->adminWikiOptName => $adminWikiOpt, $this->adminShowNavName => $adminShowNav); // Get values from the WP options table in the database, re-assign if found $dbOptions = get_option($this->adminOptionsName); if (!empty($dbOptions)) { foreach ($dbOptions as $key => $option) $adminOptions[$key] = $option; } // Update the options for the panel update_option($this->adminOptionsName, $adminOptions); return $adminOptions; } // Print the admin page for the plugin function printAdminPage() { // Get the admin options $adminOptions = $this->getAdminOptions(); if (isset($_POST['update_wpngCalendarSettings'])) { if (isset($_POST['wpngAPIKey'])) { $adminOptions[$this->adminKeyOptName] = $_POST['wpngAPIKey']; } if (isset($_POST['wpngCalFeeds'])) { $adminOptions[$this->adminCalFeedsOptName] = $_POST['wpngCalFeeds']; } if (isset($_POST['wpngPageMax'])) { $adminOptions[$this->adminPageMaxEntriesOptName] = $_POST['wpngPageMax']; } if (isset($_POST['wpngShowWiki'])) { $adminOptions[$this->adminWikiOptName] = $_POST['wpngShowWiki']; } if (isset($_POST['wpngShowNav'])) { $adminOptions[$this->adminShowNavName] = $_POST['wpngShowNav']; } update_option($this->adminOptionsName, $adminOptions); // update settings notification below ?>
Sidebar title:
'; echo 'Number of events to show:
'; echo ''; } register_sidebar_widget('Austin Tech Events','widgetWPNGCalendar'); register_widget_control('Austin Tech Events','widgetWPNGCalendarOptions', 200, 200); } } } // Instantiate the class if (class_exists("WPNGCalendar")) { $dl_pluginWPNGCal = new WPNGCalendar(); } // Initialize the admin panel if the plugin has been activated if (!function_exists("WPNGCalendar_ap")) { function WPNGCalendar_ap() { global $dl_pluginWPNGCal; if (!isset($dl_pluginWPNGCal)) { return; } if (function_exists('add_options_page')) { add_options_page('Austin Tech Events', 'Austin Tech Events', 9, basename(__FILE__), array(&$dl_pluginWPNGCal, 'printAdminPage')); } } } // Actions and filters if (isset($dl_pluginWPNGCal)) { /*-------------------------------------------------------------------- Actions --------------------------------------------------------------------*/ // Add the admin menu add_action('admin_menu', 'WPNGCalendar_ap'); // Initialize options on plugin activation add_action("activate_austin-tech-events-calendar/austin-tech-events.php", array(&$dl_pluginWPNGCal, 'init')); // Add plugin needs to the header of each page add_action('wp_head', array(&$dl_pluginWPNGCal, 'addJSAPIHeader'), 1); add_action('wp_head', array(&$dl_pluginWPNGCal, 'addWPNGSettings'), 1); add_action('wp_head', array(&$dl_pluginWPNGCal, 'addWPNGHeader'), 1); add_action('wp_head', array(&$dl_pluginWPNGCal, 'addOnLoadScript'), 1); // Add the widget add_action('plugins_loaded', array(&$dl_pluginWPNGCal, 'widgetWPNGCalendarInit'), 1); /*-------------------------------------------------------------------- Filters --------------------------------------------------------------------*/ // Filter to display the calendar in a page add_filter('the_content', array(&$dl_pluginWPNGCal, 'placePageCalendar'), '7'); } ?>