Defer term counting until all nav menu items are updated. see #12734

git-svn-id: http://svn.automattic.com/wordpress/trunk@14562 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-05-11 16:41:23 +00:00
parent c7f520240c
commit 4138294f52
1 changed files with 3 additions and 0 deletions

View File

@ -300,6 +300,7 @@ switch ( $action ) {
if ( ! is_wp_error( $_menu_object ) ) {
$menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') );
$post_fields = array( 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 'menu-item-append', 'menu-item-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' );
wp_defer_term_counting(true);
// Loop through all the menu items' POST variables
if ( ! empty( $_POST['menu-item-db-id'] ) ) {
foreach( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
@ -330,6 +331,8 @@ switch ( $action ) {
}
}
wp_defer_term_counting(false);
do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
$messages[] = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been updated.'), $nav_menu_selected_title ) . '</p></div>';