WC_Payment_Gateways::was_gateway_enabled
Determines from changes in settings if a gateway was enabled.
Method of the class: WC_Payment_Gateways{}
No Hooks.
Returns
true|false. Whether the gateway was enabled or not.
Usage
// private - for code of main (parent) class only $result = $this->was_gateway_enabled( $value, $old_value );
- $value(array) (required)
- New value.
- $old_value(array)
- Old value.
Default:null
WC_Payment_Gateways::was_gateway_enabled() WC Payment Gateways::was gateway enabled code WC 10.5.0
private function was_gateway_enabled( $value, $old_value = null ) {
if ( null === $old_value ) {
// There was no old value, so this is a new option.
if ( ! empty( $value ) && is_array( $value ) && isset( $value['enabled'] ) && 'yes' === $value['enabled'] && isset( $value['title'] ) ) {
return true;
}
return false;
}
// There was an old value, so this is an update.
if (
ArrayUtil::get_value_or_default( $value, 'enabled' ) === 'yes' &&
ArrayUtil::get_value_or_default( $old_value, 'enabled' ) !== 'yes' ) {
return true;
}
return false;
}