pmpro_is_ready

Checks if all required settings are set.

Description

pmpro_is_ready(); 

Usage

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

Defined (1)

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

/includes/functions.php  
  1. function pmpro_is_ready() 
  2. global $wpdb, $pmpro_pages, $pmpro_level_ready, $pmpro_gateway_ready, $pmpro_pages_ready; 
  3.  
  4. //check if there is at least one level 
  5. $pmpro_level_ready = (bool)$wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_levels LIMIT 1"); 
  6.  
  7. //check if thegatewaysettings are good. first check if it's needed (is there paid membership level) 
  8. $paid_membership_level = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_levels WHERE allow_signups = 1 AND (initial_payment > 0 OR billing_amount > 0 OR trial_amount > 0) LIMIT 1"); 
  9. $paid_user_subscription = $wpdb->get_var("SELECT user_id FROM $wpdb->pmpro_memberships_users WHERE initial_payment > 0 OR billing_amount > 0 OR trial_amount > 0 LIMIT 1"); 
  10.  
  11. if(empty($paid_membership_level) && empty($paid_user_subscription)) 
  12. //no paid membership level now or attached to a user. we don't need thegatewaysetup 
  13. $pmpro_gateway_ready = true; 
  14. else 
  15. $gateway = pmpro_getOption("gateway"); 
  16. if($gateway == "authorizenet") 
  17. if(pmpro_getOption("gateway_environment") && pmpro_getOption("loginname") && pmpro_getOption("transactionkey")) 
  18. $pmpro_gateway_ready = true; 
  19. else 
  20. $pmpro_gateway_ready = false; 
  21. elseif($gateway == "paypal" || $gateway == "paypalexpress") 
  22. if(pmpro_getOption("gateway_environment") && pmpro_getOption("gateway_email") && pmpro_getOption("apiusername") && pmpro_getOption("apipassword") && pmpro_getOption("apisignature")) 
  23. $pmpro_gateway_ready = true; 
  24. else 
  25. $pmpro_gateway_ready = false; 
  26. elseif($gateway == "paypalstandard") 
  27. if(pmpro_getOption("gateway_environment") && pmpro_getOption("gateway_email")) 
  28. $pmpro_gateway_ready = true; 
  29. else 
  30. $pmpro_gateway_ready = false; 
  31. elseif($gateway == "payflowpro") 
  32. if(pmpro_getOption("payflow_partner") && pmpro_getOption("payflow_vendor") && pmpro_getOption("payflow_user") && pmpro_getOption("payflow_pwd")) 
  33. $pmpro_gateway_ready = true; 
  34. else 
  35. $pmpro_gateway_ready = false; 
  36. elseif($gateway == "stripe") 
  37. if(pmpro_getOption("gateway_environment") && pmpro_getOption("stripe_secretkey") && pmpro_getOption("stripe_publishablekey")) 
  38. $pmpro_gateway_ready = true; 
  39. else 
  40. $pmpro_gateway_ready = false; 
  41. elseif($gateway == "braintree") 
  42. if(pmpro_getOption("gateway_environment") && pmpro_getOption("braintree_merchantid") && pmpro_getOption("braintree_publickey") && pmpro_getOption("braintree_privatekey")) 
  43. $pmpro_gateway_ready = true; 
  44. else 
  45. $pmpro_gateway_ready = false; 
  46. elseif($gateway == "twocheckout") 
  47. if(pmpro_getOption("gateway_environment") && pmpro_getOption("twocheckout_apiusername") && pmpro_getOption("twocheckout_apipassword")) 
  48. $pmpro_gateway_ready = true; 
  49. else 
  50. $pmpro_gateway_ready = false; 
  51. elseif($gateway == "cybersource") 
  52. if(pmpro_getOption("gateway_environment") && pmpro_getOption("cybersource_merchantid") && pmpro_getOption("cybersource_securitykey")) 
  53. $pmpro_gateway_ready = true; 
  54. else 
  55. $pmpro_gateway_ready = false; 
  56. elseif($gateway == "check") 
  57. $pmpro_gateway_ready = true; 
  58. else 
  59. $pmpro_gateway_ready = false; 
  60.  
  61. //check if we have all pages 
  62. if($pmpro_pages["account"] && 
  63. $pmpro_pages["billing"] && 
  64. $pmpro_pages["cancel"] && 
  65. $pmpro_pages["checkout"] && 
  66. $pmpro_pages["confirmation"] && 
  67. $pmpro_pages["invoice"] && 
  68. $pmpro_pages["levels"]) 
  69. $pmpro_pages_ready = true; 
  70. else 
  71. $pmpro_pages_ready = false; 
  72.  
  73. //now check both 
  74. if($pmpro_gateway_ready && $pmpro_pages_ready) 
  75. $r = true; 
  76. else 
  77. $r = false; 
  78.  
  79. /** 
  80. * Filter to determine if PMProsetupis complete or 
  81. * if notices or warnings need to be shown in the PMPro settings. 
  82. * Note: The filter should return true or false and also set 
  83. * the $pmpro_level_ready, $pmpro_gateway_ready, $pmpro_pages_ready global variabls. 
  84. * @since 1.8.4.5 
  85. * @param bool $r ready? 
  86. */ 
  87. $r = apply_filters('pmpro_is_ready', $r); 
  88.  
  89. return $r;