Prevent menu items with '0' label from being removed on menu saving. props MikeHansenMe, kovshenin. fixes #23051.

git-svn-id: http://core.svn.wordpress.org/trunk@24235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2013-05-10 18:03:09 +00:00
parent 73b3aa1535
commit 4b174612ab
2 changed files with 6 additions and 7 deletions

View File

@ -79,7 +79,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
$title = sprintf( __('%s (Pending)'), $item->title );
}
$title = empty( $item->label ) ? $title : $item->label;
$title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
$submenu_text = '';
if ( 0 == $depth )
@ -1235,7 +1235,7 @@ function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_select
foreach( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
// Menu item title can't be blank
if ( empty( $_POST['menu-item-title'][$_key] ) )
if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] )
continue;
$args = array();

View File

@ -336,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