*/
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();
}
/**
$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 );
$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
$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 = '';