pmpro_getClassesForPaymentSettingsField

Get the gateway-related classes for fields on the payment settings page.

Description

pmpro_getClassesForPaymentSettingsField( (string) $field, (constant) $force = false ); 

Parameters (2)

0. $field (string)
The name of the field to check.
1. $force — Optional. (constant) => false
If true, it will rebuild the cached results.

Usage

  1. if ( !function_exists( 'pmpro_getClassesForPaymentSettingsField' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/adminpages/functions.php'; 
  3.  
  4. // The name of the field to check. 
  5. $field = ''; 
  6.  
  7. // If true, it will rebuild the cached results. 
  8. $force = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = pmpro_getClassesForPaymentSettingsField($field, $force); 
  12.  

Defined (1)

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

/adminpages/functions.php  
  1. function pmpro_getClassesForPaymentSettingsField($field, $force = false) 
  2. global $pmpro_gateway_options; 
  3. $pmpro_gateways = pmpro_gateways(); 
  4.  
  5. //build array of gateways and options 
  6. if(!isset($pmpro_gateway_options) || $force) 
  7. $pmpro_gateway_options = array(); 
  8.  
  9. foreach($pmpro_gateways as $gateway => $label) 
  10. //get options 
  11. if(class_exists('PMProGateway_' . $gateway) && method_exists('PMProGateway_' . $gateway, 'getGatewayOptions')) 
  12. $pmpro_gateway_options[$gateway] = call_user_func(array('PMProGateway_' . $gateway, 'getGatewayOptions')); 
  13.  
  14. //now check where this field shows up 
  15. $rgateways = array(); 
  16. foreach($pmpro_gateway_options as $gateway => $options) 
  17. if(in_array($field, $options)) 
  18. $rgateways[] = "gateway_" . $gateway; 
  19.  
  20. //return space separated string 
  21. return implode(" ", $rgateways);