Skip to content

Commit 74d88ca

Browse files
committed
Use empty string if API option is missing
1 parent 712c295 commit 74d88ca

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Services/ApiKeyService.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public function __construct() {
1515
$this->test_api_key = get_option( 'monei_test_apikey', '' );
1616
$this->live_api_key = get_option( 'monei_live_apikey', '' );
1717
$this->api_key_mode = get_option( 'monei_apikey_mode', 'test' );
18-
$this->test_account_id = get_option( 'monei_test_accountid' );
19-
$this->live_account_id = get_option( 'monei_live_accountid' );
18+
$this->test_account_id = get_option( 'monei_test_accountid', '' );
19+
$this->live_account_id = get_option( 'monei_live_accountid', '' );
2020

2121
// Copy the API keys to the central settings when the plugin is activated or updated
2222
add_action( 'init', array( $this, 'copyKeysToCentralSettings' ), 0 );
@@ -56,19 +56,19 @@ public function get_account_id(): string {
5656
public function update_keys(): void {
5757
$this->test_api_key = get_option( 'monei_test_apikey', '' );
5858
$this->live_api_key = get_option( 'monei_live_apikey', '' );
59-
$this->test_account_id = get_option( 'monei_test_accountid' );
60-
$this->live_account_id = get_option( 'monei_live_accountid' );
59+
$this->test_account_id = get_option( 'monei_test_accountid', '' );
60+
$this->live_account_id = get_option( 'monei_live_accountid', '' );
6161
$this->api_key_mode = get_option( 'monei_apikey_mode', 'test' );
6262
}
6363

6464
public function copyKeysToCentralSettings() {
6565
add_filter(
6666
'option_woocommerce_monei_settings',
6767
function ( $default_params ) {
68-
$centralApiKey = get_option( 'monei_apikey' );
69-
$centralAccountId = get_option( 'monei_accountid' );
70-
$ccApiKey = $default_params['apikey'] ?? false;
71-
$ccAccountId = $default_params['accountid'] ?? false;
68+
$centralApiKey = get_option( 'monei_apikey', '' );
69+
$centralAccountId = get_option( 'monei_accountid', '' );
70+
$ccApiKey = $default_params['apikey'] ?? '';
71+
$ccAccountId = $default_params['accountid'] ?? '';
7272

7373
if ( empty( $centralApiKey ) && empty( $ccApiKey ) ) {
7474
return $default_params;

0 commit comments

Comments
 (0)