has_features_enabled_license() && $sdk->is_registered() && $sdk->get_site() instanceof \FS_Site) { // is_plan()/get_plan() may synchronize missing plans. This accessor's // false flag reads only official cached plans, including while offline. $cached = $sdk->_get_plan_by_id($sdk->get_site()->plan_id, false); if ($cached instanceof \FS_Plugin_Plan && in_array($cached->name, ['starter', 'club', 'pro'], true)) { $plan = $cached->name; } } $this->resolvedPlan = $plan; $this->updates = $plan !== 'lite' && $sdk->has_active_valid_license(); } public function plan(): string { return $this->resolvedPlan; } public function updateSupportEntitled(): ?bool { return $this->updates; } /** Admin-only projection: deliberately no raw SDK entities or license keys. */ public function status(): array { $license = $this->sdk ? $this->sdk->_get_license() : null; $state = 'unlicensed'; if ($license instanceof \FS_Plugin_License && is_numeric($license->id)) { $state = !$license->is_active() ? 'revoked' : ($license->is_expired() ? 'expired' : 'active'); } $subscription = $license instanceof \FS_Plugin_License && is_numeric($license->id) ? $this->sdk->_get_subscription($license->id) : null; return [ 'state' => $state, 'updates' => $this->updates, 'expires_at' => $license instanceof \FS_Plugin_License ? $license->expiration : null, 'renewal_cancelled' => $subscription instanceof \FS_Subscription ? $subscription->is_canceled() : null, 'production_sites' => $license instanceof \FS_Plugin_License ? $license->quota : null, 'account_url' => $this->sdk ? ($this->sdk->is_registered() ? $this->sdk->get_account_url() : ($this->sdk->is_activation_mode() ? $this->sdk->get_activation_url() : $this->sdk->get_reconnect_url())) : null, 'upgrade_url' => $this->sdk ? $this->sdk->get_upgrade_url() : null, ]; } }