| @@ -32,14 +32,14 @@ | ||
| 32 | 32 | /** |
| 33 | 33 | * Hook into plugins_loaded at priority 9999 (same as LegacyBridge) |
| 34 | 34 | * and yaycommerce_licenses_page at priority 100 for card rendering. |
| 35 | 35 | */ |
| 36 | - public function init() : void | |
| 36 | + public function init(): void | |
| 37 | 37 | { |
| 38 | - \add_action('plugins_loaded', [$this, 'load_addon_plugins'], 9999); | |
| 39 | - if (\is_admin()) { | |
| 40 | - \add_action('yaycommerce_licenses_page', [$this, 'render_addon_cards'], 100); | |
| 41 | - \add_action('admin_enqueue_scripts', [$this, 'enqueue_addon_scripts']); | |
| 38 | + add_action('plugins_loaded', [$this, 'load_addon_plugins'], 9999); | |
| 39 | + if (is_admin()) { | |
| 40 | + add_action('yaycommerce_licenses_page', [$this, 'render_addon_cards'], 100); | |
| 41 | + add_action('admin_enqueue_scripts', [$this, 'enqueue_addon_scripts']); | |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | /** |
| 45 | 45 | * Read addon filter and convert entries to PluginLicenseInfo stubs. |
| @@ -45,11 +45,11 @@ | ||
| 45 | 45 | * Read addon filter and convert entries to PluginLicenseInfo stubs. |
| 46 | 46 | * Addon format matches yaycommerce_licensing_plugins: |
| 47 | 47 | * [ 'slug', 'name', 'basename', 'file', 'url', 'item_id' ] |
| 48 | 48 | */ |
| 49 | - public function load_addon_plugins() : void | |
| 49 | + public function load_addon_plugins(): void | |
| 50 | 50 | { |
| 51 | - $addons = \apply_filters($this->filter_name, []); | |
| 51 | + $addons = apply_filters($this->filter_name, []); | |
| 52 | 52 | foreach ($addons as $plugin) { |
| 53 | 53 | $slug = $plugin['slug'] ?? ''; |
| 54 | 54 | if (empty($slug) || $this->registry->has($slug)) { |
| 55 | 55 | continue; |
| @@ -66,16 +66,16 @@ | ||
| 66 | 66 | * Build a PluginLicenseInfo from an addon filter entry. |
| 67 | 67 | * Reads {slug}_license_info from wp_options for current status. |
| 68 | 68 | * Pattern mirrors LegacyBridge::build_legacy_info(). |
| 69 | 69 | */ |
| 70 | - private function build_addon_info(array $plugin) : PluginLicenseInfo | |
| 70 | + private function build_addon_info(array $plugin): PluginLicenseInfo | |
| 71 | 71 | { |
| 72 | 72 | $slug = $plugin['slug'] ?? ''; |
| 73 | - $raw_info = \get_option($slug . '_license_info', []); | |
| 74 | - if (\is_string($raw_info)) { | |
| 75 | - $raw_info = \json_decode($raw_info, \true) ?: []; | |
| 73 | + $raw_info = get_option($slug . '_license_info', []); | |
| 74 | + if (is_string($raw_info)) { | |
| 75 | + $raw_info = json_decode($raw_info, \true) ?: []; | |
| 76 | 76 | } |
| 77 | - $license_key = (string) \get_option($slug . '_license_key', ''); | |
| 77 | + $license_key = (string) get_option($slug . '_license_key', ''); | |
| 78 | 78 | $expires_raw = $raw_info['expires'] ?? null; |
| 79 | 79 | $status = $this->derive_status($license_key, $raw_info); |
| 80 | 80 | $info = new PluginLicenseInfo(); |
| 81 | 81 | $info->slug = $slug; |
| @@ -96,9 +96,9 @@ | ||
| 96 | 96 | /** |
| 97 | 97 | * Derive normalized status from wp_options data. |
| 98 | 98 | * Mirrors LegacyBridge::derive_status(). |
| 99 | 99 | */ |
| 100 | - private function derive_status(string $license_key, array $raw_info) : string | |
| 100 | + private function derive_status(string $license_key, array $raw_info): string | |
| 101 | 101 | { |
| 102 | 102 | if (empty($license_key)) { |
| 103 | 103 | return 'inactive'; |
| 104 | 104 | } |
| @@ -103,9 +103,9 @@ | ||
| 103 | 103 | return 'inactive'; |
| 104 | 104 | } |
| 105 | 105 | $expires = $raw_info['expires'] ?? null; |
| 106 | 106 | if ($expires && 'lifetime' !== $expires && 'Not updated' !== $expires) { |
| 107 | - if (\strtotime($expires) < \time()) { | |
| 107 | + if (strtotime($expires) < time()) { | |
| 108 | 108 | return 'expired'; |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | return 'valid'; |
| @@ -114,9 +114,9 @@ | ||
| 114 | 114 | * Render license cards for addon entries this bridge registered. |
| 115 | 115 | * Builds a minimal LicenseConfigAdapter per addon so the License |
| 116 | 116 | * class and card templates work without modification. |
| 117 | 117 | */ |
| 118 | - public function render_addon_cards() : void | |
| 118 | + public function render_addon_cards(): void | |
| 119 | 119 | { |
| 120 | 120 | foreach ($this->addon_slugs as $slug) { |
| 121 | 121 | $plugin_data = $this->addon_data[$slug] ?? []; |
| 122 | 122 | if (empty($plugin_data)) { |
| @@ -138,9 +138,9 @@ | ||
| 138 | 138 | * |
| 139 | 139 | * NOTE: Addon must register REST routes at {slug}/v1/license/* |
| 140 | 140 | * for the activate/update/deactivate buttons to work. |
| 141 | 141 | */ |
| 142 | - public function enqueue_addon_scripts() : void | |
| 142 | + public function enqueue_addon_scripts(): void | |
| 143 | 143 | { |
| 144 | 144 | if (!isset($_GET['page']) || 'yaycommerce-licenses' !== $_GET['page']) { |
| 145 | 145 | // phpcs:ignore WordPress.Security.NonceVerification |
| 146 | 146 | return; |
| @@ -147,12 +147,12 @@ | ||
| 147 | 147 | } |
| 148 | 148 | if (empty($this->addon_slugs)) { |
| 149 | 149 | return; |
| 150 | 150 | } |
| 151 | - $assets_url = \plugin_dir_url(__FILE__) . '../../assets/'; | |
| 152 | - \wp_enqueue_script('yaycommerce-license', $assets_url . 'js/license.js', ['jquery'], '1.0', \true); | |
| 151 | + $assets_url = plugin_dir_url(__FILE__) . '../../assets/'; | |
| 152 | + wp_enqueue_script('yaycommerce-license', $assets_url . 'js/license.js', ['jquery'], '1.0', \true); | |
| 153 | 153 | foreach ($this->addon_slugs as $slug) { |
| 154 | - \wp_localize_script('yaycommerce-license', Slug::to_var_name($slug) . 'LicenseData', ['slug' => $slug, 'apiSettings' => ['restNonce' => \wp_create_nonce('wp_rest'), 'restUrl' => \esc_url_raw(\rest_url(Slug::to_var_name($slug) . '/v1')), 'adminUrl' => \admin_url()]]); | |
| 154 | + wp_localize_script('yaycommerce-license', Slug::to_var_name($slug) . 'LicenseData', ['slug' => $slug, 'apiSettings' => ['restNonce' => wp_create_nonce('wp_rest'), 'restUrl' => esc_url_raw(rest_url(Slug::to_var_name($slug) . '/v1')), 'adminUrl' => admin_url()]]); | |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | /** |
| 158 | 158 | * Build a minimal LicenseConfigAdapter from addon filter data. |
| @@ -157,9 +157,9 @@ | ||
| 157 | 157 | /** |
| 158 | 158 | * Build a minimal LicenseConfigAdapter from addon filter data. |
| 159 | 159 | * Used by License constructor + card templates. |
| 160 | 160 | */ |
| 161 | - private function build_addon_adapter(array $plugin_data) : AddonLicenseAdapter | |
| 161 | + private function build_addon_adapter(array $plugin_data): AddonLicenseAdapter | |
| 162 | 162 | { |
| 163 | 163 | return new AddonLicenseAdapter($plugin_data); |
| 164 | 164 | } |
| 165 | 165 | } |