| @@ -8,9 +8,8 @@ | ||
| 8 | 8 | * legacy registration into a PluginLicenseInfo stub with is_legacy=true. |
| 9 | 9 | * |
| 10 | 10 | * This enables the unified Licenses page to display un-migrated plugins |
| 11 | 11 | * alongside migrated ones during incremental rollout. |
| 12 | - * @internal | |
| 13 | 12 | */ |
| 14 | 13 | class LegacyBridge |
| 15 | 14 | { |
| 16 | 15 | private LicenseRegistry $registry; |
| @@ -28,9 +27,9 @@ | ||
| 28 | 27 | * all legacy plugins register via yaycommerce_licensing_plugins at 100. |
| 29 | 28 | * |
| 30 | 29 | * INVARIANT: if VersionedLoader priority changes, update this priority too. |
| 31 | 30 | */ |
| 32 | - public function init() : void | |
| 31 | + public function init(): void | |
| 33 | 32 | { |
| 34 | 33 | add_action('plugins_loaded', [$this, 'load_legacy_plugins'], 9999); |
| 35 | 34 | } |
| 36 | 35 | /** |
| @@ -38,11 +37,11 @@ | ||
| 38 | 37 | * |
| 39 | 38 | * Legacy format (each entry): |
| 40 | 39 | * [ 'slug', 'basename', 'file', 'url', 'item_id', 'dir_path', 'name' ] |
| 41 | 40 | */ |
| 42 | - public function load_legacy_plugins() : void | |
| 41 | + public function load_legacy_plugins(): void | |
| 43 | 42 | { |
| 44 | - $legacy_plugins = \apply_filters('yaycommerce_licensing_plugins', []); | |
| 43 | + $legacy_plugins = apply_filters('yaycommerce_licensing_plugins', []); | |
| 45 | 44 | foreach ($legacy_plugins as $plugin) { |
| 46 | 45 | $slug = $plugin['slug'] ?? ''; |
| 47 | 46 | if (empty($slug)) { |
| 48 | 47 | continue; |
| @@ -58,14 +57,14 @@ | ||
| 58 | 57 | /** |
| 59 | 58 | * Build a PluginLicenseInfo from a legacy filter entry. |
| 60 | 59 | * Reads {slug}_license_info from wp_options to get current status. |
| 61 | 60 | */ |
| 62 | - private function build_legacy_info(array $plugin) : PluginLicenseInfo | |
| 61 | + private function build_legacy_info(array $plugin): PluginLicenseInfo | |
| 63 | 62 | { |
| 64 | 63 | $slug = $plugin['slug'] ?? ''; |
| 65 | 64 | $raw_info = get_option($slug . '_license_info', []); |
| 66 | - if (\is_string($raw_info)) { | |
| 67 | - $raw_info = \json_decode($raw_info, \true) ?: []; | |
| 65 | + if (is_string($raw_info)) { | |
| 66 | + $raw_info = json_decode($raw_info, \true) ?: []; | |
| 68 | 67 | } |
| 69 | 68 | $license_key = (string) get_option($slug . '_license_key', ''); |
| 70 | 69 | $expires_raw = $raw_info['expires'] ?? null; |
| 71 | 70 | $status = $this->derive_status($license_key, $raw_info); |
| @@ -88,9 +87,9 @@ | ||
| 88 | 87 | } |
| 89 | 88 | /** |
| 90 | 89 | * Derive a normalized status string from legacy option data. |
| 91 | 90 | */ |
| 92 | - private function derive_status(string $license_key, array $raw_info) : string | |
| 91 | + private function derive_status(string $license_key, array $raw_info): string | |
| 93 | 92 | { |
| 94 | 93 | if (empty($license_key)) { |
| 95 | 94 | return 'inactive'; |
| 96 | 95 | } |
| @@ -95,9 +94,9 @@ | ||
| 95 | 94 | return 'inactive'; |
| 96 | 95 | } |
| 97 | 96 | $expires = $raw_info['expires'] ?? null; |
| 98 | 97 | if ($expires && 'lifetime' !== $expires && 'Not updated' !== $expires) { |
| 99 | - if (\strtotime($expires) < \time()) { | |
| 98 | + if (strtotime($expires) < time()) { | |
| 100 | 99 | return 'expired'; |
| 101 | 100 | } |
| 102 | 101 | } |
| 103 | 102 | return 'valid'; |