PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.2
YayMail – WooCommerce Email Customizer v4.4.2
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 / Menu / TopLevelMenu.php

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

68 lines 3.3 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\Support\AdminContext;
6 /**
7 * Registers the shared YayCommerce top-level admin menu.
8 *
9 * First-to-register-wins: uses $admin_page_hooks['yaycommerce'] guard so only
10 * ONE instance runs across all co-installed plugins. Ported from YayMail Pro
11 * RegisterMenu.php — cross-plugin class_exists() probes removed because
12 * LicenseRegistry now handles plugin discovery.
13 *
14 * Position 56 (after WooCommerce), capability manage_options, slug yaycommerce.
15 * @internal
16 */
17 class TopLevelMenu
18 {
19 public static int $position = 56;
20 public static string $capability = 'manage_options';
21 public function init() : void
22 {
23 AdminContext::bind_menu([$this, 'register_menu'], 9);
24 }
25 /**
26 * Register top-level menu. Guard ensures only the first plugin wins.
27 */
28 public function register_menu() : void
29 {
30 global $admin_page_hooks;
31 // First-to-register-wins — if another plugin already registered the
32 // 'yaycommerce' top-level menu, skip. This replaces the old cross-plugin
33 // class_exists() probes that existed in RegisterMenu.php lines 88-105.
34 if (isset($admin_page_hooks['yaycommerce'])) {
35 return;
36 }
37 add_menu_page(
38 'yaycommerce',
39 'YayCommerce',
40 self::$capability,
41 'yaycommerce',
42 null,
43 // no callback — submenus render content
44 self::get_logo_url(),
45 self::$position
46 );
47 // Remove the auto-created "YayCommerce" submenu AFTER all submenus are registered.
48 // This runs inside the firing menu hook, so the context is known — bind only
49 // to the current hook (admin_menu or network_admin_menu) rather than both.
50 add_action(AdminContext::hook(), [__CLASS__, 'remove_parent_submenu'], 999);
51 }
52 /**
53 * WP auto-creates a submenu matching the parent slug. Remove it late
54 * so it runs after all plugins have registered their submenus.
55 */
56 public static function remove_parent_submenu() : void
57 {
58 remove_submenu_page('yaycommerce', 'yaycommerce');
59 }
60 /**
61 * Inline base64 SVG logo — copied as-is from YayMail Pro RegisterMenu.php.
62 */
63 public static function get_logo_url() : string
64 {
65 return 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjQiIGhlaWdodD0iNjQiIHZpZXdCb3g9IjAgMCA2NCA2NCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTQ2LjI0NzYgNi40MDg5NkM0Ni4yNDc2IDkuOTQ4MTYgNDMuMzc3OCAxMi44MTc5IDM5LjgzODYgMTIuODE3OUMzNi4yOTk0IDEyLjgxNzkgMzMuNDI5NyA5Ljk0ODE2IDMzLjQyOTcgNi40MDg5NkMzMy40Mjk3IDIuODY5NzYgMzYuMjk4MSAwIDM5LjgzODYgMEM0My4zNzkxIDAgNDYuMjQ3NiAyLjg2OTc2IDQ2LjI0NzYgNi40MDg5NlpNMS4xNjQ3MSAyMi45OTI2Qy0wLjIxODk3MiAyMy4xMzIyIC0wLjQzNzg1MiAyNS4wNTg2IDAuODc5MjY4IDI1LjUwNEM5LjI1NDMxIDI4LjMzNjYgMjEuMzAwNCAzMC45OTUyIDI3LjI0OTggMzIuMjM0MkMyOS4yOTkxIDMyLjY2MDUgMzAuNjIzOSAzNC42NDgzIDMwLjI0MTIgMzYuNzA2NkMyOC41NDUyIDQ1LjgwNjEgMjUuMzc4NSA1NS41Mjc3IDIzLjM2ODkgNjIuMzM0N0MyMi45ODYyIDYzLjYzMTQgMjQuNTk5IDY0LjU3MjIgMjUuNTM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