admin管理员组

文章数量:1122832

I'm working on customizing the admin sidebar menu specifically for the WordPress Multisite Network Admin area. I want to add a new top-level menu called "Header Builder" and some submenus like "Top Bar Menu" and "Main Menu". When any of these submenus are clicked, the admin sidebar should remain the same as in the network admin interface.

Here are my requirements:

No plugins – I want to modify the core or theme files directly to achieve this. The new menu should appear in the Network Admin Sidebar. The menu should have nested submenus (e.g., "Top Bar Menu", "Main Menu"). The sidebar menu should persist when navigating between these submenus. I’ve found lots of resources about adding admin menus in standard WordPress but nothing specific to network admin customization without using plugins.

Any help on which files to modify or how to hook into the admin menu for multisite would be greatly appreciated!

I'm working on customizing the admin sidebar menu specifically for the WordPress Multisite Network Admin area. I want to add a new top-level menu called "Header Builder" and some submenus like "Top Bar Menu" and "Main Menu". When any of these submenus are clicked, the admin sidebar should remain the same as in the network admin interface.

Here are my requirements:

No plugins – I want to modify the core or theme files directly to achieve this. The new menu should appear in the Network Admin Sidebar. The menu should have nested submenus (e.g., "Top Bar Menu", "Main Menu"). The sidebar menu should persist when navigating between these submenus. I’ve found lots of resources about adding admin menus in standard WordPress but nothing specific to network admin customization without using plugins.

Any help on which files to modify or how to hook into the admin menu for multisite would be greatly appreciated!

Share Improve this question asked Sep 16, 2024 at 12:33 TheAMTheAM 1 2
  • 2 Obligatory don't do that. If you modify the core files then your changes would get wiped by an auto-update. You can work around this, e.g. by turning off auto-updates, or working with a git checkout and a branch, or creating a patch with your changes that you apply to the update after it's been downloaded, or something else, but it's going to be hassle. The point of all the hooks is so that you can do customisation from plugins: unless you need to do something there isn't a hook for then plugins are the way to go. – Rup Commented Sep 16, 2024 at 13:08
  • 1 But honestly if you're editing the files, do you need our help? Just find the file with the menu you want to modify and edit it. If you've got advice how to do it with a plugin, look at what hook they're hooking then find where that's called from and that's where you need to look. – Rup Commented Sep 16, 2024 at 13:09
Add a comment  | 

1 Answer 1

Reset to default 1

Firstly, you should absolutely not modify core files. Ever. Any changes you make to core files can and will be overwritten any time WordPress updates. There are umpteen ways in which WP has been written to allow you to change its behaviour without hacking on core files: hooks, filters, APIs. Use those instead.

In this case you should be writing a plugin, because you're changing functionality. That's in a plugin's wheelhouse, a theme should only be concerned with displaying the frontend of the site.

You can add to the sidebar with add_menu_page() and add_submenu_page(), both of which are well documented in the developer docs I linked.

本文标签: