// 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;
/*
* Ensure the user will be able to scroll horizontally
* by adding a class for the max menu depth.
+ *
+ * @global int $_wp_nav_menu_max_depth
*/
global $_wp_nav_menu_max_depth;
$_wp_nav_menu_max_depth = 0;
$edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id );
}
-function wp_nav_menu_max_depth($classes) {
+/**
+ *
+ * @global int $_wp_nav_menu_max_depth
+ *
+ * @param string $classes
+ * @return string
+ */
+function wp_nav_menu_max_depth( $classes ) {
global $_wp_nav_menu_max_depth;
return "$classes menu-max-depth-$_wp_nav_menu_max_depth";
}
require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="wrap">
+ <h1><?php echo esc_html( __( 'Menus' ) ); ?>
+ <?php
+ if ( current_user_can( 'customize' ) ) :
+ $focus = $locations_screen ? array( 'section' => 'menu_locations' ) : array( 'panel' => 'nav_menus' );
+ printf(
+ ' <a class="page-title-action hide-if-no-customize" href="%1$s">%2$s</a>',
+ esc_url( add_query_arg( array(
+ array( 'autofocus' => $focus ),
+ 'return' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
+ ), admin_url( 'customize.php' ) ) ),
+ __( 'Manage in Customizer' )
+ );
+ endif;
+ ?>
+ </h1>
<h2 class="nav-tab-wrapper">
<a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Edit Menus' ); ?></a>
<?php if ( $num_locations && $menu_count ) : ?>
<a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( $locations_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Manage Locations' ); ?></a>
- <?php endif; ?>
+ <?php
+ endif;
+ ?>
</h2>
<?php
foreach( $messages as $message ) :
<?php else : ?>
<form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>">
<input type="hidden" name="action" value="edit" />
- <label for="menu" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label>
- <select name="menu" id="menu">
+ <label for="select-menu-to-edit" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label>
+ <select name="menu" id="select-menu-to-edit">
<?php if ( $add_new_screen ) : ?>
<option value="0" selected="selected"><?php _e( '— Select —' ); ?></option>
<?php endif; ?>