]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/nav-menu.php
Wordpress 3.6
[autoinstalls/wordpress.git] / wp-includes / nav-menu.php
index 7a5da9e20269a49e9c6e2198f5cafd9aaadc6286..794f4b2d1177f4d5658fc66bc0304d0ff008d9e8 100644 (file)
@@ -127,7 +127,8 @@ function get_registered_nav_menus() {
  */
 
 function get_nav_menu_locations() {
-       return get_theme_mod( 'nav_menu_locations' );
+       $locations = get_theme_mod( 'nav_menu_locations' );
+       return ( is_array( $locations ) ) ? $locations : array();
 }
 
 /**
@@ -188,6 +189,14 @@ function wp_delete_nav_menu( $menu ) {
 
        $result = wp_delete_term( $menu->term_id, 'nav_menu' );
 
+       // Remove this menu from any locations.
+       $locations = get_theme_mod( 'nav_menu_locations' );
+       foreach ( (array) $locations as $location => $menu_id ) {
+               if ( $menu_id == $menu->term_id )
+                       $locations[ $location ] = 0;
+       }
+       set_theme_mod( 'nav_menu_locations', $locations );
+
        if ( $result && !is_wp_error($result) )
                do_action( 'wp_delete_nav_menu', $menu->term_id );
 
@@ -327,13 +336,12 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item
                        $original_title = $original_object->post_title;
                }
 
-               if ( empty( $args['menu-item-title'] ) || $args['menu-item-title'] == $original_title ) {
+               if ( $args['menu-item-title'] == $original_title )
                        $args['menu-item-title'] = '';
 
-                       // hack to get wp to create a post object when too many properties are empty
-                       if ( empty( $args['menu-item-description'] ) )
-                               $args['menu-item-description'] = ' ';
-               }
+               // hack to get wp to create a post object when too many properties are empty
+               if ( '' ==  $args['menu-item-title'] && '' == $args['menu-item-description'] )
+                       $args['menu-item-description'] = ' ';
        }
 
        // Populate the menu item object
@@ -633,6 +641,9 @@ function wp_setup_nav_menu_item( $menu_item ) {
                        $menu_item->object = $object->name;
                        $menu_item->type_label = $object->labels->singular_name;
 
+                       if ( '' === $menu_item->post_title )
+                               $menu_item->post_title = sprintf( __( '#%d (no title)' ), $menu_item->ID );
+
                        $menu_item->title = $menu_item->post_title;
                        $menu_item->url = get_permalink( $menu_item->ID );
                        $menu_item->target = '';