From f4b61796ce7800542de14b71f8ca0bbb804a04f0 Mon Sep 17 00:00:00 2001 From: Moustafa Gouda Date: Mon, 29 Jul 2024 16:35:32 +0300 Subject: [PATCH] Fix an issue in verifying collection URL --- app/Settings.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/Settings.php b/app/Settings.php index 2ed8304..612f10d 100644 --- a/app/Settings.php +++ b/app/Settings.php @@ -96,9 +96,19 @@ private function addHooks(): void */ public function verifyCollectionUrl() { - $manager = new PccSyncManager(); - if (!$manager->isPCCConfigured()) { - $manager->disconnect(); + $accessToken = $this->getAccessToken(); + $siteId = $this->getSiteId(); + $encodedSiteURL = get_option(PCC_ENCODED_SITE_URL_OPTION_KEY); + $apiKey = $this->getAPIAccessKey(); + + if (!$accessToken || !$siteId || !$apiKey || !$encodedSiteURL) { + return; + } + + $currentHashedSiteURL = md5(wp_parse_url(site_url())['host']); + // if both are not equal then disconnect + if ($encodedSiteURL !== $currentHashedSiteURL) { + (new PccSyncManager())->disconnect(); } }