diff --git a/wp-admin/css/wp-admin-rtl.css b/wp-admin/css/wp-admin-rtl.css index dd314489e0..ba157f570d 100644 --- a/wp-admin/css/wp-admin-rtl.css +++ b/wp-admin/css/wp-admin-rtl.css @@ -697,6 +697,9 @@ form.upgrade .hint { .fixed .column-comments a { float: right; } +.fixed .column-menus { + text-align: right; +} .sorting-indicator { margin-left: 0; margin-right: 7px; @@ -2083,6 +2086,27 @@ body.login { float: right; } +.menu-location-menus select { + float: right; +} + +.locations-row-links { + float: right; + margin: 4px 6px 0 0; +} + +.locations-add-menu-link { + direction: rtl; +} + +.locations-edit-menu-link { + border-left: 1px solid #CCCCCC; + border-right: 0; + padding-left: 6px; + padding-right: 0; + float: right; +} + /* Menu Container */ #menu-management-liquid { float: right; diff --git a/wp-admin/css/wp-admin.css b/wp-admin/css/wp-admin.css index 99d444def7..7fb44bc2ab 100644 --- a/wp-admin/css/wp-admin.css +++ b/wp-admin/css/wp-admin.css @@ -2423,6 +2423,7 @@ table.fixed { width: 8%; } +.fixed .column-posts, .fixed .column-date, .fixed .column-parent, .fixed .column-links, @@ -2439,6 +2440,14 @@ table.fixed { width: 15%; } +.fixed .column-slug { + width: 25%; +} + +.fixed .column-locations { + width: 35%; +} + .fixed .column-comments { width: 4em; padding: 8px 0; @@ -2453,14 +2462,6 @@ table.fixed { float: left; } -.fixed .column-slug { - width: 25%; -} - -.fixed .column-posts { - width: 10%; -} - .fixed .column-icon { width: 80px; } @@ -2547,6 +2548,10 @@ tr.wp-locked .row-actions .trash { margin-top: 3px; } +#menu-locations-wrap .widefat { + width: 60%; +} + .widefat th.sortable, .widefat th.sorted { padding: 0; @@ -7384,7 +7389,7 @@ body.interim-login { #nav-menus-frame { margin-left: 300px; - margin-top: 28px; + margin-top: 23px; } #wpbody-content #menu-settings-column { @@ -7401,7 +7406,8 @@ body.interim-login { margin: 10px 0 0; } -.metabox-holder-disabled .postbox { +.metabox-holder-disabled .postbox, +.metabox-holder-disabled .accordion-section-content { opacity: 0.5; filter: alpha(opacity=50); } @@ -7432,7 +7438,7 @@ body.interim-login { } .manage-menus { - margin-top: 13px; + margin-top: 23px; padding: 10px; overflow: hidden; -webkit-border-radius: 3px; @@ -7566,6 +7572,39 @@ body.interim-login { margin-top: -2px; } +.widefat td.menu-location-menus { + padding-bottom: 5px; +} + +.menu-location-menus select { + float: left; +} + +#locations-nav-menu-wrapper { + padding: 5px 0; +} + +.locations-nav-menu-select select { + float: left; + width: 160px; + margin-right: 5px; +} + +.locations-row-links { + float: left; + margin: 6px 0 0 6px; +} + +.locations-edit-menu-link, +.locations-add-menu-link { + margin: 0 3px; +} + +.locations-edit-menu-link { + padding-right: 3px; + border-right: 1px solid #ccc; +} + #wpbody .open-label { display: block; float:left; diff --git a/wp-admin/js/nav-menu.js b/wp-admin/js/nav-menu.js index 0b650ab1c2..ee829da826 100644 --- a/wp-admin/js/nav-menu.js +++ b/wp-admin/js/nav-menu.js @@ -48,6 +48,8 @@ var wpNavMenu; if ( menus.oneThemeLocationNoMenus ) $( '#posttype-page' ).addSelectedToMenu( api.addMenuItemToBottom ); + this.initManageLocations(); + this.initAccessibility(); this.initToggles(); @@ -735,6 +737,19 @@ var wpNavMenu; } }, + initManageLocations : function () { + $('#menu-locations-wrap form').submit(function(){ + window.onbeforeunload = null; + }); + $('.menu-location-menus select').on('change', function () { + var editLink = $(this).closest('tr').find('.locations-edit-menu-link'); + if ($(this).find('option:selected').data('orig')) + editLink.show(); + else + editLink.hide(); + }); + }, + attachMenuEditListeners : function() { var that = this; $('#update-nav-menu').bind('click', function(e) { @@ -927,11 +942,11 @@ var wpNavMenu; }, attachUnsavedChangesListener : function() { - $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea').change(function(){ + $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea, .menu-location-menus select').change(function(){ api.registerChange(); }); - if ( 0 != $('#menu-to-edit').length ) { + if ( 0 != $('#menu-to-edit').length || 0 != $('.menu-location-menus select').length ) { window.onbeforeunload = function(){ if ( api.menusChanged ) return navMenuL10n.saveAlert; diff --git a/wp-admin/nav-menus.php b/wp-admin/nav-menus.php index a43f7574e5..66950945af 100644 --- a/wp-admin/nav-menus.php +++ b/wp-admin/nav-menus.php @@ -37,6 +37,11 @@ $nav_menu_selected_title = ''; // The menu id of the current menu being edited $nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0; +// Get existing menu locations assignments +$locations = get_registered_nav_menus(); +$menu_locations = get_nav_menu_locations(); +$num_locations = count( array_keys( $locations ) ); + // Allowed actions: add, update, delete $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit'; @@ -262,10 +267,6 @@ switch ( $action ) { case 'update': check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' ); - // Get existing menu locations assignments - $locations = get_registered_nav_menus(); - $menu_locations = get_nav_menu_locations(); - // Remove menu locations that have been unchecked foreach ( $locations as $location => $description ) { if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ) @@ -307,7 +308,15 @@ switch ( $action ) { } set_theme_mod( 'nav_menu_locations', $locations ); } - $messages[] = '

' . sprintf( __( '%s has been created.' ), $nav_menu_selected_title ) . '

'; + if ( isset( $_REQUEST['use-location'] ) ) { + $locations = get_theme_mod( 'nav_menu_locations' ); + if ( isset( $locations[$_REQUEST['use-location']] ) ) + $locations[$_REQUEST['use-location']] = $nav_menu_selected_id; + set_theme_mod( 'nav_menu_locations', $locations ); + } + // $messages[] = '

' . sprintf( __( '%s has been created.' ), $nav_menu_selected_title ) . '

'; + wp_redirect( admin_url( 'nav-menus.php?menu=' . $_nav_menu_selected_id ) ); + exit(); } } else { $messages[] = '

' . __( 'Please enter a valid menu name.' ) . '

'; @@ -341,6 +350,20 @@ switch ( $action ) { } } break; + case 'locations': + add_filter( 'screen_options_show_screen', '__return_false' ); + + if ( isset( $_POST['menu-locations'] ) ) { + check_admin_referer( 'save-menu-locations' ); + + $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); + $menu_locations = array_merge( $menu_locations, $new_menu_locations ); + // Set menu locations + set_theme_mod( 'nav_menu_locations', $menu_locations ); + + $messages[] = '

' . __( 'Menu locations updated.' ) . '

'; + } + break; } // Get all nav menus @@ -350,6 +373,8 @@ $menu_count = count( $nav_menus ); // Are we on the add new screen? $add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false; +$locations_screen = ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) ? true : false; + // If we have one theme location, and zero menus, we take them right into editing their first menu $page_count = wp_count_posts( 'page' ); $one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false; @@ -474,19 +499,82 @@ require_once( './admin-header.php' ); ?>
-

+ + ' . sprintf( _n( 'Your theme supports %s menu. Select which menu you would like to use below.', 'Your theme supports %s menus. Select a menu to use for each theme location below.', $num_locations ), number_format_i18n( $num_locations ) ) . '

'; + ?> + + +
- + create a new menu.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?> - -
+ + +
+