Opened 15 years ago
Closed 15 years ago
#16326 closed defect (bug) (invalid)
remove_menu_page doesn't work
| Reported by: | czepol | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Administration | Version: | 3.1 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.