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 = ''; } ?> for="options_name; ?>[]"> plugin_textdomain ); ?> />

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

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

Ahalogy Support

optionsDrawCheckbox( 'insert_code', 'Include code snippet on my site', '', 'color:#000;' ); ?> optionsDrawCheckbox( 'mobilify_optin', 'Enable Ahalogy Labs (beta)', '', 'color:#000;' ); ?>
/> (recommended)
/>

optionsGetOptions(); // code removed for all pages $disabled = sprintf(' ' , $this->plugin_version ); // Ahalogy widget code $widget_code = sprintf( ' ' , $this->plugin_version , $options['client_id'] , $this->widget_js_domain ); // build code if( !$options['insert_code'] || strlen($options['client_id'])<10) echo $disabled; else echo $widget_code ; } /** * Generic function to show a message to the user using WP's * standard CSS classes to make use of the already-defined * message colour scheme. * * @param $message The message you want to tell the user. * @param $errormsg If true, the message is an error, so use * the red message style. If false, the message is a status * message, so use the yellow information message style. */ function showMessage($message, $errormsg = false) { if ($errormsg) { echo '
'; } else { echo '
'; } echo "

$message

"; } /** * Just show ClientID error message if necessary */ function showAdminMessages() { //Show a message on all admin pages if the client id is not set $options = get_option( $this->options_name, $this->optionsGetDefaults() ); if (empty($options['client_id'])) { // Only show to admins if ( current_user_can('manage_options') ) { $this->showMessage("Please enter your client ID to activate the Ahalogy plugin.", true); } } } } // end class endif; // end collision check $ahalogyWP_instance = new ahalogyWP; include_once dirname(__FILE__) . '/Ahalogy-wp-mobile.php'; include_once dirname(__FILE__) . '/Ahalogy-wp-mobile-post.php'; include_once dirname(__FILE__) . '/Ahalogy-wp-mobile-category.php'; include_once dirname(__FILE__) . '/Ahalogy-wp-mobile-author.php'; include_once dirname(__FILE__) . '/Ahalogy-wp-mobile-attachment.php';