Skip to content

Commit 56077b5

Browse files
authored
Merge pull request #3 from Bit-Apps-Pro/feat/license-multisite-support
feat: enable single-site license support for multisite
2 parents 6571b87 + 609d1a3 commit 56077b5

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

backend/pro/src/HTTP/Controllers/LicenseController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function activateLicense()
3434

3535
$data['licenseKey'] = $licenseKey;
3636

37-
$data['domain'] = site_url();
37+
$data['domain'] = is_multisite() ? network_site_url() : site_url();
3838

3939
$data['slug'] = PluginCommonConfig::getProPluginSlug();
4040

@@ -71,7 +71,7 @@ public function deactivateLicense()
7171

7272
$data['licenseKey'] = $licenseData['key'];
7373

74-
$data['domain'] = site_url();
74+
$data['domain'] = is_multisite() ? network_site_url() : site_url();
7575

7676
$this->httpClient->setHeaders([
7777
'content-type' => 'application/json',

backend/pro/src/Services/LicenseService.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,19 @@ public static function setLicenseData($licenseKey, $licData)
2727

2828
$data['expireIn'] = $licData->expireIn;
2929

30-
return update_option(PluginCommonConfig::getProPluginPrefix() . 'license_data', $data, null);
30+
if (is_multisite()) {
31+
$networkSites = get_sites();
32+
33+
foreach ($networkSites as $site) {
34+
switch_to_blog($site->blog_id);
35+
36+
update_option(PluginCommonConfig::getProPluginPrefix() . 'license_data', $data, null);
37+
38+
restore_current_blog();
39+
}
40+
} else {
41+
update_option(PluginCommonConfig::getProPluginPrefix() . 'license_data', $data, null);
42+
}
3143
}
3244

3345
public static function getUpdatedInfo()

frontend/components/SupportPage/data/useCheckLicenseValidity.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function useCheckLicenseValidity(forceRequest = false) {
2525
queryFn: () =>
2626
proxyRequest<CheckUpdateResponse>({
2727
bodyParams: {
28-
domain: config.SITE_URL,
28+
domain: config.SITE_BASE_URL,
2929
licenseKey: config.KEY ? { encryption: 'hmac_decrypt', value: config.KEY } : ''
3030
},
3131
method: 'POST',

0 commit comments

Comments
 (0)