function pmpro_upgrade_1_8_7() { //fix cron jobs $jobs = _get_cron_array(); // Remove all pmpro cron jobs (for now). foreach ($jobs as $when => $job_array) { foreach ($job_array as $name => $job) { //delete pmpro cron if (false !== stripos($name, 'pmpro_cron')) { unset($jobs[$when][$name]); } } //delete empty cron time slots if (empty($jobs[$when])) { unset($jobs[$when]); } } // Save the data _set_cron_array($jobs); //add the three we want back pmpro_maybe_schedule_event(current_time('timestamp'), 'daily', 'pmpro_cron_expire_memberships'); pmpro_maybe_schedule_event(current_time('timestamp') + 1, 'daily', 'pmpro_cron_expiration_warnings'); pmpro_maybe_schedule_event(current_time('timestamp'), 'monthly', 'pmpro_cron_credit_card_expiring_warnings'); pmpro_setOption("db_version", "1.87"); return 1.87; }
function pmpro_upgrade_1_7() { pmpro_db_delta(); //just a db delta pmpro_setOption("db_version", "1.7"); return 1.7; }
function pmpro_upgrade_1_8_6_9() { global $wpdb; $orders = $wpdb->get_results("SELECT id, user_id, membership_id, subscription_transaction_id FROM {$wpdb->pmpro_membership_orders} WHERE gateway = 'stripe' AND subscription_transaction_id LIKE 'cus_%'"); if (!empty($orders)) { if (count($orders) > 100) { //if more than 100 orders, we'll need to do this via AJAX pmpro_addUpdate('pmpro_upgrade_1_8_6_9_ajax'); } else { //less than 100, let's just do them now $subids = array(); foreach ($orders as $order) { if (!empty($subids[$order->subscription_transaction_id])) { $wpdb->query("UPDATE {$wpdb->pmpro_membership_orders} SET subscription_transaction_id = '" . esc_sql($subids[$order->subscription_transaction_id]) . "' WHERE id = '" . $order->id . "' LIMIT 1"); //echo "Updating subid for #" . $order->id . " " . $order->subscription_transaction_id . ".<br />"; } elseif (isset($subids[$order->subscription_transaction_id])) { //no sub id found, so let it go //echo "No subid found for #" . $order->id . " " . $order->subscription_transaction_id . " in cache.<br />"; } else { //need to look for a sub id in the database $subid = $wpdb->get_var("SELECT subscription_transaction_id FROM {$wpdb->pmpro_membership_orders} WHERE membership_id = '" . $order->membership_id . "' AND user_id = '" . $order->user_id . "' AND subscription_transaction_id LIKE 'sub_%' LIMIT 1"); $subids[$order->subscription_transaction_id] = $subid; if (!empty($subid)) { $wpdb->query("UPDATE {$wpdb->pmpro_membership_orders} SET subscription_transaction_id = '" . esc_sql($subid) . "' WHERE id = '" . $order->id . "' LIMIT 1"); //echo "Updating subid for #" . $order->id . " " . $order->subscription_transaction_id . ".<br />"; } else { //echo "No subid found for #" . $order->id . " " . $order->subscription_transaction_id . ".<br />"; } } } } } pmpro_setOption("db_version", "1.869"); return 1.869; }
function pmpro_upgrade_1_2_3() { global $wpdb; $wpdb->hide_errors(); $wpdb->pmpro_membership_levels = $wpdb->prefix . 'pmpro_membership_levels'; $wpdb->pmpro_memberships_users = $wpdb->prefix . 'pmpro_memberships_users'; $wpdb->pmpro_memberships_categories = $wpdb->prefix . 'pmpro_memberships_categories'; $wpdb->pmpro_memberships_pages = $wpdb->prefix . 'pmpro_memberships_pages'; $wpdb->pmpro_membership_orders = $wpdb->prefix . 'pmpro_membership_orders'; $wpdb->pmpro_discount_codes = $wpdb->prefix . 'pmpro_discount_codes'; $wpdb->pmpro_discount_codes_levels = $wpdb->prefix . 'pmpro_discount_codes_levels'; $wpdb->pmpro_discount_codes_uses = $wpdb->prefix . 'pmpro_discount_codes_uses'; //expiration number and period for levels $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_membership_levels . "` ADD `expiration_number` INT UNSIGNED NOT NULL ,\r\nADD `expiration_period` ENUM( 'Day', 'Week', 'Month', 'Year' ) NOT NULL\r\n\t"; $wpdb->query($sqlQuery); //expiration number and period for discount code levels $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_discount_codes_levels . "` ADD `expiration_number` INT UNSIGNED NOT NULL ,\r\nADD `expiration_period` ENUM( 'Day', 'Week', 'Month', 'Year' ) NOT NULL\r\n\t"; $wpdb->query($sqlQuery); //end date for members $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_memberships_users . "` ADD `enddate` DATETIME NULL AFTER `startdate`\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_memberships_users . "` ADD INDEX ( `enddate` )\r\n\t"; $wpdb->query($sqlQuery); pmpro_setOption("db_version", "1.23"); return 1.23; }
function pmproet_save_template_data() { //update this template's settings pmpro_setOption($_REQUEST['template'] . '_subject', stripslashes($_REQUEST['subject'])); pmpro_setOption($_REQUEST['template'] . '_body', stripslashes($_REQUEST['body'])); echo 'Template Saved'; exit; }
function pmpro_upgrade_1_1_15() { /* DB table setup */ global $wpdb; $wpdb->hide_errors(); $wpdb->pmpro_membership_levels = $wpdb->prefix . 'pmpro_membership_levels'; $wpdb->pmpro_memberships_users = $wpdb->prefix . 'pmpro_memberships_users'; $wpdb->pmpro_memberships_categories = $wpdb->prefix . 'pmpro_memberships_categories'; $wpdb->pmpro_memberships_pages = $wpdb->prefix . 'pmpro_memberships_pages'; $wpdb->pmpro_membership_orders = $wpdb->prefix . 'pmpro_membership_orders'; $wpdb->pmpro_discount_codes = $wpdb->prefix . 'pmpro_discount_codes'; $wpdb->pmpro_discount_codes_levels = $wpdb->prefix . 'pmpro_discount_codes_levels'; $wpdb->pmpro_discount_codes_uses = $wpdb->prefix . 'pmpro_discount_codes_uses'; /* Changing some id columns to unsigned. */ $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_membership_levels . "` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_memberships_categories . "` CHANGE `membership_id` `membership_id` INT( 11 ) UNSIGNED NOT NULL\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_memberships_categories . "` CHANGE `category_id` `category_id` INT( 11 ) UNSIGNED NOT NULL\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_memberships_pages . "` CHANGE `membership_id` `membership_id` INT( 11 ) UNSIGNED NOT NULL\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_memberships_pages . "` CHANGE `page_id` `page_id` INT( 11 ) UNSIGNED NOT NULL\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_memberships_users . "` CHANGE `user_id` `user_id` INT( 11 ) UNSIGNED NOT NULL\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_memberships_users . "` CHANGE `membership_id` `membership_id` INT( 11 ) UNSIGNED NOT NULL\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_membership_orders . "` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_membership_orders . "` CHANGE `user_id` `user_id` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0'\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_membership_orders . "` CHANGE `membership_id` `membership_id` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0'\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_memberships_users . "` ADD `code_id` INT UNSIGNED NOT NULL AFTER `membership_id` ;\r\n\t"; $wpdb->query($sqlQuery); $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_memberships_users . "` ADD INDEX ( `code_id` )\r\n\t"; $wpdb->query($sqlQuery); /* New tables for discount codes */ //wp_pmpro_discount_codes $sqlQuery = "\t\t\r\n\t\tCREATE TABLE `" . $wpdb->pmpro_discount_codes . "` (\r\n\t\t `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\r\n\t\t `code` varchar(32) NOT NULL,\r\n\t\t `starts` date NOT NULL,\r\n\t\t `expires` date NOT NULL,\r\n\t\t `uses` int(11) NOT NULL,\r\n\t\t PRIMARY KEY (`id`),\r\n\t\t UNIQUE KEY `code` (`code`),\r\n\t\t KEY `starts` (`starts`),\r\n\t\t KEY `expires` (`expires`)\r\n\t\t);\r\n\t"; $wpdb->query($sqlQuery); //wp_pmpro_discount_codes_levels $sqlQuery = "\t\t\r\n\t\tCREATE TABLE `" . $wpdb->pmpro_discount_codes_levels . "` (\r\n\t\t `code_id` int(11) unsigned NOT NULL,\r\n\t\t `level_id` int(11) unsigned NOT NULL,\r\n\t\t `initial_payment` decimal(10,2) NOT NULL DEFAULT '0.00',\r\n\t\t `billing_amount` decimal(10,2) NOT NULL DEFAULT '0.00',\r\n\t\t `cycle_number` int(11) NOT NULL DEFAULT '0',\r\n\t\t `cycle_period` enum('Day','Week','Month','Year') DEFAULT 'Month',\r\n\t\t `billing_limit` int(11) NOT NULL COMMENT 'After how many cycles should billing stop?',\r\n\t\t `trial_amount` decimal(10,2) NOT NULL DEFAULT '0.00',\r\n\t\t `trial_limit` int(11) NOT NULL DEFAULT '0',\r\n\t\t PRIMARY KEY (`code_id`,`level_id`),\r\n\t\t KEY `initial_payment` (`initial_payment`)\r\n\t\t);\r\n\t"; $wpdb->query($sqlQuery); //wp_pmpro_discount_codes_uses $sqlQuery = "\t\t\r\n\t\tCREATE TABLE `" . $wpdb->pmpro_discount_codes_uses . "` (\r\n\t\t `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\r\n\t\t `code_id` int(10) unsigned NOT NULL,\r\n\t\t `user_id` int(10) unsigned NOT NULL,\r\n\t\t `order_id` int(10) unsigned NOT NULL,\r\n\t\t `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\r\n\t\t PRIMARY KEY (`id`),\r\n\t\t KEY `user_id` (`user_id`),\r\n\t\t KEY `timestamp` (`timestamp`)\r\n\t\t);\r\n\t"; $wpdb->query($sqlQuery); pmpro_setOption("db_version", "1.115"); //do the next update return 1.115; }
function pmproet_save_template_data() { check_ajax_referer('pmproet', 'security'); //update this template's settings pmpro_setOption('email_' . $_REQUEST['template'] . '_subject', stripslashes($_REQUEST['subject'])); pmpro_setOption('email_' . $_REQUEST['template'] . '_body', stripslashes($_REQUEST['body'])); echo 'Template Saved'; exit; }
function pmpro_upgrade_1_3_18() { //setting new email settings defaults pmpro_setOption("email_admin_checkout", "1"); pmpro_setOption("email_admin_changes", "1"); pmpro_setOption("email_admin_cancels", "1"); pmpro_setOption("email_admin_billing", "1"); pmpro_setOption("db_version", "1.318"); return 1.318; }
function pmpro_upgrade_1_6() { global $wpdb; $wpdb->hide_errors(); $wpdb->pmpro_membership_orders = $wpdb->prefix . 'pmpro_membership_orders'; //add notes column to orders $sqlQuery = "ALTER TABLE `" . $wpdb->pmpro_membership_orders . "` ADD `notes` TEXT NOT NULL"; $wpdb->query($sqlQuery); pmpro_setOption("db_version", "1.6"); return 1.6; }
function pmpro_upgrade_1_8_9_1() { global $wpdb; //Fixing Stripe orders where user_id/membership_id = 0. (Sets up update via AJAX) $orders = $wpdb->get_col("SELECT id FROM {$wpdb->pmpro_membership_orders} WHERE gateway = 'stripe' AND user_id = 0 AND membership_id = 0 AND status <> 'error' "); if (!empty($orders)) { pmpro_addUpdate('pmpro_upgrade_1_8_9_1_ajax'); } pmpro_setOption("db_version", "1.891"); return 1.891; }
function pmpro_upgrade_1_4() { global $wpdb; $wpdb->hide_errors(); $wpdb->pmpro_membership_levels = $wpdb->prefix . 'pmpro_membership_levels'; //confirmation message $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_membership_levels . "` ADD `confirmation` LONGTEXT NOT NULL AFTER `description`\r\n\t"; $wpdb->query($sqlQuery); pmpro_setOption("db_version", "1.4"); return 1.4; }
function pmpro_upgrade_1_8_9_3() { global $wpdb; //Fixing incorrect start and end dates. (Sets up update via AJAX) $user_ids = $wpdb->get_col("SELECT user_id FROM {$wpdb->pmpro_memberships_users} WHERE status = 'active' AND modified > '2016-05-19'"); if (!empty($user_ids)) { pmpro_addUpdate('pmpro_upgrade_1_8_9_3_ajax'); } pmpro_setOption("db_version", "1.91"); return 1.893; }
function pmpro_upgrade_1_5_9() { global $wpdb; $wpdb->hide_errors(); $wpdb->pmpro_membership_orders = $wpdb->prefix . 'pmpro_membership_orders'; //fix firstpayment statuses $sqlQuery = "UPDATE " . $wpdb->pmpro_membership_orders . " SET status = 'success' WHERE status = 'firstpayment'"; $wpdb->query($sqlQuery); pmpro_setOption("db_version", "1.59"); return 1.59; }
function pmpro_upgrade_1_4_8() { /* Adding a billing_country field to the orders table. */ global $wpdb; $wpdb->hide_errors(); $wpdb->pmpro_membership_orders = $wpdb->prefix . 'pmpro_membership_orders'; //billing_country $sqlQuery = "\r\n\t\tALTER TABLE `" . $wpdb->pmpro_membership_orders . "` ADD `billing_country` VARCHAR( 128 ) NOT NULL AFTER `billing_zip`\r\n\t"; $wpdb->query($sqlQuery); pmpro_setOption("db_version", "1.48"); return 1.48; }
function pmpro_upgrade_1_4_2() { /* Setting the new use_ssl setting. PayPal Website Payments Pro, Authorize.net, and Stripe will default to use ssl. PayPal Express and the test gateway (no gateway) will default to not use ssl. */ $gateway = pmpro_getOption("gateway"); if ($gateway == "paypal" || $gateway == "authorizenet" || $gateway == "stripe") { pmpro_setOption("use_ssl", 1); } else { pmpro_setOption("use_ssl", 0); } pmpro_setOption("db_version", "1.42"); return 1.42; }
function pmpro_upgrade_1_8_8() { global $wpdb; //Running the cron job cleanup again. require_once PMPRO_DIR . "/includes/updates/upgrade_1_8_7.php"; pmpro_upgrade_1_8_7(); //Fixing old Authorize.net orders with empty status. $sqlQuery = "UPDATE {$wpdb->pmpro_membership_orders} SET status = 'success' WHERE gateway = 'authorizenet' AND status = ''"; $wpdb->query($sqlQuery); //Fixing old $0 Stripe orders. (Sets up update via AJAX) $orders = $wpdb->get_col("SELECT id FROM {$wpdb->pmpro_membership_orders} WHERE gateway = 'stripe' AND total = 0"); if (!empty($orders)) { pmpro_addUpdate('pmpro_upgrade_1_8_8_ajax'); } pmpro_setOption("db_version", "1.88"); return 1.88; }
function pmpro_upgrade_1_5() { /* Add the id and status fields to pmpro_memberships_users, change primary key to id instead of user_id */ global $wpdb; $wpdb->hide_errors(); $wpdb->pmpro_memberships_users = $wpdb->prefix . 'pmpro_memberships_users'; //remove primary key $sqlQuery = "ALTER TABLE `" . $wpdb->pmpro_memberships_users . "` DROP PRIMARY KEY"; $wpdb->query($sqlQuery); //id $sqlQuery = "ALTER TABLE `" . $wpdb->pmpro_memberships_users . "` ADD `id` BIGINT( 20 ) UNSIGNED AUTO_INCREMENT FIRST, ADD PRIMARY KEY(id)"; $wpdb->query($sqlQuery); //status $sqlQuery = "ALTER TABLE `" . $wpdb->pmpro_memberships_users . "` ADD `status` varchar( 20 ) NOT NULL DEFAULT 'active' AFTER `trial_limit`"; $wpdb->query($sqlQuery); pmpro_setOption("db_version", "1.5"); return 1.5; }
function pmpro_upgrade_1() { /* default options */ $nonmembertext = sprintf(__('This content is for !!levels!! members only.<br /><a href="%s">Register</a>', 'pmpro'), wp_login_url() . "?action=register"); pmpro_setOption("nonmembertext", $nonmembertext); $notloggedintext = sprintf(__('This content is for !!levels!! members only.<br /><a href="%s">Log In</a> <a href="%s">Register</a>', 'pmpro'), wp_login_url(), wp_login_url() . "?action=register"); '?action=register">Register</a>'; pmpro_setOption("notloggedintext", $notloggedintext); $rsstext = __("This content is for !!levels!! members only. Visit the site and log in/register to read.", 'pmpro'); pmpro_setOption("rsstext", $rsstext); $gateway_environment = "sandbox"; pmpro_setOption("gateway_environment", $gateway_environment); $pmpro_currency = "USD"; pmpro_setOption("currency", $pmpro_currency); $pmpro_accepted_credit_cards = "Visa,Mastercard,American Express,Discover"; pmpro_setOption("accepted_credit_cards", $pmpro_accepted_credit_cards); $parsed = parse_url(home_url()); $hostname = $parsed['host']; $hostparts = explode(".", $hostname); $email_domain = $hostparts[count($hostparts) - 2] . "." . $hostparts[count($hostparts) - 1]; $from_email = "wordpress@" . $email_domain; pmpro_setOption("from_email", $from_email); $from_name = "WordPress"; pmpro_setOption("from_name", $from_name); //setting new email settings defaults pmpro_setOption("email_admin_checkout", "1"); pmpro_setOption("email_admin_changes", "1"); pmpro_setOption("email_admin_cancels", "1"); pmpro_setOption("email_admin_billing", "1"); pmpro_setOption("tospage", ""); //db update pmpro_db_delta(); //update version and return pmpro_setOption("db_version", "1.71"); //no need to run other updates return 1.71; }
function pmpro_upgrade_1() { /* default options */ $nonmembertext = "This content is for !!levels!! members only. <a href=\"" . wp_login_url() . "?action=register\">Register here</a>."; pmpro_setOption("nonmembertext", $nonmembertext); $notloggedintext = "This content is for !!levels!! members only. Please <a href=\"" . wp_login_url( get_permalink() ) . "\">login</a> to view this content. (<a href=\"" . wp_login_url() . "?action=register\">Register here</a>.)"; pmpro_setOption("notloggedintext", $notloggedintext); $rsstext = "This content is for !!levels!! members only. Visit the site and log in/register to read."; pmpro_setOption("rsstext", $rsstext); $gateway_environment = "sandbox"; pmpro_setOption("gateway_environment", $gateway_environment); $pmpro_currency = "USD"; pmpro_setOption("currency", $pmpro_currency); $pmpro_accepted_credit_cards = "Visa,Mastercard,American Express,Discover"; pmpro_setOption("accepted_credit_cards", $pmpro_accepted_credit_cards); $parsed = parse_url(home_url()); $hostname = $parsed['host']; $hostparts = split("\.", $hostname); $email_domain = $hostparts[count($hostparts) - 2] . "." . $hostparts[count($hostparts) - 1]; $from_email = "wordpress@" . $email_domain; pmpro_setOption("from_email", $from_email); $from_name = "WordPress"; pmpro_setOption("from_name", $from_name); pmpro_setOption("tospage", ""); /* DB table setup */ global $wpdb; $wpdb->hide_errors(); $wpdb->pmpro_membership_levels = $wpdb->prefix . 'pmpro_membership_levels'; $wpdb->pmpro_memberships_users = $wpdb->prefix . 'pmpro_memberships_users'; $wpdb->pmpro_memberships_categories = $wpdb->prefix . 'pmpro_memberships_categories'; $wpdb->pmpro_memberships_pages = $wpdb->prefix . 'pmpro_memberships_pages'; $wpdb->pmpro_membership_orders = $wpdb->prefix . 'pmpro_membership_orders'; $wpdb->pmpro_discount_codes = $wpdb->prefix . 'pmpro_discount_codes'; $wpdb->pmpro_discount_codes_levels = $wpdb->prefix . 'pmpro_discount_codes_levels'; $wpdb->pmpro_discount_codes_uses = $wpdb->prefix . 'pmpro_discount_codes_uses'; //wp_pmpro_membership_levels $sqlQuery = " CREATE TABLE `" . $wpdb->pmpro_membership_levels . "` ( `id` int(11) UNSIGNED NOT NULL auto_increment, `name` varchar(255) NOT NULL, `description` longtext NOT NULL, `initial_payment` decimal(10,2) NOT NULL default '0.00', `billing_amount` decimal(10,2) NOT NULL default '0.00', `cycle_number` int(11) NOT NULL default '0', `cycle_period` enum('Day','Week','Month','Year') default 'Month', `billing_limit` int(11) NOT NULL COMMENT 'After how many cycles should billing stop?', `trial_amount` decimal(10,2) NOT NULL default '0.00', `trial_limit` int(11) NOT NULL default '0', `allow_signups` tinyint(4) NOT NULL default '1', PRIMARY KEY (`id`), KEY `allow_signups` (`allow_signups`), KEY `initial_payment` (`initial_payment`), KEY `name` (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 "; $wpdb->query($sqlQuery); //wp_pmpro_membership_orders $sqlQuery = " CREATE TABLE `" . $wpdb->pmpro_membership_orders . "` ( `id` int(11) UNSIGNED NOT NULL auto_increment, `code` varchar(10) NOT NULL, `session_id` varchar(64) NOT NULL default '', `user_id` int(11) UNSIGNED NOT NULL default '0', `membership_id` int(11) UNSIGNED NOT NULL default '0', `paypal_token` varchar(64) NOT NULL default '', `billing_name` varchar(128) NOT NULL default '', `billing_street` varchar(128) NOT NULL default '', `billing_city` varchar(128) NOT NULL default '', `billing_state` varchar(32) NOT NULL default '', `billing_zip` varchar(16) NOT NULL default '', `billing_phone` varchar(32) NOT NULL, `subtotal` varchar(16) NOT NULL default '', `tax` varchar(16) NOT NULL default '', `couponamount` varchar(16) NOT NULL default '', `certificate_id` int(11) NOT NULL default '0', `certificateamount` varchar(16) NOT NULL default '', `total` varchar(16) NOT NULL default '', `payment_type` varchar(64) NOT NULL default '', `cardtype` varchar(32) NOT NULL default '', `accountnumber` varchar(32) NOT NULL default '', `expirationmonth` char(2) NOT NULL default '', `expirationyear` varchar(4) NOT NULL default '', `status` varchar(32) NOT NULL default '', `gateway` varchar(64) NOT NULL, `gateway_environment` varchar(64) NOT NULL, `payment_transaction_id` varchar(64) NOT NULL, `subscription_transaction_id` varchar(32) NOT NULL, `timestamp` datetime NOT NULL default '0000-00-00 00:00:00', `affiliate_id` varchar(32) NOT NULL, `affiliate_subid` varchar(32) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`), KEY `session_id` (`session_id`), KEY `user_id` (`user_id`), KEY `membership_id` (`membership_id`), KEY `timestamp` (`timestamp`), KEY `gateway` (`gateway`), KEY `gateway_environment` (`gateway_environment`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; "; $wpdb->query($sqlQuery); //wp_pmpro_memberships_categories $sqlQuery = " CREATE TABLE `" . $wpdb->pmpro_memberships_categories . "` ( `membership_id` int(11) UNSIGNED NOT NULL, `category_id` int(11) UNSIGNED NOT NULL, `modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, UNIQUE KEY `membership_category` (`membership_id`,`category_id`), UNIQUE KEY `category_membership` (`category_id`,`membership_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; "; $wpdb->query($sqlQuery); //wp_pmpro_memberships_pages $sqlQuery = " CREATE TABLE `" . $wpdb->pmpro_memberships_pages . "` ( `membership_id` int(11) UNSIGNED NOT NULL, `page_id` int(11) UNSIGNED NOT NULL, `modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, UNIQUE KEY `category_membership` (`page_id`,`membership_id`), UNIQUE KEY `membership_page` (`membership_id`,`page_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; "; $wpdb->query($sqlQuery); //wp_pmpro_memberships_users $sqlQuery = " CREATE TABLE `" . $wpdb->pmpro_memberships_users . "` ( `user_id` int(11) UNSIGNED NOT NULL, `membership_id` int(11) UNSIGNED NOT NULL, `code_id` int(11) UNSIGNED NOT NULL, `initial_payment` decimal(10,2) NOT NULL, `billing_amount` decimal(10,2) NOT NULL, `cycle_number` int(11) NOT NULL, `cycle_period` enum('Day','Week','Month','Year') NOT NULL default 'Month', `billing_limit` int(11) NOT NULL, `trial_amount` decimal(10,2) NOT NULL, `trial_limit` int(11) NOT NULL, `startdate` datetime NOT NULL, `modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`user_id`), KEY `membership_id` (`membership_id`), KEY `modified` (`modified`), KEY `code_id` (`code_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; "; $wpdb->query($sqlQuery); //wp_pmpro_discount_codes $sqlQuery = " CREATE TABLE `" . $wpdb->pmpro_discount_codes . "` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(32) NOT NULL, `starts` date NOT NULL, `expires` date NOT NULL, `uses` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`), KEY `starts` (`starts`), KEY `expires` (`expires`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; "; $wpdb->query($sqlQuery); //wp_pmpro_discount_codes_levels $sqlQuery = " CREATE TABLE `" . $wpdb->pmpro_discount_codes_levels . "` ( `code_id` int(11) unsigned NOT NULL, `level_id` int(11) unsigned NOT NULL, `initial_payment` decimal(10,2) NOT NULL DEFAULT '0.00', `billing_amount` decimal(10,2) NOT NULL DEFAULT '0.00', `cycle_number` int(11) NOT NULL DEFAULT '0', `cycle_period` enum('Day','Week','Month','Year') DEFAULT 'Month', `billing_limit` int(11) NOT NULL COMMENT 'After how many cycles should billing stop?', `trial_amount` decimal(10,2) NOT NULL DEFAULT '0.00', `trial_limit` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`code_id`,`level_id`), KEY `initial_payment` (`initial_payment`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; "; $wpdb->query($sqlQuery); //wp_pmpro_discount_codes_uses $sqlQuery = " CREATE TABLE `" . $wpdb->pmpro_discount_codes_uses . "` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code_id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL, `order_id` int(10) unsigned NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `user_id` (`user_id`), KEY `timestamp` (`timestamp`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; "; $wpdb->query($sqlQuery); pmpro_setOption("db_version", "1.115"); return 1.115; }
function pmprorh_pmpro_save_membership_level($saveid) { $restrict_emails = $_REQUEST['restrict_emails']; pmpro_setOption("level_" . $saveid . "_restrict_emails", $restrict_emails); $restrict_emails = $_REQUEST['restrict_usernames']; pmpro_setOption("level_" . $saveid . "_restrict_usernames", $restrict_emails); }
function pmpro_checkForUpgrades() { $pmpro_db_version = pmpro_getOption("db_version"); //if we can't find the DB tables, reset db_version to 0 global $wpdb; $wpdb->hide_errors(); $wpdb->pmpro_membership_levels = $wpdb->prefix . 'pmpro_membership_levels'; $table_exists = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->pmpro_membership_levels . "'"); if (!$table_exists) { $pmpro_db_version = 0; } //default options if (!$pmpro_db_version) { require_once PMPRO_DIR . "/includes/updates/upgrade_1.php"; $pmpro_db_version = pmpro_upgrade_1(); } //upgrading from early early versions of PMPro if ($pmpro_db_version < 1.115) { require_once PMPRO_DIR . "/includes/updates/upgrade_1_1_15.php"; $pmpro_db_version = pmpro_upgrade_1_1_15(); } //upgrading from early early versions of PMPro if ($pmpro_db_version < 1.23) { require_once PMPRO_DIR . "/includes/updates/upgrade_1_2_3.php"; $pmpro_db_version = pmpro_upgrade_1_2_3(); } //upgrading from early early versions of PMPro if ($pmpro_db_version < 1.318) { require_once PMPRO_DIR . "/includes/updates/upgrade_1_3_18.php"; $pmpro_db_version = pmpro_upgrade_1_3_18(); } //upgrading from early early versions of PMPro if ($pmpro_db_version < 1.4) { require_once PMPRO_DIR . "/includes/updates/upgrade_1_4.php"; $pmpro_db_version = pmpro_upgrade_1_4(); } //upgrading from early early versions of PMPro if ($pmpro_db_version < 1.42) { require_once PMPRO_DIR . "/includes/updates/upgrade_1_4_2.php"; $pmpro_db_version = pmpro_upgrade_1_4_2(); } //upgrading from early early versions of PMPro if ($pmpro_db_version < 1.48) { require_once PMPRO_DIR . "/includes/updates/upgrade_1_4_8.php"; $pmpro_db_version = pmpro_upgrade_1_4_8(); } //upgrading from early early versions of PMPro if ($pmpro_db_version < 1.5) { require_once PMPRO_DIR . "/includes/updates/upgrade_1_5.php"; $pmpro_db_version = pmpro_upgrade_1_5(); } //upgrading from early early versions of PMPro if ($pmpro_db_version < 1.59) { require_once PMPRO_DIR . "/includes/updates/upgrade_1_5_9.php"; $pmpro_db_version = pmpro_upgrade_1_5_9(); } //upgrading from early early versions of PMPro if ($pmpro_db_version < 1.6) { require_once PMPRO_DIR . "/includes/updates/upgrade_1_6.php"; $pmpro_db_version = pmpro_upgrade_1_6(); } //fix for fresh 1.7 installs if ($pmpro_db_version == 1.7) { //check if we have an id column in the memberships_users table $wpdb->pmpro_memberships_users = $wpdb->prefix . 'pmpro_memberships_users'; $col = $wpdb->get_var("SELECT id FROM {$wpdb->pmpro_memberships_users} LIMIT 1"); if ($wpdb->last_error == "Unknown column 'id' in 'field list'") { //redo 1.5 fix require_once PMPRO_DIR . "/includes/updates/upgrade_1_5.php"; pmpro_upgrade_1_5(); } pmpro_db_delta(); pmpro_setOption("db_version", "1.703"); $pmpro_db_version = 1.703; } //updates from this point on should be like this if DB only if ($pmpro_db_version < 1.71) { pmpro_db_delta(); pmpro_setOption("db_version", "1.71"); $pmpro_db_version = 1.71; } //schedule the credit card expiring cron if ($pmpro_db_version < 1.72) { //schedule the credit card expiring cron pmpro_maybe_schedule_event(current_time('timestamp'), 'monthly', 'pmpro_cron_credit_card_expiring_warnings'); pmpro_setOption("db_version", "1.72"); $pmpro_db_version = 1.72; } //register capabilities required for menus now if ($pmpro_db_version < 1.79) { //need to register caps for menu pmpro_activation(); pmpro_setOption("db_version", "1.79"); $pmpro_db_version = 1.79; } //set default filter_queries setting if ($pmpro_db_version < 1.791) { if (!pmpro_getOption("showexcerpts")) { pmpro_setOption("filterqueries", 1); } else { pmpro_SetOption("filterqueries", 0); } pmpro_setOption("db_version", "1.791"); $pmpro_db_version = 1.791; } //fix subscription ids on stripe orders require_once PMPRO_DIR . "/includes/updates/upgrade_1_8_6_9.php"; //need to include this for AJAX calls if ($pmpro_db_version < 1.869) { $pmpro_db_version = pmpro_upgrade_1_8_6_9(); } //Remove extra cron jobs inserted in version 1.8.7 and 1.8.7.1 if ($pmpro_db_version < 1.87) { require_once PMPRO_DIR . "/includes/updates/upgrade_1_8_7.php"; $pmpro_db_version = pmpro_upgrade_1_8_7(); } /* v1.8.8 * Running the cron job cleanup again. * Fixing old $0 Stripe orders. * Fixing old Authorize.net orders with empty status. */ require_once PMPRO_DIR . "/includes/updates/upgrade_1_8_8.php"; if ($pmpro_db_version < 1.88) { $pmpro_db_version = pmpro_upgrade_1_8_8(); } /* v1.8.9.1 * Fixing Stripe orders where user_id/membership_id = 0 */ require_once PMPRO_DIR . "/includes/updates/upgrade_1_8_9_1.php"; if ($pmpro_db_version < 1.891) { $pmpro_db_version = pmpro_upgrade_1_8_9_1(); } /* v1.8.9.2 (db v1.9) * Changed 'code' column of pmpro_membership_orders table to 32 characters. */ if ($pmpro_db_version < 1.892) { pmpro_db_delta(); $pmpro_db_version = 1.892; pmpro_setOption("db_version", "1.892"); } /* v1.8.9.3 (db v1.91) * Fixing incorrect start and end dates. */ require_once PMPRO_DIR . "/includes/updates/upgrade_1_8_9_3.php"; if ($pmpro_db_version < 1.91) { $pmpro_db_version = pmpro_upgrade_1_8_9_3(); } /* v1.8.10 (db v1.92) Added checkout_id column to pmpro_membership_orders */ if ($pmpro_db_version < 1.92) { pmpro_db_delta(); $pmpro_db_version = 1.92; pmpro_setOption("db_version", "1.92"); } /* v1.8.10.2 (db v1.93) Run dbDelta again to fix broken/missing orders tables. */ if ($pmpro_db_version < 1.93) { pmpro_db_delta(); $pmpro_db_version = 1.93; pmpro_setOption("db_version", "1.93"); } }
//remove levels from order if they are gone foreach ($order as $key => $level_id) { if (!in_array($level_id, $level_ids)) { unset($order[$key]); } } //add levels to the end if they aren't in the order array foreach ($level_ids as $level_id) { if (!in_array($level_id, $order)) { $order[] = $level_id; } } //remove dupes $order = array_unique($order); //save the level order pmpro_setOption('level_order', implode(',', $order)); //reorder levels here $reordered_levels = array(); foreach ($order as $level_id) { foreach ($levels as $level) { if ($level_id == $level->id) { $reordered_levels[] = $level; } } } } else { $reordered_levels = $levels; } $count = 0; foreach ($reordered_levels as $level) { ?>
function pmpro_update_level_order() { echo pmpro_setOption('level_order'); exit; }
if($pmpro_page_name != "account") { $insert['post_parent'] = $pmpro_pages['account']; } //create the page $pmpro_pages[$pmpro_page_name] = wp_insert_post( $insert ); //add besecure post option to pages that need it /* these pages are handling this themselves in the preheader if(in_array($pmpro_page_name, array("billing", "checkout"))) update_post_meta($pmpro_pages[$pmpro_page_name], "besecure", 1); */ //update the option too pmpro_setOption($pmpro_page_name . "_page_id", $pmpro_pages[$pmpro_page_name]); $pages_created[] = $pmpro_pages[$pmpro_page_name]; } } if(!empty($pages_created)) { $msg = true; $msgt = "The following pages have been created for you: " . implode(", ", $pages_created) . "."; } } require_once(dirname(__FILE__) . "/admin_header.php"); ?>
$tax_rate = pmpro_getOption("tax_rate"); //make sure the tax rate is not > 1 if ((double) $tax_rate > 1) { //assume the entered X% $tax_rate = $tax_rate / 100; pmpro_setOption("tax_rate", $tax_rate); } $use_ssl = pmpro_getOption("use_ssl"); //default settings if (empty($gateway_environment)) { $gateway_environment = "sandbox"; pmpro_setOption("gateway_environment", $gateway_environment); } if (empty($pmpro_accepted_credit_cards)) { $pmpro_accepted_credit_cards = "Visa,Mastercard,American Express,Discover"; pmpro_setOption("accepted_credit_cards", $pmpro_accepted_credit_cards); } $pmpro_accepted_credit_cards = explode(",", $pmpro_accepted_credit_cards); require_once dirname(__FILE__) . "/admin_header.php"; ?> <form action="" method="post" enctype="multipart/form-data"> <h2><?php _e('Payment Gateway', 'pmpro'); ?> & <?php _e('SSL Settings', 'pmpro'); ?> </h2> <p><?php
pmpro_setOption("checkout_page_id"); pmpro_setOption("confirmation_page_id"); pmpro_setOption("invoice_page_id"); pmpro_setOption("levels_page_id"); //update the pages array $pmpro_pages["account"] = pmpro_getOption("account_page_id"); $pmpro_pages["billing"] = pmpro_getOption("billing_page_id"); $pmpro_pages["cancel"] = pmpro_getOption("cancel_page_id"); $pmpro_pages["checkout"] = pmpro_getOption("checkout_page_id"); $pmpro_pages["confirmation"] = pmpro_getOption("confirmation_page_id"); $pmpro_pages["invoice"] = pmpro_getOption("invoice_page_id"); $pmpro_pages["levels"] = pmpro_getOption("levels_page_id"); //save additional pages if (!empty($extra_pages)) { foreach ($extra_pages as $name => $label) { pmpro_setOption($name . '_page_id'); $pmpro_pages[$name] = pmpro_getOption($name . '_page_id'); } } //assume success $msg = true; $msgt = __("Your page settings have been updated.", "pmpro"); } //are we generating pages? if (!empty($_REQUEST['createpages'])) { $pages = array(); if (empty($_REQUEST['page_name'])) { //default pages $pages['account'] = __('Membership Account', 'pmpro'); $pages['billing'] = __('Membership Billing', 'pmpro'); $pages['cancel'] = __('Membership Cancel', 'pmpro');
/** * Function to generate PMPro front end pages. * * @param array $pages { * Formatted as array($name => $title) or array(array('title'=>'The Title', 'content'=>'The Content')) * * @type string $name Page name. (Letters, numbers, and underscores only.) * @type string $title Page title. * } * @return array $created_pages Created page IDs. * @since 1.8.5 */ function pmpro_generatePages($pages) { global $pmpro_pages; $pages_created = array(); if (!empty($pages)) { foreach ($pages as $name => $page) { //does it already exist? if (!empty($pmpro_pages[$name])) { continue; } //no id set. create an array to store the page info if (is_array($page)) { $title = $page['title']; $content = $page['content']; } else { $title = $page; $content = '[pmpro_' . $name . ']'; } $insert = array('post_title' => $title, 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => $content, 'comment_status' => 'closed', 'ping_status' => 'closed'); //make non-account pages a subpage of account if ($name != "account") { $insert['post_parent'] = $pmpro_pages['account']; } //create the page $pmpro_pages[$name] = wp_insert_post($insert); //update the option too pmpro_setOption($name . "_page_id", $pmpro_pages[$name]); $pages_created[] = $pmpro_pages[$name]; } } return $pages_created; }
$recaptcha_publickey = pmpro_getOption("recaptcha_publickey"); $recaptcha_privatekey = pmpro_getOption("recaptcha_privatekey"); $tospage = pmpro_getOption("tospage"); $hide_footer_link = pmpro_getOption("hide_footer_link"); //default settings if (!$nonmembertext) { $nonmembertext = sprintf(__('This content is for !!levels!! members only. <a href="%s">Register here</a>.', 'pmpro'), wp_login_url() . "?action=register"); pmpro_setOption("nonmembertext", $nonmembertext); } if (!$notloggedintext) { $notloggedintext = sprintf(__('Please <a href="%s">login</a> to view this content. (<a href="%s">Register here</a>.)', 'pmpro'), wp_login_url(get_permalink()), wp_login_url() . "?action=register"); pmpro_setOption("notloggedintext", $notloggedintext); } if (!$rsstext) { $rsstext = __('This content is for members only. Visit the site and log in/register to read.', 'pmpro'); pmpro_setOption("rsstext", $rsstext); } $levels = $wpdb->get_results("SELECT * FROM {$wpdb->pmpro_membership_levels}", OBJECT); require_once dirname(__FILE__) . "/admin_header.php"; ?> <form action="" method="post" enctype="multipart/form-data"> <h2><?php _e('Advanced Settings', 'pmpro'); ?> </h2> <table class="form-table"> <tbody> <tr> <th scope="row" valign="top">
$email_admin_checkout = pmpro_getOption("email_admin_checkout"); $email_admin_changes = pmpro_getOption("email_admin_changes"); $email_admin_cancels = pmpro_getOption("email_admin_cancels"); $email_admin_billing = pmpro_getOption("email_admin_billing"); $email_member_notification = pmpro_getOption("email_member_notification"); if (empty($from_email)) { $parsed = parse_url(home_url()); $hostname = $parsed[host]; $hostparts = split("\\.", $hostname); $email_domain = $hostparts[count($hostparts) - 2] . "." . $hostparts[count($hostparts) - 1]; $from_email = "wordpress@" . $email_domain; pmpro_setOption("from_email", $from_email); } if (empty($from_name)) { $from_name = "WordPress"; pmpro_setOption("from_name", $from_name); } // default from email wordpress@sitename $sitename = strtolower($_SERVER['SERVER_NAME']); if (substr($sitename, 0, 4) == 'www.') { $sitename = substr($sitename, 4); } $default_from_email = 'wordpress@' . $sitename; require_once dirname(__FILE__) . "/admin_header.php"; ?> <form action="" method="post" enctype="multipart/form-data"> <h2><?php _e('Email Settings', 'pmpro'); ?> </h2>