From 072e722406e66ec0ead470ac5321051a5a54ab2a Mon Sep 17 00:00:00 2001 From: justinstern Date: Wed, 7 Jan 2015 21:11:24 -0500 Subject: [PATCH] Support gateway objects in the $load_gateways array Rather than requiring $load_gateways to be the string class names of the payment gateways to load, support client code returning the actual gateway instance from the 'woocommerce_payment_gateways' filter. This affords much more fine grained control over how, when, and how often, a payment gateway is instantiated --- includes/class-wc-payment-gateways.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-payment-gateways.php b/includes/class-wc-payment-gateways.php index 14c924f0090..880188c560b 100644 --- a/includes/class-wc-payment-gateways.php +++ b/includes/class-wc-payment-gateways.php @@ -96,7 +96,7 @@ class WC_Payment_Gateways { // Load gateways in order foreach ( $load_gateways as $gateway ) { - $load_gateway = new $gateway(); + $load_gateway = is_string( $gateway ) ? new $gateway() : $gateway; if ( isset( $ordering[ $load_gateway->id ] ) && is_numeric( $ordering[ $load_gateway->id ] ) ) { // Add in position