WordPress.org

Forums

Top-level menu duplicated as submenu in admin section plugin (5 posts)

  1. solidsquid
    Member
    Posted 5 years ago #

    I've seen a couple of posts about this, but none of the fixes seem to be working for me. I'm trying to create a menu for a plugin which has two submenus, but the top-level title keeps being duplicated as a submenu.

    The following are variations I've tried to get this working:

    add_menu_page("Manage News", "Manage News", 1, "manage_news_admin", "include_core");
    add_submenu_page(basename(__FILE__), 'Edit', 'Edit', 10, basename(__FILE__), 'section_edit');
    add_menu_page("Manage News", "Manage News", 1, "manage_news_admin", "include_core");
    add_submenu_page(basename(__FILE__), 'Edit', 'Edit', 10, basename(__FILE__), 'section_edit');
    add_menu_page("Manage News", "Manage News", 1, "manage_news_admin", "include_core");
    add_submenu_page(__FILE__, 'Edit', 'Edit', 10, 'section-edit', 'section_edit');
    add_menu_page("Manage News", "Manage News", 1, "manage_news_admin", "include_core");
    add_submenu_page('section_edit', 'section_edit', 'section_edit', 10, 'section-edit', 'section_edit');

    And the full code for the plugin file is:

    function configure_menu(){
    add_menu_page("Manage News", "Manage News", 1, "manage_news_admin", "include_core");
    [code for removing duplicate goes here];
    }
    
    function include_core(){
    include('aggregator/aggregator_core.php');
    }
    
    function feed_list_admin() {
    include('aggregator/feed_management.php');
    }
    
    function feed_tags_admin() {
    include('aggregator/feed_tag_management.php');
    }
    
    function feed_list_actions() {
    add_submenu_page("manage_news_admin", "Feed List", "Feed List", 1, "aggregator/feed_management.php", "feed_list_admin");
    }
    
    function feed_tags_actions() {
    add_submenu_page("manage_news_admin", "Feed Keywords", "Feed Keywords", 1, "aggregator/feed_tag_management.php", "feed_tags_admin");
    }
    
    add_action('admin_menu', 'configure_menu');
    
    add_action('admin_menu', 'feed_list_actions');
    
    add_action('admin_menu', 'feed_tags_actions');

    If anyone has any advice on how to get this working I would really appreciate it, as this is pretty much the only bit left to get working.

  2. chrillemeter
    Member
    Posted 5 years ago #

    Should work.

    add_menu_page("Manage News", "Manage News", "manage_news_admin", "include_core");
    add_submenu_page("manage_news_admin", "News", "Manage", "manage_news_admin", "include_core");

    Don't show in menu.

    add_submenu_page("manage_news_admin", "News", "", "manage_news_admin", "include_core");
  3. solidsquid
    Member
    Posted 5 years ago #

    Thanks for the help, but that doesn't seem to work for me. If I remove the number from the add_menu_page function as you've got in that first code segment the entire menu disappears rather than just the sub-menu which duplicates the top-level menu. Keeping the number and using the same second lines you wrote don't seem to work either.

    EDIT: I don't know if this'll make any difference, but It's probably worth mentioning that I'm running this on XAMPP just in case this is what's causing the problem

  4. wankwank
    Member
    Posted 4 years ago #

    Frustrating as hell eh?

    This finally did it for me (in WP 3.0.1):

    add_menu_page('page_title','menu_title','manage_options','menu_slug','function');
    add_submenu_page('menu_slug','','','manage_options','menu_slug','function');
    add_submenu_page('menu_slug','1st Real Submenu','1st Real Submenu','manage_options','1st_real_submenu_slug','function');

    What results from this setup is that the 3rd line (the 2nd submenu page we're adding) will be the first submenu that displays.

  5. complainer
    Member
    Posted 4 years ago #

    Your last fix worked for me!

    I inserted your second line AFTER my add_menu_page line and inserted my custom 'menu_slug" in both places, left everything else along and the duplicate disappeared.

    It's because of you I have a couple of hairs left on my head...

Topic Closed

This topic has been closed to new replies.

About this Topic