wp = $wp; $this->settings = $settings; } public function detect() { $referralId = $this->settings->get(self::REFERRAL_SETTING_NAME, null); if ($referralId) { return $referralId; } $referralId = $this->wp->getOption(self::REFERRAL_CONSTANT_NAME, null); if ($referralId === null && defined(self::REFERRAL_CONSTANT_NAME)) { $referralId = constant(self::REFERRAL_CONSTANT_NAME); } if ($referralId !== null) { $this->settings->set(self::REFERRAL_SETTING_NAME, $referralId); } return $referralId; } }