I noticed today that my error logs are littered with this information. I'm not quite sure what's causing it. Has anyone seen this before?

[Mon Mar 25 17:24:23 2013] [error] [client] PHP Warning: Invalid argument supplied for foreach() in /var/www/html/mysite/wp-admin/includes/plugin.php on line 1290, referer: http://mysite/contact/

Line 1290 is the foreach in the following code. I am not sure what's referencing this or where to begin looking.

 * Remove a top level admin menu
 * @since 3.1.0
 * @param string $menu_slug The slug of the menu
 * @return array|bool The removed menu on success, False if not found

function remove_menu_page( $menu_slug ) {
global $menu;

foreach ( $menu as $i => $item ) {
    if ( $menu_slug == $item[2] ) {
        unset( $menu[$i] );
        return $item;

return false;

I'm not hooking into admin_menu as far as I can tell.

Any ideas?

  • 1
    This is most likely caused by a plugin. Deactivate them all, and reactivate one by one.
    – vancoder
    Mar 25, 2013 at 21:34
  • Looks like I narrowed it down to a plugin, which tells me I must have been getting this error for a few months and just didn't notice. Pop that one liner into an answer and I'll check it off for you. Thanks @vancoder
    – Pat
    Mar 25, 2013 at 22:04
  • Was it a Twitter (or twitter related) plugin perchance? they've recently updated their API so a lot of plugins are failing.
    – vancoder
    Mar 25, 2013 at 22:15
  • No it was WP Most Popular (which for what it's worth, never seemed to work rock-solid anyways). wordpress.org/extend/plugins/wp-most-popular
    – Pat
    Mar 25, 2013 at 22:16

2 Answers 2


This is most likely caused by a plugin. Deactivate them all, and reactivate one by one.


I had same problem while developing my own plugin. Turns out that I didn't uninstall menu the right way in uninstall.php. Here is right way with hook:

function myplugin_remove_menus() {
remove_menu_page( 'myplugin-admin-menu' );
remove_menu_page( 'myplugin-admin-menu-logs' );
// proper way with admin_menu hook
add_action( 'admin_menu', 'myplugin_remove_menus' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.