Ticket #23119: 23119.29.1.diff
| File 23119.29.1.diff, 59.8 KB (added by lessbloat, 3 months ago) |
|---|
-
wp-admin/includes/nav-menu.php
81 81 82 82 $title = empty( $item->label ) ? $title : $item->label; 83 83 84 $submenu_text = ''; 85 if (0 == $depth) 86 $submenu_text = 'style="display: none;"'; 87 84 88 ?> 85 89 <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>"> 86 90 <dl class="menu-item-bar"> 87 91 <dt class="menu-item-handle"> 88 <span class="item-title"><?php echo esc_html( $title ); ?> </span>92 <span class="item-title"><?php echo esc_html( $title ); ?> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span></span> 89 93 <span class="item-controls"> 90 94 <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span> 91 95 <span class="item-order hide-if-js"> … … 185 189 remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) ) 186 190 ), 187 191 'delete-menu_item_' . $item_id 188 ); ?>"><?php _e('Remove'); ?></a> <span class="meta-sep "> | </span> <a class="item-cancel submitcancel" id="cancel-<?php echo $item_id; ?>" href="<?php echo esc_url( add_query_arg( array('edit-menu-item' => $item_id, 'cancel' => time()), remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) ) ) );192 ); ?>"><?php _e('Remove'); ?></a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php echo $item_id; ?>" href="<?php echo esc_url( add_query_arg( array('edit-menu-item' => $item_id, 'cancel' => time()), remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) ) ) ); 189 193 ?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel'); ?></a> 190 194 </div> 191 195 … … 382 386 **/ 383 387 function wp_nav_menu_setup() { 384 388 // Register meta boxes 385 if ( wp_get_nav_menus() )386 add_meta_box( 'nav-menu-theme-locations', __( 'Theme Locations' ), 'wp_nav_menu_locations_meta_box' , 'nav-menus', 'side', 'default' );387 add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );388 389 wp_nav_menu_post_type_meta_boxes(); 390 add_meta_box( 'add-custom-links', __('Add Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); 389 391 wp_nav_menu_taxonomy_meta_boxes(); 390 392 391 393 // Register advanced menu items (columns) … … 411 413 if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) 412 414 return; 413 415 414 $initial_meta_boxes = array( 'nav-menu-theme-locations', 'add- custom-links', 'add-page', 'add-category' );416 $initial_meta_boxes = array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category' ); 415 417 $hidden_meta_boxes = array(); 416 418 417 419 foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) { … … 445 447 $post_type = apply_filters( 'nav_menu_meta_box_object', $post_type ); 446 448 if ( $post_type ) { 447 449 $id = $post_type->name; 448 add_meta_box( "add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type );450 add_meta_box( "add-{$id}", __('Add ') . $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type ); 449 451 } 450 452 } 451 453 } … … 465 467 $tax = apply_filters( 'nav_menu_meta_box_object', $tax ); 466 468 if ( $tax ) { 467 469 $id = $tax->name; 468 add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );470 add_meta_box( "add-{$id}", __('Add ') . $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax ); 469 471 } 470 472 } 471 473 } … … 489 491 $menu_locations = get_nav_menu_locations(); 490 492 $num_locations = count( array_keys($locations) ); 491 493 492 echo '<p class="howto">' . sprintf( _n('Your theme supports %s menu. Select which menu you would like to use.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n($num_locations)) . '</p>';494 echo '<p class="howto">' . _n('Select a menu to use within your theme.', 'Select the menus you will use in your theme.', $num_locations ) . '</p>'; 493 495 494 496 foreach ( $locations as $location => $description ) { 495 497 ?> … … 512 514 } 513 515 ?> 514 516 <p class="button-controls"> 515 <?php submit_button( __( 'Save' ), 'primary right', 'nav-menu-locations', false, disabled( $nav_menu_selected_id, 0, false) ); ?>517 <?php submit_button( __( 'Save' ), 'primary right', 'nav-menu-locations', false, wp_nav_menu_disabled_check( $nav_menu_selected_id ) ); ?> 516 518 <span class="spinner"></span> 517 519 </p> 518 520 <?php 519 521 } 520 522 521 523 /** 524 * Check whether to disable the Menu Locations meta box submit button 525 * 526 * @since 3.6.0 527 * 528 * @uses global $one_theme_location_no_menus to determine if no menus exist 529 * @uses disabled() to output the disabled attribute in $other_attributes param in submit_button() 530 * 531 * @param int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu 532 * @return string Disabled attribute if at least one menu exists, false if not 533 */ 534 function wp_nav_menu_disabled_check( $nav_menu_selected_id ) { 535 global $one_theme_location_no_menus; 536 537 if ( $one_theme_location_no_menus ) 538 return false; 539 540 return disabled( $nav_menu_selected_id, 0 ); 541 } 542 543 /** 522 544 * Displays a metabox for the custom links menu item. 523 545 * 524 546 * @since 3.0.0 … … 554 576 555 577 <p id="menu-item-name-wrap"> 556 578 <label class="howto" for="custom-menu-item-name"> 557 <span><?php _e('L abel'); ?></span>579 <span><?php _e('Link Text'); ?></span> 558 580 <input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e('Menu Item'); ?>" /> 559 581 </label> 560 582 </p> 561 583 562 584 <p class="button-controls"> 563 585 <span class="add-to-menu"> 564 <input type="submit"<?php disabled( $nav_menu_selected_id, 0); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />586 <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" /> 565 587 <span class="spinner"></span> 566 588 </span> 567 589 </p> … … 779 801 </span> 780 802 781 803 <span class="add-to-menu"> 782 <input type="submit"<?php disabled( $nav_menu_selected_id, 0); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" id="submit-posttype-<?php echo $post_type_name; ?>" />804 <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" id="submit-posttype-<?php echo $post_type_name; ?>" /> 783 805 <span class="spinner"></span> 784 806 </span> 785 807 </p> … … 955 977 </span> 956 978 957 979 <span class="add-to-menu"> 958 <input type="submit"<?php disabled( $nav_menu_selected_id, 0); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" id="submit-taxonomy-<?php echo $taxonomy_name; ?>" />980 <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" id="submit-taxonomy-<?php echo $taxonomy_name; ?>" /> 959 981 <span class="spinner"></span> 960 982 </span> 961 983 </p> … … 1084 1106 // If the menu exists, get its items. 1085 1107 if ( is_nav_menu( $menu ) ) { 1086 1108 $menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') ); 1087 $result = '<div id="menu-instructions" class="post-body-plain'; 1109 $result = '<div id="menu-instructions" class="post-body-plain'; 1088 1110 $result .= ( ! empty($menu_items) ) ? ' menu-instructions-inactive">' : '">'; 1089 $result .= '<p>' . __(' Select menu items (pages, categories, links) from the boxes at left to begin building your custom menu.') . '</p>';1090 $result .= '</div>'; 1111 $result .= '<p>' . __('Next, add menu items (i.e. pages, links, categories) from the column on the left.') . '</p>'; 1112 $result .= '</div>'; 1091 1113 1092 1114 if( empty($menu_items) ) 1093 1115 return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; … … 1158 1180 foreach( (array) $menu_items_to_delete as $menu_item_id ) 1159 1181 wp_delete_post( $menu_item_id, true ); 1160 1182 } 1183 add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items'); 1161 1184 1162 add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items'); 1185 /** 1186 * Delete nav menus from the nav menu management screen 1187 * 1188 * @since 3.6.0 1189 * @access private 1190 * 1191 * @param int|string $nav_menu_id The menu to delete (id, slug, or name) 1192 * @return false if Error, otherwise true 1193 */ 1194 function _wp_delete_nav_menu( $nav_menu_id ) { 1195 1196 if ( ! is_nav_menu( $nav_menu_id ) ) 1197 return; 1198 1199 $deleted_nav_menu = wp_get_nav_menu_object( $nav_menu_id ); 1200 $delete_nav_menu = wp_delete_nav_menu( $nav_menu_id ); 1201 1202 if ( is_wp_error( $delete_nav_menu ) ) 1203 return $delete_nav_menu; 1204 1205 // Remove this menu from any locations. 1206 $locations = get_theme_mod( 'nav_menu_locations' ); 1207 foreach ( (array) $locations as $location => $menu_id ) { 1208 if ( $menu_id == $nav_menu_id ) 1209 $locations[ $location ] = 0; 1210 } 1211 set_theme_mod( 'nav_menu_locations', $locations ); 1212 return true; 1213 } 1214 1215 /** 1216 * Saves nav menu items 1217 * 1218 * @since 3.6.0 1219 * 1220 * @uses wp_get_nav_menu_items() to retrieve the nav menu's menu items 1221 * @uses wp_defer_term_counter() to enable then disable term counting 1222 * 1223 * @param int|string $nav_menu_selected_id (id, slug, or name ) of the currently-selected menu 1224 * @param string $nav_menu_selected_title Title of the currently-selected menu 1225 * @return array $messages The menu updated message 1226 */ 1227 function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) { 1228 $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) ); 1229 1230 $menu_items = array(); 1231 // Index menu items by db ID 1232 foreach ( $unsorted_menu_items as $_item ) 1233 $menu_items[$_item->db_id] = $_item; 1234 1235 $post_fields = array( 1236 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 1237 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 1238 'menu-item-title', 'menu-item-url', 'menu-item-description', 1239 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' 1240 ); 1241 1242 wp_defer_term_counting( true ); 1243 // Loop through all the menu items' POST variables 1244 if ( ! empty( $_POST['menu-item-db-id'] ) ) { 1245 foreach( (array) $_POST['menu-item-db-id'] as $_key => $k ) { 1246 1247 // Menu item title can't be blank 1248 if ( empty( $_POST['menu-item-title'][$_key] ) ) 1249 continue; 1250 1251 $args = array(); 1252 foreach ( $post_fields as $field ) 1253 $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; 1254 1255 $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args ); 1256 1257 if ( is_wp_error( $menu_item_db_id ) ) 1258 $messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>'; 1259 elseif ( isset( $menu_items[$menu_item_db_id] ) ) 1260 unset( $menu_items[$menu_item_db_id] ); 1261 } 1262 } 1263 1264 // Remove menu items from the menu that weren't in $_POST 1265 if ( ! empty( $menu_items ) ) { 1266 foreach ( array_keys( $menu_items ) as $menu_item_id ) { 1267 if ( is_nav_menu_item( $menu_item_id ) ) { 1268 wp_delete_post( $menu_item_id ); 1269 } 1270 } 1271 } 1272 1273 // Store 'auto-add' pages. 1274 $auto_add = ! empty( $_POST['auto-add-pages'] ); 1275 $nav_menu_option = (array) get_option( 'nav_menu_options' ); 1276 if ( ! isset( $nav_menu_option['auto_add'] ) ) 1277 $nav_menu_option['auto_add'] = array(); 1278 if ( $auto_add ) { 1279 if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) 1280 $nav_menu_option['auto_add'][] = $nav_menu_selected_id; 1281 } else { 1282 if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) 1283 unset( $nav_menu_option['auto_add'][$key] ); 1284 } 1285 // Remove nonexistent/deleted menus 1286 $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); 1287 update_option( 'nav_menu_options', $nav_menu_option ); 1288 1289 wp_defer_term_counting( false ); 1290 1291 do_action( 'wp_update_nav_menu', $nav_menu_selected_id ); 1292 1293 $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%1$s</strong> has been updated.' ), $nav_menu_selected_title ) . '</p></div>'; 1294 unset( $menu_items, $unsorted_menu_items ); 1295 1296 return $messages; 1297 } 1298 No newline at end of file -
wp-admin/js/nav-menu.js
45 45 if( api.menuList.length ) // If no menu, we're in the + tab. 46 46 this.initSortables(); 47 47 48 if( oneThemeLocationNoMenus ) 49 $('#posttype-page').addSelectedToMenu( api.addMenuItemToBottom ); 50 51 this.messageFadeIn(); 52 53 this.initAccessibility(); 54 48 55 this.initToggles(); 49 50 this.initTabManager();51 56 }, 52 57 53 58 jQueryExtensions : function() { … … 84 89 }); 85 90 return result; 86 91 }, 92 shiftHorizontally : function(dir) { 93 return this.each(function(){ 94 var t = $(this), 95 depth = t.menuItemDepth(), 96 newDepth = depth + dir; 97 98 // Change .menu-item-depth-n class 99 t.moveHorizontally(newDepth, depth); 100 }); 101 }, 102 moveHorizontally : function(newDepth, depth) { 103 return this.each(function(){ 104 var t = $(this), 105 children = t.childMenuItems(), 106 diff = newDepth - depth, 107 subItemText = t.find('.is-submenu'); 108 109 // Change .menu-item-depth-n class 110 t.updateDepthClass(newDepth, depth).updateParentMenuItemDBId(); 111 112 // If it has children, move those too 113 if (children) { 114 children.each(function( index ) { 115 var thisDepth = $(this).menuItemDepth(), 116 newDepth = thisDepth + diff; 117 $(this).updateDepthClass(newDepth, thisDepth).updateParentMenuItemDBId(); 118 }); 119 } 120 121 // Show "Sub item" helper text 122 if (0 === newDepth) 123 subItemText.hide(); 124 else 125 subItemText.show(); 126 }); 127 }, 87 128 updateParentMenuItemDBId : function() { 88 129 return this.each(function(){ 89 130 var item = $(this), 90 131 input = item.find('.menu-item-data-parent-id'), 91 depth = item.menuItemDepth(), 92 parent = item.prev(); 132 depth = parseInt(item.menuItemDepth()), 133 parentDepth = depth - 1, 134 parent = item.prevAll('.menu-item-depth-' + parentDepth).first(); 93 135 94 136 if( depth == 0 ) { // Item is on the top level, has no parent 95 137 input.val(0); 96 138 } else { // Find the parent item, and retrieve its object id. 97 while( ! parent[0] || ! parent[0].className || -1 == parent[0].className.indexOf('menu-item') || ( parent.menuItemDepth() != depth - 1 ) )98 parent = parent.prev();99 139 input.val( parent.find('.menu-item-data-db-id').val() ); 100 140 } 101 141 }); … … 120 160 121 161 return this.each(function() { 122 162 var t = $(this), menuItems = {}, 123 checkboxes = t.find('.tabs-panel-active .categorychecklist li input:checked'),163 checkboxes = ( oneThemeLocationNoMenus && 0 == t.find('.tabs-panel-active .categorychecklist li input:checked').length ) ? t.find('#page-all li input[type="checkbox"]') : t.find('.tabs-panel-active .categorychecklist li input:checked'), 124 164 re = new RegExp('menu-item\\[(\[^\\]\]*)'); 125 165 126 166 processMethod = processMethod || api.addMenuItemToBottom; … … 223 263 }); 224 264 }, 225 265 266 initAccessibility : function() { 267 $('.item-edit').off('focus').on('focus', function () { 268 $(this).on('keydown', function (e) { 269 270 // Bail if it's not an arrow key 271 if (e.which !== 37 && e.which !== 38 && e.which !== 39 && e.which !== 40) 272 return; 273 274 // Avoid multiple keydown events 275 $(this).off('keydown'); 276 277 var menuItems = $('#menu-to-edit li'); 278 menuItemsCount = menuItems.length, 279 thisItem = $(this).parents('li.menu-item'), 280 thisItemChildren = thisItem.childMenuItems(), 281 thisItemData = thisItem.getItemData(), 282 thisItemDepth = parseInt(thisItem.menuItemDepth()), 283 thisItemPosition = parseInt(thisItem.index()), 284 nextItem = thisItem.next(), 285 nextItemChildren = nextItem.childMenuItems(), 286 nextItemDepth = parseInt(nextItem.menuItemDepth()) + 1, 287 prevItem = thisItem.prev(), 288 prevItemDepth = parseInt(prevItem.menuItemDepth()), 289 prevItemId = prevItem.getItemData()['menu-item-db-id']; 290 291 // Bail if there is only one menu item 292 if (1 === menuItemsCount) 293 return; 294 295 // If RTL, swap left/right arrows 296 var arrows = { '38' : 'up', '40' : 'down', '37' : 'left', '39' : 'right' }; 297 if ($('body').hasClass('rtl')) 298 arrows = { '38' : 'up', '40' : 'down', '39' : 'left', '37' : 'right' }; 299 300 switch (arrows[e.which]) { 301 case 'up': 302 var newItemPosition = thisItemPosition - 1; 303 304 // Already at top 305 if (0 === thisItemPosition) 306 break; 307 308 // If a sub item is moved to top, shift it to 0 depth 309 if (0 === newItemPosition && 0 !== thisItemDepth) 310 thisItem.moveHorizontally(0, thisItemDepth); 311 312 // If prev item is sub item, shift to match depth 313 if (0 !== prevItemDepth) 314 thisItem.moveHorizontally(prevItemDepth, thisItemDepth); 315 316 // Does this item have sub items? 317 if (thisItemChildren) { 318 var items = thisItem.add(thisItemChildren); 319 // Move the entire block 320 items.detach().insertBefore(menuItems.eq(newItemPosition)); 321 } else { 322 thisItem.detach().insertBefore(menuItems.eq(newItemPosition)); 323 } 324 break; 325 case 'down': 326 // Does this item have sub items? 327 if (thisItemChildren) { 328 var items = thisItem.add(thisItemChildren), 329 nextItem = menuItems.eq(items.length + thisItemPosition), 330 nextItemChildren = 0 !== nextItem.childMenuItems().length; 331 332 if (nextItemChildren) { 333 var newDepth = parseInt(nextItem.menuItemDepth()) + 1; 334 thisItem.moveHorizontally(newDepth, thisItemDepth); 335 } 336 337 // Have we reached the bottom? 338 if (menuItemsCount === thisItemPosition + items.length) 339 break; 340 341 items.detach().insertAfter(menuItems.eq(thisItemPosition + items.length)); 342 } else { 343 // If next item has sub items, shift depth 344 if (0 !== nextItemChildren.length) 345 thisItem.moveHorizontally(nextItemDepth, thisItemDepth); 346 347 // Have we reached the bottom 348 if (menuItemsCount === thisItemPosition + 1) 349 break; 350 thisItem.detach().insertAfter(menuItems.eq(thisItemPosition + 1)); 351 } 352 break; 353 case 'left': 354 // As far left as possible 355 if (0 === thisItemDepth) 356 break; 357 thisItem.shiftHorizontally(-1); 358 break; 359 case 'right': 360 // Can't be sub item at top 361 if (0 === thisItemPosition) 362 break; 363 // Already sub item of prevItem 364 if (thisItemData['menu-item-parent-id'] === prevItemId) 365 break; 366 thisItem.shiftHorizontally(1); 367 break; 368 } 369 api.registerChange(); 370 // Put focus back on same menu item 371 $('#edit-' + thisItemData['menu-item-db-id']).focus(); 372 return false; 373 }); 374 }).blur(function () { 375 $(this).off('keydown'); 376 }); 377 }, 378 379 messageFadeIn : function() { 380 var messages = $('#message'); 381 382 // Visual change when users save menus multiple times in a row 383 messages.slideDown('slow'); 384 }, 385 226 386 initToggles : function() { 227 387 // init postboxes 228 388 postboxes.add_postbox_toggles('nav-menus'); … … 236 396 $('.field-' + field).addClass('hidden-field'); 237 397 } 238 398 // hide fields 239 api.menuList.hideAdvancedMenuItemFields(); 399 api.menuList.hideAdvancedMenuItemFields(); 240 400 }, 241 401 242 402 initSortables : function() { … … 246 406 body = $('body'), maxChildDepth, 247 407 menuMaxDepth = initialMenuMaxDepth(); 248 408 409 if( 0 != $('#menu-to-edit li').length ) 410 $('.drag-instructions').show(); 411 249 412 // Use the right edge if RTL. 250 413 menuEdge += api.isRTL ? api.menuList.width() : 0; 251 414 … … 308 471 // Return child elements to the list 309 472 children = transport.children().insertAfter(ui.item); 310 473 474 // Add "sub menu" description 475 var subMenuTitle = ui.item.find('.item-title .is-submenu'); 476 if (0 < currentDepth) 477 subMenuTitle.show(); 478 else 479 subMenuTitle.hide(); 480 311 481 // Update depth classes 312 482 if( depthChange != 0 ) { 313 483 ui.item.updateDepthClass( currentDepth ); … … 327 497 ui.item[0].style.left = 'auto'; 328 498 ui.item[0].style.right = 0; 329 499 } 330 331 // The width of the tab bar might have changed. Just in case.332 api.refreshMenuTabs( true );333 500 }, 334 501 change: function(e, ui) { 335 502 // Make sure the placeholder is inside the menu. … … 461 628 if( '' == $t.val() ) 462 629 $t.addClass( name ).val( $t.data(name) ); 463 630 }); 631 632 $('.blank-slate .input-with-default-title').focus(); 464 633 }, 465 634 466 635 attachThemeLocationsListeners : function() { … … 572 741 $.post( ajaxurl, params, function(menuMarkup) { 573 742 var ins = $('#menu-instructions'); 574 743 processMethod(menuMarkup, params); 744 // Make it stand out a bit more visually, by adding a fadeIn 745 $('li.pending').hide().fadeIn('slow'); 746 $('.drag-instructions').show(); 575 747 if( ! ins.hasClass('menu-instructions-inactive') && ins.siblings().length ) 576 748 ins.addClass('menu-instructions-inactive'); 577 749 callback(); … … 586 758 */ 587 759 addMenuItemToBottom : function( menuMarkup, req ) { 588 760 $(menuMarkup).hideAdvancedMenuItemFields().appendTo( api.targetList ); 761 api.initAccessibility(); 589 762 }, 590 763 591 764 addMenuItemToTop : function( menuMarkup, req ) { 592 765 $(menuMarkup).hideAdvancedMenuItemFields().prependTo( api.targetList ); 766 api.initAccessibility(); 593 767 }, 594 768 595 769 attachUnsavedChangesListener : function() { … … 604 778 }; 605 779 } else { 606 780 // Make the post boxes read-only, as they can't be used yet 607 $('#menu-settings-column').find('input,select'). prop('disabled', true).end().find('a').attr('href', '#').unbind('click');781 $('#menu-settings-column').find('input,select').end().find('a').attr('href', '#').unbind('click'); 608 782 } 609 783 }, 610 784 … … 688 862 }); 689 863 }, 690 864 691 initTabManager : function() {692 var fixed = $('.nav-tabs-wrapper'),693 fluid = fixed.children('.nav-tabs'),694 active = fluid.children('.nav-tab-active'),695 tabs = fluid.children('.nav-tab'),696 tabsWidth = 0,697 fixedRight, fixedLeft,698 arrowLeft, arrowRight, resizeTimer, css = {},699 marginFluid = api.isRTL ? 'margin-right' : 'margin-left',700 marginFixed = api.isRTL ? 'margin-left' : 'margin-right',701 msPerPx = 2;702 703 /**704 * Refreshes the menu tabs.705 * Will show and hide arrows where necessary.706 * Scrolls to the active tab by default.707 *708 * @param savePosition {boolean} Optional. Prevents scrolling so709 * that the current position is maintained. Default false.710 **/711 api.refreshMenuTabs = function( savePosition ) {712 var fixedWidth = fixed.width(),713 margin = 0, css = {};714 fixedLeft = fixed.offset().left;715 fixedRight = fixedLeft + fixedWidth;716 717 if( !savePosition )718 active.makeTabVisible();719 720 // Prevent space from building up next to the last tab if there's more to show721 if( tabs.last().isTabVisible() ) {722 margin = fixed.width() - tabsWidth;723 margin = margin > 0 ? 0 : margin;724 css[marginFluid] = margin + 'px';725 fluid.animate( css, 100, "linear" );726 }727 728 // Show the arrows only when necessary729 if( fixedWidth > tabsWidth )730 arrowLeft.add( arrowRight ).hide();731 else732 arrowLeft.add( arrowRight ).show();733 }734 735 $.fn.extend({736 makeTabVisible : function() {737 var t = this.eq(0), left, right, css = {}, shift = 0;738 739 if( ! t.length ) return this;740 741 left = t.offset().left;742 right = left + t.outerWidth();743 744 if( right > fixedRight )745 shift = fixedRight - right;746 else if ( left < fixedLeft )747 shift = fixedLeft - left;748 749 if( ! shift ) return this;750 751 css[marginFluid] = "+=" + api.negateIfRTL * shift + 'px';752 fluid.animate( css, Math.abs( shift ) * msPerPx, "linear" );753 return this;754 },755 isTabVisible : function() {756 var t = this.eq(0),757 left = t.offset().left,758 right = left + t.outerWidth();759 return ( right <= fixedRight && left >= fixedLeft ) ? true : false;760 }761 });762 763 // Find the width of all tabs764 tabs.each(function(){765 tabsWidth += $(this).outerWidth(true);766 });767 768 // Set up fixed margin for overflow, unset padding769 css['padding'] = 0;770 css[marginFixed] = (-1 * tabsWidth) + 'px';771 fluid.css( css );772 773 // Build tab navigation774 arrowLeft = $('<div class="nav-tabs-arrow nav-tabs-arrow-left"><a>«</a></div>');775 arrowRight = $('<div class="nav-tabs-arrow nav-tabs-arrow-right"><a>»</a></div>');776 // Attach to the document777 fixed.wrap('<div class="nav-tabs-nav"/>').parent().prepend( arrowLeft ).append( arrowRight );778 779 // Set the menu tabs780 api.refreshMenuTabs();781 // Make sure the tabs reset on resize782 $(window).resize(function() {783 if( resizeTimer ) clearTimeout(resizeTimer);784 resizeTimer = setTimeout( api.refreshMenuTabs, 200);785 });786 787 // Build arrow functions788 $.each([{789 arrow : arrowLeft,790 next : "next",791 last : "first",792 operator : "+="793 },{794 arrow : arrowRight,795 next : "prev",796 last : "last",797 operator : "-="798 }], function(){799 var that = this;800 this.arrow.mousedown(function(){801 var marginFluidVal = Math.abs( parseInt( fluid.css(marginFluid) ) ),802 shift = marginFluidVal,803 css = {};804 805 if( "-=" == that.operator )806 shift = Math.abs( tabsWidth - fixed.width() ) - marginFluidVal;807 808 if( ! shift ) return;809 810 css[marginFluid] = that.operator + shift + 'px';811 fluid.animate( css, shift * msPerPx, "linear" );812 }).mouseup(function(){813 var tab, next;814 fluid.stop(true);815 tab = tabs[that.last]();816 while( (next = tab[that.next]()) && next.length && ! next.isTabVisible() ) {817 tab = next;818 }819 tab.makeTabVisible();820 });821 });822 },823 824 865 eventOnClickEditLink : function(clickedEl) { 825 866 var settings, item, 826 867 matchedSection = /#(.*)$/.exec(clickedEl.href); … … 846 887 }, 847 888 848 889 eventOnClickCancelLink : function(clickedEl) { 849 var settings = $(clickedEl).closest('.menu-item-settings'); 850 settings.setItemData( settings.data('menu-item-data') ); 890 var settings = $(clickedEl).closest('.menu-item-settings'), 891 thisMenuItem = $(clickedEl).closest('.menu-item'); 892 thisMenuItem.removeClass('menu-item-edit-active').addClass('menu-item-edit-inactive'); 893 settings.setItemData( settings.data('menu-item-data') ).hide(); 851 894 return false; 852 895 }, 853 896 … … 945 988 var ins = $('#menu-instructions'); 946 989 el.remove(); 947 990 children.shiftDepthClass(-1).updateParentMenuItemDBId(); 948 if( ! ins.siblings().length ) 991 if( 0 == $('#menu-to-edit li').length ) { 992 $('.drag-instructions').hide(); 949 993 ins.removeClass('menu-instructions-inactive'); 994 } 950 995 }); 951 996 }, 952 997 -
wp-admin/nav-menus.php
221 221 if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) ) 222 222 $messages[] = '<div id="message" class="updated"><p>' . __('The menu item has been successfully deleted.') . '</p></div>'; 223 223 break; 224 224 225 case 'delete': 225 226 check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id ); 226 227 227 if ( is_nav_menu( $nav_menu_selected_id ) ) { 228 $deleted_nav_menu = wp_get_nav_menu_object( $nav_menu_selected_id ); 229 $delete_nav_menu = wp_delete_nav_menu( $nav_menu_selected_id ); 230 231 if ( is_wp_error($delete_nav_menu) ) { 232 $messages[] = '<div id="message" class="error"><p>' . $delete_nav_menu->get_error_message() . '</p></div>'; 233 } else { 234 // Remove this menu from any locations. 235 $locations = get_theme_mod( 'nav_menu_locations' ); 236 foreach ( (array) $locations as $location => $menu_id ) { 237 if ( $menu_id == $nav_menu_selected_id ) 238 $locations[ $location ] = 0; 239 } 240 set_theme_mod( 'nav_menu_locations', $locations ); 241 $messages[] = '<div id="message" class="updated"><p>' . __('The menu has been successfully deleted.') . '</p></div>'; 242 // Select the next available menu 243 $nav_menu_selected_id = 0; 244 $_nav_menus = wp_get_nav_menus( array('orderby' => 'name') ); 245 foreach( $_nav_menus as $index => $_nav_menu ) { 246 if ( strcmp( $_nav_menu->name, $deleted_nav_menu->name ) >= 0 247 || $index == count( $_nav_menus ) - 1 ) { 248 $nav_menu_selected_id = $_nav_menu->term_id; 249 break; 250 } 251 } 252 } 253 unset( $delete_nav_menu, $deleted_nav_menu, $_nav_menus ); 228 $deletion = _wp_delete_nav_menu( $nav_menu_selected_id ); 254 229 } else { 255 230 // Reset the selected menu 256 231 $nav_menu_selected_id = 0; 257 232 unset( $_REQUEST['menu'] ); 258 233 } 234 235 if ( ! isset( $deletion ) ) 236 break; 237 238 if ( is_wp_error( $deletion ) ) 239 $messages[] = '<div id="message" class="error"><p>' . $deletion->get_error_message() . '</p></div>'; 240 else 241 $messages[] = '<div id="message" class="updated"><p>' . __( 'The menu has been successfully deleted.' ) . '</p></div>'; 259 242 break; 260 243 244 case 'delete_menus': 245 check_admin_referer( 'nav_menus_bulk_actions' ); 246 foreach ( $_REQUEST['delete_menus'] as $menu_id_to_delete ) { 247 if ( ! is_nav_menu( $menu_id_to_delete ) ) 248 continue; 249 250 $deletion = _wp_delete_nav_menu( $menu_id_to_delete ); 251 if ( is_wp_error( $deletion ) ) { 252 $messages[] = '<div id="message" class="error"><p>' . $deletion->get_error_message() . '</p></div>'; 253 $deletion_error = true; 254 } 255 } 256 257 if ( empty( $deletion_error ) ) 258 $messages[] = '<div id="message" class="updated"><p>' . __( 'Selected menus have been successfully deleted.' ) . '</p></div>'; 259 break; 260 261 261 case 'update': 262 262 check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' ); 263 263 264 // Update menu theme locations265 if ( isset( $_POST['menu-locations'] ) )266 set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ));264 // get existing menu locations assignments 265 $locations = get_registered_nav_menus(); 266 $menu_locations = get_nav_menu_locations(); 267 267 268 // remove menu locations that have been unchecked 269 foreach ( $locations as $location => $description ) { 270 if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ) 271 unset( $menu_locations[ $location ] ); 272 } 273 274 // merge new and existing menu locations if any new ones are set 275 if ( isset( $_POST['menu-locations'] ) ) { 276 $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); 277 $menu_locations = array_merge( $menu_locations, $new_menu_locations ); 278 } 279 280 // set menu locations 281 set_theme_mod( 'nav_menu_locations', $menu_locations ); 282 268 283 // Add Menu 269 284 if ( 0 == $nav_menu_selected_id ) { 270 285 $new_menu_title = trim( esc_html( $_POST['menu-name'] ) ); … … 278 293 $_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id ); 279 294 $nav_menu_selected_id = $_nav_menu_selected_id; 280 295 $nav_menu_selected_title = $_menu_object->name; 281 $messages[] = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been successfully created.'), $nav_menu_selected_title ) . '</p></div>'; 296 if ( isset( $_REQUEST['menu-item'] ) ) 297 wp_save_nav_menu_items( $nav_menu_selected_id, $_REQUEST['menu-item'] ); 298 if ( isset( $_REQUEST['zero-menu-state'] ) ) { 299 // If there are menu items, add them 300 wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ); 301 // Auto-save nav_menu_locations 302 $locations = get_theme_mod( 'nav_menu_locations' ); 303 foreach ( (array) $locations as $location => $menu_id ) { 304 $locations[ $location ] = $nav_menu_selected_id; 305 break; // There should only be 1 306 } 307 set_theme_mod( 'nav_menu_locations', $locations ); 308 } 309 $messages[] = '<div id="message" class="updated"><p>' . sprintf( __('<strong>%s</strong> has been created.'), $nav_menu_selected_title ) . '</p></div>'; 282 310 } 283 311 } else { 284 312 $messages[] = '<div id="message" class="error"><p>' . __('Please enter a valid menu name.') . '</p></div>'; … … 309 337 // Update menu items 310 338 311 339 if ( ! is_wp_error( $_menu_object ) ) { 312 $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish') ); 313 $menu_items = array(); 314 // Index menu items by db ID 315 foreach( $unsorted_menu_items as $_item ) 316 $menu_items[$_item->db_id] = $_item; 317 318 $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-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' ); 319 wp_defer_term_counting(true); 320 // Loop through all the menu items' POST variables 321 if ( ! empty( $_POST['menu-item-db-id'] ) ) { 322 foreach( (array) $_POST['menu-item-db-id'] as $_key => $k ) { 323 324 // Menu item title can't be blank 325 if ( empty( $_POST['menu-item-title'][$_key] ) ) 326 continue; 327 328 $args = array(); 329 foreach ( $post_fields as $field ) 330 $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; 331 332 $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args ); 333 334 if ( is_wp_error( $menu_item_db_id ) ) 335 $messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>'; 336 elseif ( isset( $menu_items[$menu_item_db_id] ) ) 337 unset( $menu_items[$menu_item_db_id] ); 338 } 339 } 340 341 // Remove menu items from the menu that weren't in $_POST 342 if ( ! empty( $menu_items ) ) { 343 foreach ( array_keys( $menu_items ) as $menu_item_id ) { 344 if ( is_nav_menu_item( $menu_item_id ) ) { 345 wp_delete_post( $menu_item_id ); 346 } 347 } 348 } 349 350 // Store 'auto-add' pages. 351 $auto_add = ! empty( $_POST['auto-add-pages'] ); 352 $nav_menu_option = (array) get_option( 'nav_menu_options' ); 353 if ( ! isset( $nav_menu_option['auto_add'] ) ) 354 $nav_menu_option['auto_add'] = array(); 355 if ( $auto_add ) { 356 if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) 357 $nav_menu_option['auto_add'][] = $nav_menu_selected_id; 358 } else { 359 if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) 360 unset( $nav_menu_option['auto_add'][$key] ); 361 } 362 // Remove nonexistent/deleted menus 363 $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); 364 update_option( 'nav_menu_options', $nav_menu_option ); 365 366 wp_defer_term_counting(false); 367 368 do_action( 'wp_update_nav_menu', $nav_menu_selected_id ); 369 370 $messages[] = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been updated.'), $nav_menu_selected_title ) . '</p></div>'; 371 unset( $menu_items, $unsorted_menu_items ); 340 $messages = array_merge( $messages, wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ) ); 372 341 } 373 342 } 374 343 break; … … 376 345 377 346 // Get all nav menus 378 347 $nav_menus = wp_get_nav_menus( array('orderby' => 'name') ); 348 $menu_count = count( $nav_menus ); 379 349 350 // Are we on the add new screen? 351 $add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false; 352 353 // If we have one theme location, and zero menus, we take them right into editing their first menu 354 $one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty($nav_menus) && 0 < count(get_pages()) ) ? true : false; 355 356 // Redirect to add screen if there are no menus and this users has either zero, or more than 1 theme locations 357 if ( 0 == $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus ) 358 wp_redirect( admin_url( 'nav-menus.php?action=edit&menu=0' ) ); 359 380 360 // Get recently edited nav menu 381 361 $recently_edited = (int) get_user_option( 'nav_menu_recently_edited' ); 382 383 // If there was no recently edited menu, and $nav_menu_selected_id is a nav menu, update recently edited menu. 384 if ( !$recently_edited && is_nav_menu( $nav_menu_selected_id ) ) { 362 if ( !$recently_edited && is_nav_menu( $nav_menu_selected_id ) ) 385 363 $recently_edited = $nav_menu_selected_id; 386 364 387 // Else if $nav_menu_selected_id is not a menu and not requesting that we create a new menu, but $recently_edited is a menu, grab that one.388 } elseif ( 0 == $nav_menu_selected_id && ! isset( $_REQUEST['menu'] ) && is_nav_menu( $recently_edited ) ) { 365 // Use $recently_edited if none are selected 366 if ( 0 == $nav_menu_selected_id && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) 389 367 $nav_menu_selected_id = $recently_edited; 390 368 391 // Else try to grab the first menu from the menus list392 } elseif ( 0 == $nav_menu_selected_id && ! isset( $_REQUEST['menu'] ) && ! empty($nav_menus) ) { 369 // On deletion of menu, if another menu exists, show it 370 if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] ) 393 371 $nav_menu_selected_id = $nav_menus[0]->term_id; 394 }395 372 373 if ( $one_theme_location_no_menus ) 374 $nav_menu_selected_id = 0; 375 396 376 // Update the user's setting 397 377 if ( $nav_menu_selected_id != $recently_edited && is_nav_menu( $nav_menu_selected_id ) ) 398 378 update_user_meta( $current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id ); … … 412 392 $nav_menus[$key]->truncated_name = $_nav_menu->truncated_name; 413 393 } 414 394 395 // Retrieve menu locations 396 if ( current_theme_supports( 'menus' ) ) { 397 $locations = get_registered_nav_menus(); 398 $menu_locations = get_nav_menu_locations(); 399 } 400 415 401 // Ensure the user will be able to scroll horizontally 416 402 // by adding a class for the max menu depth. 417 403 global $_wp_nav_menu_max_depth; 418 404 $_wp_nav_menu_max_depth = 0; 419 405 420 406 // Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth 421 if ( is_nav_menu( $nav_menu_selected_id ) ) 407 if ( is_nav_menu( $nav_menu_selected_id ) ) { 408 $menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('post_status' => 'any') ); 422 409 $edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id ); 410 } 423 411 424 412 function wp_nav_menu_max_depth($classes) { 425 413 global $_wp_nav_menu_max_depth; … … 460 448 ?> 461 449 <div class="wrap"> 462 450 <?php screen_icon(); ?> 463 <h2><?php esc_html_e('Menus'); ?></h2>451 <h2><?php _e( 'Menus' ); ?> <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0, ), admin_url( 'nav-menus.php' ) ) ); ?>" class="add-new-h2"><?php _e( 'Add New' ); ?></a></h2> 464 452 <?php 465 453 foreach( $messages as $message ) : 466 454 echo $message . "\n"; 467 455 endforeach; 468 456 ?> 457 <?php if ( 1 < $menu_count ) : ?> 458 <form method="post"> 459 <input type="hidden" name="action" value="edit" /> 460 <div class="manage-menus"> 461 <span class="selected-menu"><?php _e('Selected menu'); ?></span> 462 <select name="menu"> 463 <?php foreach( (array) $nav_menus as $_nav_menu ) : ?> 464 <option value="<?php echo esc_attr( $_nav_menu->term_id ); ?>" <?php if ( $nav_menu_selected_id == $_nav_menu->term_id ) echo 'selected="selected"'; ?>> 465 <?php 466 echo esc_html( $_nav_menu->truncated_name ) ; 467 if ( ! empty( $menu_locations ) && in_array( $_nav_menu->term_id, $menu_locations ) ) { 468 $locations_assigned_to_this_menu = array(); 469 foreach ( array_keys( $menu_locations, $_nav_menu->term_id ) as $menu_location_key ) { 470 $locations_assigned_to_this_menu[] = $locations[ $menu_location_key ]; 471 } 472 $assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ) ); 473 // Adds ellipses following the number of locations defined in $assigned_locations 474 printf( ' (%1$s%2$s)', 475 implode( ', ', $assigned_locations ), 476 count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' …' : '' 477 ); 478 } 479 ?> 480 </option> 481 <?php endforeach; ?> 482 </select> 483 <span class="submit-btn"><input type="submit" class="button-secondary" value="<?php _e( 'Go' ); ?>"></span> 484 </div> 485 </form> 486 <?php endif; ?> 469 487 <div id="nav-menus-frame"> 470 <div id="menu-settings-column" class="metabox-holder<?php if ( !$nav_menu_selected_id) { echo ' metabox-holder-disabled'; } ?>">488 <div id="menu-settings-column" class="metabox-holder<?php if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] ) { echo ' metabox-holder-disabled'; } ?>"> 471 489 490 <div class="clear"></div> 491 472 492 <form id="nav-menu-meta" action="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-menu-meta" method="post" enctype="multipart/form-data"> 473 493 <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> 474 494 <input type="hidden" name="action" value="add-menu-item" /> … … 479 499 </div><!-- /#menu-settings-column --> 480 500 <div id="menu-management-liquid"> 481 501 <div id="menu-management"> 482 <div id="select-nav-menu-container" class="hide-if-js"> 483 <form id="select-nav-menu" action=""> 484 <strong><label for="select-nav-menu"><?php esc_html_e( 'Select Menu:' ); ?></label></strong> 485 <select class="select-nav-menu" name="menu"> 486 <?php foreach( (array) $nav_menus as $_nav_menu ) : ?> 487 <option value="<?php echo esc_attr($_nav_menu->term_id) ?>" <?php selected($nav_menu_selected_id, $_nav_menu->term_id); ?>> 488 <?php echo esc_html( $_nav_menu->truncated_name ); ?> 489 </option> 490 <?php endforeach; ?> 491 <option value="0"><?php esc_html_e('Add New Menu'); ?></option> 492 </select> 493 <input type="hidden" name="action" value="edit" /> 494 <?php submit_button( __( 'Select' ), 'secondary', 'select_menu', false ); ?> 495 </form> 496 </div> 497 <div class="nav-tabs-wrapper"> 498 <div class="nav-tabs"> 499 <?php 500 foreach( (array) $nav_menus as $_nav_menu ) : 501 if ( $nav_menu_selected_id == $_nav_menu->term_id ) : ?><span class="nav-tab nav-tab-active"> 502 <?php echo esc_html( $_nav_menu->truncated_name ); ?> 503 </span><?php else : ?><a href="<?php 504 echo esc_url(add_query_arg( 505 array( 506 'action' => 'edit', 507 'menu' => $_nav_menu->term_id, 508 ), 509 admin_url( 'nav-menus.php' ) 510 )); 511 ?>" class="nav-tab hide-if-no-js"> 512 <?php echo esc_html( $_nav_menu->truncated_name ); ?> 513 </a><?php endif; 514 endforeach; 515 if ( 0 == $nav_menu_selected_id ) : ?><span class="nav-tab menu-add-new nav-tab-active"> 516 <?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add menu' ) ); ?> 517 </span><?php else : ?><a href="<?php 518 echo esc_url(add_query_arg( 519 array( 520 'action' => 'edit', 521 'menu' => 0, 522 ), 523 admin_url( 'nav-menus.php' ) 524 )); 525 ?>" class="nav-tab menu-add-new"> 526 <?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add menu' ) ); ?> 527 </a><?php endif; ?> 528 </div> 529 </div> 530 <div class="menu-edit"> 531 <form id="update-nav-menu" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data"> 502 <form id="update-nav-menu" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data"> 503 <div class="menu-edit <?php if ( $add_new_screen ) echo 'blank-slate'; ?>"> 504 <?php 505 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); 506 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); 507 wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' ); 508 ?> 509 <?php if ( $one_theme_location_no_menus ) { ?> 510 <input type="hidden" name="zero-menu-state" value="true" /> 511 <?php } ?> 512 <input type="hidden" name="action" value="update" /> 513 <input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> 532 514 <div id="nav-menu-header"> 533 <div id="submitpost" class="submitbox"> 534 <div class="major-publishing-actions"> 535 <label class="menu-name-label howto open-label" for="menu-name"> 536 <span><?php _e('Menu Name'); ?></span> 537 <input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e('Enter menu name here'); ?>" value="<?php echo esc_attr( $nav_menu_selected_title ); ?>" /> 538 </label> 539 <?php if ( !empty( $nav_menu_selected_id ) ) : 540 if ( ! isset( $auto_add ) ) { 541 $auto_add = get_option( 'nav_menu_options' ); 542 if ( ! isset( $auto_add['auto_add'] ) ) 543 $auto_add = false; 544 elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'] ) ) 545 $auto_add = true; 546 else 547 $auto_add = false; 548 } 549 ?> 550 <div class="auto-add-pages"> 551 <label class="howto"><input type="checkbox"<?php checked( $auto_add ); ?> name="auto-add-pages" value="1" /> <?php printf( __('Automatically add new top-level pages' ), esc_url( admin_url( 'edit.php?post_type=page' ) ) ); ?></label> 552 </div> 553 <?php endif; ?> 554 <br class="clear" /> 555 <div class="publishing-action"> 556 <?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false, array( 'id' => 'save_menu_header' ) ); ?> 557 </div><!-- END .publishing-action --> 558 559 <?php if ( ! empty( $nav_menu_selected_id ) ) : ?> 560 <div class="delete-action"> 561 <a class="submitdelete deletion menu-delete" href="<?php echo esc_url( wp_nonce_url( admin_url('nav-menus.php?action=delete&menu=' . $nav_menu_selected_id), 'delete-nav_menu-' . $nav_menu_selected_id ) ); ?>"><?php _e('Delete Menu'); ?></a> 562 </div><!-- END .delete-action --> 563 <?php endif; ?> 564 </div><!-- END .major-publishing-actions --> 565 </div><!-- END #submitpost .submitbox --> 566 <?php 567 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); 568 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); 569 wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' ); 570 ?> 571 <input type="hidden" name="action" value="update" /> 572 <input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> 573 </div><!-- END #nav-menu-header --> 515 <div class="major-publishing-actions"> 516 <label class="menu-name-label howto open-label" for="menu-name"> 517 <span><?php _e('Menu Name'); ?></span> 518 <input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e('Enter menu name here'); ?>" value="<?php if ( $one_theme_location_no_menus ) { _e('Menu 1'); } else { echo esc_attr( $nav_menu_selected_title ); } ?>" /> 519 </label> 520 <div class="publishing-action"> 521 <?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false, array( 'id' => 'save_menu_header' ) ); ?> 522 </div><!-- END .publishing-action --> 523 </div><!-- END .major-publishing-actions --> 524 </div><!-- END .nav-menu-header --> 574 525 <div id="post-body"> 575 526 <div id="post-body-content"> 527 <?php if ( ! $add_new_screen ) : ?> 528 <?php $starter_copy = ( $one_theme_location_no_menus ) ? __("Edit your default menu by adding or removing items. Drag each item into the order you prefer. Click Create Menu to save your changes.") : __('Drag each item into the order you prefer. Click an item to reveal additional configuration options.') ; ?> 529 <div class="drag-instructions post-body-plain" <?php if ( isset( $menu_items ) && 0 == count( $menu_items ) ) { ?>style="display: none;"<?php } ?>> 530 <p><?php echo $starter_copy; ?></p> 531 </div> 576 532 <?php 577 if ( isset( $edit_markup ) ) { 578 if ( ! is_wp_error( $edit_markup ) ) 579 echo $edit_markup; 580 } else if ( empty( $nav_menu_selected_id ) ) { 581 echo '<div class="post-body-plain">'; 582 echo '<p>' . __('To create a custom menu, give it a name above and click Create Menu. Then choose items like pages, categories or custom links from the left column to add to this menu.') . '</p>'; 583 echo '<p>' . __('After you have added your items, drag and drop to put them in the order you want. You can also click each item to reveal additional configuration options.') . '</p>'; 584 echo '<p>' . __('When you have finished building your custom menu, make sure you click the Save Menu button.') . '</p>'; 585 echo '</div>'; 586 } 533 if ( isset( $edit_markup ) && ! is_wp_error( $edit_markup ) ) { 534 echo $edit_markup; 535 } else { 587 536 ?> 537 <ul class="menu" id="menu-to-edit"></ul> 538 <?php } ?> 539 <?php endif; ?> 540 <?php if ( $add_new_screen ) : ?> 541 <p class="post-body-plain"><?php _e('Give your menu a name above, then click Create Menu.'); ?></p> 542 <?php endif; ?> 543 <div class="menu-settings" <?php if ( $one_theme_location_no_menus ) { ?>style="display: none;"<?php } ?>> 544 <?php 545 if ( ! isset( $auto_add ) ) { 546 $auto_add = get_option( 'nav_menu_options' ); 547 if ( ! isset( $auto_add['auto_add'] ) ) 548 $auto_add = false; 549 elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'] ) ) 550 $auto_add = true; 551 else 552 $auto_add = false; 553 } ?> 554 555 <dl class="auto-add-pages"> 556 <dt class="howto"><?php _e('Auto add pages'); ?></dt> 557 <dd class="checkbox-input"><input type="checkbox"<?php checked( $auto_add ); ?> name="auto-add-pages" id="auto-add-pages" value="1" /> <label for="auto-add-pages"><?php printf( __('Automatically add new top-level pages to this menu' ), esc_url( admin_url( 'edit.php?post_type=page' ) ) ); ?></label></dd> 558 </dl> 559 560 <?php if ( current_theme_supports( 'menus' ) ) : ?> 561 562 <dl class="menu-theme-locations"> 563 <dt class="howto"><?php _e( 'Theme locations' ); ?></dt> 564 <?php foreach ( $locations as $location => $description ) : ?> 565 <dd class="checkbox-input"> 566 <input type="checkbox"<?php checked( isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ); ?> name="menu-locations[<?php echo esc_attr( $location ); ?>]" id="locations-<?php echo esc_attr( $location ); ?>" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> <label for="locations-<?php echo esc_attr( $location ); ?>"><?php echo $description; ?></label> 567 <?php if ( ! empty( $menu_locations[ $location ] ) && $menu_locations[ $location ] != $nav_menu_selected_id ) : ?> 568 <span class="theme-location-set"> <?php printf( __( "(Currently set to: %s)" ), wp_get_nav_menu_object( $menu_locations[ $location ] )->name ); ?> </span> 569 <?php endif; ?> 570 </dd> 571 <?php endforeach; ?> 572 </dl> 573 574 <?php endif; ?> 575 576 </div> 588 577 </div><!-- /#post-body-content --> 589 578 </div><!-- /#post-body --> 590 579 <div id="nav-menu-footer"> 591 580 <div class="major-publishing-actions"> 592 <div class="publishing-action"> 593 <?php 594 if ( ! empty( $nav_menu_selected_id ) ) 595 submit_button( __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false, array( 'id' => 'save_menu_footer' ) ); 596 ?> 597 </div> 598 </div> 581 <?php if ( 0 != $menu_count && ! $add_new_screen ) : ?> 582 <span class="delete-action"> 583 <a class="submitdelete deletion menu-delete" href="<?php echo esc_url( wp_nonce_url( admin_url('nav-menus.php?action=delete&menu=' . $nav_menu_selected_id), 'delete-nav_menu-' . $nav_menu_selected_id ) ); ?>"><?php _e('Delete Menu'); ?></a> 584 </span><!-- END .delete-action --> 585 <?php endif; ?> 586 <div class="publishing-action"> 587 <?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false, array( 'id' => 'save_menu_header' ) ); ?> 588 </div><!-- END .publishing-action --> 589 </div><!-- END .major-publishing-actions --> 599 590 </div><!-- /#nav-menu-footer --> 600 </ form><!-- /#update-nav-menu-->601 </ div><!-- /.menu-edit-->591 </div><!-- /.menu-edit --> 592 </form><!-- /#update-nav-menu --> 602 593 </div><!-- /#menu-management --> 603 594 </div><!-- /#menu-management-liquid --> 604 595 </div><!-- /#nav-menus-frame --> 605 596 </div><!-- /.wrap--> 606 597 <script type="text/javascript">var oneThemeLocationNoMenus = <?php if ( $one_theme_location_no_menus ) { echo 'true'; } else { echo 'false'; } ?>;</script> 607 598 <?php include( './admin-footer.php' ); ?> -
wp-admin/css/colors-fresh.css
409 409 410 410 .submitbox .submitdelete:hover, 411 411 #media-items a.delete:hover, 412 #media-items a.delete-permanently:hover { 412 #media-items a.delete-permanently:hover, 413 #nav-menu-footer .menu-delete:hover { 413 414 color: #fff; 414 415 background-color: #f00; 415 416 border-bottom-color: #f00; … … 1741 1742 background: #21759b; 1742 1743 color: #fff; 1743 1744 } 1745 1746 .manage-menus { 1747 border: 1px solid #eee; 1748 background: #fbfbfb; 1749 } 1750 1751 .menu-settings { 1752 border-top: 1px solid #eee; 1753 } 1754 1755 .theme-location-set { 1756 color: #999; 1757 } 1758 1759 .nav-menus-php .delete-action a { 1760 color: #bc0b0b; 1761 } 1762 1763 .is-submenu { 1764 color: #999; 1765 } 1744 1766 /* end added from nav-menu.css */ 1745 1767 1746 1768 .nav-tab { -
wp-admin/css/wp-admin-rtl.css
44 44 25.0 - TinyMCE tweaks 45 45 26.0 - Full Overlay w/ Sidebar 46 46 27.0 - Customize Loader 47 28.0 - Nav Menus 48 29.0 - HiDPI 47 49 48 50 49 51 ------------------------------------------------------------------------------*/ … … 2303 2305 margin-right:0; 2304 2306 } 2305 2307 2306 .auto-add-pages {2307 float: right;2308 }2309 2310 2308 /* Star ratings */ 2311 2309 div.star-holder { 2312 2310 background: url('../images/stars-rtl.png?ver=20121108') repeat-x bottom right; … … 2534 2532 direction: ltr; 2535 2533 } 2536 2534 2537 /** 2538 * HiDPI Displays 2539 */ 2535 /*------------------------------------------------------------------------------ 2536 28.0 - Nav Menus 2537 ------------------------------------------------------------------------------*/ 2538 .nav-menus-php .major-publishing-actions .publishing-action { 2539 float: left; 2540 } 2541 2542 .menu-settings dd { 2543 float: right; 2544 padding-right: 170px; 2545 } 2546 2547 .manage-menus span { 2548 float: right; 2549 } 2550 2551 .menu-settings dt { 2552 left: auto; 2553 right: 0; 2554 } 2555 2556 .menu-settings dd input, 2557 .menu-settings dd span, 2558 .menu-settings dd label, 2559 .manage-menus select { 2560 float: right; 2561 margin-right: 6px; 2562 } 2563 2564 /*------------------------------------------------------------------------------ 2565 29.0 - HiDPI 2566 ------------------------------------------------------------------------------*/ 2540 2567 @media print, 2541 2568 (-o-min-device-pixel-ratio: 5/4), 2542 2569 (-webkit-min-device-pixel-ratio: 1.25), -
wp-admin/css/wp-admin.css
6760 6760 6761 6761 /* nav-menu */ 6762 6762 6763 .nav-menus-php #message { 6764 display: none; 6765 } 6766 6767 .no-js #message { 6768 display: block; 6769 } 6770 6763 6771 #nav-menus-frame { 6764 6772 margin-left: 300px; 6773 margin-top: 28px; 6765 6774 } 6766 6775 6767 6776 #wpbody-content #menu-settings-column { … … 6770 6779 margin-left: -300px; 6771 6780 clear: both; 6772 6781 float: left; 6773 padding-top: 24px;6782 padding-top: 0; 6774 6783 } 6775 6784 6776 .no-js #wpbody-content #menu-settings-column {6777 padding-top: 31px;6778 }6779 6780 6785 #menu-settings-column .inside { 6781 6786 clear: both; 6782 6787 margin: 10px 0 0; … … 6795 6800 position: relative; 6796 6801 } 6797 6802 6803 .blank-slate .menu-name { 6804 height: 2em; 6805 } 6806 6807 .blank-slate .menu-settings { 6808 border: none; 6809 margin-top: 0; 6810 padding-top: 0; 6811 overflow: hidden; 6812 } 6813 6814 .is-submenu { 6815 font-style: italic; 6816 font-weight: normal; 6817 margin-left: 4px; 6818 } 6819 6820 .manage-menus { 6821 margin-top: 13px; 6822 padding: 10px; 6823 overflow: hidden; 6824 -webkit-border-radius: 3px; 6825 border-radius: 3px; 6826 } 6827 6828 .manage-menus select { 6829 float: left; 6830 min-width: 180px; 6831 margin-right: 6px; 6832 } 6833 6834 .manage-menus .selected-menu { 6835 float: left; 6836 margin: 5px 6px 0 0; 6837 } 6838 6839 .manage-menus .submit-btn { 6840 float: left; 6841 margin-top: 1px; 6842 } 6843 6844 .menu-edit p { 6845 margin: .3em 0 .6em; 6846 } 6847 6848 .menu-settings { 6849 margin-top: 2em; 6850 padding-top: 16px; 6851 overflow: hidden; 6852 } 6853 6854 .menu-settings dl { 6855 margin: 0 0 10px; 6856 overflow: hidden; 6857 position: relative; 6858 } 6859 6860 .menu-settings dd { 6861 float: left; 6862 margin: 0; 6863 width: 60%; 6864 padding-left: 170px; 6865 } 6866 6867 .menu-settings dt { 6868 clear: both; 6869 left: 0; 6870 padding: 3px 0 0; 6871 position: absolute; 6872 } 6873 6874 .menu-edit .checkbox-input { 6875 margin-top: 4px; 6876 } 6877 6878 .theme-location-set { 6879 font-size: 11px; 6880 } 6881 6798 6882 /* Menu Container */ 6799 6883 #menu-management-liquid { 6800 6884 float: left; 6801 6885 min-width: 100%; 6886 margin-top: 3px; 6802 6887 } 6803 6888 6804 6889 #menu-management { … … 6813 6898 } 6814 6899 6815 6900 .nav-menus-php #post-body { 6816 padding: 10px;6901 padding: 0 10px; 6817 6902 border-width: 1px 0; 6818 6903 border-style: solid; 6819 6904 } … … 6825 6910 6826 6911 #nav-menu-header { 6827 6912 border-bottom: 1px solid; 6913 margin-bottom: 13px; 6828 6914 } 6829 6915 6916 #nav-menu-header .menu-name-label { 6917 margin-top: 2px; 6918 } 6919 6830 6920 #nav-menu-footer { 6831 6921 border-top: 1px solid; 6832 6922 } … … 6845 6935 font-weight:bold; 6846 6936 } 6847 6937 6848 /* Menu Tabs */6849 6850 #menu-management .nav-tabs-nav {6851 margin: 0 20px;6852 }6853 6854 #menu-management .nav-tabs-arrow {6855 width: 10px;6856 padding: 0 5px 4px;6857 cursor: pointer;6858 position: absolute;6859 top: 0;6860 line-height: 22px;6861 font-size: 18px;6862 text-shadow: 0 1px 0 #fff;6863 }6864 6865 #menu-management .nav-tabs-arrow-left {6866 left: 0;6867 }6868 6869 #menu-management .nav-tabs-arrow-right {6870 right: 0;6871 text-align: right;6872 }6873 6874 #menu-management .nav-tabs-wrapper {6875 width: 100%;6876 height: 28px;6877 margin-bottom: -1px;6878 overflow: hidden;6879 }6880 6881 #menu-management .nav-tabs {6882 padding-left: 20px;6883 padding-right: 10px;6884 }6885 6886 .js #menu-management .nav-tabs {6887 float: left;6888 margin-left: 0px;6889 margin-right: -400px;6890 }6891 6892 #menu-management .nav-tab {6893 margin-bottom: 0;6894 font-size: 14px;6895 }6896 6897 6938 #select-nav-menu-container { 6898 6939 text-align: right; 6899 6940 padding: 0 10px 3px 10px; … … 7090 7131 } 7091 7132 7092 7133 #menu-to-edit { 7093 padding: 1em 0; 7134 margin: 0; 7135 padding: 0.1em 0; 7094 7136 } 7095 7137 7096 7138 .menu ul { … … 7106 7148 clear:both; 7107 7149 line-height:1.5em; 7108 7150 position:relative; 7109 margin: 13px 00 0;7151 margin: 9px 0 0; 7110 7152 } 7111 7153 7112 7154 .menu-item-handle { … … 7333 7375 text-align: right; 7334 7376 float: right; 7335 7377 line-height: 23px; 7336 margin: 5px 0 1px;7378 margin: 2px 0 1px; 7337 7379 } 7338 7380 7339 .nav-menus-php .major-publishing-actions .delete-action { 7340 vertical-align: middle; 7341 text-align: left; 7342 float: left; 7343 padding-right: 15px; 7344 margin-top: 5px; 7381 .nav-menus-php .blank-slate .menu-settings { 7382 display: none; 7345 7383 } 7346 7384 7347 .menu-name-label span, 7348 .auto-add-pages label { 7349 font-size: 12px; 7350 font-style: normal; 7351 } 7352 7353 .menu-name-label { 7354 margin-right: 15px; 7355 } 7356 7357 .auto-add-pages input { 7358 margin-top: 0; 7359 } 7360 7361 .auto-add-pages { 7362 margin-top: 4px; 7385 .nav-menus-php .delete-action { 7363 7386 float: left; 7387 margin-top: 2px; 7364 7388 } 7365 7389 7366 7390 .nav-menus-php .submitbox .submitcancel {
