From 0820b6b86780173112b20c2027a33ad90981f6a3 Mon Sep 17 00:00:00 2001 From: Nick Green Date: Fri, 29 Sep 2023 14:36:38 -0700 Subject: [PATCH] Allow for backwards compatibility --- woocommerce-gateway-dummy.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/woocommerce-gateway-dummy.php b/woocommerce-gateway-dummy.php index 344bbf4..f0f236f 100644 --- a/woocommerce-gateway-dummy.php +++ b/woocommerce-gateway-dummy.php @@ -53,8 +53,15 @@ public static function init() { * @param array */ public static function add_gateway( $gateways ) { - $options = get_option( 'woocommerce_dummy_settings', array() ); - $hide_for_non_admin_users = $options['hide_for_non_admin_users']; + + $options = get_option( 'woocommerce_dummy_settings', array() ); + + if ( isset( $options['hide_for_non_admin_users'] ) ) { + $hide_for_non_admin_users = $options['hide_for_non_admin_users']; + } else { + $hide_for_non_admin_users = 'no'; + } + if ( ( 'yes' === $hide_for_non_admin_users && current_user_can( 'manage_options' ) ) || 'no' === $hide_for_non_admin_users ) { $gateways[] = 'WC_Gateway_Dummy'; } @@ -100,7 +107,7 @@ public static function woocommerce_gateway_dummy_woocommerce_block_support() { add_action( 'woocommerce_blocks_payment_method_type_registration', function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { - $payment_method_registry->register( new WC_Gateway_Dummy_Blocks_Support ); + $payment_method_registry->register( new WC_Gateway_Dummy_Blocks_Support() ); } ); }