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