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 );
	}
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 );
	}
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 ) ; }
Deletes one or more items from a menu.

## OPTIONS

<db-id>...
: Database ID for the menu item(s).

## EXAMPLES

$ wp menu item delete 45
Success: 1 menu item deleted.

@subcommand delete
Deletes one or more items from a menu .