register_gateway($id, $title, $desc, $class_name, $hidden); } // end wu_register_gateway; /** * Returns the currently registered gateways. * * @since 2.0.0 * * @return array */ function wu_get_gateways() { return Gateway_Manager::get_instance()->get_registered_gateways(); } // end wu_get_gateways; /** * Returns the currently registered and active gateways. * * @since 2.0.0 * @return array */ function wu_get_active_gateways() { $gateways = array(); $active_gateways = (array) wu_get_setting('active_gateways', array()); foreach ($active_gateways as $active_gateway) { if (Gateway_Manager::get_instance()->is_gateway_registered($active_gateway)) { $gateways[$active_gateway] = Gateway_Manager::get_instance()->get_gateway($active_gateway); } // end if; } // end foreach; return apply_filters('wu_get_active_gateways', $gateways); } // end wu_get_active_gateways; /** * Returns a gateway class if it exists. * * @since 2.0.0 * * @param string $id Gateway ID. * @param string $subscription Subscription object to load into the gateway. * @return mixed Gateway class. */ function wu_get_gateway($id, $subscription = null) { $gateway = Gateway_Manager::get_instance()->get_gateway($id); if (!$gateway) { return false; } // end if; $gateway_class = new $gateway['class_name'](); return $gateway_class; } // end wu_get_gateway; /** * Returns the list of available gateways as key => name. * * @since 2.0.0 * @return array */ function wu_get_gateway_as_options() { $options = array(); foreach (wu_get_gateways() as $gateway_slug => $gateway) { $instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false; if ($instance === false || $gateway['hidden']) { continue; } // end if; $options[$gateway_slug] = $gateway['title']; } // end foreach; return $options; } // end wu_get_gateway_as_options; /** * Get the active gateways. * * @since 2.0.0 * @return array */ function wu_get_active_gateway_as_options() { $options = array(); foreach (wu_get_active_gateways() as $gateway_slug => $gateway) { $instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false; if ($instance === false || $gateway['hidden']) { continue; } // end if; $title = $instance->get_public_title(); $options[$gateway_slug] = apply_filters("wu_gateway_{$gateway_slug}_as_option_title", $title, $gateway); } // end foreach; return $options; } // end wu_get_active_gateway_as_options;