function rcp_options_install() { global $wpdb, $rcp_db_name, $rcp_db_version, $rcp_discounts_db_name, $rcp_discounts_db_version, $rcp_payments_db_name, $rcp_payments_db_version; // create the RCP subscription level database table if ($wpdb->get_var("show tables like '{$rcp_db_name}'") != $rcp_db_name) { $sql = "CREATE TABLE " . $rcp_db_name . " (\n\t\tid mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\tname tinytext NOT NULL,\n\t\tdescription longtext NOT NULL,\n\t\tduration smallint NOT NULL,\n\t\tduration_unit tinytext NOT NULL,\n\t\tprice tinytext NOT NULL,\n\t\tfee tinytext NOT NULL,\n\t\tlist_order mediumint NOT NULL,\n\t\tlevel mediumint NOT NULL,\n\t\tstatus tinytext NOT NULL,\n\t\trole tinytext NOT NULL,\n\t\tUNIQUE KEY id (id)\n\t\t) CHARACTER SET utf8 COLLATE utf8_general_ci;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); add_option("rcp_db_version", $rcp_db_version); } // create the RCP discounts database table if ($wpdb->get_var("show tables like '{$rcp_discounts_db_name}'") != $rcp_discounts_db_name) { $sql = "CREATE TABLE " . $rcp_discounts_db_name . " (\n\t\tid mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\tname tinytext NOT NULL,\n\t\tdescription longtext NOT NULL,\n\t\tamount tinytext NOT NULL,\n\t\tunit tinytext NOT NULL,\n\t\tcode tinytext NOT NULL,\n\t\tuse_count mediumint NOT NULL,\n\t\tmax_uses mediumint NOT NULL,\n\t\tstatus tinytext NOT NULL,\n\t\texpiration mediumtext NOT NULL,\n\t\tsubscription_id mediumint NOT NULL,\n\t\tUNIQUE KEY id (id)\n\t\t) CHARACTER SET utf8 COLLATE utf8_general_ci;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); add_option("rcp_discounts_db_version", $rcp_discounts_db_version); } // create the RCP payments database table if ($wpdb->get_var("show tables like '{$rcp_payments_db_name}'") != $rcp_payments_db_name) { $sql = "CREATE TABLE " . $rcp_payments_db_name . " (\n\t\tid mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\tsubscription mediumtext NOT NULL,\n\t\tdate datetime NOT NULL,\n\t\tamount mediumtext NOT NULL,\n\t\tuser_id mediumint NOT NULL,\n\t\tpayment_type tinytext NOT NULL,\n\t\tsubscription_key mediumtext NOT NULL,\n\t\ttransaction_id tinytext NOT NULL,\n\t\tUNIQUE KEY id (id)\n\t\t) CHARACTER SET utf8 COLLATE utf8_general_ci;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); add_option("rcp_payments_db_version", $rcp_payments_db_version); } // Create RCP caps $caps = new RCP_Capabilities(); $caps->add_caps(); // and option that allows us to make sure RCP is installed add_option('rcp_is_installed', '1'); }
function rcp_options_install() { global $wpdb, $rcp_db_name, $rcp_db_version, $rcp_discounts_db_name, $rcp_discounts_db_version, $rcp_payments_db_name, $rcp_payments_db_version; $rcp_options = get_option('rcp_settings', array()); // create the RCP subscription level database table if ($wpdb->get_var("show tables like '{$rcp_db_name}'") != $rcp_db_name) { $sql = "CREATE TABLE " . $rcp_db_name . " (\n\t\tid mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\tname tinytext NOT NULL,\n\t\tdescription longtext NOT NULL,\n\t\tduration smallint NOT NULL,\n\t\tduration_unit tinytext NOT NULL,\n\t\tprice tinytext NOT NULL,\n\t\tfee tinytext NOT NULL,\n\t\tlist_order mediumint NOT NULL,\n\t\tlevel mediumint NOT NULL,\n\t\tstatus tinytext NOT NULL,\n\t\trole tinytext NOT NULL,\n\t\tUNIQUE KEY id (id)\n\t\t) CHARACTER SET utf8 COLLATE utf8_general_ci;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); add_option("rcp_db_version", $rcp_db_version); } // create the RCP discounts database table if ($wpdb->get_var("show tables like '{$rcp_discounts_db_name}'") != $rcp_discounts_db_name) { $sql = "CREATE TABLE " . $rcp_discounts_db_name . " (\n\t\tid mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\tname tinytext NOT NULL,\n\t\tdescription longtext NOT NULL,\n\t\tamount tinytext NOT NULL,\n\t\tunit tinytext NOT NULL,\n\t\tcode tinytext NOT NULL,\n\t\tuse_count mediumint NOT NULL,\n\t\tmax_uses mediumint NOT NULL,\n\t\tstatus tinytext NOT NULL,\n\t\texpiration mediumtext NOT NULL,\n\t\tsubscription_id mediumint NOT NULL,\n\t\tUNIQUE KEY id (id)\n\t\t) CHARACTER SET utf8 COLLATE utf8_general_ci;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); add_option("rcp_discounts_db_version", $rcp_discounts_db_version); } // create the RCP payments database table if ($wpdb->get_var("show tables like '{$rcp_payments_db_name}'") != $rcp_payments_db_name) { $sql = "CREATE TABLE " . $rcp_payments_db_name . " (\n\t\tid mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\tsubscription mediumtext NOT NULL,\n\t\tdate datetime NOT NULL,\n\t\tamount mediumtext NOT NULL,\n\t\tuser_id mediumint NOT NULL,\n\t\tpayment_type tinytext NOT NULL,\n\t\tsubscription_key mediumtext NOT NULL,\n\t\ttransaction_id tinytext NOT NULL,\n\t\tstatus varchar(200) NOT NULL,\n\t\tUNIQUE KEY id (id)\n\t\t) CHARACTER SET utf8 COLLATE utf8_general_ci;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); add_option("rcp_payments_db_version", $rcp_payments_db_version); } // Create RCP caps $caps = new RCP_Capabilities(); $caps->add_caps(); // Setup some default options $options = array(); // Checks if the purchase page option exists if (!isset($rcp_options['registration_page'])) { // Register Page $register = wp_insert_post(array('post_title' => __('Register', 'edd'), 'post_content' => '[register_form]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'comment_status' => 'closed')); // Welcome (Success) Page $success = wp_insert_post(array('post_title' => __('Welcome', 'edd'), 'post_content' => __('Welcome! This is your success page where members are redirected after completing their registration.', 'edd'), 'post_status' => 'publish', 'post_author' => 1, 'post_parent' => $register, 'post_type' => 'page', 'comment_status' => 'closed')); // Store our page IDs $options['registration_page'] = $register; $options['redirect'] = $success; } update_option('rcp_settings', array_merge($rcp_options, $options)); // and option that allows us to make sure RCP is installed add_option('rcp_is_installed', '1'); }
function rcp_options_install() { global $wpdb, $rcp_db_name, $rcp_db_version, $rcp_discounts_db_name, $rcp_discounts_db_version, $rcp_payments_db_name, $rcp_payments_db_version; $rcp_options = get_option('rcp_settings', array()); require_once ABSPATH . 'wp-admin/includes/upgrade.php'; // create the RCP subscription level database table $sql = "CREATE TABLE {$rcp_db_name} (\r\n\t\tid bigint(9) NOT NULL AUTO_INCREMENT,\r\n\t\tname varchar(200) NOT NULL,\r\n\t\tdescription longtext NOT NULL,\r\n\t\tduration smallint NOT NULL,\r\n\t\tduration_unit tinytext NOT NULL,\r\n\t\tprice tinytext NOT NULL,\r\n\t\tfee tinytext NOT NULL,\r\n\t\tlist_order mediumint NOT NULL,\r\n\t\tlevel mediumint NOT NULL,\r\n\t\tstatus varchar(12) NOT NULL,\r\n\t\trole tinytext NOT NULL,\r\n\t\tPRIMARY KEY id (id),\r\n\t\tKEY name (name),\r\n\t\tKEY status (status)\r\n\t\t) CHARACTER SET utf8 COLLATE utf8_general_ci;"; @dbDelta($sql); update_option("rcp_db_version", $rcp_db_version); // Create subscription meta table $sub_meta_table_name = rcp_get_level_meta_db_name(); $sql = "CREATE TABLE {$sub_meta_table_name} (\r\n\t\tmeta_id bigint(20) NOT NULL AUTO_INCREMENT,\r\n\t\tlevel_id bigint(20) NOT NULL DEFAULT '0',\r\n\t\tmeta_key varchar(255) DEFAULT NULL,\r\n\t\tmeta_value longtext,\r\n\t\tPRIMARY KEY meta_id (meta_id),\r\n\t\tKEY level_id (level_id),\r\n\t\tKEY meta_key (meta_key)\r\n\t\t) CHARACTER SET utf8 COLLATE utf8_general_ci;"; @dbDelta($sql); // create the RCP discounts database table $sql = "CREATE TABLE {$rcp_discounts_db_name} (\r\n\t\tid bigint(9) NOT NULL AUTO_INCREMENT,\r\n\t\tname tinytext NOT NULL,\r\n\t\tdescription longtext NOT NULL,\r\n\t\tamount tinytext NOT NULL,\r\n\t\tunit tinytext NOT NULL,\r\n\t\tcode tinytext NOT NULL,\r\n\t\tuse_count mediumint NOT NULL,\r\n\t\tmax_uses mediumint NOT NULL,\r\n\t\tstatus tinytext NOT NULL,\r\n\t\texpiration mediumtext NOT NULL,\r\n\t\tsubscription_id mediumint NOT NULL,\r\n\t\tPRIMARY KEY id (id)\r\n\t\t) CHARACTER SET utf8 COLLATE utf8_general_ci;"; @dbDelta($sql); update_option("rcp_discounts_db_version", $rcp_discounts_db_version); // create the RCP payments database table $sql = "CREATE TABLE {$rcp_payments_db_name} (\r\n\t\tid bigint(9) NOT NULL AUTO_INCREMENT,\r\n\t\tsubscription varchar(200) NOT NULL,\r\n\t\tdate datetime NOT NULL,\r\n\t\tamount mediumtext NOT NULL,\r\n\t\tuser_id mediumint NOT NULL,\r\n\t\tpayment_type tinytext NOT NULL,\r\n\t\tsubscription_key varchar(32) NOT NULL,\r\n\t\ttransaction_id varchar(64) NOT NULL,\r\n\t\tstatus varchar(12) NOT NULL,\r\n\t\tPRIMARY KEY id (id),\r\n\t\tKEY subscription(subscription),\r\n\t\tKEY user_id (user_id),\r\n\t\tKEY subscription_key (subscription_key),\r\n\t\tKEY transaction_id (transaction_id),\r\n\t\tKEY status (status)\r\n\t\t) CHARACTER SET utf8 COLLATE utf8_general_ci;"; @dbDelta($sql); update_option("rcp_payments_db_version", $rcp_payments_db_version); // Create payment meta table $sub_meta_table_name = rcp_get_payment_meta_db_name(); $sql = "CREATE TABLE {$sub_meta_table_name} (\r\n\t\tmeta_id bigint(20) NOT NULL AUTO_INCREMENT,\r\n\t\tpayment_id bigint(20) NOT NULL DEFAULT '0',\r\n\t\tmeta_key varchar(255) DEFAULT NULL,\r\n\t\tmeta_value longtext,\r\n\t\tPRIMARY KEY meta_id (meta_id),\r\n\t\tKEY payment_id (payment_id),\r\n\t\tKEY meta_key (meta_key)\r\n\t\t) CHARACTER SET utf8 COLLATE utf8_general_ci;"; @dbDelta($sql); // Create RCP caps $caps = new RCP_Capabilities(); $caps->add_caps(); // Checks if the purchase page option exists if (!isset($rcp_options['registration_page'])) { // Register Page $register = wp_insert_post(array('post_title' => __('Register', 'rcp'), 'post_content' => '[register_form]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'comment_status' => 'closed')); // Welcome (Success) Page $success = wp_insert_post(array('post_title' => __('Welcome', 'rcp'), 'post_content' => __('Welcome! This is your success page where members are redirected after completing their registration.', 'rcp'), 'post_status' => 'publish', 'post_author' => 1, 'post_parent' => $register, 'post_type' => 'page', 'comment_status' => 'closed')); // Store our page IDs $rcp_options['registration_page'] = $register; $rcp_options['redirect'] = $success; } // Checks if the account page option exists if (empty($rcp_options['account_page'])) { $account = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'page' AND post_content LIKE '%[subscription_details%' LIMIT 1;"); if (empty($account)) { // Account Page $account = wp_insert_post(array('post_title' => __('Your Membership', 'rcp'), 'post_content' => '[subscription_details]', 'post_status' => 'publish', 'post_author' => 1, 'post_parent' => $rcp_options['registration_page'], 'post_type' => 'page', 'comment_status' => 'closed')); } // Store our page IDs $rcp_options['account_page'] = $account; } // Checks if the profile editor page option exists if (empty($rcp_options['edit_profile'])) { $profile = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'page' AND post_content LIKE '%[rcp_profile_editor%' LIMIT 1;"); if (empty($profile)) { // Profile editor Page $profile = wp_insert_post(array('post_title' => __('Edit Your Profile', 'rcp'), 'post_content' => '[rcp_profile_editor]', 'post_status' => 'publish', 'post_author' => 1, 'post_parent' => $rcp_options['registration_page'], 'post_type' => 'page', 'comment_status' => 'closed')); } // Store our page IDs $rcp_options['edit_profile'] = $profile; } // Checks if the update billing card page option exists if (empty($rcp_options['update_card'])) { $update_card = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'page' AND post_content LIKE '%[rcp_update_card%' LIMIT 1;"); if (empty($update_card)) { // update_card editor Page $update_card = wp_insert_post(array('post_title' => __('Update Billing Card', 'rcp'), 'post_content' => '[rcp_update_card]', 'post_status' => 'publish', 'post_author' => 1, 'post_parent' => $rcp_options['registration_page'], 'post_type' => 'page', 'comment_status' => 'closed')); } // Store our page IDs $rcp_options['update_card'] = $update_card; } update_option('rcp_settings', $rcp_options); // and option that allows us to make sure RCP is installed update_option('rcp_is_installed', '1'); update_option('rcp_version', RCP_PLUGIN_VERSION); }