WordPress.org

Make WordPress Core

Changeset 13362


Ignore:
Timestamp:
02/24/2010 06:41:35 AM (12 years ago)
Author:
ryan
Message:

Return menu object from wp_create_nav_menu(). Fix trailing separator in menu list. Disable menu delete because it deletes the current menu when a new menu is added. see #11817

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/custom-navigation.php

    r13355 r13362  
    5555    $updated = true;
    5656}
     57
    5758// Default Menu to show
    58 $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
     59$custom_menus = wp_get_nav_menus();
    5960if ( ! $menu_selected_id && ! empty( $custom_menus ) )
    6061    $menu_selected_id = $custom_menus[0]->term_id;
     
    175176    <div id="pages-left">
    176177        <ul class="subsubsub">
    177 <?php           if ( ! empty( $custom_menus ) ) {
     178<?php       if ( ! empty( $custom_menus ) ) {
    178179                foreach ( $custom_menus as $menu ) {
    179                     $menu_term = get_term( $menu, 'nav_menu' );
     180                    $sep = end($custom_menus) == $menu ? '' : ' | ';
     181                    // $menu_term = get_term( $menu, 'nav_menu' );
    180182                    if ( ( $menu_id_in_edit == $menu->term_id ) || ( $menu_selected_id == $menu->term_id ) ) { ?>
    181             <li><?php echo esc_html( $menu_term->name ); ?> |</li>
    182 <?php                   } else { ?>
    183             <li><a href='custom-navigation.php?edit_menu=<?php echo esc_attr($menu_term->term_id); ?>'><?php echo esc_html( $menu_term->name ); ?></a> |</li>
    184 <?php                   }
     183                        <li><?php echo esc_html( $menu->name ) . $sep; ?></li>
     184<?php               } else { ?>
     185            <li><a href='custom-navigation.php?edit_menu=<?php echo esc_attr($menu->term_id); ?>'><?php echo esc_html( $menu->name ); ?></a><?php echo $sep; ?></li>
     186<?php               }
    185187                }
    186188            } else { ?>
    187189            <li><?php _e( 'Default' ); ?></li>
    188 <?php           } ?>
     190<?php       } ?>
    189191        </ul>
    190192        <div class="clear"></div>
     
    234236            updatepostdata();
    235237        </script>
    236 
    237         <input id="delete_menu" name="delete_menu" type="submit" value="<?php esc_attr_e('Delete This Menu'); ?>" />
     238        <!-- <input id="delete_menu" name="delete_menu" type="submit" value="<?php esc_attr_e('Delete This Menu'); ?>" /> -->
    238239        <input id="save_bottom" name="save_bottom" type="submit" value="<?php esc_attr_e('Save All Changes'); ?>" /></p>
    239240        </div><!-- /.inside -->
  • trunk/wp-includes/custom-navigation.php

    r13361 r13362  
    4747        return WP_Error('menu_exists', sprintf( __('A menu named "%s" already exists; please try another name.'), $menu_exists->name ));
    4848
    49     return wp_insert_term( $menu_name, 'nav_menu' );
     49    $menu = wp_insert_term( $menu_name, 'nav_menu' );
     50    if ( is_wp_error($menu) )
     51        return $menu;
     52
     53    return get_term( $menu['term_id'], 'nav_menu');
    5054}
    5155
Note: See TracChangeset for help on using the changeset viewer.