| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace YayMailScoped\YayCommerce\AdminShell\Support; |
| 4 | 4 | |
| 5 | 5 | use YayMailScoped\YayCommerce\AdminShell\Contracts\PluginMenuAdapter; |
| 6 | -\defined('ABSPATH') || exit; | |
| 6 | +defined('ABSPATH') || exit; | |
| 7 | 7 | /** |
| 8 | 8 | * Resolves the current admin context (site dashboard vs Multisite Network Admin) |
| 9 | 9 | * and the per-plugin opt-in for each context. |
| 10 | 10 | * |
| @@ -15,9 +15,8 @@ | ||
| 15 | 15 | * |
| 16 | 16 | * Opt-in is read via optional adapter methods detected with method_exists() — |
| 17 | 17 | * the same backward-compatible pattern PluginSubmenu uses for is_licensed(). |
| 18 | 18 | * Adapters that predate these methods keep the safe defaults (site-only). |
| 19 | - * @internal | |
| 20 | 19 | */ |
| 21 | 20 | class AdminContext |
| 22 | 21 | { |
| 23 | 22 | /** Network Admin capability — super-admins only. */ |
| @@ -36,9 +35,9 @@ | ||
| 36 | 35 | * before the admin context is reliably known. |
| 37 | 36 | * |
| 38 | 37 | * @param callable $callback |
| 39 | 38 | */ |
| 40 | - public static function bind_menu($callback, int $priority) : void | |
| 39 | + public static function bind_menu($callback, int $priority): void | |
| 41 | 40 | { |
| 42 | 41 | foreach (self::MENU_HOOKS as $hook) { |
| 43 | 42 | add_action($hook, $callback, $priority); |
| 44 | 43 | } |
| @@ -48,16 +47,16 @@ | ||
| 48 | 47 | * |
| 49 | 48 | * Guarded with function_exists() so the class is usable in non-WP unit |
| 50 | 49 | * context, where the function is absent and site context is assumed. |
| 51 | 50 | */ |
| 52 | - public static function is_network() : bool | |
| 51 | + public static function is_network(): bool | |
| 53 | 52 | { |
| 54 | - return \function_exists('YayMailScoped\\is_network_admin') && \YayMailScoped\is_network_admin(); | |
| 53 | + return \function_exists('YayMailScoped\is_network_admin') && \YayMailScoped\is_network_admin(); | |
| 55 | 54 | } |
| 56 | 55 | /** |
| 57 | 56 | * The admin_menu hook that fires for the current context. |
| 58 | 57 | */ |
| 59 | - public static function hook() : string | |
| 58 | + public static function hook(): string | |
| 60 | 59 | { |
| 61 | 60 | return self::is_network() ? 'network_admin_menu' : 'admin_menu'; |
| 62 | 61 | } |
| 63 | 62 | /** |
| @@ -63,9 +62,9 @@ | ||
| 63 | 62 | /** |
| 64 | 63 | * Capability required for menus/pages in the current context. |
| 65 | 64 | * Network Admin requires `manage_network`; site dashboard keeps $default. |
| 66 | 65 | */ |
| 67 | - public static function capability(string $default) : string | |
| 66 | + public static function capability(string $default): string | |
| 68 | 67 | { |
| 69 | 68 | return self::is_network() ? self::NETWORK_CAPABILITY : $default; |
| 70 | 69 | } |
| 71 | 70 | /** |
| @@ -71,9 +70,9 @@ | ||
| 71 | 70 | /** |
| 72 | 71 | * Whether the plugin wants its submenu on the per-site dashboard. |
| 73 | 72 | * Optional method — absent ⇒ true (legacy adapters stay site-visible). |
| 74 | 73 | */ |
| 75 | - public static function wants_site(PluginMenuAdapter $adapter) : bool | |
| 74 | + public static function wants_site(PluginMenuAdapter $adapter): bool | |
| 76 | 75 | { |
| 77 | 76 | if (!\method_exists($adapter, 'wants_site_menu')) { |
| 78 | 77 | return \true; |
| 79 | 78 | } |
| @@ -82,9 +81,9 @@ | ||
| 82 | 81 | /** |
| 83 | 82 | * Whether the plugin wants its submenu in Network Admin. |
| 84 | 83 | * Optional method — absent ⇒ false (legacy adapters never go to network). |
| 85 | 84 | */ |
| 86 | - public static function wants_network(PluginMenuAdapter $adapter) : bool | |
| 85 | + public static function wants_network(PluginMenuAdapter $adapter): bool | |
| 87 | 86 | { |
| 88 | 87 | if (!\method_exists($adapter, 'wants_network_menu')) { |
| 89 | 88 | return \false; |
| 90 | 89 | } |