Make WordPress Core


Ignore:
Timestamp:
05/04/2010 07:40:04 PM (16 years ago)
Author:
nacin
Message:

Non-JS menu ordering fixes, also parent handling fixes. props filosofo, fixes #13135, fixes #13249

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/nav-menu.php

    r14404 r14450  
    257257    }
    258258
     259    $original_parent = 0 < $menu_item_db_id ? get_post_field( 'post_parent', $menu_item_db_id ) : 0;
     260
    259261    if ( 'custom' != $args['menu-item-type'] ) {
    260262        /* if non-custom menu item, then:
     
    267269        $original_title = '';
    268270        if ( 'taxonomy' == $args['menu-item-type'] ) {
     271            $original_parent = get_term_field( 'parent', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' );
    269272            $original_title = get_term_field( 'name', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' );
    270273        } elseif ( 'post_type' == $args['menu-item-type'] ) {
    271274
    272275            $original_object = get_post( $args['menu-item-object-id'] );
     276            $original_parent = (int) $original_object->post_parent;
    273277            $original_title = $original_object->post_title;
    274278
     
    298302        'post_content' => $args['menu-item-description'],
    299303        'post_excerpt' => $args['menu-item-attr-title'],
    300         'post_parent' => $args['menu-item-parent-id'],
     304        'post_parent' => $original_parent,
    301305        'post_title' => $args['menu-item-title'],
    302306        'post_type' => 'nav_menu_item',
     
    327331
    328332        update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key($args['menu-item-type']) );
     333        update_post_meta( $menu_item_db_id, '_menu_item_menu_item_parent', (int) $args['menu-item-parent-id'] );
    329334        update_post_meta( $menu_item_db_id, '_menu_item_object_id', (int) $args['menu-item-object-id'] );
    330335        update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key($args['menu-item-object']) );
     
    440445 *
    441446 * Properties:
    442  * - db_id:         The DB ID of the this item as a nav_menu_item object, if it exists (0 if it doesn't exist).
     447 * - db_id:         The DB ID of this item as a nav_menu_item object, if it exists (0 if it doesn't exist).
    443448 * - object_id:     The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.
    444449 * - type:      The family of objects originally represented, such as "post_type" or "taxonomy."
    445450 * - object:        The type of object originally represented, such as "category," "post", or "attachment."
    446451 * - append:        The singular label used to describe this type of menu item.
    447  * - parent:        The DB ID of the original object's parent object, if any (0 otherwise).
     452 * - post_parent:   The DB ID of the original object's parent object, if any (0 otherwise).
     453 * - menu_item_parent:  The DB ID of the nav_menu_item that is this item's menu parent, if any.  0 otherwise.
    448454 * - url:       The URL to which this menu item points.
    449455 * - title:     The title of this menu item.
     
    463469        if ( 'nav_menu_item' == $menu_item->post_type ) {
    464470            $menu_item->db_id = (int) $menu_item->ID;
     471            $menu_item->menu_item_parent = get_post_meta( $menu_item->ID, '_menu_item_menu_item_parent', true );
    465472            $menu_item->object_id = get_post_meta( $menu_item->ID, '_menu_item_object_id', true );
    466473            $menu_item->object = get_post_meta( $menu_item->ID, '_menu_item_object', true );
     
    499506        } else {
    500507            $menu_item->db_id = 0;
     508            $menu_item->menu_item_parent = 0;
    501509            $menu_item->object_id = (int) $menu_item->ID;
    502510            $menu_item->type = 'post_type';
     
    518526        $menu_item->ID = $menu_item->term_id;
    519527        $menu_item->db_id = 0;
     528        $menu_item->menu_item_parent = 0;
    520529        $menu_item->object_id = (int) $menu_item->term_id;
    521530        $menu_item->post_parent = (int) $menu_item->parent;
Note: See TracChangeset for help on using the changeset viewer.