/** * Short Description. Plugin Activation. * * Long Description. Creates our custom form tables on activation. * * @since 6.0.0 */ static function _activate_yikes_easy_mailchimp($wpdb) { // single site $custom_table_name = $wpdb->prefix . 'yikes_easy_mc_forms'; /* * Setup charset to prevent ???s saved into the database for special charset * @sinec 6.0.3.8 * Resource: http://codex.wordpress.org/Creating_Tables_with_Plugins#Creating_or_Updating_the_Table */ $charset_collate = $wpdb->get_charset_collate(); // create the Yikes Inc. Easy MailChimp database table $sql = "CREATE TABLE {$custom_table_name} (\n\t\tid INT NOT NULL AUTO_INCREMENT,\n\t\tlist_id TEXT NOT NULL,\n\t\tform_name TEXT NOT NULL,\n\t\tform_description TEXT NOT NULL,\n\t\tfields TEXT NOT NULL,\n\t\tcustom_styles TEXT NOT NULL,\n\t\tcustom_template TEXT NOT NULL,\n\t\tsend_welcome_email INT NOT NULL,\n\t\tredirect_user_on_submit INT NOT NULL,\n\t\tredirect_page TEXT NOT NULL,\n\t\tsubmission_settings TEXT NOT NULL,\n\t\toptin_settings TEXT NOT NULL,\n\t\tform_settings TEXT NOT NULL,\n\t\terror_messages TEXT NOT NULL,\n\t\tcustom_notifications TEXT NOT NULL,\n\t\timpressions INT NOT NULL,\n\t\tsubmissions INT NOT NULL,\n\t\tcustom_fields TEXT NOT NULL,\n\t\tUNIQUE KEY id (id)\n\t\t) {$charset_collate};"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); // create an option for the date that the user initially activated the plugin // used to display a two week notice, asking for a review or to upgrade if (!get_option('yikes_easy_mailchimp_activation_date') || get_option('yikes_easy_mailchimp_activation_date') == '') { update_option('yikes_easy_mailchimp_activation_date', strtotime('now')); } // Create an option for the forms. if (class_exists('Yikes_Inc_Easy_MailChimp_Extender_Option_Forms')) { $option_class = new Yikes_Inc_Easy_MailChimp_Extender_Option_Forms(); $option_class->create_option(); } // Add the DB version option. add_option('yikes_easy_mailchimp_extender_version', YIKES_MC_VERSION); }
/** * Handle the conversion from custom table to WP Options. * * @author Jeremy Pry */ public function convert_db_to_option() { /** @var wpdb */ global $wpdb; $db_interface = new Yikes_Inc_Easy_MailChimp_Extender_Forms($wpdb); $option_interface = new Yikes_Inc_Easy_MailChimp_Extender_Option_Forms(); $form_option = array(); $form_ids = $db_interface->get_form_ids(); if (empty($form_ids)) { return; } foreach ($form_ids as $form_id) { $form_option[$form_id] = $db_interface->get_form($form_id); } $option_interface->import_forms($form_option, true); }