transfer_settings(); $this->icon_url = plugins_url('/backend/img/icon.png', dirname(__FILE__)); add_filter("plugin_action_links_{$this->filename}", array(&$this, 'add_settings_link')); add_action('admin_menu', array(&$this, 'add_option_page')); add_action('admin_init', array(&$this, 'settings_init')); // add dashboard widget hook add_action('wp_dashboard_setup', array(&$this, 'widget_setup')); // register function to remove options upon deactivation register_deactivation_hook($this->filename, array(&$this, 'remove_options')); /* Only do stuff on admin page of this plugin */ if (isset($_GET['page']) && stripos($_GET['page'], $this->hook) !== FALSE) { add_action("admin_print_styles", array(&$this, 'add_admin_styles')); add_action("admin_print_scripts", array(&$this, 'add_admin_scripts')); } add_action('bp_include', array(&$this, 'set_bp_active')); } /** * If buddypress is loaded, set buddypress_active to TRUE */ function set_bp_active() { $this->bp_active = TRUE; } /** * Enqueue the necessary stylesheets */ function add_admin_styles() { wp_enqueue_style($this->hook . '_css', plugins_url('/backend/css/backend.css', dirname(__FILE__))); } /** * Enqueue the necessary admin scripts */ function add_admin_scripts() { wp_enqueue_script(array('jquery', 'dashboard', 'postbox')); wp_enqueue_script('ns_admin_js', plugins_url('/backend/js/backend.js', dirname(__FILE__))); } /** * The default settings page */ function options_page_default() { $opts = get_option('nsu_mailinglist'); $viewed_mp = NULL; if (!empty($_GET['mp'])) $viewed_mp = $_GET['mp']; elseif (empty($_GET['mp']) && isset($opts['provider'])) $viewed_mp = $opts['provider']; if (!in_array($viewed_mp, array('mailchimp', 'icontact', 'aweber', 'phplist', 'ymlp', 'other'))) $viewed_mp = NULL; // Fill in some predefined values if options not set or set for other newsletter service if (!isset($opts['provider']) || $opts['provider'] != $viewed_mp) { switch ($viewed_mp) { case 'mailchimp': if (empty($opts['email_id'])) $opts['email_id'] = 'EMAIL'; if (empty($opts['name_id'])) $opts['name_id'] = 'NAME'; break; case 'ymlp': if (empty($opts['email_id'])) $opts['email_id'] = 'YMP0'; break; case 'aweber': if (empty($opts['form_action'])) $opts['form_action'] = 'http://www.aweber.com/scripts/addlead.pl'; if (empty($opts['email_id'])) $opts['email_id'] = 'email'; if (empty($opts['name_id'])) $opts['name_id'] = 'name'; break; case 'icontact': if (empty($opts['email_id'])) $opts['email_id'] = 'fields_email'; break; } } require 'views/dashboard.php'; } /** * The admin page for managing checkbox settings */ function options_page_checkbox_settings() { $opts = get_option('nsu_checkbox'); require 'views/checkbox_settings.php'; } /** * The admin page for managing form settings */ function options_page_form_settings() { $opts = get_option('nsu_form'); $opts['mailinglist'] = get_option('nsu_mailinglist'); require 'views/form_settings.php'; } /** * The page for the configuration extractor */ function options_page_config_helper() { if (isset($_POST['form'])) { $error = true; $form = $_POST['form']; // strip unneccessary tags $form = strip_tags($form, '