pmpro_upgrade_1_1_15

The Paid Memberships Pro pmpro upgrade 1 15 function.

Description

pmpro_upgrade_1_1_15(); 

Usage

  1. if ( !function_exists( 'pmpro_upgrade_1_1_15' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/updates/upgrade_1_1_15.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = pmpro_upgrade_1_1_15(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/updates/upgrade_1_1_15.php  
  1. function pmpro_upgrade_1_1_15() 
  2. /** 
  3. DB tablesetup  
  4. */ 
  5. global $wpdb; 
  6. $wpdb->hide_errors(); 
  7. $wpdb->pmpro_membership_levels = $wpdb->prefix . 'pmpro_membership_levels'; 
  8. $wpdb->pmpro_memberships_users = $wpdb->prefix . 'pmpro_memberships_users'; 
  9. $wpdb->pmpro_memberships_categories = $wpdb->prefix . 'pmpro_memberships_categories'; 
  10. $wpdb->pmpro_memberships_pages = $wpdb->prefix . 'pmpro_memberships_pages'; 
  11. $wpdb->pmpro_membership_orders = $wpdb->prefix . 'pmpro_membership_orders'; 
  12. $wpdb->pmpro_discount_codes = $wpdb->prefix . 'pmpro_discount_codes'; 
  13. $wpdb->pmpro_discount_codes_levels = $wpdb->prefix . 'pmpro_discount_codes_levels'; 
  14. $wpdb->pmpro_discount_codes_uses = $wpdb->prefix . 'pmpro_discount_codes_uses'; 
  15.  
  16. /** 
  17. Changing some id columns to unsigned.  
  18. */ 
  19. $sqlQuery = " 
  20. ALTER TABLE `" . $wpdb->pmpro_membership_levels . "` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT 
  21. "; 
  22. $wpdb->query($sqlQuery); 
  23.  
  24. $sqlQuery = " 
  25. ALTER TABLE `" . $wpdb->pmpro_memberships_categories . "` CHANGE `membership_id` `membership_id` INT( 11 ) UNSIGNED NOT NULL 
  26. "; 
  27. $wpdb->query($sqlQuery); 
  28.  
  29. $sqlQuery = " 
  30. ALTER TABLE `" . $wpdb->pmpro_memberships_categories . "` CHANGE `category_id` `category_id` INT( 11 ) UNSIGNED NOT NULL 
  31. "; 
  32. $wpdb->query($sqlQuery); 
  33.  
  34. $sqlQuery = " 
  35. ALTER TABLE `" . $wpdb->pmpro_memberships_pages . "` CHANGE `membership_id` `membership_id` INT( 11 ) UNSIGNED NOT NULL 
  36. "; 
  37. $wpdb->query($sqlQuery); 
  38.  
  39. $sqlQuery = " 
  40. ALTER TABLE `" . $wpdb->pmpro_memberships_pages . "` CHANGE `page_id` `page_id` INT( 11 ) UNSIGNED NOT NULL 
  41. "; 
  42. $wpdb->query($sqlQuery); 
  43.  
  44. $sqlQuery = " 
  45. ALTER TABLE `" . $wpdb->pmpro_memberships_users . "` CHANGE `user_id` `user_id` INT( 11 ) UNSIGNED NOT NULL 
  46. "; 
  47. $wpdb->query($sqlQuery); 
  48.  
  49. $sqlQuery = " 
  50. ALTER TABLE `" . $wpdb->pmpro_memberships_users . "` CHANGE `membership_id` `membership_id` INT( 11 ) UNSIGNED NOT NULL 
  51. "; 
  52. $wpdb->query($sqlQuery); 
  53.  
  54. $sqlQuery = " 
  55. ALTER TABLE `" . $wpdb->pmpro_membership_orders . "` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT 
  56. "; 
  57. $wpdb->query($sqlQuery); 
  58.  
  59. $sqlQuery = " 
  60. ALTER TABLE `" . $wpdb->pmpro_membership_orders . "` CHANGE `user_id` `user_id` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0' 
  61. "; 
  62. $wpdb->query($sqlQuery); 
  63.  
  64. $sqlQuery = " 
  65. ALTER TABLE `" . $wpdb->pmpro_membership_orders . "` CHANGE `membership_id` `membership_id` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0' 
  66. "; 
  67. $wpdb->query($sqlQuery); 
  68.  
  69. $sqlQuery = " 
  70. ALTER TABLE `" . $wpdb->pmpro_memberships_users . "` ADD `code_id` INT UNSIGNED NOT NULL AFTER `membership_id` ; 
  71. "; 
  72. $wpdb->query($sqlQuery); 
  73.  
  74. $sqlQuery = " 
  75. ALTER TABLE `" . $wpdb->pmpro_memberships_users . "` ADD INDEX ( `code_id` ) 
  76. "; 
  77. $wpdb->query($sqlQuery); 
  78.  
  79. /** 
  80. New tables fordiscountcodes 
  81. */ 
  82.  
  83. //wp_pmpro_discount_codes 
  84. $sqlQuery = "  
  85. CREATE TABLE `" . $wpdb->pmpro_discount_codes . "` ( 
  86. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,  
  87. `code` varchar(32) NOT NULL,  
  88. `starts` date NOT NULL,  
  89. `expires` date NOT NULL,  
  90. `uses` int(11) NOT NULL,  
  91. PRIMARY KEY (`id`),  
  92. UNIQUE KEY `code` (`code`),  
  93. KEY `starts` (`starts`),  
  94. KEY `expires` (`expires`) 
  95. ); 
  96. "; 
  97. $wpdb->query($sqlQuery); 
  98.  
  99. //wp_pmpro_discount_codes_levels 
  100. $sqlQuery = "  
  101. CREATE TABLE `" . $wpdb->pmpro_discount_codes_levels . "` ( 
  102. `code_id` int(11) unsigned NOT NULL,  
  103. `level_id` int(11) unsigned NOT NULL,  
  104. `initial_payment` decimal(10, 2) NOT NULL DEFAULT '0.00',  
  105. `billing_amount` decimal(10, 2) NOT NULL DEFAULT '0.00',  
  106. `cycle_number` int(11) NOT NULL DEFAULT '0',  
  107. `cycle_period` enum('Day', 'Week', 'Month', 'Year') DEFAULT 'Month',  
  108. `billing_limit` int(11) NOT NULL COMMENT 'After how many cycles should billing stop?',  
  109. `trial_amount` decimal(10, 2) NOT NULL DEFAULT '0.00',  
  110. `trial_limit` int(11) NOT NULL DEFAULT '0',  
  111. PRIMARY KEY (`code_id`, `level_id`),  
  112. KEY `initial_payment` (`initial_payment`) 
  113. ); 
  114. "; 
  115. $wpdb->query($sqlQuery); 
  116.  
  117. //wp_pmpro_discount_codes_uses 
  118. $sqlQuery = "  
  119. CREATE TABLE `" . $wpdb->pmpro_discount_codes_uses . "` ( 
  120. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,  
  121. `code_id` int(10) unsigned NOT NULL,  
  122. `user_id` int(10) unsigned NOT NULL,  
  123. `order_id` int(10) unsigned NOT NULL,  
  124. `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  
  125. PRIMARY KEY (`id`),  
  126. KEY `user_id` (`user_id`),  
  127. KEY `timestamp` (`timestamp`) 
  128. ); 
  129. "; 
  130. $wpdb->query($sqlQuery); 
  131.  
  132. pmpro_setOption("db_version", "1.115"); 
  133.  
  134. //do the next update 
  135. return 1.115;