Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#16326 closed defect (bug) (invalid)

remove_menu_page doesn't work

Reported by: czepol Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Administration Keywords:
Focuses: Cc:


Probably a mistake. Maybe I'm doing something wrong, but:


require_once(ABSPATH . 'wp-admin/includes/admin.php');

remove_menu_page( 'link-manager.php' );


This code returns error: Warning: Invalid argument supplied for foreach() in /var/www/3.1/app/wp-admin/includes/plugin.php on line 1263


foreach ( $menu as $i => $item ) {

This code returns NULL:

global $menu;

Change History (2)

#1 @nacin
7 years ago

That's cause $menu isn't set up yet. You need to wait until the admin_menu hook or so.

Not sure why you're including includes/admin.php outside of an example. You'd really only ever include that in rare cases (read: never), and in those cases you wouldn't have a menu initialized.

#2 @nacin
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.