plugin_info = array( 'slug' => 'wp_karmacracy_wdgt', 'version' => '2.0', 'name' => 'WP Karmacracy Widget', 'url' => 'http://karmacracy.com/sections/widget/wordpress/wordpress-plugin.php', 'locale' => 'wp_karmacracy_wdgt', 'path' => plugin_basename(__FILE__) ); $this->plugin_url = rtrim(plugin_dir_url(__FILE__), '/'); $this->plugin_dir = rtrim(plugin_dir_path(__FILE__), '/'); add_action('init', array(&$this, 'init')); //Check if widget is active, and if it is, set the filter. Widget options are in "wp_karmacracy_wdgt-widget" group. $options=get_option($this->get_plugin_info('slug')."-widget"); if ($options["widget_active"]) { switch ($options["widget_location"]) { case "manual": break; case "title": $filter="the_title"; break; case "body": case "beforebody": default: $filter="the_content"; break; } if ($filter!="") { add_filter($filter,array(&$this,'widget_filter')); } } $this->widget_options=$options; } //end constructor /** * add_settings_page() * * Adds an options page to the admin panel area * * */ public function add_settings_page() { add_options_page('Widget Karmacracy', 'Widget Karmacracy', 'manage_options', 'wp_karmacracy_wdgt', array(&$this, 'output_settings')); } //end add_settings_page /** * get_plugin_dir() * * Returns an absolute path to a plugin item * * @param string $path Relative path to make absolute (e.g., /css/image.png) * @return string An absolute path (e.g., /htdocs/ithemes/wp-content/.../css/image.png) */ public function get_plugin_dir($path = '') { $dir = $this->plugin_dir; if (!empty($path) && is_string($path)) $dir .= '/' . ltrim($path, '/'); return $dir; } //end get_plugin_dir /** * get_plugin_info() * * Returns a localized plugin key * * @param string $key Plugin Key to Retrieve * @return mixed The results of the plugin key. False if not present. */ public function get_plugin_info($key = '') { if (array_key_exists($key, $this->plugin_info)) { return $this->plugin_info[$key]; } return false; } //end get_plugin_info /** * get_plugin_url() * * Returns an absolute url to a plugin item * * @param string $path Relative path to plugin (e.g., /css/image.png) * @return string An absolute url (e.g., http://www.domain.com/plugin_url/.../css/image.png) */ public function get_plugin_url($path = '') { $dir = $this->plugin_url; if (!empty($path) && is_string($path)) $dir .= '/' . ltrim($path, '/'); return $dir; } //get_plugin_url /** * init() * * Initializes plugin localization, post types, updaters, plugin info, and adds actions/filters * */ function init() { //Add plugin info require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); $this->plugin_info = wp_parse_args(array_change_key_case(get_plugin_data(__FILE__, false, false), CASE_LOWER), $this->plugin_info); //Admin menu add_action('admin_menu', array(&$this, 'add_settings_page')); } //end function init public function output_settings() { ?>