optionsGetOptions(); add_filter( 'plugin_row_meta', array( &$this, 'optionsSetPluginMeta' ), 10, 2 ); // add plugin page meta links add_action( 'admin_init', array( &$this, 'optionsInit' ) ); // whitelist options page add_action( 'admin_menu', array( &$this, 'optionsAddPage' ) ); // add link to plugin's settings page in 'settings' menu on admin menu initilization if( $options['location'] == 'head' ) add_action( 'wp_head', array( &$this, 'getAhalogyCode' ), 99999 ); else add_action( 'wp_footer', array( &$this, 'getAhalogyCode' ), 99999 ); } // load i18n textdomain function loadTextDomain() { load_plugin_textdomain( $this->plugin_textdomain, false, trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) . 'lang/' ); } // get default plugin options function optionsGetDefaults() { $defaults = array( 'client_id' => '', 'insert_code' => 0, 'location' => 'head', ); return $defaults; } function optionsGetOptions() { $options = get_option( $this->options_name, $this->optionsGetDefaults() ); return $options; } // set plugin links function optionsSetPluginMeta( $links, $file ) { $plugin = plugin_basename( __FILE__ ); if ( $file == $plugin ) { // if called for THIS plugin then: $newlinks = array( '' . __( 'Settings', $this->plugin_textdomain ) . '' ); // array of links to add return array_merge( $links, $newlinks ); // merge new links into existing $links } return $links; // return the $links (merged or otherwise) } // plugin startup function optionsInit() { register_setting( $this->options_group, $this->options_name, array( &$this, 'optionsValidate' ) ); } // create and link options page function optionsAddPage() { add_options_page( $this->plugin_name . ' ' . __( 'Settings', $this->plugin_textdomain ), __( 'Ahalogy', $this->plugin_textdomain ), 'manage_options', $this->options_page, array( &$this, 'optionsDrawPage' ) ); } // sanitize and validate options input function optionsValidate( $input ) { $input['insert_code'] = ( $input['insert_code'] ? 1 : 0 ); // (checkbox) if TRUE then 1, else NULL $input['client_id'] = wp_filter_nohtml_kses( $input['client_id'] ); // (textbox) safe text, no html $input['location'] = ( $input['location'] == 'head' ? 'head' : 'body' ); // (radio) either head or body return $input; } // draw a checkbox option function optionsDrawCheckbox( $slug, $label, $style_checked='', $style_unchecked='' ) { $options = $this->optionsGetOptions(); if( !$options[$slug] ) if( !empty( $style_unchecked ) ) $style = ' style="' . $style_unchecked . '"'; else $style = ''; else if( !empty( $style_checked ) ) $style = ' style="' . $style_checked . '"'; else $style = ''; ?> for="options_name; ?>[]"> plugin_textdomain ); ?> />

plugin_name . __( ' Settings', $this->plugin_textdomain ); ?>

options_group ); // nonce settings page ?> optionsGetOptions(); //populate $options array from database ?>

We welcome feedback.', $this->plugin_textdomain ), $this->plugin_homepage ); ?>

optionsDrawCheckbox( 'insert_code', 'Include Ahalogy code on your site?', '', 'color:#f00;' ); ?>
/> (recommended)
/>

optionsGetOptions(); // code removed for all pages $disabled = ' '; // Ahalogy widget code $widget_code = sprintf( ' ' , $options['client_id'] ); // build code if( !$options['insert_code'] || strlen($options['client_id'])<10) echo $disabled; else echo $widget_code ; } } // end class endif; // end collision check $ahalogyWP_instance = new ahalogyWP; ?>