Deletes one or more menus.

## OPTIONS

<menu>...
: The name, slug, or term ID for the menu(s).

## EXAMPLES

$ wp menu delete "My Menu"
Success: 1 menu deleted.
507589
public function delete( $args, $assoc_args ) {

		$count  = 0;
		$errors = 0;
		foreach ( $args as $arg ) {
			$ret = wp_delete_nav_menu( $arg );
			if ( ! $ret || is_wp_error( $ret ) ) {
				WP_CLI::warning( "Couldn't delete menu '{$arg}'." );
				$errors++;
			} else {
				WP_CLI::log( "Deleted menu '{$arg}'." );
				$count++;
			}
		}

		Utils\report_batch_operation_results( 'menu', 'delete', count( $args ), $count, $errors );
	}
487843
public function delete()
    {
        if (!$this->ID) {
            return false;
        }

        try {
            global $wpdb;
            $sql = 'DELETE FROM ' . static::getTableName() . ' WHERE ' . static::$PK . ' = %d';

            return $wpdb->query($wpdb->prepare($sql, $this->ID));
        } catch (Exception $e) {
            return false;
        }
    }
787062
protected function clearSelectedMenuEntries(Menu $menu) {

		while(($e = $menu->getSelectedEntry())) {

			// dynamic menus come either with unselected entry or have a selected entry explicitly set

			if($menu->getType() == 'static') {
				$menu->clearSelectedEntry();
			}
			if(!($menu = $e->getSubMenu())) {
				break;
			}
		}
	}
454230
def del_view_menu(self, name):
        
        obj = self.find_view_menu(name)
        if obj:
            try:
                obj.delete()
            except Exception as e:
                log.error(c.LOGMSG_ERR_SEC_DEL_PERMISSION.format(str(e)))
277297
public function deleteAction($id)
    {
        /** @var Menus_Entity_Table_Menu $table */
        $table = ORM::getTable($this->plugin, 'Menu');
        /** @var Menus_Entity_Menu $menu */
        $menu = $table->find($id);

        if (!is_null($menu))
        {
            $table->delete($menu);
        }
        HTTP::redirect(str_replace('&amp;', '&', $this->ui->url()));
    }
706124
function delete() {
			$this->_data = array();

			$all_data = $this->get_all_data();
			unset( $all_data[ $this->_secondary_id ] );
			$options_manager = $this->get_option_manager();
			$options_manager->set_option( $this->_id, $all_data, true );
		}
168467
def delete(options = {}, invalidate = true)
      if invalidate
        self.invalidate
      end
      options = @options.merge(options)
      response = self.class.delete(@uri, options)
      if response.success?
        deserialize(response)
      else
        fail HttpError, response.response
      end
    end
726805
public function DeleteCategory($CategoryID = FALSE) {
      // Check permission
      $this->Permission('Garden.Settings.Manage');
      
      // Set up head
      $this->AddJsFile('categories.js');
      $this->Title(T('Delete Category'));
      $this->AddSideMenu('vanilla/settings/managecategories');

      // Get category data
      $this->Category = $this->CategoryModel->GetID($CategoryID);
      
      
      if (!$this->Category) {
         $this->Form->AddError('The specified category could not be found.');
      } else {
         // Make sure the form knows which item we are deleting.
         $this->Form->AddHidden('CategoryID', $CategoryID);
         
         // Get a list of categories other than this one that can act as a replacement
         $this->OtherCategories = $this->CategoryModel->GetWhere(
            array(
               'CategoryID <>' => $CategoryID,
               'AllowDiscussions' => $this->Category->AllowDiscussions, // Don't allow a category with discussion to be the replacement for one without discussions (or vice versa)
               'CategoryID >' => 0
            ),
            'Sort'
         );
         
         if (!$this->Form->AuthenticatedPostBack()) {
            $this->Form->SetFormValue('DeleteDiscussions', '1'); // Checked by default
         } else {
            $ReplacementCategoryID = $this->Form->GetValue('ReplacementCategoryID');
            $ReplacementCategory = $this->CategoryModel->GetID($ReplacementCategoryID);
            // Error if:
            // 1. The category being deleted is the last remaining category that
            // allows discussions.
            if ($this->Category->AllowDiscussions == '1'
               && $this->OtherCategories->NumRows() == 0)
               $this->Form->AddError('You cannot remove the only remaining category that allows discussions');
            
            /*
            // 2. The category being deleted allows discussions, and it contains
            // discussions, and there is no replacement category specified.
            if ($this->Form->ErrorCount() == 0
               && $this->Category->AllowDiscussions == '1'
               && $this->Category->CountDiscussions > 0
               && ($ReplacementCategory == FALSE || $ReplacementCategory->AllowDiscussions != '1'))
               $this->Form->AddError('You must select a replacement category in order to remove this category.');
            */
            
            // 3. The category being deleted does not allow discussions, and it
            // does contain other categories, and there are replacement parent
            // categories available, and one is not selected.
            /*
            if ($this->Category->AllowDiscussions == '0'
               && $this->OtherCategories->NumRows() > 0
               && !$ReplacementCategory) {
               if ($this->CategoryModel->GetWhere(array('ParentCategoryID' => $CategoryID))->NumRows() > 0)
                  $this->Form->AddError('You must select a replacement category in order to remove this category.');
            }
            */
            
            if ($this->Form->ErrorCount() == 0) {
               // Go ahead and delete the category
               try {
                  $this->CategoryModel->Delete($this->Category, $this->Form->GetValue('ReplacementCategoryID'));
               } catch (Exception $ex) {
                  $this->Form->AddError($ex);
               }
               if ($this->Form->ErrorCount() == 0) {
                  $this->RedirectUrl = Url('vanilla/settings/managecategories');
                  $this->InformMessage(T('Deleting category...'));
               }
            }
         }
      }
      
      // Render default view
      $this->Render();
   }
