PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.5
YayMail – WooCommerce Email Customizer v4.4.5
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
yaymail / vendor-prefixed / src / Registry / LicenseRegistry.php

LicenseRegistry.php in YayMail – WooCommerce Email Customizer 4.4.5, at vendor-prefixed/src/Registry/LicenseRegistry.php

59 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMailScoped\YayCommerce\AdminShell\Registry;
4
5 /**
6 * Central registry for all plugin license info objects.
7 *
8 * Plugins call register() during 'yaycommerce_admin_shell_booted' action.
9 * The Licenses page calls all() to render the unified list.
10 */
11 class LicenseRegistry
12 {
13 /** @var PluginLicenseInfo[] keyed by slug */
14 private array $plugins = [];
15 /**
16 * Register a plugin's license info. Applies the decoration filter before storing.
17 */
18 public function register($info): void
19 {
20 /** @var PluginLicenseInfo $info */
21 $info = apply_filters('yaycommerce_admin_shell_plugin_info', $info, $info->slug);
22 $this->plugins[$info->slug] = $info;
23 }
24 /**
25 * Return all registered PluginLicenseInfo objects, keyed by slug.
26 *
27 * @return PluginLicenseInfo[]
28 */
29 public function all(): array
30 {
31 // Refactor old licensing plugin integration
32 $old_plugins = [];
33 $handlers = ['YayMailScoped\YAYDP\License\License_Handler', 'YayMailScoped\YayMail\License\LicenseHandler', 'YayMailScoped\Yay_Currency\License\LicenseHandler', 'YayMailScoped\Yay_Swatches\License\LicenseHandler', 'YayMailScoped\YayExtra\License\LicenseHandler', 'YayMailScoped\YayRev\License\LicenseHandler', 'YayMailScoped\YayWholesaleB2B\License\LicenseHandler', 'YayMailScoped\YaySMTP\License\LicenseHandler'];
34 foreach ($handlers as $handler) {
35 if (class_exists($handler) && method_exists($handler, 'get_licensing_plugins')) {
36 $plugins = $handler::get_licensing_plugins();
37 if (is_array($plugins)) {
38 $old_plugins = array_merge($old_plugins, $plugins);
39 }
40 }
41 }
42 return array_merge($this->plugins, $old_plugins);
43 }
44 /**
45 * Return a single PluginLicenseInfo by slug, or null if not registered.
46 */
47 public function get(string $slug): ?PluginLicenseInfo
48 {
49 return $this->plugins[$slug] ?? null;
50 }
51 /**
52 * Check if a slug is registered.
53 */
54 public function has(string $slug): bool
55 {
56 return isset($this->plugins[$slug]);
57 }
58 }
59