__construct();} /** * PHP 5 Constructor */ function __construct(){ //Language Setup $locale = get_locale(); $mo = dirname(__FILE__) . "/languages/" . $this->localizationDomain . "-".$locale.".mo"; load_textdomain($this->localizationDomain, $mo); //"Constants" setup $this->thispluginurl = PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)).'/'; $this->thispluginpath = PLUGIN_PATH . '/' . dirname(plugin_basename(__FILE__)).'/'; //Initialize the options //This is REQUIRED to initialize the options when the plugin is loaded! $this->getOptions(); //Actions add_action("admin_menu", array(&$this,"admin_menu_link")); //Widget Registration Actions add_action('plugins_loaded', array(&$this,'register_widgets')); /* add_action("wp_head", array(&$this,"add_css")); add_action('wp_print_scripts', array(&$this, 'add_js')); */ //Filters /* add_filter('the_content', array(&$this, 'filter_content'), 0); */ } /** * Retrieves the plugin options from the database. * @return array */ function getOptions() { //Don't forget to set up the default options if (!$theOptions = get_option($this->optionsName)) { $theOptions = array('default'=>'options'); update_option($this->optionsName, $theOptions); } $this->options = $theOptions; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //There is no return here, because you should use the $this->options variable!!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } /** * Saves the admin options to the database. */ function saveAdminOptions(){ return update_option($this->optionsName, $this->options); } /** * @desc Adds the options subpanel */ function admin_menu_link() { //If you change this from add_options_page, MAKE SURE you change the filter_plugin_actions function (below) to //reflect the page filename (ie - options-general.php) of the page your plugin is under! add_options_page('{Full Plugin Name}', '{Full Plugin Name}', 10, basename(__FILE__), array(&$this,'admin_options_page')); add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'filter_plugin_actions'), 10, 2 ); } /** * @desc Adds the Settings link to the plugin activate/deactivate page */ function filter_plugin_actions($links, $file) { //If your plugin is under a different top-level menu than Settiongs (IE - you changed the function above to something other than add_options_page) //Then you're going to want to change options-general.php below to the name of your top-level page $settings_link = '' . __('Settings') . ''; array_unshift( $links, $settings_link ); // before other links return $links; } /** * Adds settings/options page */ function admin_options_page() { if($_POST['{plugin_slug}_save']){ if (! wp_verify_nonce($_POST['_wpnonce'], '{plugin_slug}-update-options') ) die('Whoops! There was a problem with the data you posted. Please go back and try again.'); $this->options['{plugin_slug}_path'] = $_POST['{plugin_slug}_path']; $this->options['{plugin_slug}_allowed_groups'] = $_POST['{plugin_slug}_allowed_groups']; $this->options['{plugin_slug}_enabled'] = ($_POST['{plugin_slug}_enabled']=='on')?true:false; $this->saveAdminOptions(); echo '

Success! Your changes were sucessfully saved!

'; } ?>

{Full Plugin Name}

localizationDomain); ?>
localizationDomain); ?>
options['{plugin_slug}_enabled']==true)?'checked="checked"':''?>>
options['title'] . $after_title; echo ''; echo $after_widget; } function {widget_slug}_control() { if ( $_POST["{plugin_slug}_{widget_slug}_submit"] ) { $this->options['{plugin_slug}-comments-title'] = stripslashes($_POST["{plugin_slug}-comments-title"]); $this->options['{plugin_slug}-comments-template'] = stripslashes($_POST["{plugin_slug}-comments-template"]); $this->options['{plugin_slug}-hide-admin-comments'] = ($_POST["{plugin_slug}-hide-admin-comments"]=='on'?'':'1'); $this->saveAdminOptions(); } $title = htmlspecialchars($options['{plugin_slug}-comments-title'], ENT_QUOTES); $template = htmlspecialchars($options['{plugin_slug}-comments-template'], ENT_QUOTES); $hide_admin_comments = $options['{plugin_slug}-hide-admin-comments']; ?>

localizationDomain); ?> localizationDomain); ?>

/>

'{widget_slug}', 'description' => __( 'Widget Description', $this->localizationDomain ) ); wp_register_sidebar_widget('{plugin_slug}-{widget_slug}', __('Widget Title', $this->localizationDomain), array($this, 'display_{widget_slug}'), $widget_ops); wp_register_widget_control('{plugin_slug}-{widget_slug}', __('Widget Title', $this->localizationDomain), array($this, '{widget_slug}_control')); } } } //End Class } //End if class exists statement //instantiate the class if (class_exists('{plugin_slug}')) { ${plugin_slug}_var = new {plugin_slug}(); } ?>