| @@ -10,9 +10,8 @@ | ||
| 10 | 10 | /** |
| 11 | 11 | * Registers Licenses, Other Plugins, and Help submenus under 'yaycommerce'. |
| 12 | 12 | * Ported from YayMail Pro RegisterMenu::add_submenus() — de-branded and |
| 13 | 13 | * adapter-driven (no hardcoded cross-plugin class_exists() probes). |
| 14 | - * @internal | |
| 15 | 14 | */ |
| 16 | 15 | class PagesRouter |
| 17 | 16 | { |
| 18 | 17 | private LicenseRegistry $registry; |
| @@ -19,9 +18,9 @@ | ||
| 19 | 18 | public function __construct(LicenseRegistry $registry) |
| 20 | 19 | { |
| 21 | 20 | $this->registry = $registry; |
| 22 | 21 | } |
| 23 | - public function init() : void | |
| 22 | + public function init(): void | |
| 24 | 23 | { |
| 25 | 24 | // Bind on both admin_menu and network_admin_menu so the shell pages |
| 26 | 25 | // (Help, Licenses, Recommended) appear in the Multisite Network Admin too. |
| 27 | 26 | AdminContext::bind_menu([$this, 'register_submenus'], 11); |
| @@ -27,9 +26,9 @@ | ||
| 27 | 26 | AdminContext::bind_menu([$this, 'register_submenus'], 11); |
| 28 | 27 | // Instantiate RecommendedPluginsPage to register its wp_ajax_* handlers. |
| 29 | 28 | RecommendedPluginsPage::get_instance(); |
| 30 | 29 | } |
| 31 | - public function register_submenus() : void | |
| 30 | + public function register_submenus(): void | |
| 32 | 31 | { |
| 33 | 32 | $submenus = $this->get_submenus(); |
| 34 | 33 | foreach ($submenus as $slug => $submenu) { |
| 35 | 34 | $page_id = add_submenu_page($submenu['parent'], $submenu['name'], $submenu['name'], $submenu['capability'], $slug, $submenu['render_callback'], $submenu['position'] ?? null); |
| @@ -37,9 +36,9 @@ | ||
| 37 | 36 | add_action('load-' . $page_id, $submenu['load_callback']); |
| 38 | 37 | } |
| 39 | 38 | } |
| 40 | 39 | } |
| 41 | - private function get_submenus() : array | |
| 40 | + private function get_submenus(): array | |
| 42 | 41 | { |
| 43 | 42 | $submenus = []; |
| 44 | 43 | // Plugin submenus use position 0-99 (via adapter). |
| 45 | 44 | // Shell pages use 900+ so they always appear at the bottom. |
| @@ -44,14 +43,14 @@ | ||
| 44 | 43 | // Plugin submenus use position 0-99 (via adapter). |
| 45 | 44 | // Shell pages use 900+ so they always appear at the bottom. |
| 46 | 45 | // In Network Admin the capability is elevated to manage_network. |
| 47 | 46 | $capability = AdminContext::capability('manage_options'); |
| 48 | - $submenus['yaycommerce-help'] = ['parent' => 'yaycommerce', 'name' => \__('Help', 'yaycommerce'), 'capability' => $capability, 'render_callback' => [HelpPage::class, 'render'], 'load_callback' => [HelpPage::class, 'load_data'], 'position' => 900]; | |
| 47 | + $submenus['yaycommerce-help'] = ['parent' => 'yaycommerce', 'name' => __('Help', 'yaycommerce'), 'capability' => $capability, 'render_callback' => [HelpPage::class, 'render'], 'load_callback' => [HelpPage::class, 'load_data'], 'position' => 900]; | |
| 49 | 48 | // Licenses submenu — only shown if any plugins are registered. |
| 50 | 49 | $has_any = !empty($this->registry->all()); |
| 51 | 50 | if ($has_any) { |
| 52 | - $submenus['yaycommerce-licenses'] = ['parent' => 'yaycommerce', 'name' => \__('Licenses', 'yaycommerce'), 'capability' => $capability, 'render_callback' => [LicensesPage::class, 'render'], 'load_callback' => [LicensesPage::class, 'load_data'], 'position' => 910]; | |
| 51 | + $submenus['yaycommerce-licenses'] = ['parent' => 'yaycommerce', 'name' => __('Licenses', 'yaycommerce'), 'capability' => $capability, 'render_callback' => [LicensesPage::class, 'render'], 'load_callback' => [LicensesPage::class, 'load_data'], 'position' => 910]; | |
| 53 | 52 | } |
| 54 | - $submenus['yaycommerce-other-plugins'] = ['parent' => 'yaycommerce', 'name' => \__('Recommended Plugins', 'yaycommerce'), 'capability' => $capability, 'render_callback' => [RecommendedPluginsPage::class, 'render'], 'load_callback' => [RecommendedPluginsPage::class, 'load_data'], 'position' => 920]; | |
| 53 | + $submenus['yaycommerce-other-plugins'] = ['parent' => 'yaycommerce', 'name' => __('Recommended Plugins', 'yaycommerce'), 'capability' => $capability, 'render_callback' => [RecommendedPluginsPage::class, 'render'], 'load_callback' => [RecommendedPluginsPage::class, 'load_data'], 'position' => 920]; | |
| 55 | 54 | return $submenus; |
| 56 | 55 | } |
| 57 | 56 | } |