is_nav_menu example


function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
    $menu_id     = (int) $menu_id;
    $items_saved = array();

    if ( 0 === $menu_id || is_nav_menu( $menu_id ) ) {

        // Loop through all the menu items' POST values.         foreach ( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
            if (
                // Checkbox is not checked.                 empty( $_item_object_data['menu-item-object-id'] ) &&
                (
                    // And item type either isn't set.                     ! isset( $_item_object_data['menu-item-type'] ) ||
                    // Or URL is the default.                     in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ), true ) ||
                    

    public static function convert( $menu ) {

        if ( ! is_nav_menu( $menu ) ) {
            return new WP_Error(
                'invalid_menu',
                __( 'The menu provided is not a valid menu.' )
            );
        }

        $menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'update_post_term_cache' => false ) );

        if ( empty( $menu_items ) ) {
            return '';
        }

        
check_admin_referer( 'delete-menu_item_' . $menu_item_id );

        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;
        }

        
Home | Imprint | This part of the site doesn't use cookies.