diff --git a/wp-admin/nav-menus.php b/wp-admin/nav-menus.php index f70826f8ff..ed9d052333 100644 --- a/wp-admin/nav-menus.php +++ b/wp-admin/nav-menus.php @@ -354,7 +354,13 @@ switch ( $action ) { // Update menu items. if ( ! is_wp_error( $_menu_object ) ) { - $messages = array_merge( $messages, wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ) ); + $messages = array_merge( $messages, wp_nav_menu_update_menu_items( $_nav_menu_selected_id, $nav_menu_selected_title ) ); + + // If the menu ID changed, redirect to the new URL. + if ( $nav_menu_selected_id != $_nav_menu_selected_id ) { + wp_redirect( admin_url( 'nav-menus.php?menu=' . intval( $_nav_menu_selected_id ) ) ); + exit(); + } } } break; diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index a1c9c97335..46fafc18b3 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -330,6 +330,7 @@ add_filter( 'determine_current_user', 'wp_validate_logged_in_cookie', 20 ); // Split term updates. add_action( 'split_shared_term', '_wp_check_split_default_terms', 10, 4 ); add_action( 'split_shared_term', '_wp_check_split_terms_in_menus', 10, 4 ); +add_action( 'split_shared_term', '_wp_check_split_nav_menu_terms', 10, 4 ); /** * Filters formerly mixed into wp-includes diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php index 29666f079b..9eb101933c 100644 --- a/wp-includes/nav-menu.php +++ b/wp-includes/nav-menu.php @@ -315,6 +315,8 @@ function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) { if ( is_wp_error( $update_response ) ) return $update_response; + $menu_id = (int) $update_response['term_id']; + /** * Fires after a navigation menu has been successfully updated. * diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index c2d0acc307..8e3e03d8d5 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -4395,6 +4395,34 @@ function _wp_check_split_terms_in_menus( $term_id, $new_term_id, $term_taxonomy_ } } +/** + * If the term being split is a nav_menu, change associations. + * + * @ignore + * @since 4.3.0 + * + * @global wpdb $wpdb + * + * @param int $term_id ID of the formerly shared term. + * @param int $new_term_id ID of the new term created for the $term_taxonomy_id. + * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split. + * @param string $taxonomy Taxonomy for the split term. + */ +function _wp_check_split_nav_menu_terms( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { + if ( 'nav_menu' !== $taxonomy ) { + return; + } + + // Update menu locations. + $locations = get_nav_menu_locations(); + foreach ( $locations as $location => $menu_id ) { + if ( $term_id == $menu_id ) { + $locations[ $location ] = $new_term_id; + } + } + set_theme_mod( 'nav_menu_locations', $locations ); +} + /** * Get data about terms that previously shared a single term_id, but have since been split. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 073963a108..7fe932446e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-RC2-33610'; +$wp_version = '4.3-RC2-33611'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.