Sanity check menu item parents and fix HTML issues. props filosofo, fixes #13600.

git-svn-id: http://svn.automattic.com/wordpress/trunk@15049 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-05-28 23:04:00 +00:00
parent fd7fe309c8
commit 35d800986f
5 changed files with 13 additions and 14 deletions

View File

@ -1006,7 +1006,7 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
$result .= '</div>'; $result .= '</div>';
if( empty($menu_items) ) if( empty($menu_items) )
return $result; return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id ); $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
@ -1024,7 +1024,9 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
if ( $some_pending_menu_items ) if ( $some_pending_menu_items )
$result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>'; $result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>';
$result .= '<ul class="menu" id="menu-to-edit"> ';
$result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) ); $result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
$result .= ' </ul> ';
return $result; return $result;
} elseif ( is_wp_error( $menu ) ) { } elseif ( is_wp_error( $menu ) ) {
return $menu; return $menu;

View File

@ -93,9 +93,8 @@ var wpNavMenu;
if( depth == 0 ) { // Item is on the top level, has no parent if( depth == 0 ) { // Item is on the top level, has no parent
input.val(0); input.val(0);
} else { // Find the parent item, and retrieve its object id. } else { // Find the parent item, and retrieve its object id.
while( parent.menuItemDepth() != depth - 1 ) { while( ! parent[0] || ! parent[0].className || -1 == parent[0].className.indexOf('menu-item') || ( parent.menuItemDepth() != depth - 1 ) )
parent = parent.prev(); parent = parent.prev();
}
input.val( parent.find('.menu-item-data-db-id').val() ); input.val( parent.find('.menu-item-data-db-id').val() );
} }
}); });

File diff suppressed because one or more lines are too long

View File

@ -562,22 +562,20 @@ require_once( 'admin-header.php' );
</div><!-- END #nav-menu-header --> </div><!-- END #nav-menu-header -->
<div id="post-body"> <div id="post-body">
<div id="post-body-content"> <div id="post-body-content">
<?php if ( is_nav_menu( $nav_menu_selected_id ) ) : ?>
<ul class="menu" id="menu-to-edit">
<?php <?php
if ( is_nav_menu( $nav_menu_selected_id ) ) :
$edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id ); $edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id );
if ( ! is_wp_error( $edit_markup ) ) { if ( ! is_wp_error( $edit_markup ) ) :
echo $edit_markup; echo $edit_markup;
} endif;
?> elseif ( empty( $nav_menu_selected_id ) ) :
</ul>
<?php elseif ( empty($nav_menu_selected_id) ):
echo '<div class="post-body-plain">'; echo '<div class="post-body-plain">';
echo '<p>' . __('To create a custom menu, give it a name above and click Create Menu. Then choose items like pages, categories or custom links from the left column to add to this menu.') . '</p>'; echo '<p>' . __('To create a custom menu, give it a name above and click Create Menu. Then choose items like pages, categories or custom links from the left column to add to this menu.') . '</p>';
echo '<p>' . __('After you have added your items, drag and drop to put them in the order you want. You can also click each item to reveal additional configuration options.') . '</p>'; echo '<p>' . __('After you have added your items, drag and drop to put them in the order you want. You can also click each item to reveal additional configuration options.') . '</p>';
echo '<p>' . __('When you have finished building your custom menu, make sure you click the Save Menu button.') . '</p>'; echo '<p>' . __('When you have finished building your custom menu, make sure you click the Save Menu button.') . '</p>';
echo '</div>'; echo '</div>';
endif; ?> endif;
?>
</div><!-- /#post-body-content --> </div><!-- /#post-body-content -->
</div><!-- /#post-body --> </div><!-- /#post-body -->
</form><!-- /#update-nav-menu --> </form><!-- /#update-nav-menu -->

View File

@ -385,7 +385,7 @@ function wp_default_scripts( &$scripts ) {
) ); ) );
// Custom Navigation // Custom Navigation
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100528' ); $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100528b' );
$scripts->localize( 'nav-menu', 'navMenuL10n', array( $scripts->localize( 'nav-menu', 'navMenuL10n', array(
'custom' => _x('Custom', 'menu nav item type'), 'custom' => _x('Custom', 'menu nav item type'),
'thickbox' => _x('Edit Menu Item', 'Thickbox Title'), 'thickbox' => _x('Edit Menu Item', 'Thickbox Title'),