invert the conditional so we can remove the nesting and go for an early return instead

This commit is contained in:
Leif Singer 2023-11-22 19:25:58 +01:00
parent 7bda29426b
commit e4c6d9a532
1 changed files with 33 additions and 32 deletions

View File

@ -586,8 +586,10 @@ function wc_notify_payment_gateway_enabled( $option, $old_value, $value ) {
if ( ! isset( $old_value['enabled'] ) || ! isset( $value['enabled'] ) ) {
return;
}
if ( 'no' !== $old_value['enabled'] || 'yes' !== $value['enabled'] ) {
return;
}
// This is a change to a payment gateway's settings.
if ( 'no' === $old_value['enabled'] && 'yes' === $value['enabled'] ) {
// The gateway was just enabled, let's send an email to the admin.
$admin_email = get_option( 'admin_email' );
/* translators: Do not translate USERNAME, GATEWAY_TITLE, GATEWAY_SETTINGS_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
@ -634,6 +636,5 @@ All at ###SITENAME###
),
$email_text
);
}
}
add_action( 'update_option', 'wc_notify_payment_gateway_enabled', 10, 3 );