pmpro_checkForUpgrades

These functions below handle DB upgrades, etc.

Description

pmpro_checkForUpgrades(); 

Usage

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

Defined (1)

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

/includes/upgradecheck.php  
  1. function pmpro_checkForUpgrades() 
  2. $pmpro_db_version = pmpro_getOption("db_version"); 
  3.  
  4. //if we can't find the DB tables, reset db_version to 0 
  5. global $wpdb; 
  6. $wpdb->hide_errors(); 
  7. $wpdb->pmpro_membership_levels = $wpdb->prefix . 'pmpro_membership_levels'; 
  8. $table_exists = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->pmpro_membership_levels . "'"); 
  9. if(!$table_exists) 
  10. $pmpro_db_version = 0; 
  11.  
  12. //default options 
  13. if(!$pmpro_db_version) { 
  14. require_once(PMPRO_DIR . "/includes/updates/upgrade_1.php"); 
  15. $pmpro_db_version = pmpro_upgrade_1(); 
  16.  
  17. //upgrading from early early versions of PMPro 
  18. if($pmpro_db_version < 1.115) { 
  19. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_1_15.php"); 
  20. $pmpro_db_version = pmpro_upgrade_1_1_15(); 
  21.  
  22. //upgrading from early early versions of PMPro 
  23. if($pmpro_db_version < 1.23) { 
  24. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_2_3.php"); 
  25. $pmpro_db_version = pmpro_upgrade_1_2_3(); 
  26.  
  27. //upgrading from early early versions of PMPro 
  28. if($pmpro_db_version < 1.318) { 
  29. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_3_18.php"); 
  30. $pmpro_db_version = pmpro_upgrade_1_3_18(); 
  31.  
  32. //upgrading from early early versions of PMPro 
  33. if($pmpro_db_version < 1.4) { 
  34. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_4.php"); 
  35. $pmpro_db_version = pmpro_upgrade_1_4(); 
  36.  
  37. //upgrading from early early versions of PMPro 
  38. if($pmpro_db_version < 1.42) { 
  39. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_4_2.php"); 
  40. $pmpro_db_version = pmpro_upgrade_1_4_2(); 
  41.  
  42. //upgrading from early early versions of PMPro 
  43. if($pmpro_db_version < 1.48) { 
  44. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_4_8.php"); 
  45. $pmpro_db_version = pmpro_upgrade_1_4_8(); 
  46.  
  47. //upgrading from early early versions of PMPro 
  48. if($pmpro_db_version < 1.5) { 
  49. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_5.php"); 
  50. $pmpro_db_version = pmpro_upgrade_1_5(); 
  51.  
  52. //upgrading from early early versions of PMPro 
  53. if($pmpro_db_version < 1.59) { 
  54. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_5_9.php"); 
  55. $pmpro_db_version = pmpro_upgrade_1_5_9(); 
  56.  
  57. //upgrading from early early versions of PMPro 
  58. if($pmpro_db_version < 1.6) { 
  59. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_6.php"); 
  60. $pmpro_db_version = pmpro_upgrade_1_6(); 
  61.  
  62. //fix for fresh 1.7 installs 
  63. if($pmpro_db_version == 1.7) 
  64. //check if we have an id column in the memberships_users table 
  65. $wpdb->pmpro_memberships_users = $wpdb->prefix . 'pmpro_memberships_users'; 
  66. $col = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_memberships_users LIMIT 1"); 
  67. if($wpdb->last_error == "Unknown column 'id' in 'field list'") 
  68. //redo 1.5 fix 
  69. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_5.php"); 
  70.  
  71.  
  72. pmpro_setOption("db_version", "1.703"); 
  73. $pmpro_db_version = 1.703; 
  74.  
  75. //updates from this point on should be like this if DB only 
  76. if($pmpro_db_version < 1.71) 
  77. pmpro_setOption("db_version", "1.71"); 
  78. $pmpro_db_version = 1.71; 
  79.  
  80. //schedule the creditcardexpiring cron 
  81. if($pmpro_db_version < 1.72) 
  82. //schedule the creditcardexpiring cron 
  83. pmpro_maybe_schedule_event(current_time('timestamp'), 'monthly', 'pmpro_cron_credit_card_expiring_warnings'); 
  84.  
  85. pmpro_setOption("db_version", "1.72"); 
  86. $pmpro_db_version = 1.72; 
  87.  
  88. //register capabilities required for menus now 
  89. if($pmpro_db_version < 1.79) 
  90. //need to register caps for menu 
  91. pmpro_activation(); 
  92.  
  93. pmpro_setOption("db_version", "1.79"); 
  94. $pmpro_db_version = 1.79; 
  95.  
  96. //set default filter_queries setting 
  97. if($pmpro_db_version < 1.791) 
  98. if(!pmpro_getOption("showexcerpts")) 
  99. pmpro_setOption("filterqueries", 1); 
  100. else 
  101. pmpro_SetOption("filterqueries", 0); 
  102.  
  103. pmpro_setOption("db_version", "1.791"); 
  104. $pmpro_db_version = 1.791; 
  105.  
  106. //fixsubscriptionids onstripeorders 
  107. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_8_6_9.php"); //need to include this for AJAX calls 
  108. if($pmpro_db_version < 1.869) {  
  109. $pmpro_db_version = pmpro_upgrade_1_8_6_9(); 
  110.  
  111. //Remove extra cron jobs inserted inversion1.8.7 and 1.8.7.1 
  112. if($pmpro_db_version < 1.87) { 
  113. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_8_7.php"); 
  114. $pmpro_db_version = pmpro_upgrade_1_8_7(); 
  115.  
  116. /** 
  117. v1.8.8 
  118. * Running the cron job cleanup again. 
  119. * Fixing old $0 Stripe orders. 
  120. * Fixing old Authorize.net orders with empty status. 
  121. */  
  122. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_8_8.php"); 
  123. if($pmpro_db_version < 1.88) {  
  124. $pmpro_db_version = pmpro_upgrade_1_8_8();  
  125.  
  126. /** 
  127. v1.8.9.1 
  128. * Fixing Stripe orders where user_id/membership_id = 0  
  129. */  
  130. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_8_9_1.php"); 
  131. if($pmpro_db_version < 1.891) {  
  132. $pmpro_db_version = pmpro_upgrade_1_8_9_1();  
  133.  
  134. /** 
  135. v1.8.9.2 (db v1.9) 
  136. * Changed 'code' column of pmpro_membership_orders table to 32 characters. 
  137. */ 
  138. if($pmpro_db_version < 1.892) { 
  139.  
  140. $pmpro_db_version = 1.892; 
  141. pmpro_setOption("db_version", "1.892"); 
  142.  
  143. /** 
  144. v1.8.9.3 (db v1.91) 
  145. * Fixing incorrect start and end dates.  
  146. */ 
  147. require_once(PMPRO_DIR . "/includes/updates/upgrade_1_8_9_3.php"); 
  148. if($pmpro_db_version < 1.91) { 
  149. $pmpro_db_version = pmpro_upgrade_1_8_9_3();  
  150.  
  151. /** 
  152. v1.8.10 (db v1.92) 
  153.   
  154. Added checkout_id column to pmpro_membership_orders 
  155. */ 
  156. if($pmpro_db_version < 1.92) { 
  157.  
  158. $pmpro_db_version = 1.92; 
  159. pmpro_setOption("db_version", "1.92"); 
  160.  
  161. /** 
  162. v1.8.10.2 (db v1.93) 
  163.   
  164. Run dbDelta again to fix broken/missing orders tables. 
  165. */ 
  166. if($pmpro_db_version < 1.93) { 
  167.  
  168. $pmpro_db_version = 1.93; 
  169. pmpro_setOption("db_version", "1.93");