function save_api_key($op) { $key = op_get_var($op, OptimizePress_Sl_Api::OPTION_API_KEY_PARAM); $status = op_sl_register($key); if (is_wp_error($status)) { op_tpl_error('op_sections_' . OptimizePress_Sl_Api::OPTION_API_KEY_PARAM, __('API key is invalid. Please re-check it.', OP_SN)); } else { op_sl_save_key($key); } }
function save_api_key($op) { $key = trim(op_get_var($op, OptimizePress_Sl_Api::OPTION_API_KEY_PARAM)); $status = op_sl_register($key); if (is_wp_error($status)) { op_group_error('global_settings'); op_section_error('global_settings_api_key'); op_tpl_error('op_sections_' . OptimizePress_Sl_Api::OPTION_API_KEY_PARAM, __('API key is invalid. Please re-check it.', 'optimizepress')); } else { op_sl_save_key($key); } }
function run_install() { //Get the global wordpress database object global $wpdb; //Make sure we are supposed to be running this function if (isset($_POST[OP_SN . '_install'])) { //Perform security verification if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'op_install')) { //Get the OP order number $key = op_post('op', 'install', 'order_number'); //Register the key and return key status $status = op_sl_register($key); //If the key is invalid, notify user, otherwise continue if (is_wp_error($status)) { //Save the API key op_sl_save_key($key); //Continue if the product is not already installed if (op_get_option('installed') != 'Y') { //CReate the Assets table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_assets` (\n\t\t\t\t\t\t\t `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t `name` varchar(64) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t `title` varchar(150) NOT NULL DEFAULT '',\n\t\t\t\t\t\t\t `settings` varchar(1) NOT NULL DEFAULT 'N',\n\t\t\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the launch funnel table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_launchfunnels` (\n\t\t\t\t\t\t\t\t`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t`title` varchar(254) NOT NULL DEFAULT '',\n\t\t\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the launch funnel pages table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_launchfunnels_pages` (\n\t\t\t\t\t\t\t\t`funnel_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t\t\t\t\t`page_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t\t\t\t\t`step` int(10) unsigned NOT NULL\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the layout categories table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_layout_categories` (\n\t\t\t\t\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t`name` varchar(255) NOT NULL,\n\t\t\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the products table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_pb_products` (\n\t\t\t\t\t\t\t `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t `post_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t\t\t\t `parent_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t\t\t\t `type` varchar(50) NOT NULL DEFAULT '',\n\t\t\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the post layouts table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_post_layouts` (\n\t\t\t\t\t\t\t `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t `post_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t\t\t\t `type` varchar(255) NOT NULL,\n\t\t\t\t\t\t\t `layout` longtext NOT NULL,\n\t\t\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the predefined layouts table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_predefined_layouts` (\n\t\t\t\t\t\t\t `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t `name` varchar(100) NOT NULL DEFAULT '',\n\t\t\t\t\t\t\t `category` int(10) unsigned NOT NULL,\n\t\t\t\t\t\t\t `description` text NOT NULL,\n\t\t\t\t\t\t\t `preview_ext` varchar(4) NOT NULL DEFAULT '',\n\t\t\t\t\t\t\t `layouts` longtext NOT NULL,\n\t\t\t\t\t\t\t `settings` longtext NOT NULL,\n\t\t\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the presets table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_presets` (\n\t\t\t\t\t\t\t `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t `name` varchar(255) NOT NULL,\n\t\t\t\t\t\t\t `layouts` longtext NOT NULL,\n\t\t\t\t\t\t\t `settings` longtext NOT NULL,\n\t\t\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Save the assets _op_assets('save_assets'); //Set the installed flag to Y so the installer doesn't run again op_update_option('installed', 'Y'); //Ping pong if (!wp_next_scheduled('ping_pong')) { wp_schedule_event(time(), 'daily', 'ping_pong'); } //Set defaults $this->set_defaults(); // install content templates $this->install_content_templates(); //Redirect to the setup wizard if (defined('OP_TYPE') && OP_TYPE == 'theme') { wp_redirect(menu_page_url(OP_SN, false) . '-setup-wizard'); } else { wp_redirect(menu_page_url(OP_SN, false)); } } else { //Reload wp_redirect(menu_page_url(OP_SN, false)); } } } else { //If the security verification failed, notify the user $this->error = __('Verification failed, please refresh the page and try again.', OP_SN); } } }