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

git-svn-id: https://develop.svn.wordpress.org/trunk@14562 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-05-11 16:41:23 +00:00
parent d5308265cd
commit 7be65b3730
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>';