PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.6
YayMail – WooCommerce Email Customizer v4.4.6
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
← All changes | vendor-prefixed/src/Registry/AddonBridge.php +14 -15 4.4.2 → 4.4.6 View file →
@@ -14,9 +14,8 @@
14 14 * yaycommerce_licensing_plugins filter.
15 15 *
16 16 * Pattern mirrors LegacyBridge — derive_status() logic intentionally
17 17 * duplicated (only two consumers; extract if a third appears).
18 - * @internal
19 18 */
20 19 class AddonBridge
21 20 {
22 21 private string $filter_name;
@@ -33,12 +32,12 @@
33 32 /**
34 33 * Hook into plugins_loaded at priority 9999 (same as LegacyBridge)
35 34 * and yaycommerce_licenses_page at priority 100 for card rendering.
36 35 */
37 - public function init() : void
36 + public function init(): void
38 37 {
39 38 add_action('plugins_loaded', [$this, 'load_addon_plugins'], 9999);
40 - if (\is_admin()) {
39 + if (is_admin()) {
41 40 add_action('yaycommerce_licenses_page', [$this, 'render_addon_cards'], 100);
42 41 add_action('admin_enqueue_scripts', [$this, 'enqueue_addon_scripts']);
43 42 }
44 43 }
@@ -46,11 +45,11 @@
46 45 * Read addon filter and convert entries to PluginLicenseInfo stubs.
47 46 * Addon format matches yaycommerce_licensing_plugins:
48 47 * [ 'slug', 'name', 'basename', 'file', 'url', 'item_id' ]
49 48 */
50 - public function load_addon_plugins() : void
49 + public function load_addon_plugins(): void
51 50 {
52 - $addons = \apply_filters($this->filter_name, []);
51 + $addons = apply_filters($this->filter_name, []);
53 52 foreach ($addons as $plugin) {
54 53 $slug = $plugin['slug'] ?? '';
55 54 if (empty($slug) || $this->registry->has($slug)) {
56 55 continue;
@@ -67,14 +66,14 @@
67 66 * Build a PluginLicenseInfo from an addon filter entry.
68 67 * Reads {slug}_license_info from wp_options for current status.
69 68 * Pattern mirrors LegacyBridge::build_legacy_info().
70 69 */
71 - private function build_addon_info(array $plugin) : PluginLicenseInfo
70 + private function build_addon_info(array $plugin): PluginLicenseInfo
72 71 {
73 72 $slug = $plugin['slug'] ?? '';
74 73 $raw_info = get_option($slug . '_license_info', []);
75 - if (\is_string($raw_info)) {
76 - $raw_info = \json_decode($raw_info, \true) ?: [];
74 + if (is_string($raw_info)) {
75 + $raw_info = json_decode($raw_info, \true) ?: [];
77 76 }
78 77 $license_key = (string) get_option($slug . '_license_key', '');
79 78 $expires_raw = $raw_info['expires'] ?? null;
80 79 $status = $this->derive_status($license_key, $raw_info);
@@ -97,9 +96,9 @@
97 96 /**
98 97 * Derive normalized status from wp_options data.
99 98 * Mirrors LegacyBridge::derive_status().
100 99 */
101 - private function derive_status(string $license_key, array $raw_info) : string
100 + private function derive_status(string $license_key, array $raw_info): string
102 101 {
103 102 if (empty($license_key)) {
104 103 return 'inactive';
105 104 }
@@ -104,9 +103,9 @@
104 103 return 'inactive';
105 104 }
106 105 $expires = $raw_info['expires'] ?? null;
107 106 if ($expires && 'lifetime' !== $expires && 'Not updated' !== $expires) {
108 - if (\strtotime($expires) < \time()) {
107 + if (strtotime($expires) < time()) {
109 108 return 'expired';
110 109 }
111 110 }
112 111 return 'valid';
@@ -115,9 +114,9 @@
115 114 * Render license cards for addon entries this bridge registered.
116 115 * Builds a minimal LicenseConfigAdapter per addon so the License
117 116 * class and card templates work without modification.
118 117 */
119 - public function render_addon_cards() : void
118 + public function render_addon_cards(): void
120 119 {
121 120 foreach ($this->addon_slugs as $slug) {
122 121 $plugin_data = $this->addon_data[$slug] ?? [];
123 122 if (empty($plugin_data)) {
@@ -139,9 +138,9 @@
139 138 *
140 139 * NOTE: Addon must register REST routes at {slug}/v1/license/*
141 140 * for the activate/update/deactivate buttons to work.
142 141 */
143 - public function enqueue_addon_scripts() : void
142 + public function enqueue_addon_scripts(): void
144 143 {
145 144 if (!isset($_GET['page']) || 'yaycommerce-licenses' !== $_GET['page']) {
146 145 // phpcs:ignore WordPress.Security.NonceVerification
147 146 return;
@@ -148,12 +147,12 @@
148 147 }
149 148 if (empty($this->addon_slugs)) {
150 149 return;
151 150 }
152 - $assets_url = \plugin_dir_url(__FILE__) . '../../assets/';
151 + $assets_url = plugin_dir_url(__FILE__) . '../../assets/';
153 152 wp_enqueue_script('yaycommerce-license', $assets_url . 'js/license.js', ['jquery'], '1.0', \true);
154 153 foreach ($this->addon_slugs as $slug) {
155 - 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()]]);
156 155 }
157 156 }
158 157 /**
159 158 * Build a minimal LicenseConfigAdapter from addon filter data.
@@ -158,9 +157,9 @@
158 157 /**
159 158 * Build a minimal LicenseConfigAdapter from addon filter data.
160 159 * Used by License constructor + card templates.
161 160 */
162 - private function build_addon_adapter(array $plugin_data) : AddonLicenseAdapter
161 + private function build_addon_adapter(array $plugin_data): AddonLicenseAdapter
163 162 {
164 163 return new AddonLicenseAdapter($plugin_data);
165 164 }
166 165 }