X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/7f1521bf193b382565eb753043c161f4cb3fcda7..refs/tags/wordpress-4.4:/wp-admin/nav-menus.php diff --git a/wp-admin/nav-menus.php b/wp-admin/nav-menus.php index 384a8566..6507f0dc 100644 --- a/wp-admin/nav-menus.php +++ b/wp-admin/nav-menus.php @@ -19,8 +19,13 @@ if ( ! current_theme_supports( 'menus' ) && ! current_theme_supports( 'widgets' wp_die( __( 'Your theme does not support navigation menus or widgets.' ) ); // Permissions Check -if ( ! current_user_can('edit_theme_options') ) - wp_die( __( 'Cheatin’ uh?' ), 403 ); +if ( ! current_user_can( 'edit_theme_options' ) ) { + wp_die( + '

' . __( 'Cheatin’ uh?' ) . '

' . + '

' . __( 'You are not allowed to edit theme options on this site.' ) . '

', + 403 + ); +} wp_enqueue_script( 'nav-menu' ); @@ -67,7 +72,7 @@ switch ( $action ) { // Set up the data we need in one pass through the array of menu items. $dbids_to_orders = array(); $orders_to_dbids = array(); - foreach( (array) $ordered_menu_items as $ordered_menu_item_object ) { + foreach ( (array) $ordered_menu_items as $ordered_menu_item_object ) { if ( isset( $ordered_menu_item_object->ID ) ) { if ( isset( $ordered_menu_item_object->menu_order ) ) { $dbids_to_orders[$ordered_menu_item_object->ID] = $ordered_menu_item_object->menu_order; @@ -140,7 +145,7 @@ switch ( $action ) { // Set up the data we need in one pass through the array of menu items. $dbids_to_orders = array(); $orders_to_dbids = array(); - foreach( (array) $ordered_menu_items as $ordered_menu_item_object ) { + foreach ( (array) $ordered_menu_items as $ordered_menu_item_object ) { if ( isset( $ordered_menu_item_object->ID ) ) { if ( isset( $ordered_menu_item_object->menu_order ) ) { $dbids_to_orders[$ordered_menu_item_object->ID] = $ordered_menu_item_object->menu_order; @@ -354,7 +359,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; @@ -454,7 +465,7 @@ if ( ! $nav_menu_selected_title && is_nav_menu( $nav_menu_selected_id ) ) { } // Generate truncated menu names. -foreach( (array) $nav_menus as $key => $_nav_menu ) { +foreach ( (array) $nav_menus as $key => $_nav_menu ) { $nav_menus[$key]->truncated_name = wp_html_excerpt( $_nav_menu->name, 40, '…' ); } @@ -467,6 +478,8 @@ if ( current_theme_supports( 'menus' ) ) { /* * 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; @@ -477,7 +490,14 @@ if ( is_nav_menu( $nav_menu_selected_id ) ) { $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"; } @@ -549,14 +569,31 @@ get_current_screen()->set_help_sidebar( require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?>
+

+ 'menu_locations' ) : array( 'panel' => 'nav_menus' ); + printf( + ' %2$s', + esc_url( add_query_arg( array( + array( 'autofocus' => $focus ), + 'return' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), + ), admin_url( 'customize.php' ) ) ), + __( 'Manage in Customizer' ) + ); + endif; + ?> +

@@ -631,12 +668,12 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
- - - +