function menu_delete

Delete a custom menu and all contained links.

Note that this function deletes all menu links in a custom menu. While menu links derived from router paths may be restored by rebuilding the menu, all customized and custom links will be irreversibly gone. Therefore, this function should usually be called from a user interface (form submit) handler only, which allows the user to confirm the action.

Parameters

$menu: An array representing a custom menu:

  • menu_name: The unique name of the custom menu.
  • title: The human readable menu title.
  • description: The custom menu description.

Modules should always pass a fully populated $menu when deleting a custom menu, so other modules are able to output proper status or watchdog messages.

See also

menu_load()

menu_delete_links() will take care of clearing the page cache. Other modules should take care of their menu-related data by implementing hook_menu_delete().

1 call to menu_delete()
menu_delete_menu_confirm_submit in modules/menu/menu.admin.inc
Delete a custom menu and all links in it.

File

modules/menu/menu.module, line 313

Code

function menu_delete($menu) {
    // Delete all links from the menu.
    menu_delete_links($menu['menu_name']);
    // Remove menu from active menus variable.
    $active_menus = variable_get('menu_default_active_menus', array_keys(menu_get_menus()));
    foreach ($active_menus as $i => $menu_name) {
        if ($menu['menu_name'] == $menu_name) {
            unset($active_menus[$i]);
            variable_set('menu_default_active_menus', $active_menus);
        }
    }
    // Delete the custom menu.
    db_delete('menu_custom')->condition('menu_name', $menu['menu_name'])
        ->execute();
    menu_cache_clear_all();
    module_invoke_all('menu_delete', $menu);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.