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 add_action( 'admin_notices', array( &$this, 'showAdminMessages' ) ); 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', 'mobilify_optin' => 0, ); 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'] = (( isset($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 $input['mobilify_optin'] = (( isset($input['mobilify_optin']) && ( $input['mobilify_optin'] )) ? 1 : 0 ); // (checkbox) if TRUE then 1, else NULL return $input; } // draw a checkbox option function optionsDrawCheckbox( $slug, $label, $style_checked='', $style_unchecked='' ) { $options = $this->optionsGetOptions(); if (!isset($options[$slug])) { //index isn't identified. set the default $defaults = $this->optionsGetDefaults(); $options[$slug] = $defaults[$slug]; } if( !$options[$slug] ) { if( !empty( $style_unchecked ) ) $style = ' style="' . $style_unchecked . '"'; else $style = ''; } else { if( !empty( $style_checked ) ) $style = ' style="' . $style_checked . '"'; else $style = ''; } ?>
$message