0

Many plugins create a top-level item in the admin menu, even though there is no need. (There is discussion of when to create a top-level item and when to create a sub-item on the codex.) This can lead to a cluttered admin menu:

enter image description here

I would like to make some of these items into a sub-item of 'Tools' or 'Settings', which is where I think the plugin author should have put them anyway.

The Admin Menu Editor plugin does this if you pay for the premium version, which is currently $29 a year for more than two sites. For the functionality I'm looking for, I'm not willing to pay that much.

Is there a way to unhook a menu item and then re-hook it to another menu using php?

I've done my searching but haven't found anything to do this.

2

Your question is very abstract. It actually vary form plugin to plugin how the organize the menu and pages. So it's kinda hard to know how the plugin developer has managed the pages in their code. By the way as far I understood, you need to remove the page by using remove_menu_page function. Here is an example of it-

function custom_menu_page_removing() {
    remove_menu_page( $menu_slug );
}
add_action( 'admin_menu', 'custom_menu_page_removing' );

Here you'll get a documentation. Please follow that.

Then you need to add the page to settings by using add_options_page. Here is

add_action( 'admin_menu', 'my_plugin_menu' );

function my_plugin_menu() {
    add_options_page( 
        'My Options',
        'My Plugin',
        'manage_options',
        'my-plugin.php',
        'my_plugin_page'
    );
}

And for adding to Tools menu use add_submenu_page.

The documentation is here.

  • This is exactly what I was looking for. My question was general because I want to remove and then re-add not just one but several plugins' menus, and I was looking for a general way that I could re-use whenever I install a new plugin that 'intrudes' on my clean admin menu interface. – Kit Johnson Aug 26 '16 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.