PluginProbe
YayMail – WooCommerce Email Customizer / trunk
YayMail – WooCommerce Email Customizer vtrunk
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 3.4.2 3.4.3 All 55 releases
yaymail / vendor-prefixed / src / Menu / ExternalPluginMenuAdapter.php

ExternalPluginMenuAdapter.php in YayMail – WooCommerce Email Customizer trunk, at vendor-prefixed/src/Menu/ExternalPluginMenuAdapter.php

41 lines 1.4 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\Menu;
4
5 use YayMailScoped\YayCommerce\AdminShell\Pages\RecommendedPluginsPage;
6 defined('ABSPATH') || exit;
7 /**
8 * Registers an "Other Plugins" submenu under an external plugin's own top-level menu.
9 * Used for plugins (e.g. whatsapp, filester) that own their own menu hierarchy
10 * and should NOT appear under the shared YayCommerce menu.
11 */
12 class ExternalPluginMenuAdapter
13 {
14 private string $parent_menu;
15 private string $menu_title;
16 private string $menu_capability;
17 private string $menu_slug;
18 public function __construct(array $config)
19 {
20 $this->parent_menu = $config['parent_menu'] ?? '';
21 $this->menu_title = 'Recommended Plugins';
22 $this->menu_capability = $config['menu_capability'] ?? 'manage_options';
23 $this->menu_slug = $config['menu_slug'] ?? '';
24 }
25 public function init(): void
26 {
27 RecommendedPluginsPage::get_instance();
28 if (!is_admin()) {
29 return;
30 }
31 add_action('admin_menu', [$this, 'register_other_plugins_submenu'], 20);
32 }
33 public function register_other_plugins_submenu(): void
34 {
35 $page_id = add_submenu_page($this->parent_menu, $this->menu_title, $this->menu_title, $this->menu_capability, $this->menu_slug, [RecommendedPluginsPage::class, 'render']);
36 add_action('load-' . $page_id, function () {
37 RecommendedPluginsPage::load_data();
38 });
39 }
40 }
41