From dab2127a64e06dc7dec574206119355157c09ac1 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Tue, 25 Mar 2025 14:20:26 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Update=20code=20style=20and=20co?=
=?UTF-8?q?mment?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/Helper/PartnerAttribution.php | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/modules/ppcp-api-client/src/Helper/PartnerAttribution.php b/modules/ppcp-api-client/src/Helper/PartnerAttribution.php
index f83aeb292..47861e5cf 100644
--- a/modules/ppcp-api-client/src/Helper/PartnerAttribution.php
+++ b/modules/ppcp-api-client/src/Helper/PartnerAttribution.php
@@ -64,13 +64,14 @@ class PartnerAttribution {
*
* @param string $installation_path The installation path used to determine the BN Code.
*/
- public function initialize_bn_code( string $installation_path ): void {
- $selected_bn_code = $this->bn_codes[ $installation_path ] ?? false;
+ public function initialize_bn_code( string $installation_path ) : void {
+ $selected_bn_code = $this->bn_codes[ $installation_path ] ?? '';
- if ( get_option( $this->bn_code_option_name ) || ! $selected_bn_code ) {
+ if ( ! $selected_bn_code || get_option( $this->bn_code_option_name ) ) {
return;
}
+ // This option is permanent and should not change.
update_option( $this->bn_code_option_name, $selected_bn_code );
}
@@ -79,10 +80,10 @@ class PartnerAttribution {
*
* @return string The stored BN Code, or the default value if no path is detected.
*/
- public function get_bn_code(): string {
- $bn_code = get_option( $this->bn_code_option_name, $this->default_bn_code ) ?? $this->default_bn_code;
+ public function get_bn_code() : string {
+ $bn_code = (string) ( get_option( $this->bn_code_option_name, $this->default_bn_code ) ?? $this->default_bn_code );
- if ( ! in_array( $bn_code, $this->bn_codes, true ) && $bn_code !== $this->default_bn_code ) {
+ if ( ! in_array( $bn_code, $this->bn_codes, true ) ) {
return $this->default_bn_code;
}