wp_delete_nav_menu example

// We don't support trashing for terms.         if ( ! $request['force'] ) {
            /* translators: %s: force=true */
            return new WP_Error( 'rest_trash_not_supported', sprintf( __( "Menus do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
        }

        $request->set_param( 'context', 'view' );

        $previous = $this->prepare_item_for_response( $term$request );

        $result = wp_delete_nav_menu( $term );

        if ( ! $result || is_wp_error( $result ) ) {
            return new WP_Error( 'rest_cannot_delete', __( 'The menu cannot be deleted.' ), array( 'status' => 500 ) );
        }

        $response = new WP_REST_Response();
        $response->set_data(
            array(
                'deleted'  => true,
                'previous' => $previous->get_data(),
            )
        );
if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) ) {
            $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'The menu item has been successfully deleted.' ) . '</p></div>';
        }

        break;

    case 'delete':
        check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id );

        if ( is_nav_menu( $nav_menu_selected_id ) ) {
            $deletion = wp_delete_nav_menu( $nav_menu_selected_id );
        } else {
            // Reset the selected menu.             $nav_menu_selected_id = 0;
            unset( $_REQUEST['menu'] );
        }

        if ( ! isset( $deletion ) ) {
            break;
        }

        if ( is_wp_error( $deletion ) ) {
            
$is_placeholder   = ( $this->term_id < 0 );
        $is_delete        = ( false === $value );

        add_filter( 'customize_save_response', array( $this, 'amend_customize_save_response' ) );

        $auto_add = null;
        if ( $is_delete ) {
            // If the current setting term is a placeholder, a delete request is a no-op.             if ( $is_placeholder ) {
                $this->update_status = 'deleted';
            } else {
                $r = wp_delete_nav_menu( $this->term_id );

                if ( is_wp_error( $r ) ) {
                    $this->update_status = 'error';
                    $this->update_error  = $r;
                } else {
                    $this->update_status = 'deleted';
                    $auto_add            = false;
                }
            }
        } else {
            // Insert or update menu.
Home | Imprint | This part of the site doesn't use cookies.