Opened 14 years ago
Closed 14 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: |
Description
Probably a mistake. Maybe I'm doing something wrong, but:
<?php 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
plugin.php:1263:
foreach ( $menu as $i => $item ) {
This code returns NULL:
global $menu; var_dump($menu);
Change History (2)
Note: See
TracTickets for help on using
tickets.
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.