Skip to content

Commit

Permalink
Allow for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
NickGreen committed Sep 29, 2023
1 parent 88b3b3e commit 0820b6b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions woocommerce-gateway-dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down Expand Up @@ -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() );
}
);
}
Expand Down

0 comments on commit 0820b6b

Please sign in to comment.