2 / 2
The mu_menu_items WordPress PHP filter allows you to manage network-wide administration menu options.
Usage
add_filter( 'mu_menu_items', 'your_custom_function' ); function your_custom_function( $admin_menus ) { // your custom code here return $admin_menus; }
Parameters
- $admin_menus (string[]) – Associative array of the menu items available.
More information
See WordPress Developer Resources: mu_menu_items
Examples
Add a custom menu item
Add a custom menu item named ‘My Custom Menu’ with a slug ‘my-custom-menu’.
add_filter( 'mu_menu_items', 'add_custom_menu_item' ); function add_custom_menu_item( $admin_menus ) { $admin_menus['my-custom-menu'] = __( 'My Custom Menu', 'text-domain' ); return $admin_menus; }
Remove the ‘plugins’ menu item
Remove the ‘plugins’ menu item from the list of available items.
add_filter( 'mu_menu_items', 'remove_plugins_menu_item' ); function remove_plugins_menu_item( $admin_menus ) { unset( $admin_menus['plugins'] ); return $admin_menus; }
Modify the ‘plugins’ menu item label
Change the label of the ‘plugins’ menu item to ‘Add-ons’.
add_filter( 'mu_menu_items', 'modify_plugins_menu_item_label' ); function modify_plugins_menu_item_label( $admin_menus ) { $admin_menus['plugins'] = __( 'Add-ons', 'text-domain' ); return $admin_menus; }
Add multiple custom menu items
Add multiple custom menu items at once.
add_filter( 'mu_menu_items', 'add_multiple_custom_menu_items' ); function add_multiple_custom_menu_items( $admin_menus ) { $admin_menus['custom-menu-1'] = __( 'Custom Menu 1', 'text-domain' ); $admin_menus['custom-menu-2'] = __( 'Custom Menu 2', 'text-domain' ); return $admin_menus; }
Clear all menu items
Clear all available menu items.
add_filter( 'mu_menu_items', 'clear_all_menu_items' ); function clear_all_menu_items( $admin_menus ) { return array(); }