admin管理员组

文章数量:1297002

I hate it, when plugins add their own settings like this:

It's cluttered and annoying. Can I somehow move them in under 'Settings':

I imagined something like, checking if there is a plugin by the given name; and if there is, then remove it from the admin bar, like this (however, this doesn't work):

function custom_menu_page_removing() {
    // Neither of these two work (the first is the 
    // link, the second is the slug
    remove_menu_page( 'admin.php?page=themepacific_jp_gallery' );
    remove_menu_page( 'tiled-gallery-carousel-without-jetpack' );
}
add_action( 'admin_menu', 'custom_menu_page_removing' );

I then imagined adding a link to generel settings like this:

function example_admin_menu() {
    global $submenu;
    $url = home_url() . '/wp-admin/admin.php?page=wpseo_dashboard';
    $submenu['options-general.php'][] = array('Yoast', 'manage_options', $url);
}
add_action('admin_menu', 'example_admin_menu');

But my two problems are these:

  • I can't find the correct remove_menu_page( 'URL' ); to remove either Yoast or TP Tiled Gallery. How do I do that?
  • If I remove the Yoast, - what will then happen to the sub-menu? How do I access that:

I hate it, when plugins add their own settings like this:

It's cluttered and annoying. Can I somehow move them in under 'Settings':

I imagined something like, checking if there is a plugin by the given name; and if there is, then remove it from the admin bar, like this (however, this doesn't work):

function custom_menu_page_removing() {
    // Neither of these two work (the first is the 
    // link, the second is the slug
    remove_menu_page( 'admin.php?page=themepacific_jp_gallery' );
    remove_menu_page( 'tiled-gallery-carousel-without-jetpack' );
}
add_action( 'admin_menu', 'custom_menu_page_removing' );

I then imagined adding a link to generel settings like this:

function example_admin_menu() {
    global $submenu;
    $url = home_url() . '/wp-admin/admin.php?page=wpseo_dashboard';
    $submenu['options-general.php'][] = array('Yoast', 'manage_options', $url);
}
add_action('admin_menu', 'example_admin_menu');

But my two problems are these:

  • I can't find the correct remove_menu_page( 'URL' ); to remove either Yoast or TP Tiled Gallery. How do I do that?
  • If I remove the Yoast, - what will then happen to the sub-menu? How do I access that:

Share Improve this question asked Jun 19, 2018 at 16:12 ZethZeth 9282 gold badges13 silver badges43 bronze badges 2
  • Different plugins behave differently, so the answers could be endless. I would recommend a plugin like Admin Menu Editor to handle everything. – SeventhSteel Commented Jun 19, 2018 at 17:22
  • Is it at least just possible to simple hide them then (and not care about the settings for the given plugin)? I'm trying to keep the plugins to a minimum... – Zeth Commented Jun 19, 2018 at 20:38
Add a comment  | 

2 Answers 2

Reset to default 3

You seem to be making life complicated. Here's the code you need;

function menu_shuffle() {
  remove_menu_page( 'plugin-page' );
  add_submenu_page('options-general.php','Page Title', 'Menu Label','manage_options', 'plugin-page' );
};

add_action( 'admin_menu', 'menu_shuffle' );

plugin-page can be found by mousing over the existing menu label and getting the part after the ?page=in this case ?page=plugin-page

The Wordpress function definition for add_submenu_page() https://developer.wordpress/reference/functions/add_submenu_page/ includes a list of all the menu page slugs (and you need the '.php').

so in the example above for Yoast (bless its pointy little head and use Hide SEO Bloat)

function menu_shuffle() {
  remove_menu_page( 'wpseo_dashboard' );
  add_submenu_page('options-general.php','Yoast SE0', 'SEO','manage_options', 'wpseo_dashboard' );
};

add_action( 'admin_menu', 'menu_shuffle' );

For Yoast, you can easily hide it, the settings are also in the WP topbar. :)

To hide it, use this code :

function mte_custom_menu_page_removing() { 
remove_menu_page( 'wpseo_dashboard' );              //Yoast

I am also interested to know how to move all other plugins in the settings submenu.

-> Maybe an other solution here

本文标签: Move pluginsettings to 39Settings39menu in the admin