Make WordPress Core


Ignore:
Timestamp:
05/24/2010 07:50:20 PM (15 years ago)
Author:
nacin
Message:

First pass on better UX for menu item save. props koopersmith, see #13525.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/nav-menus.php

    r14833 r14852  
    319319
    320320            if ( ! is_wp_error( $_menu_object ) ) {
    321                 $menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') );
     321                $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') );
     322                $menu_items = array();
     323                // Index menu items by db ID
     324                foreach( $unsorted_menu_items as $_item )
     325                    $menu_items[$_item->db_id] = $_item;
     326
    322327                $post_fields = array( 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 'menu-item-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' );
    323328                wp_defer_term_counting(true);
     
    357362
    358363                $messages[] = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been updated.'), $nav_menu_selected_title ) . '</p></div>';
    359                 unset( $menu_items );
     364                unset( $menu_items, $unsorted_menu_items );
    360365            }
    361366        }
     
    411416    wp_nav_menu_setup();
    412417    $messages[] = '<div id="message" class="error"><p>' . __('The current theme does not natively support menus, but you can use the &#8220;Navigation Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p></div>';
    413 
    414 // The theme supports neither menus nor widgets.
    415 } else {
    416     remove_meta_box( 'create-menu', 'nav-menus', 'side' );
    417     $messages[] = '<div id="message" class="error"><p>' . __('The current theme does not support menus.') . '</p></div>';
    418418}
    419419
     
    513513                            </div><!--END .major-publishing-actions-->
    514514                        </div><!--END #submitpost .submitbox-->
    515                         <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
    516                         <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
    517                         <?php wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' ); ?>
     515                        <?php
     516                        wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
     517                        wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
     518                        wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' );
     519                        ?>
    518520                        <input type="hidden" name="action" value="update" />
    519521                        <input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
Note: See TracChangeset for help on using the changeset viewer.