Invalid Arguement in Foreach when calling add_submenu_page
-
I’m using a nightly build from January 30th. I’ve made a plug-in that injects itself into the Admin Menu. It works but I get the following error:
Warning: Invalid argument supplied for foreach() in /home/zsd/clients/cadex/httpdocs/wp-admin/admin-functions.php on line 874In my plugin file I add the submenus with this:
add_submenu_page(__(“profile.php”), __(‘Clients’), __(‘Clients’), 8, ‘softshop_clients.php’);
add_submenu_page(__(“profile.php”), __(‘Orders’), __(‘Orders’), 8, ‘softshop_orders.php’);
add_submenu_page(__(“profile.php”), __(‘Products’), __(‘Products’), 8, ‘softshop_products.php’);
add_submenu_page(__(“profile.php”), __(‘Product Formats’), __(‘Product Formats’), 8, ‘softshop_productformats.php’);here is the function that is having trouble. The foreach statement is where the error is coming from:
function add_submenu_page($parent, $page_title, $menu_title, $access_level, $file) {
global $submenu;
global $menu;$parent = plugin_basename($parent);
$file = plugin_basename($file);if (! isset($submenu[$parent]) && $file != $parent) {
foreach ($menu as $parent_menu) {
if ($parent_menu[2] == $parent) {
$submenu[$parent][] = $parent_menu;
}
}
}$submenu[$parent][] = array($menu_title, $access_level, $file, $page_title);
}If things are showing up ok on the menu, what is causing the invalid argument in the foreach? Thanks
- The topic ‘Invalid Arguement in Foreach when calling add_submenu_page’ is closed to new replies.