402858
private function mainMenuIdent($options = null)
    {
        if ($this->mainMenuIdentLoaded === false) {
            $mainMenuIdent = null;

            if (isset($this['main_menu_item'])) {
                $mainMenuIdent = $this['main_menu_item'];
            }

            if (!(empty($options) && !is_numeric($options))) {
                if (is_string($options)) {
                    $mainMenuIdent = $options;
                } elseif (is_array($options)) {
                    if (isset($options['widget_options']['ident'])) {
                        $mainMenuIdent = $options['widget_options']['ident'];
                    }
                }
            }

            // Get main menu from the obj_type
            $objType = filter_input(INPUT_GET, 'obj_type', FILTER_SANITIZE_STRING);
            if ($objType) {
                $secondaryMenuItems = $this->adminConfig('secondary_menu');
                foreach ($secondaryMenuItems as $main => $item) {
                    if ($this->isObjTypeInSecondaryMenuItem($objType, $item)) {
                        $mainMenuIdent = $main;
                        break;
                    }
                }
            }

            // Choose main menu with a get parameter
            $mainMenuFromRequest = filter_input(INPUT_GET, 'main_menu', FILTER_SANITIZE_STRING);
            if ($mainMenuFromRequest) {
                $mainMenuIdent = $mainMenuFromRequest;
            }

            $this->mainMenuIdent = $mainMenuIdent;
            $this->mainMenuIdentLoaded = true;
        }

        return $this->mainMenuIdent;
    }
581296
public function removeCachedMenu()
    {
        $menuTypeIds = $this->menu_items()->pluck('menu_type_id')->unique()->all();

        foreach ( $menuTypeIds as $menuTypeId ) {
            MenuHelper::clearCache($menuTypeId, app()->getLocale());
        }
    }
1165402
def remove_menu(self, name):
        
        if name not in self._menus:
            raise exceptions.MenuNotFound(
                "Menu {!r} was not found. It might be deleted, or belong to another menu manager.".format(name))

        self._menu.removeAction(self._menus[name].menuAction())
        del self._menus[name]
493226
public function delete()
    {
        if (empty($this->id)) {
            $this->id = shmop_open($this->key, $this->mode, $this->permission, $this->size);
        }
        @shmop_delete($this->id);
        @shmop_close($this->id);

        return true;

    }
678781
public function delete()
	{
		if ( ! $this->is_loaded() ) return false;

		$error = wp_delete_post( $this->attributes['ID'], $this->forceDelete );

		return $error !== false;
	}
240223
public function remove( $args, $assoc_args ) {

		list( $menu, $location ) = $args;

		$menu = wp_get_nav_menu_object( $menu );
		if ( ! $menu || is_wp_error( $menu ) ) {
			WP_CLI::error( 'Invalid menu.' );
		}

		$locations = get_nav_menu_locations();
		if ( Utils\get_flag_value( $locations, $location ) !== $menu->term_id ) {
			WP_CLI::error( "Menu isn't assigned to location." );
		}

		$locations[ $location ] = 0;
		set_theme_mod( 'nav_menu_locations', $locations );

		WP_CLI::success( 'Removed location from menu.' );

	}
369755
public function delete( $args, $assoc_args ) {
		global $wpdb;

		$count  = 0;
		$errors = 0;

		foreach ( $args as $arg ) {

			$parent_menu_id = (int) get_post_meta( $arg, '_menu_item_menu_item_parent', true );
			$result         = wp_delete_post( $arg, true );
			if ( ! $result ) {
				WP_CLI::warning( "Couldn't delete menu item {$arg}." );
				$errors++;
			} elseif ( $parent_menu_id ) {
				$children = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_menu_item_menu_item_parent' AND meta_value=%s", (int) $arg ) );
				if ( $children ) {
					$children_query = $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = %d WHERE meta_key = '_menu_item_menu_item_parent' AND meta_value=%s", $parent_menu_id, (int) $arg );
					// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- $children_query is already prepared above.
					$wpdb->query( $children_query );
					foreach ( $children as $child ) {
						clean_post_cache( $child );
					}
				}
			}

			// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Will increase count for non existent menu.
			if ( false != $result ) {
				$count++;
			}
		}

		Utils\report_batch_operation_results( 'menu item', 'delete', count( $args ), $count, $errors );
	}
257354
public function destroy($id)
    {
        $link = $this->repository->find($id);
        $menu = $link->menu_id;

        if (empty($link)) {
            Cms::notification('Link not found', 'warning');

            return redirect(route($this->routeBase.'.menus.index'));
        }

        $order = json_decode($link->menu->order);
        $key = array_search($id, $order);
        unset($order[$key]);

        $link->menu->update([
            'order' => json_encode(array_values($order)),
        ]);

        $link->delete();

        Cms::notification('Link deleted successfully.', 'success');

        return redirect(route($this->routeBase.'.menus.edit', [$link->menu_id]));
    }
999361
public function delete($id)
    {
        $this->request->allowMethod('post');

        $menu = $this->Menus->get($id);
        if ($this->Menus->delete($menu)) {
            $this->Flash->success(__d('wasabi_core', 'The menu <strong>{0}</strong> has been deleted.', $menu->name));
        } else {
            $this->Flash->error($this->dbErrorMessage);
        }
        $this->redirect(['action' => 'index']);
        return;
    }