Make WordPress Core

Ticket #17221: 17221.2.diff

File 17221.2.diff, 3.1 KB (added by greuben, 14 years ago)
  • wp-admin/admin-ajax.php

     
    784784        if ( is_wp_error( $item_ids ) )
    785785                die('-1');
    786786
     787        $post_parent_ids = array();
    787788        foreach ( (array) $item_ids as $menu_item_id ) {
    788789                $menu_obj = get_post( $menu_item_id );
    789790                if ( ! empty( $menu_obj->ID ) ) {
    790791                        $menu_obj = wp_setup_nav_menu_item( $menu_obj );
    791792                        $menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items
    792793                        $menu_items[] = $menu_obj;
     794                        $post_parent_ids[$menu_obj->object_id] = $menu_obj->db_id;
    793795                }
    794796        }
    795797
     
    799801                        'before' => '',
    800802                        'link_after' => '',
    801803                        'link_before' => '',
    802                         'walker' => new Walker_Nav_Menu_Edit,
     804                        'walker' => new Walker_Nav_Menu_Edit( array( 'id' => 'object_id', 'parent' => 'post_parent', 'parent_ids' => $post_parent_ids ) ),
    803805                );
    804806                echo walk_nav_menu_tree( $menu_items, 0, (object) $args );
    805807        }
  • wp-admin/includes/nav-menu.php

     
    88 * @uses Walker_Nav_Menu
    99 */
    1010class Walker_Nav_Menu_Edit extends Walker_Nav_Menu  {
     11       
     12        function __construct( $fields = false ) {
     13                if ( $fields )
     14                        $this->db_fields = $fields;
     15        }
     16       
    1117        /**
    1218         * @see Walker_Nav_Menu::start_lvl()
    1319         * @since 3.0.0
     
    7480                }
    7581
    7682                $title = empty( $item->label ) ? $title : $item->label;
     83                if ( $this->db_fields['parent'] == 'menu_item_parent' ) {
     84                        $menu_item_parent = $item->menu_item_parent;
     85                } else if ( isset( $this->db_fields['parent_ids'][$item->post_parent] ) ) {
     86                        $menu_item_parent = $this->db_fields['parent_ids'][$item->post_parent];
     87                } else {
     88                        $menu_item_parent = 0;
     89                }
    7790
    7891                ?>
    7992                <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
     
    189202                                <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
    190203                                <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" />
    191204                                <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
    192                                 <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" />
     205                                <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item_parent ); ?>" />
    193206                                <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
    194207                                <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
    195208                        </div><!-- .menu-item-settings-->